Jetson/Cloning

Like with all x86 host operations performed on the Jetson, you will need the Jetson TK1 Development Pack.

Reading partition table
cd into the /opt/JetPackTK*/Linux_for_Tegra/bootloader directory.

You can then get a list of the partitions available by doing:

./nvflash --getpartitiontable table --bl ardbeg/fastboot.bin --go

This will create a text file called table with the partitions listed inside.

Cloning the image
To make a carbon copy of an existing Jetson install, first connect the Jetson's micro-B USB flash port to the Linux machine that you originally flashed L4T from. Then enter the Jetson into recovery mode by holding RECOVERY and pressing RESET.

Old Jetson TK1 Development Pack
cd into the Linux_for_Tegra/bootloader directory that you used when originally flashing the Jetson. Inspect flash.cfg to obtain the partition id of system.img (in this case, 9)

[partition] name=APP id=9 type=data allocation_policy=sequential filesystem_type=basic size=15288238080 file_system_attribute=0 partition_attribute=0 allocation_attribute=8 percent_reserved=0 filename=system.img

Next, remove the old system.img built from the initial flashing and download the new image from the Jetson. If the id of your system.img partition is different than 9, substitute that in the nvflash command.

sudo rm system.img sudo ./nvflash --read 9 system.img --bl fastboot.bin --go

(On more recent Jetson TK1 Development Pack releases, fastboot.bin has been moved to ardbeg/fastboot.bin)

(downloading the image can take a while)

Recent Jetson TK1 Development Pack
A partition can be read by name or number. APP is the partition of the root filesystem. You can check you have an APP partition in the partition table. It will probably be partition 9.

You can then clone the partition to a file called system.img by doing:

sudo ./nvflash --read APP system.img --bl ardbeg/fastboot.bin --go

(downloading the image can take a while)

You can also clone the whole flash by doing:

sudo ./nvflash --rawdeviceread 0 3849216 all.img --bl ardbeg/fastboot.bin --go

(downloading the image can take a while)

Mounting
To mount the backed-up image to your system, execute the following command: sudo mount -t ext4 -o loop system.img /mnt

You can now inspect the Jetson's filesystem in /mnt and make edits, perform cross-compiling, ect. When finished, unmount the image with: sudo umount /mnt

Restoring
The image can be restored to a Jetson by flashing it with the -r 'skip building and reuse existing system.img' flag. Substitute the size of your partition if you originally flashed with a size different than 14580MiB.

cd ../ sudo ./flash.sh -r -S 14580MiB jetson-tk1 mmcblk0p1

Reboot the Jetson when it's done flashing and the system should be restored to the state at the time of cloning.

Likewise the following restores a full image clone. sudo ./nvflash --rawdevicewrite 0 3849216 all.img --bl ardbeg/fastboot.bin --go

Packaging
Keep the Linux_for_Tegra directory used during the cloning process to successfully restore the image. Linux_for_Tegra/rootfs can be removed as it's no longer needed. However the other L4T files should be transported along with the system.img to use during restoration.

sudo rm -r -f rootfs cd ../ tar -zcvf my_backup.tar.gz Linux_for_Tegra

tar.gz can significantly compress the size of system.img and will retain the access privileges and is now convenient to copy/FTP/ect.