Yes. You said “raw” image, which is exactly what you need since it can be loopback mounted.
“Covering” a file with loopback means the loopback device can be treated as an ordinary block device (a partition or an entire disk). Covering a raw image with loopback means the loopback device becomes an ext4
partition. Do keep in mind that when done you need to release the loop device, otherwise you will run out.
The simplest method is to let mount
do the loopback covering (you can do it in manual steps if you wish). Example, if the file is named “system.img.raw
”:
sudo mount -o loop ./system.img.raw /mnt
ls /mnt
sudo umount /mnt
Note that you can list all active loop devices with “losetup -a
”. You can detach a specific loop device (using “/dev/loop0
” as an example) with “sudo losetup -d /dev/loop0
”. You can blanket detach devices with “sudo losetup -D
”). There are cases where using losetup
as a regular user will list a loop device, but not create nor modify that device, whereas doing the same thing as user root/sudo will create a device in addition to listing it.
If you were to have temporarily mounted your loopback image on “/mnt
”, then you can add or remove or alter files in “/mnt/boot
”, for example, the kernel. You could add a kernel and modify “/mnt/boot/extlinux/extlinux.conf
” to provide a new boot entry (and thus be able to use serial console to pick which entry to boot if you want the non-default entry, and perhaps rescue a system without use of flash).
Note that a normal command line flash might be something like this, which generates a new image each time run (adjust for your Jetson model):
sudo ./flash.sh jetson-xavier mmcblk0p1
(this writes a new “bootloader/system.img
” and “bootloader/system.img.raw
” each time)
However, to “reuse” the rootfs image, and not create a new one:
sudo ./flash.sh -r jetson-xavier mmcblk0p1
The above never overwrites and never creates any change to “bootloader/system.img.raw
” or “bootloader/system.img
”.
During flash only the actual “system.img
” is flashed, and this is a “sparse” file by default, but a raw image works the same way without error if it is named system.img
, but it takes longer to flash. You could place your modified image (make sure it is not mounted and not covered by loopback before you start…perhaps it wouldn’t be a problem, but it is asking for trouble to flash something mounted) as “bootloader/system.img
” and that is what would be installed.
The “mksparse
” (with fill pattern “0
”) can be used to convert a raw file to sparse if you wish.
Note that there are also ways to set your kernel Image
file by way of a conf file as well, such that it would still generate a new image prior to flash, but the image would use your kernel.