一、参考资料
rootOnNVMe
How to Boot from NVMe SSD?
仅两步,把JETSON XAVIER NX的系统移动到nvme硬盘上
NVIDIA JETSON XAVIER NX (二)设置M.2 Key M SSD为系统盘
二、总体步骤
2.1 安装nvme固态硬盘
2.2 Jetson NX刷机
参考Jeson TX2刷机教程:Jetson TX2刷机教程
连接USB,连接跳线(连接第二、第三个位置),Host上位机打开 SDKManager,安装 Jetson OS;
连接USB
连接跳线(连接第二、第三个位置)
安装 Jetson OS
2.3 拔掉跳线,重启NX(可进入Ubuntu系统)
2.4 设置nvme为系统盘
关键步骤,请见下文。
2.5 安装 Jetson SDK Components
Host上位机打开 SDKManager,安装 Jetson SDK Components;
三、关键步骤
3.1 设置硬盘格式
# 进入parted
sudo parted /dev/nvme0n1#将磁盘设置为gpt格式
mklabel gpt #将磁盘所有的容量设置为GPT格式
mkpart logical 0 -1 #查看分区结果
print # 退出parted
quit
xjzk@ubuntu:/$ sudo parted /dev/nvme0n1
GNU Parted 3.2
Using /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/nvme0n1 will be destroyed and all data
on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart logical 0 -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted) print
Model: aigo NVMe SSD P2000 128GB (nvme)
Disk /dev/nvme0n1: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:Number Start End Size File system Name Flags1 17.4kB 128GB 128GB logical(parted) quit
Information: You may need to update /etc/fstab.
3.2 查看分区
#查看分区
df -l
df -a
lsblk
3.3 创建分区
# 进入硬盘
sudo fdisk /dev/nvme0n1# 查看帮助
Command (m for help): m# 添加分区
Command (m for help): n# 添加拓展分区
Select (default p): e# 分区编号,Enter回车默认
Partition number (1-4, default 1):# 分区首地址,Enter回车默认
First sector (2048-250069679, default 2048):# 分区尾地址,Enter回车默认
Last sector, +sectors or +size{K,M,G,T,P} (2048-250069679, default 250069679):# 打印分区
Command (m for help): p# 保存修改
Command (m for help): w
xjzk@ubuntu:~$ sudo fdisk /dev/nvme0n1Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): n
Partition typep primary (0 primary, 0 extended, 4 free)e extended (container for logical partitions)
Select (default p): e
Partition number (1-4, default 1):
First sector (2048-250069679, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-250069679, default 250069679):Created a new partition 1 of type 'Extended' and of size 119.2 GiB.Command (m for help): p
Disk /dev/nvme0n1: 119.2 GiB, 128035676160 bytes, 250069680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x09833de0Device Boot Start End Sectors Size Id Type
/dev/nvme0n1p1 2048 250069679 250067632 119.2G 5 ExtendedCommand (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
3.4 格式化分区
sudo mke2fs -t ext4 /dev/nvme0n1p1 #格式化分区
xjzk@ubuntu:/$ sudo mke2fs -t ext4 /dev/nvme0n1p1
[sudo] password for xjzk:
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 31258461 4k blocks and 7815168 inodes
Filesystem UUID: 83a62e34-6619-4ef4-b44f-5734f0af8b3f
Superblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424, 20480000, 23887872Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done
3.5 拷贝rootfs
将eMMC / SD卡的rootfs复制到SSD。
# 进入目录
cd rootOnNVMe #执行复制脚本
./copy-rootfs-ssd.sh
xjzk@ubuntu:~/Desktop$ cd rootOnNVMe/
xjzk@ubuntu:~/Desktop/rootOnNVMe$ ./copy-rootfs-ssd.sh5,092,410,373 90% 56.35MB/s 0:01:26 (xfr#109670, to-chk=0/166927)
3.6 设置rootfs
安装启动脚本:将rootfs设置为NVME。
# 将rootfs设置为NVME
./setup-service.sh #重启
sudo reboot
xjzk@ubuntu:~/Desktop/rootOnNVMe$ ./setup-service.sh
[sudo] password for xjzk:
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: xjzk,,, (xjzk)
Password:
==== AUTHENTICATION COMPLETE ===
Created symlink /etc/systemd/system/default.target.wants/setssdroot.service → /etc/systemd/system/setssdroot.service.
Service to set the rootfs to the SSD installed.
Make sure that you have copied the rootfs to SSD.
Reboot for changes to take effect.
3.7 查看是否成功
查看硬盘挂载点,/dev/nvme0n1p1
成功挂载到 /
挂载点上。
xjzk@ubuntu:~$ df -l
Filesystem 1K-blocks Used Available Use% Mounted on
none 3591204 0 3591204 0% /dev
tmpfs 3975892 40 3975852 1% /dev/shm
tmpfs 3975892 30388 3945504 1% /run
tmpfs 5120 4 5116 1% /run/lock
tmpfs 3975892 0 3975892 0% /sys/fs/cgroup
/dev/nvme0n1p1 122547172 14721792 101557304 13% /
tmpfs 795176 12 795164 1% /run/user/120
tmpfs 795176 140 795036 1% /run/user/1000
/dev/mmcblk0p1 14318640 5353472 8214784 40% /media/xjzk/d6876fc2-e036-47bb-b2f6-bfe96b226e2a