< >
Home » NX入门教程硬件篇 » NX入门教程基础篇-使用NVMe硬盘做启动盘

NX入门教程基础篇-使用NVMe硬盘做启动盘

NX入门教程基础篇-使用NVMe硬盘做启动盘

说明:

  • 介绍使用NVMe固态硬盘做启动盘
  • 支持m.2 key.m 2280 nvme的硬盘

步骤:

请输入图片描述

  • 格式固态硬盘
sudo parted /dev/nvme0n1 #进入parted
mklabel gpt #将磁盘设置为gpt格式,
mkpart logical 0 -1 #将磁盘所有的容量设置为GPT格式
print #查看分区结果
sudo mkfs -t ext4  /dev/nvme0n1p1 #格式化分区
  • 将eMMC/SD卡的rootfs复制到SSD
  • 下载脚本
git clone https://github.com/ncnynl/rootOnNVMe
cd rootOnNVMe #进入目录
./copy-rootfs-ssd.sh #执行复制脚本
  • copy-rootfs-ssd.sh脚本内容如下:
#!/bin/bash
# Mount the SSD as /mnt
sudo mount /dev/nvme0n1p1 /mnt
# Copy over the rootfs from the SD card to the SSD
sudo rsync -axHAWX --numeric-ids --info=progress2 --exclude={"/dev/","/proc/","/sys/","/tmp/","/run/","/mnt/","/media/*","/lost+found"} / /mnt
# We want to keep the SSD mounted for further operations
# So we do not unmount the SSD
  • 安装启动脚本:将rootfs设置为NVME
./setup-service.sh #将rootfs设置为NVME
sudo reboot  #重启
  • setup-service.sh脚本内容如下:
#!/bin/sh
# Setup the service to set the rootfs to point to the SSD
sudo cp data/setssdroot.service /etc/systemd/system
sudo cp data/setssdroot.sh /sbin
sudo chmod 777 /sbin/setssdroot.sh
systemctl daemon-reload
sudo systemctl enable setssdroot.service

# Copy these over to the SSD
sudo cp /etc/systemd/system/setssdroot.service /mnt/etc/systemd/system/setssdroot.service
sudo cp /sbin/setssdroot.sh /mnt/sbin/setssdroot.sh

# Create setssdroot.conf which tells the service script to set the rootfs to the SSD
# If you want to boot from SD again, remove the file /etc/setssdroot.conf from the SD card.
# touch creates an empty file
sudo touch /etc/setssdroot.conf
echo 'Service to set the rootfs to the SSD installed.'
echo 'Make sure that you have copied the rootfs to SSD.'
echo 'Reboot for changes to take effect.'
  • 重启之后,就正常使用固态硬盘作为启动盘

参考:

  • https://github.com/jetsonhacks/rootOnNVMe
  • https://forums.developer.nvidia.com/t/how-to-boot-from-nvme-ssd/65147/22

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: none