The Deep Learning Robot comes with 16Gb built-in flash on the Jetson TK1 board. That’s fine to begin with, but after downloading a few Caffe models, you’ll be out of space. Fortunately, the TK1 comes with an SD Card slot for adding extra storage. This post describes how to add and configure an SD Card to give yourself more room.

SD Card on the Deep Learning Robot

Choosing an SD Card

My instinct is always to choose the fastest, biggest SD Card. I bought a SanDisk 64Gb SD Card for around $60. Prices seem to vary wildly between different local shops. The card is a class 10 / U3 designed for 4k video files and claims to have a read-write speed of 90Mb/s. I’m unclear about how much the speed matters; there may be limitations on the TK1 that prevent it using all this bandwidth. You need a full size SD card, not a mini-SD.

Push the SD card into the slot on the motherboard.

Configure the card with the following steps:

  1. Format the SD card with the ext4 file system.
  2. Determine the UUID of the formatted card.
  3. Create a mount point
  4. Backup and edit the fstab file.
  5. Test before rebooting.
  6. Create a symbolic link to your user directory.
  7. Reboot and test again.

1. Format the SD card with the ext4 file system.

Shell into the robot as usual. Display a list of the attached block devices with:

lsblk

My listing looked like this:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
 mmcblk0rpmb 179:16 0 4M 0 disk
 mmcblk0 179:0 0 14.7G 0 disk
 |-mmcblk0p1 179:1 0 14.2G 0 part /
 |-mmcblk0p2 179:2 0 4M 0 part
 |-mmcblk0p3 179:3 0 64M 0 part
 |-mmcblk0p4 179:4 0 4M 0 part
 |-mmcblk0p5 179:5 0 4M 0 part
 |-mmcblk0p6 179:6 0 4M 0 part
 |-mmcblk0p7 179:7 0 4M 0 part
 |-mmcblk0p8 179:8 0 2M 0 part
 `-mmcblk0p9 179:9 0 314M 0 part
 mmcblk1 179:32 0 59.5G 0 disk
 `-mmcblk1p1 179:33 0 59.5G 0 part

Yours may vary. The “14.2G” partition is the built in 16Gb flash. You’re looking for the partition that you need to format, which can be identified by the size of the inserted card. In my case it was a 64Gb card, so the closest match is the last line of the listing:

`-mmcblk1p1 179:33 0 59.5G 0 part

In my case, the partition name is therefore mmcblk1p1.

Make damn sure you get the right one so you don’t accidentally format your root disk. I would strongly advice against using a 16Gb SD card for that very reason; it may be hard to distinguish from the built in flash which would show up as the same size.

Now format the card using the name derived from the previous step. So for me this was:

sudo mkfs.ext4 /dev/mmcblk1p1

Replace mmcblk1p1 with your partition name if it is different.

2. Determine the UUID of the formatted card.

Each partition is assigned a unique name, called a UUID. This is so that it can be addressed independently of the slot the card is plugged into (irrelevant in the present case of a single slot board). To find the UUID of the card you just formatted, type:

sudo blkid

I got:

/dev/mmcblk0p1: UUID="3e25022b-286b-4739-ba6b-fb4c0423fda3" TYPE="ext4" 
/dev/mmcblk1p1: UUID="4b5b1122-33a0-4a5b-bfe5-7354b46996dc" TYPE="ext4"

This shows the block devices with their IDs. In my case, it was the second line as the name /dev/mmcblk1p1 corresponds to the name found in step 1. So my UUID is 4b5b1122-33a0-4a5b-bfe5-7354b46996dc. Yours will be different.

3. Create a mount point

Now let’s create a mount point (the place in the filesystem where the mounted card will appear):

sudo mkdir /media/sdmount

4. Backup and edit the fstab file.

The /etc/fstab file contains a list of devices that need mounting on each boot. We’re going to add the mount point for the card to this file, so it gets automatically mounted each time the robot is switched on.

We don’t want to mess up this file, so it’s advisable to make a backup:

sudo cp /etc/fstab /etc/fstab.orig

Now let’s edit the fstab file using Vim (instructions on Vim here).

sudo vim /etc/fstab

My file consisted of a single comment, but yours may be different. If it already contains devices then be careful when you edit as you may brick your device otherwise.

At the end of the file add a line with this format:

UUID=<your UUID>  /media/sdmount ext4 defaults,users 0 0

Mine was

UUID=4b5b1122-33a0-4a5b-bfe5-7354b46996dc /media/sdmount ext4 defaults,users 0 0

Let’s unpack this. We’re telling the system that we want to mount a partition with the specified UUID at the mount point /media/sdmount (which we just created). ‘ext4’ specifies the filesystem type, which we formatted earlier. The options defaults,users sets the partition with read-write permissions for all users (see more options here under “Filesystem Independent Mount Options”). The final two parameters which are both zero specify whether we want to dump or auto check the filesystem (more details under “Editing Ubuntu’s filesystem table”).

Save the file with :wq! and exit Vim.

5. Test before rebooting.

Let’s test what we just did and ask the system to mount all devices specified in /etc/fstab:

sudo mount -a

You should now be able to access the card at the mount point. Type:

ls /media/sdmount

You should see

lost+found

6. Create a symbolic link to your user directory.

It’s more useful to be able to access the card from your home directory at /home/ubuntu. Let’s create a symbolic link from /home/ubuntu/sdcard to a directory under /media/sdmount by first creating the target directory:

cd ~
sudo mkdir /media/sdmount/sdcard

Then change the ownership of the target directory so the ubuntu user can read and write to it:

sudo chown ubuntu /media/sdmount/sdcard

Finally, link it:

ln -s /media/sdmount/sdcard sdcard

Now we have a subdirectory at /home/ubuntu/sdcard with 64Gb of space!

7. Reboot and test again.

Finally reboot and make sure the subdirectory is present and working.

You might want to consider creating a new catkin workspace here for ROS projects. You could also copy or move your Caffe installation here to make room for downloading new models. Let me know how you get on.