Jetson NX设置nvme固态硬盘为系统盘
一、参考资料
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 设置硬盘格式
# 进入partedsudo parted /dev/nvme0n1#将磁盘设置为gpt格式mklabel gpt #将磁盘所有的容量设置为GPT格式mkpart logical 0 -1 #查看分区结果print # 退出partedquit
xjzk@ubuntu:/$ sudo parted /dev/nvme0n1GNU Parted 3.2Using /dev/nvme0n1Welcome to GNU Parted! Type 'help' to view a list of commands.(parted) mklabel gptWarning: The existing disk label on /dev/nvme0n1 will be destroyed and all dataon this disk will be lost. Do you want to continue?Yes/No? Yes(parted) mkpart logical 0 -1Warning: The resulting partition is not properly aligned for best performance.Ignore/Cancel? Ignore(parted) printModel: aigo NVMe SSD P2000 128GB (nvme)Disk /dev/nvme0n1: 128GBSector size (logical/physical): 512B/512BPartition Table: gptDisk Flags:Number Start End Size File system Name Flags 1 17.4kB 128GB 128GB logical (parted) quitInformation: You may need to update /etc/fstab.
3.2 查看分区
#查看分区df -ldf -alsblk
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): nPartition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions)Select (default p): ePartition 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): pDisk /dev/nvme0n1: 119.2 GiB, 128035676160 bytes, 250069680 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x09833de0Device Boot StartEnd Sectors Size Id Type/dev/nvme0n1p12048 250069679 250067632 119.2G 5 ExtendedCommand (m for help): wThe 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: doneCreating filesystem with 31258461 4k blocks and 7815168 inodesFilesystem UUID: 83a62e34-6619-4ef4-b44f-5734f0af8b3fSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872Allocating group tables: doneWriting inode tables: doneCreating journal (131072 blocks): doneWriting 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.sh 5,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 -lFilesystem 1K-blocks Used Available Use% Mounted onnone 3591204 0 3591204 0% /devtmpfs 397589240 3975852 1% /dev/shmtmpfs 3975892 30388 3945504 1% /runtmpfs 5120 4 5116 1% /run/locktmpfs 3975892 0 3975892 0% /sys/fs/cgroup/dev/nvme0n1p1 122547172 14721792 101557304 13% /tmpfs 79517612 795164 1% /run/user/120tmpfs 795176 140 795036 1% /run/user/1000/dev/mmcblk0p1 14318640 5353472 8214784 40% /media/xjzk/d6876fc2-e036-47bb-b2f6-bfe96b226e2a