Could anyone please direct towards a method to clone the entire rootfs on the internal eMMC, of a production Nano?
What we want to achieve is like an image based flashing.
With the current infrastructure, we are able to flash the Nanos, but then we have to do some updates and upgrades and also install our custom software (often over the internet) later on.
Now, is there is a way to clone the root file system entirely such that it contains the updates before hand, and we could use this modified (updated) root file system inside the Jetpack directory and use the flash script to transfer these contents on a new Nano?
P.S. : We use the flash.sh script currently to flash the OS from Jetpack on the Nano (as it is the only method to do so, as far as I know). Also, I referred this topic: https://devtalk.nvidia.com/default/topic/1044148/how-to-copy-whole-rootfs-of-jetson-tx2-to-pc/,
but since we also need to take into account our custom software, which runs only a Nano platform, this method does not work for us. Also, we have some custom drivers implemented in the kernel.
you may use the flash script to backup the system image, which will also contain rootfs.
for example, $ sudo ./flash.sh -r -k APP -G backup.img nano mmcblk0p1
however, here’s an known issue that performing image back-up were malfunction currently.
you might have an alternative way, with dd commands to back-up APP partition. please refer to Topic 1067292 as see-also.
thanks
I use rsync to do exactly what you describe. You can rsync a running Nano via ssh or rsyncd.
There are things you should do on the source device before the copy…
Make sure there’s no swapfile on the root filesystem.
Clean out /var/cache, /tmp, and any other directories that might contain transient files.
You can do those things after the copy of course but it saves time if you do it before.
Once I get a device in the exact state I want I perform the following on my host machine:
### As root
# cd Linux_for_Tegra
### Move the current rootfs directory if you have one
# mv rootfs rootfs.stock
# mkdir rootfs
# rsync -vaHAx jetson:/. ./rootfs/
Things to do in ./rootfs/ after the copy…
Reset /etc/hostname
Clean out /var/lib/NetworkManager
Check /etc/fstab for UUID references.
Make any other changes you need.
Now you can use create-jetson-nano-sd-card-image.sh to create a full disk image or if you
just want to image the root filesystem, you can…
### Create a sparse file large enough to hold the root filesystem
# dd if=/dev/zero of=rootfs.img bs=1M count=0 seek=8192
### Format the filesystem
# mkfs.ext4 ./rootfs.img
### Create a temp directory to mount the image
# mkdir rootfs.tmp
### Mount the image
# mount -o loop ./rootfs.img rootfs.tmp
### Copy the cntents
# rsync -vaHAx roofs/. ./rootfs.tmp/
### Unnount the image
# umount rootfs.tmp
### Now you have an image of just the root filesystem.