General
cancel
Showing results for 
Search instead for 
Did you mean: 

Mount bootable ISO or IMG file and change files

SOLVED
Go to solution
'chris'
Super Advisor

Mount bootable ISO or IMG file and change files

hi

Howto mount bootable ISO or IMG file to change files and save these changes?
8 REPLIES
Alzhy
Honored Contributor
Solution

Re: Mount bootable ISO or IMG file and change files

I don't think you can do it directly. When you mount an ISO file - it will always be Read Only.

Your best bet is to find out how the ISO was created, its format and edit files from there. Then re-create the ISO.

What kind/type of ISO / IMG file are we talking about here?
Hakuna Matata.
Lucifer Megacruel
Valued Contributor

Re: Mount bootable ISO or IMG file and change files

Hi chirs,

Of course that is possible. You need to mount the iso or img file as loop back , then make changes and exit.

eg

mount -o loop cdrom.iso /mnt/loop

cd /mnt/loop
make changes < Bla bla.>

umount /mnt/loop

Truly Evil
Lucifer Megacruel

"To Denouce the Evils of Truth and Love. To cause may hem and destruction and necromancy , Lucifer is here"
Lucifer Megacruel
Valued Contributor

Re: Mount bootable ISO or IMG file and change files

Sorry,

Just checked on what Alzhy said , it is mounted read only :P. You can copy contents and make use of mkisofs to recreate a new image.

Truly Evil
Lucifer Megacruel
"To Denouce the Evils of Truth and Love. To cause may hem and destruction and necromancy , Lucifer is here"
Lucifer Megacruel
Valued Contributor

Re: Mount bootable ISO or IMG file and change files

Hi,

Here's how I would do it :)

mkdir -p /mnt/loopback
mount -oloop cdrom.iso /mnt/loopback
mkdir -p /home/Lucifer/remaster
cp -rf /mnt/loopback/ /home/Lucifer/remaster

Now make we can make glorious modifications in /home/Lucifer/remaster . After we are doing we can create the iso image again.

mkisofs -R -b /mnt/loopback/isolinux/isolinux.bin -c /mnt/loopback/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /home/Lucifer/new.iso /home/Lucifer/


The caveat is the CD's can be booted in floppy emulation mode , so the exact steps i said may not really apply. But it should work in most of the cases.


You can test the newly created images easily using qemu and see that it boots okay ( I am typing it from memory ). You can also use bochs too ( Bochs is somewhat slower , but it is very good for debugging the kernel)

qemu -net-none -m256 -boot cdrom -hdc /home/Lucifer/image.iso

Truly Evil
Lucifer Megacruel
"To Denouce the Evils of Truth and Love. To cause may hem and destruction and necromancy , Lucifer is here"
'chris'
Super Advisor

Re: Mount bootable ISO or IMG file and change files

Thx a lot, I try to mount as a root user an img file on debian lenny and get this problem:

# mount -o loop binary.img /mnt/loopback
mount: you must specify the filesystem type

# file binary.img
binary.img: x86 boot sector; partition 1: ID=0x83, active, starthead 0, startsector 1, 593919 sectors
Lucifer Megacruel
Valued Contributor

Re: Mount bootable ISO or IMG file and change files

Hi Chirs,

If it is a valid iso image, you should be able to mount it using
mount -tiso9660 -oloop cdrom.iso /mnt/loopback

If it is some hard disk image created using qemu or bochs, they you possibly may not be able to mount it.

to create an iso file from a cd, use the dd command

dd if=/dev/hdc /of=cdrom.iso ( put it in if what basically points to your cd drive )


Truly Evil
Lucifer Megacruel
"To Denouce the Evils of Truth and Love. To cause may hem and destruction and necromancy , Lucifer is here"
'chris'
Super Advisor

Re: Mount bootable ISO or IMG file and change files

Thx again, this is not ISO-file, it's a bootable USB Live image file.

Anyway I can mount it using:

# mount -o loop,offset=512 binary.img_old /mnt/loopback

I don't know if I can do a change, that I really need, because I cannot see there
a linux file structure.

# cd /mnt/loopback
# ls
doc ldlinux.sys live md5sum.txt syslinux
# cd syslinux
# ls
boot.txt f1.txt f4.txt f7.txt footer.cfg menu.cfg syslinux.cfg
data f2.txt f5.txt f8.txt header.cfg prompt.cfg
f10.txt f3.txt f6.txt f9.txt help.cfg syslinux.bin

Lucifer Megacruel
Valued Contributor

Re: Mount bootable ISO or IMG file and change files

Hi chris,

syslinux is basically a bootloader :). You wont find anything in that directory other than boot loader related stuff . Check the live directory. Basically the directory structure depends on configuration , there are some small linux distros that runs entirely of the initial ram disk.

Truly Evil
Lucifer Megacruel
"To Denouce the Evils of Truth and Love. To cause may hem and destruction and necromancy , Lucifer is here"