This is quite easy to do, but is not done during flash. Any Linux doc will describe this and it isn’t any different for a Jetson. This is how I manage my host PC. I’ll describe below, starting with an example of certain behavior.
For the sake of argument let’s say “/
” is “/dev/mmcblk0p1
”, and that you also have an empty partition “/dev/nvme0n1p1
” (but formatted for ext4
). Also, for the sake of argument, let’s pretend your user name is “ubuntu
”.
Before mounting anything special, consider that you have content in “/home/ubuntu
”. If you were to manually mount over this, then you would:
sudo mount /dev/nvme0n1p1 /home
cd /home
# If you run "`ls`" or "`du -h -s .`" it would show no content.
Now if you leave that location and umount
:
cd /
sudo umount /home
# Now cd back:
cd /home
ls
du -h -s .
All content would show up again. Whenever you mount a partition over an existing location, that content becomes inaccessible on the original partition, but that content is still there unharmed. You could “move” that content onto the NVMe, or you could simply “copy without changing the original data”, and once mounted to “/home
”, the result would look the same.
For the case of not removing the old data, this could serve as a backup, or as an emergency content should the NVMe be removed. Leaving the old data in place though would mean the eMMC has used space which cannot be accessed (at least not while the NVMe is mounted). If you don’t need that extra space, then I’d advise leaving it there for emergencies or utility.
There is nothing you need to do which is “special” for first boot, although you would still want to customize “/etc/fstab
”. However, there is an important point about the different mount options: If your fstab
mount specification does not make this “optional”, then it means boot will fail by locking up at the point in boot where that partition mounts, and it will wait forever. You’d end up flashing again to correct this, or else adding a partition matching the mount specification. If the mount is optional, then boot will continue without the mount if mount is not possible; even so, the mount will do as you wish if it is possible to mount. Mount options matter.
Let’s say you have blank partition, and you want to truly mv
this rather than cp
. You’d mount on an alternate mount point, and literally use the “mv
” command. Example:
# Temporary mount:
sudo mount /dev/nvme0n1p1 /mnt
cd /home
# Copy to temporary mount:
sudo mv * /mnt
# Be certain there are no "`.name`" "dot" files still present...the "`.`" and "`..`" of course
# don't count. Being "`/home`" there won't be any, but similar copy from some other
# location might have such an issue.
cd /
sudo umount /mnt
sudo mount /dev/nvme0n1p1 /home
ls /home/
On the other hand, if you want to copy and not truly move, then use a tool designed for this, e.g., rsync
. Example (note that there are many ways to use rsync
, and I am throwing in the proverbial “kitchen sync” with progress logs, so on):
# Same temporary mount:
sudo mount /dev/nvme0n1p1 /mnt
cd /home
# Now it differs:
sudo rsync -avcrltxAP --info=progress2,stats2 --numeric-ids --exclude '.gfvs' --exclude 'lost+found' /home/* /mnt
# Same warning about "`.name`" "dot" files...the "`.`" and "`..`" don't count. "/home" won't have any
# dot files, but other locations might.
cd /
sudo umount /mnt
sudo mount /dev/nvme0n1p1 /home
ls /home/
“rsync
” can do the right thing with symbolic links, device special files, named pipes, so on, in ways which “cp
” might do incorrectly. “mv
” is not generally an issue because it relocates files rather than copying contents.
About permanent mount and “/etc/fstab
”: You can specify what to mount either via a device path, e.g., “/dev/nvme0n1p1
”, or via a UUID. I prefer UUID because it can be used on any device, but there is a learning curve involved. If you want to know about UUID just ask, but for the moment I’ll go with the simpler device path. Also, if you mark the device as “ok to fail”, then boot would continue even if the device is missing or fails. Should you have created a copy instead of a move, then the original content will be there to provide an environment for your user during the missing/failed mount. Summary:
- Optional mount means it can fail and you won’t need to flash since boot won’t lock.
- Copy instead of move means that if mount fails you have a backup environment.
Specifically, a line in fstab
will look something like this for the most basic case (where failure will break boot):
# field1 field2 field3 field4 field5 field6
/dev/nvme0n1p1 /home ext4 defaults 0 2
Btw, you can put as many spaces as you want between fields in fstab
for clarity.
Note that “defaults
” is equivalent to a comma-delimited set of these options:
rw,suid,dev,exec,auto,nouser,async
You can tell it to allow errors, and thus continue to boot if either the partition is missing or somehow failed. That is the “nofail
” option. An example with all else being default:
rw,suid,dev,exec,auto,nouser,async,nofail
(notices “,nofail
” on the end…no spaces between any option)
For debug purposes, while experimenting with partition mounts, it is sometimes useful to know about the “noauto
” option. Normally you could not just “mount /home
” as it is missing options like which drive is there. Should you have this entry, then it would not auto mount, but it would do exactly the right thing if you “mount
” or “unmount
” either “/home
” or “/dev/nvme0n1p1
”:
rw,suid,dev,exec,auto,nouser,async,nofail,noauto
During flash, if using defaults, the content of “Linux_for_Tegra/rootfs/
” is used almost verbatim to create the image to flash. “Almost” because some of the “/boot
” content will be altered depending on boot options, e.g., the Image
and extlinux.conf
can be altered, but the rest is left alone. So if you were to add this line for testing, then after boot “/home
” would “just do the right thing” if available:
/dev/nvme0n1p1 /home ext4 rw,suid,dev,exec,auto,nouser,async,nofail 0 2
You can read about fields 5 and 6 in “man fstab
”. These are related to what backup software will do, and the order in which done. One would for example not want an fsck.ext4
on both “/
” and “/home
” at the same time should something go wrong…you’d want this to be sequential. If “/
” is order “1
”, and “/home
” is order “2
”, then it’ll first fsck
“/
” if needed, and then fsck
“/home
” if needed. Thus the “1
” or “2
” in the last field.