Command Line Militia: How to edit a Linux Live CD ISO in 30 easy steps

Command Line Militia: How to edit a Linux Live CD ISO in 30 easy steps by voncrud - 2005-05-04 19:58:17
So you have a Linux Live CD, but it doesnt have that particular
program you need to have and you must edit the CD. Just to make it interesting, we are going to do it all by command line, including
burning the ISO to cdrom:


EXTRACT CD:

1) Boot up a Linux Box (I used WhiteBox Enterprise with 2.4.21-27 kern)
2) Insert CD into CDROM
3) mkdir /cdiso
4) cp -av /mnt/cdrom/* /cdiso

EXTRACT and EDIT INITRD.IMG (The Linux Filesystem)

5) mkdir /cdinitimg
6) find the initrd.gz or initrd.img in /cdiso
7) gunzip -c /cdiso/isolinux/initrd.img > /cdinitimg/initrd.img
- believe it or not the image is compressed
8) cd /cdinitimg
9) mdkir point
10) mount initrd.img point -o loop
11) mkdir /cdimgextract
12) cp -av /cdinitimg/point/* /cdimgextract
13) umount /cdinitimg/point
14) rm -rf /cdinitimg
15) make any changes you need to the initrd.img in /cdimgextract

REMAKE MODIFIED INITRD.IMG

16) mkdir /cdinitrd
17) dd if=/dev/zero of=initrd.img bs=1k count=60960
18) mke2fs -i 1024 -b 1024 -m 5 -F -v initrd.img
19) mount initrd.img cdinitrd -t ext2 -o loop
20) cp -av /cdimgextract/* /cdinitrd
21) umount /cdinitrd
22) gzip --best initrd.img
23) cp initrd.img /cdiso/isolinux/
24) rm -rf /cdinitrd
25) rm -rf /cdimgextract

REMAKE MODIFIED ISO

26) cd /cdiso
27) use this shell script:
-note: you may have to edit it a little to fit your ISO.

#!/bin/bash
# make the new iso and put in root.
mkisofs -o /new.iso -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
-boot-info-table -J -R -V disks .
#

28) now you have a new ISO named new.iso in your / directory

BURN THE NEW ISO IMAGE

29) eject the old cd, and pop in a blank
- make sure you have cdrecord
30) cdrecord -v -pad speed=1 dev=0,0,0 /new.iso

NOTE: For the record, I had to edit a G4U CD to add dolly client
(a peer to peer client for clustering) for a project here at work.
This is the documentational(?) output.

#EOF
( 2 Comments )