Cloning or taking snapshot of TX2 board

Hi,
Is there a step by step guide to clone the currently installed and running disk image of TX2 board and restore from it?
I Jetpack(3.0) installed on my TX2 from Ubuntu 14.04 and want to setup other TX2 dev kits with the same image on and on.
Thanks,

Kyu

Please refer to https://devtalk.nvidia.com/default/topic/1008830/jetson-tx2/best-way-to-backup-a-tx2-prefer-image-backup-restore/
Once you have connected a Jetson in Forced Recovery mode with Host OS you could use the proprietary unix dd way: https://en.wikipedia.org/wiki/Dd_(Unix)

Hi Andrey1984,

I already checked the link you gave but they all talk about going to bootloader directory like
/opt/JetPackTK*/Linux_for_Tegra/bootloader and use script like ./flash.sh however they are not located in the linux running on TX2.
Is the flash.sh file is something I have to copy from the host PC to target TX2?
Thanks,

U may use dd to make a raw clone image of the whole drive
Flash sh is a somewhat script which execution should perform similar to dd actions, as it seems to me.
It should be something like cp or mv. U may use as reference https://devtalk.nvidia.com/default/topic/1003072/jetson-tx2/jetson-tx2-is-not-reboot-after-flash/post/5148940/#5148940.

It means that when you call the flash.sh it perform copying or a copy&extract actions from location A to location B. Locations are passed as arguments. It is supposed that you run flash.sh from Host side and it populates filesystem on Jetson overriding existing structure.
You may also try to do dd from within jetson over the network using scp.

Additional info: flash.sh is part of the “driver package”, and runs on the x86_64 PC host. When the Jetson is in recovery mode it becomes a custom USB device instead of a host. The driver package is what understands the recovery mode Jetson. The L4T R27.1 downloads page (includes driver package…JetPack is a front end to the driver package and some extra software) is at:
https://developer.nvidia.com/embedded/linux-tegra

If you want to clone read this thread (there is a modified flash.sh script…the listing there can just be copied and pasted into a file “flash.sh” set with execute permission):
https://devtalk.nvidia.com/default/topic/1000105/jetson-tx2/tx2-cloning/

Normally the flash process goes like this:

  1. Unpack driver package.
  2. cd to the rootfs subdirectory.
  3. Unpack the sample rootfs using sudo.
  4. cd ..
  5. sudo ./apply_binaries.sh
  6. Put the Jetson in recovery mode.
  7. Run sudo flash.sh
    1. rootfs is modified with boot edits
    2. An empty file the size of the destination file system is created (perhaps 28GB in size).
    3. The blank file is formatted as ext4 under loopback.
    4. rootfs is copied over to the blank file under loopback.
    5. A "sparse" (compressed) version of that raw/uncompressed image is created.
    6. The sparse image is copied to the Jetson eMMC
    7. Flash is complete.

Historically there was not always a sparse (compressed image), but due to how long it took to copy over USB2 the sparse image had support added. Prior to sparse images the flash program just used the raw image directly. The current flash program can still use an uncompressed/raw image. The order of dealing with flash images is that “bootloader/system.img” is created; this is then moved to “bootloader/system.img.raw”, and then system.img.raw is used to compress into system.img. flash.sh does not care if system.img is raw or sparse, it works.

When you clone the root partition you can place it in the bootloader subdirectory with the name “system.img”. If you use the command line option to flash.sh of “-r”, then all of the steps to build the system.img and system.img.raw are skipped…in this case it expects system.img to already exist, and flashes that without touching it. So you clone, name the clone file system.img, put it in the bootloader subdirectory, and flash something like this:

sudo ./flash.sh -r jetson-tx2 mmcblk0p1

The raw system.img is loopback mountable so it can be edited, explored, so on. This should produce exactly the same file as dd would produce when covering the mmcblk0p1 partition. The difference is that dd requires a running Jetson, and cloning works on a recovery mode Jetson regardless of whether the Jetson can be booted or not. You could use a dd image named system.img and achieve the same results from restore with the “-r” option.

Note that there are many hidden partitions on a Jetson. Most of the time it isn’t necessary to clone those or back them up since they have no effect on most customizations. I don’t know what the command is on the current flash script to clone “all” as a single image (meaning including hidden partitions), but you could use dd on mmcblk0 instead of mmcblk0p1 and get that entire image. dd could then be used again with the proper offsets and lengths to extract the root partition and you’d once more end up with exactly the same image as what a clone or mmcblk0p1 dd would give.

Note that the “bootloader/mksparse” program is able to take a raw image and convert it to a sparse image, but as soon as you do that your clone or backup can no longer be loopback mounted or edited. You can still flash with it. For info on mksparse see the JTK1 clone info:
http://elinux.org/Jetson/Cloning

There are ways to convert a sparse image back to a raw image, but I have not researched that so I couldn’t tell you what the command would be.