Howto mkfs.ext4/create filesystem into image file? #27156
-
Build task needs to create an OS image. Image is written to file, now need to add ext4 partition (or vfat or anything really) to the image. Is there a way to do that? Mounting the image using loopback fails. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You need to create the filesystem before you can mount it. You can apply If you need to set up partitions within the image file you need to set up the loop device first using |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick answer. I already have the image file containing 3 partitions (boot, root, unallocated). I understand I need to I’m still failing to do so on CI- any hint would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
You can use command like this to set up the loop device:
The The example command should give you additional devices for the partitions, named like |
Beta Was this translation helpful? Give feedback.
You can use command like this to set up the loop device:
The
--partscan
parameters enables detection of partitions in the loop device,/dev/loop0
is the loop device you want to use. You might need to use another if you already use other loop devices, or use-f
to automatically use a free one (but then you need to find which one).The example command should give you additional devices for the partitions, named like
/dev/loop0p1
(with 1 being the partition number here). You can work with those like with any disk partition, e.g. runmkfs.ext4 /dev/loop0p3
.