Clone system, Jetson Nano

Good Afternoon,
I have a question. I have a system uploaded on a Jetson Nano module and would like to make a clone of it and upload the system to another jetson nano module. Is anyone able to help me how to do this?

Is this an NVIDIA Nano dev kit? Beware that dev kits are slightly different versus third party units.

If this is an NVIDIA dev kit, then it requires using the SD card for the operating system. If not, then it probably uses eMMC instead. Cloning and restoring is different for the two types.

Dev kits have the SD card mounted directly on the underside of the module itself. If this is a third party carrier board, then the SD card is instead mounted to the carrier board. It is important to know the distinction.

Note that cloning an SD card is fairly trivial if you have a host PC running Linux (probably easy with Macs too, not really sure; Windows would complicate things, but there are applications which would work with that too).

Cloning eMMC requires a recovery mode Jetson and an Ubuntu (18.04 in this case) host PC.

Regardless of which type of Nano it is, every Nano has some software which is equivalent to a PC’s BIOS, plus software related to boot (such as the bootloader). This must be the correct release for the o/s software to function correctly. On a dev kit, without eMMC, this content is in QSPI memory on the module. This is typically flashed to a known compatible release, and then any SD card compatible with this can be used. For an eMMC model, this is normally in the format of other partitions in eMMC.

I have a Jetson Nano with eMMC and directly want to make a clone of the system that is on it to replicate it to another Jetson. Will it be correct if I use the following line in the temrminal on the ubuntu computer?
$ sudo ./flash.sh -r -k APP -G mmcblk0p1
Sorry for the trivia questions, but I’m just starting out with Linux

Hi,

you should also specify the file name of the backup image with -G.
Check our developer guide for more information:
https://docs.nvidia.com/jetson/archives/r35.3.1/DeveloperGuide/text/SD/FlashingSupport.html#to-clone-a-jetson-device-and-flash

Be aware of whether the target device has been flashed before, as the required command will be different.

Was, there is already a flash of the system on it and it is this that I want to make a copy of, but what is directly already on Jetson.

I’m not quite sure about your English usage here. Can you elaborate it more?

The issue is that the rootfs resides in eMMC on your Jetson Nano module, whereas the bootloader (Uboot and other stuff like that) is in QSPI memory.

sudo ./flash.sh -r -k APP mmcblk0p1

will only flash the rootfs, but not the bootloader in QSPI, so if your board has not been flashed, you have to use this command, which takes out the -k APP option, to flash the bootloader in addition to the rootfs.

sudo ./flash.sh -r mmcblk0p1

Any other question that you don’t understand?

Just to clarify, when you clone, it will clone a specific rootfs (“APP”) partition of the eMMC. This is everything which runs in the operating system. Although none of the (many) other partitions or content will not clone like that, those other partitions do not normally need a clone. As mentioned by @DaveYYY, the clone command also requires the name of the file to clone to (more on that mentioned later) on the Linux host PC where the command is issued:
sudo ./flash.sh -r -k APP -G my_backup.img mmcblk0p1 jetson-nano-emmc
(this generates “my_backup.img” and “my_backup.img.raw”)

When reflashing, this image should work on any Jetson (third party or not) in which the other (non-rootfs) content is a valid release. That other (non-rootfs) content will likely need to be flashed at least once (or again under some circumstances). One would normally flash both the rootfs and non-rootfs at the same time, but for a clone restore, one would also specify that the clone is to be used instead of a newly generated rootfs.

That non-rootfs content will not normally be from NVIDIA for the case of a third party carrier board. Because the layout of that carrier is likely different compared to the carrier board from the third party, the device tree (and perhaps some drivers) will likely differ. In a few cases a third party carrier board will match the electrical layout of the dev kit, and in that case the NVIDIA software will work (and the third party manufacturer will state that it is ok to use the NVIDIA flash software). Most likely though the manufacturer of the carrier board will supply a board support package (BSP), which is used to flash with (this in turn might actually just be a patch to add to NVIDIA’s software, or it might be a complete download).

Typically, it is ok to clone anything from NVIDIA’s software, it is the restore side which tends to need specific software. When you clone it will create two files: One is a “sparse” file, the other is a “raw” file. The two have the same content, but they have different uses. A raw file is an exact bit-for-bit copy of the entire rootfs partition. So if the partition is 14 GiB in size (I use GiB instead of GB for a reason), then the file will be exactly that same 14 GiB. The sparse file is usually smaller, and it is essentially everything in the raw file, except it excludes blank space. So if the partition is using 8 GiB of space (it is a formatted partition with ext4 filesystem, but not necessarily full), then the sparse file will be slightly over 8 GiB. As the filesystem fills and approaches 100% of capacity, so too the sparse file will approach the full size of the partition.

The sparse backup file can be used for flash. However, you can’t easily mount it or examine it. It has less content, and so flashing with this is faster than flashing with the raw file. Aside from time to flash, both result in the same flash. However, a raw file is rather interesting if you ever want to examine or rescue or edit.

Note that “GB” is a base 10 multiple of 1000*1000*1000, whereas “GiB” is base 2, and is a multiple of “1024*1024*1024”. Options which specify partition sizes usually use “GiB” or “MiB”.

Raw files can be loopback mounted, examined, edited, so on. There are even some interesting tricks that would allow you to resize them (smaller is easier, but you can also increase the size of a loopback device if you’ve properly prepared). One can also generate a sparse image from a raw image.

In the flash software you will notice that it has the base (“top”) directory “Linux_for_Tegra/”. Placing the clone as “Linux_for_Tegra/bootloader/system.img”, and then flashing (provided you say to reuse the existing image) results in whatever flash command you use putting the clone in instead of a freshly created image. It is the “system.img” name which decides if your clone is used or not.

Note that those are very large files. A 14 GiB file takes a lot of time merely to copy. Even a sparse file, e.g., perhaps 3 GiB, takes quite some time to copy. Both together could easily be 20 GiB in size, and all of that consumes what used to be free disk space. I tend to throw away the sparse image, and save only the raw image. When I’m not using it I will compress the raw image with “bzip2 -9” (which takes a long time to compress or decompress for a file that large).

The third party software will probably provide the flash command when reusing the rootfs. This might be exactly the same as the NVIDIA command, although the result of what gets flashed to the non-rootfs would differ. If this were NVIDIA’s flash software, then the command might be something like:
sudo ./flash.sh -r mmcblk0p1 jetson-nano-emmc

The “-r” says to reuse the rootfs and not overwrite the existing bootloader/system.img.

In all cases, whether using third party flash software or NVDIA’s software, you’d want to allow that software to flash all other content. You’d get the right content by using the same release of flash software as that which originally created the installation the clone is from.

Note that “L4T” (“Linux for Tegra”) is what gets flashed, and consists of Ubuntu plus NVIDIA drivers. JetPack/SDK Manager is the front end flash software. The two have their versions linked, so picking one generally picks the other. Unless the third party manufacturer says to use NVIDIA’s software, you’d use theirs. You would probably still want to know which L4T release is currently installed, and to do that, you can run the command “head -n 1 /etc/nv_tegra_release”. Use that to pick the correct release to flash from. Since clone does not clone non-rootfs it is generally not a problem to create a clone from anyone’s flash software.

So go to the third party manufacturer’s web page and find out what software they use, and download that. For people who are flashing with NVIDIA’s software, look up your release and go to that via either of:

Tip: Nano’s can use up to L4T R32.x. You have to have an Xavier or newer to go past that.

2 Likes

That helped! Thank you for your help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.