How to create .img of .iso file

Using bash script

Below script will create test.img file with two partation

First Partation:

Name: BOOT
FS Type: Fat 32
FLAGS: lba, boot
Size: 128 M

Second Partation:

Name: rootfs
FS Type: ext4
Size: 1024 - 128 M
 #!/bin/bash

IMAGE=test.img

dd if=/dev/zero of=$IMAGE bs=1M count=1024

sync

cat << END | fdisk $IMAGE
o
n
p
1

+128M
n
p
2


t
1
c
a
1
w
END

sync

fdisk -lu $IMAGE

sync

# mount $IMAGE to format partations
udisksctl loop-setup --file $IMAGE

sync

# Format partation 1 as vfat
sudo mkfs.vfat -F 32 -n "BOOT" /dev/loop27p1 

sync

# Format partation 2 as ext4
sudo mkfs.ext4 -L "rootfs" /dev/loop27p2

sync

Mount .img file in linux

udisksctl loop-setup --file test.img

Extract .img file in linux

Using peazip, we can extract .img file

Download

https://peazip.github.io/peazip-linux.html

NOTE: you can download either GTK2 or Qt5 based peazip, so bydefault GTK2 libs will present in linux. if you are downloading Qt5 based peazip then you need to install dependency.

install

sudo dpkg -i peazip_6.5.1.LINUX.GTK2-2_all.deb

run

search peazip in "show application" to run peazip


©2023-2024 rculock.com