Skip to content

Howto mkfs.ext4/create filesystem into image file? #27156

Answered by airtower-luna
andig asked this question in Actions
Discussion options

You must be logged in to vote

You can use command like this to set up the loop device:

sudo losetup --partscan /dev/loop0 disk.img

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. run mkfs.ext4 /dev/loop0p3.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants