Is it possible to create a complete SD image in linux without having root privileges (that is, no loopback mount)? I\'m looking for a way to automate embedded system image creat
I'm trying to do the same thing. My first attempt used the loopback block device, but I have found work-arounds to both steps that require loopback.
Here's what I'm doing ( $1 is image file name, $2 is file size):
dd if=/dev/zero of=$1 bs=512 count=$(($2/512))
parted -s $1 mklabel msdos
parted -s $1 "mkpart primary 0% 100%"
sudo losetup --find $1 --offset $OFFSET_TO_PARTITION_BYTES
mkfs.ext4 -I 128 -L BOOT -b 2048 -O ^has_journal /dev/loop0 $SIZE_IN_2048_BLOCKS
The loopback is used because
Shitty work-around for step 4 & 5:
Work-around solution to step 6:
Caveat: ext4 support is not advertised in their documentation, and attempts to mount come with a warning:
This is experimental code, opening rw a real file system could be
dangerous for your data. Please add "-o ro" if you want to open the file
system image in read-only mode, or "-o rw+" if you accept the risk to test
this module
vdfuse should be able to mount a raw image without the help of xmount, but there is a bug which ignores the RAW option.
I tracked down and fixed the bug with a patch here:
https://bugs.launchpad.net/ubuntu/+source/virtualbox-ose/+bug/1019075