How to clone M.2 mounted nvme partition using flash.sh on Xavier / JP4.3

Hi,

Wondering if it’s possible to use the flash.sh script to clone an nvme partition I’m using as my root and everything else on a Xavier that’s running Jetpack 4.3?

Used to be able to do it with the TX2 and a SATA mounted partition.

Thanks,
Ben

on jetson xavier

sudo parted /dev/nvme0n1
mklabel gpt
mkpart primary 2048s 100%
quit

sudo mkfs.ext4 /dev/nvme0n1p1

sudo blkid /dev/nvme0n1p1
my device partuuid
/dev/nvme0n1p1: UUID=“b11f5460-ec67-4f4a-9c41-8cffd4b11df4” TYPE=“ext4” PARTLABEL=“primary” PARTUUID=“532ead91-c15f-4412-83b5-e5675ff21773”

sudo dd if=/dev/mmcblk0p1 of=/dev/nvme0n1p1

on linux host

echo ‘532ead91-c15f-4412-83b5-e5675ff21773’ > bootloader/l4t-rootfs-uuid.txt

sudo ./flash.sh jetson-xavier external

on jetson xavier

sudo resize2fs /dev/nvme0n1p1

Hi @jocover,

Thank you for the reply and the help. Sorry, I’ve been traveling.

Looking at what you wrote, it looks to me like instructions for setting up the nvme drive and for flashing the filesystem to that drive.

I already have that. I have a big installation of other software setup now and I want to be able to backup my work.

I used to be able to use the flash.sh script to do that with earlier JetPacks like this:

[b]Cloning the Image

cd into the directory containing the L4T installation package on the host PC. The command below will save the TX2’s eMMC image to the specified file on the host.

$ sudo ./flash.sh -r -k APP -G backup.img jetson-tx2 mmcblk0p1

In this case, we call the file backup.img, so the same flash.sh script can be re-used to format and flash other Jetson’s with the image.

Note that if you receive an error from the script about unrecognized -G option, replace your flash.sh with the script from this post.
Copy the backup raw image to flashing directory

copy the .raw file which contains complete image from source device.

$ sudo cp backup.img.raw bootloader/system.img

Restoring the Image

The recommended way to restore multiple units with different serial numbers is to save the image above as “system.img” and use the head L4T flashing script, flash.sh, with the -r option (to reuse your backed-up system.img without rebuilding the vanilla image from scratch):

$ sudo ./flash.sh -r -k APP jetson-tx2 mmcblk0p1[/b]

That doesn’t work now, as the partition doesn’t get detected. The Xavier is in recovery mode.

Any other thoughts?

@carolyuu / @WayneWWW / @linuxdev…any ideas please?

Thanks
Ben

Cloning an image of a non-rootfs eMMC partition via flash.sh probably isn’t advised, and “dd” will likely do all that you want with less effort. “dd” is fairly flexible.

Can you mount the drive on your host PC? If so, then this is really simple.

If you can only mount the drive on the Jetson, but the Jetson is running correctly, and if the NVMe is not actually mounted for write, then this too is fairly simple. There are some questions to answer for this latter case, such as how big is the partition, where do you want to store it, is this a running rootfs or is this something you can access without it being write mounted?