How to add files or directories to the qemu-img
created raw disk file. For example. I use qemu-img create -f raw disk.raw 1G
to generate a disk.raw
file. I want to copy some /bin
, /usr
directories to the disk.raw
file.
I have tried the following commands. With the reference to here.
qemu-img create -f raw disk.raw 1G
mkdir /image
losetup /dev/loop0 disk.raw
fdisk /dev/loop0
> n
> p
> ENTER
> ENTER
> ENTER
> a
> w
kpartx -a /dev/loop0
mount /dev/mapper/loop0p1 /image
However, the last commands output the following error messages: mount: /image: wrong fs type, bad option, bad superblock on /dev/mapper/loop0p1, missing codepage or helper program, or other error.
mkfs.ext4 /dev/mapper/loop0p1
mount /dev/mapper/loop0p1 /image