6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Jetson Xavier NX でルートファイルシステムを NVMe SSD ドライブへ変更した際の注意点

Last updated at Posted at 2020-06-06

はじめに

ルートファイルシステムを NVMe SSD ドライブへ変更すると OS の起動時間や起動後の動作が劇的に改善するとのことで、さっそく試してみました。
最初に SD カードからの起動は変わりませんが、systemd によるシステム起動シーケンスで initrd からルートファイルシステムへの chroot 先を SD カードから NVMe SSD ドライブへ切り替えることにより起動時間が早くなります。

OS 起動時間の比較

systemd-analyze で OS 起動時間を比較したところ 33.2 秒 → 17.3 秒へ短縮されました。

$ systemd-analyze plot > result.svg

左: SD カード、右: NVMe SSD ドライブ (result.svg の表示例)
systemd_analyze.png

カーネルビルド時間の比較

buildKernelAndModules ツールを使用してカーネルイメージやモジュールのビルド時間を比較したところ以下のように短縮されました。

$ ./makeKernel.sh
real    111m40.689s
user    44m39.048s
sys     3m40.908s
↓
real    22m50.904s
user    92m5.668s
sys     8m16.444s

$ ./makeModules.sh
real    207m34.403s
user    108m12.652s
sys     9m6.864s
↓
real    27m43.071s
user    123m45.088s
sys     10m5.556s

ルートファイルシステムを NVMe SSD ドライブへ変更する手順

パーティションを作成します。

$ sudo fdisk /dev/nvme0n1

Command (m for help): n ← n を入力

Select (default p): p ← p を入力
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): (改行) ← Enter を入力

Command (m for help): w ← w を入力

ファイルシステムを ext4 でフォーマットします。

$ sudo mkfs -t ext4 /dev/nvme0n1p1

JetsonHacks のスクリプトをダウンロードして実行します。

$ git clone https://github.com/jetsonhacks/rootOnNVMe.git
$ cd rootOnNVMe/
$ ./copy-rootfs-ssd.sh
$ ./setup-service.sh

最後に再起動します。

$ sudo reboot

変更後の注意点

JetsonHacks にも記載されていますが、カーネルイメージやカーネルモジュールを更新した場合は SD カードへの反映も必要になります。
スクリーンショット 2020-06-06 21.44.21.png

カーネルイメージとモジュールを更新した後に SD カードへ反映するコマンドのサンプルです。
( <UUID> の部分は デバイス毎に変わるため mount や df コマンド等で確認)

$ sudo rsync -av /boot/ /media/jetson/<UUID>/boot/
$ sudo rsync -av /lib/modules/4.9.140-tegra/ /media/jetson/<UUID>/lib/modules/4.9.140-tegra/

例.

$ sudo rsync -av /boot/ /media/jetson/239f3029-4825-443b-972e-4392c57f5749/boot/
$ sudo rsync -av /lib/modules/4.9.140-tegra/ /media/jetson/239f3029-4825-443b-972e-4392c57f5749/lib/modules/4.9.140-tegra/
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?