Tag Archives: iso9660

New in nbdkit: Create an ISO image on the fly

nbdkit is the pluggable Network Block Device server that Eric and I wrote. I have submitted a talk to FOSDEM next February about the many weird and wonderful ways you can use nbdkit as a flexible replacement for loopback mounting.

Anyway, new in nbdkit 1.7.6 you can now create ISO 9660 (CD-ROM) disk images on the fly from a directory:

# nbdkit iso /boot params="-JrT"
# nbd-client -b 512 localhost /dev/nbd0
# file -bsL /dev/nbd0
ISO 9660 CD-ROM filesystem data 'CDROM'
# mount /dev/nbd0 /tmp/mnt
# ls /tmp/mnt
# umount /tmp/mnt
# nbd-client -d /dev/nbd0
# killall nbdkit

That ISO wouldn’t actually be bootable, but you could create one (eg. an El Torito ISO) by adding the appropriate extra parameters.

To head off the first question: If you copy files into the directory while nbdkit is running, do they appear in the ISO? Answer: No! This is largely impossible with the way Linux block devices work.



Filed under Uncategorized

Use libguestfs to edit a CD ISO

If you want to install a virtual machine from a CD, but you need to pass extra parameters to the Linux kernel, how can you do it?

Virt-install has an option to pass extra parameters to the kernel, but it doesn’t work with CD images because Linux CDs contain their own boot configuration system called ISOLINUX. Of course you can manually type in the extra parameters at the boot prompt, but that cannot be automated.

I was asked today can we use libguestfs to edit the ISOLINUX configuration inside the ISO directly? My first answer was yes, just do:

guestfish -a boot.iso -m /dev/sda edit /isolinux/isolinux.cfg

Unfortunately this doesn’t work for CD ISOs formatted using the standard ISO9660 filesystem. The kernel driver that guestfish uses is read-only, and you’ll get an error when the edit command tries to save the file. (As an aside, it should just work on UDF-formatted ISOs such as DVD images, but I didn’t try it).

Still, all is not lost and we can use guestfish to make the edit and still not require root. We just have to unpack the ISO, make the edit, and pack it up again, like this:

mkdir /tmp/iso
cd /tmp/iso
guestfish -a ../boot.iso -m /dev/sda tar-out / - | tar xvf -
vi isolinux/isolinux.cfg
mkisofs [flags - see comments] -o ../newboot.iso .


Filed under Uncategorized