How to create a multi partition SD disk image without root privileges?

后端 未结 5 770
陌清茗
陌清茗 2021-02-13 11:06

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

5条回答
  •  梦毁少年i
    2021-02-13 11:27

    Yes, this is possible with guestfish:

    $ cat << END > extlinux.conf
    > default linux
    > timeout 0
    >
    > label linux
    > kernel /vmlinuz
    > append initrd=/initrd.img root=/dev/vda1 rw console=ttyS0
    END
    $ guestfish -N debian-unstable.img=disk:2G -- \
        part-disk /dev/sda mbr : \
        part-set-bootable /dev/sda 1 true : \
        mkfs ext2 /dev/sda1 : mount /dev/sda1 / : \
        tar-in debian-unstable.tar / : \
        extlinux / : \
        copy-in extlinux.conf /
    

    The result will be debian-unstable.img with one ext2 partition on it, containing all files from the tarball debian-unstable.tar and the whole thing is made bootable with extlinux. You can verify the disk image using qemu.

提交回复
热议问题