Clone procedure and restore can depend on which release you are using (see “head -n 1 /etc/nv_tegra_release”…this will still exist in your host’s “Linux_for_Tegra/rootfs/etc/nv_tegra_release” if you kept your flash setup).
Basically a clone means you put it in recovery mode, and then run something like this, depending on release (it takes a lot of space…make sure you have over 30GB of spare space…e.g, “df -H /where/ever/you/clone/Linux_for_Tegra/”):
sudo ./flash.sh -r -k APP -G "backup.img" jetson-xavier mmcblk0p1
This will produce two files, “backup.img” and “backup.img.raw”. You can throw away the smaller “backup.img”. Keep a safe copy of “backup.img.raw” somewhere (it’ll be about 28GB in size…might take an hour just to copy the file). This is the file you can loopback mount. Example:
sudo mount -o loop backup.img.raw /mnt
# ...do stuff there..., then umount:
sudo umount /mnt
sudo losetup -D
If you still have the original flash in “Linux_for_Tegra/rootfs/”, then you might be able to copy in these files, but keep in mind that if first boot was needed, then these files won’t have your account listed:
Linux_for_Tegra/rootfs/etc/
... group group- gshadow gshadow- passwd passwd- shadow shadow-
In reality, if someone did hack in, then there might be more changed than just a password and you probably shouldn’t trust it. What you could do instead is take any valuable code, copy it into the “rootfs/” directory, and then flash normally (you have a backup, and so it doesn’t hurt if you fail). You’d get the sample rootfs plus whatever edits you made (the image would be created from rootfs plus some boot content based on arguments to flash.sh).
If you do want to use the backup.img.raw, then place a copy with the name “system.img” at:
Linux_for_Tegra/bootloader/system.img
…then flash:
sudo ./flash.sh <b><i>-r</i></b> jetson-xavier mmcblk0p1