Booting from a SD card is a traditional way of running OS on NVIDIA Jetson Nano 2GB model and it works really great. But what if you’re running out of disk space. Say, you are running AI-based heavy-duty container workloads on your 16GB SD card and suddenly, you find that these gigs of container images are eating up your disk space. Ask Nvidia support team and they might suggest to get the new SD card with the larger disk space. But I have got a workaround for you with the existing SD card and here goes the story…
But Wait… What is NVIDIA Jetson Nano 2GB?
The NVIDIA Jetson Nano 2GB Developer Kit is the ideal platform for teaching, learning, and developing AI and robotics applications. It uses the same proven NVIDIA JetPack Software Development Kit (SDK) used in breakthrough AI-based products. The new developer kit is unique in its ability to utilise the entire NVIDIA CUDA-X™ accelerated computing software stack including TensorRT for fast and efficient AI inference — all in a small form factor and at a significantly lower price.
Hardware
- Jetson Nano
- A Camera Module
- A 5V 4Ampere Charger
- 32GB SD card
Software
- Jetson SD card image from https://developer.nvidia.com/embedded/downloads
- Etcher software installed on your system
Preparing Your Jetson Nano
1. Preparing Your Raspberry Pi Flashing Jetson SD Card Image
- Unzip the SD card image
- Insert SD card into your system.
- Bring up Etcher tool and select the target SD card to which you want to flash the image.
Once the flashing is done, just insert SD card into Jetson Nano SD card slot and let it boot the OS.
Preparing the USB
Insert the 64GB USB storage device to the Jetson Nano device.
Formatting the USB Drive using Linux Command
To simplify the steps for formatting the USB drive using command line, make sure that you only have one USB drive being connected to the Jetson Nano. Firstly, we need to search for the device path of the USB drive by entering the command in the terminal:
$ sudo parted -l
We have to obtain the optimal IO size and physical block size of the USB drive by entering the 2 commands below (you have to change the term “sda” into the device path as obtained from the previous step):
$ cat /sys/block/sda/queue/optimal_io_size
$ cat /sys/block/sda/queue/physical_block_size
After obtaining the number of sector, it’s time to format the USB drive. Make sure that there are no important files inside before proceeding to the next step!
$ sudo parted /dev/sda
$ mklabel gpt
You might be prompted to confirm the formatting, just enter “y” for confirmation. After formatting, we need to create the partition in the USB drive. Replace the variable with the number of sector which we calculated earlier.
$ mkpart primary ext4 s 100%
Press ctrl + D to exit the parted command line. Then, we have to properly format the partition we created earlier to ext4 file system. Make sure that you change the term “sda” into the device path being obtained previously.
$ mkfs.ext4 /dev/sda1
$ sudo parted -l
Look for the device path of the USB drive, in this case it is “/dev/sda”. Search for the USB drive again. If all of the steps are taken correctly, you will see that the Partition Table is set to “gpt” and the file system for the partition is “ext4” as shown in the image above.
ajeetraina@ajeetraina-desktop:~$ sudo mount /dev/sda1 /mnt/usbboot
[sudo] password for ajeetraina:
ajeetraina@ajeetraina-desktop:~$ sudo df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk0p1 15G 12G 2.6G 82% /
none 947M 0 947M 0% /dev
tmpfs 986M 4.0K 986M 1% /dev/shm
tmpfs 986M 27M 960M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 986M 0 986M 0% /sys/fs/cgroup
tmpfs 198M 4.0K 198M 1% /run/user/121
tmpfs 198M 0 198M 0% /run/user/1000
/dev/sda1 29G 12G 16G 43% /mnt/usbboot
Cloning the repository
git clone https://github.com/jetsonhacks/bootFromUSB
ajeetraina@ajeetraina-desktop:~/bootFromUSB$ ./copyRootToUSB.sh -p /dev/sda1
Device Path: /dev/sda1
Target: /mnt/usbboot
..
Setting up rsync (3.1.2-2.1ubuntu1.2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for systemd (237-3ubuntu10.50) ...
11,511,169,692 95% 17.93MB/s 0:10:12 (xfr#142716, to-chk=0/205797)
ajeetraina@ajeetraina-desktop:~/bootFromUSB$
Copy the below content and put it in extlinux.conf file as shown below:
ajeetraina@ajeetraina-desktop:/mnt/usbboot/boot/extlinux$ cat extlinux.conf
TIMEOUT 30
DEFAULT sdcard
MENU TITLE L4T boot options
# Sample extlinux.conf file for booting from USB
# You will need to set the root environment variable to match your system
#
# You can set the root to various levels of specificity
# If you have multiple USB storage devices, the PARTUUID approach is very useful
# PARTUUID is the PARTUUID of the USB device; most exact - recommended
# LABELNAME is a little more specific; root=LABEL=jetson_drive
# /dev/sda1 is the most general; root=/dev/sda1
# Note: The UUID options seems to have some issues on the Jetson
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=PARTUUID=32a76e0a-9aa7-4744-9954-dfe6f353c6a7 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
# sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot
LABEL sdcard
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} quiet root=/dev/sda1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
That’s it. Now remove the SD card and let your Jetson nano boot from USB drive
ajeetraina@ajeetraina-desktop:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 29G 12G 16G 43% /
none 947M 0 947M 0% /dev
tmpfs 986M 40K 986M 1% /dev/shm
tmpfs 986M 27M 960M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 986M 0 986M 0% /sys/fs/cgroup
tmpfs 198M 8.0K 198M 1% /run/user/1000
ajeetraina@ajeetraina-desktop:~$
Yay! I was able to boot Jetson Nano from USB instead of SD card
Further Read:
Comments are closed.