December 03, 2002
How to edit a Linux bootable CDROM under FreeBSD [ Software ]
One of my cow-orkers has been out of town for the past week or so, and he was thoughtful enough to leave a BIOS boot password on his Dell workstation. Not like we needed access to this workstation while he was gone, no, no one would ever leave a machine locked down like that if it was needed. That would inspire others to acts of BOFHery.
So that lasted until I ripped the "reset password" jumper out from the motherboard (love those easy-access cases), reset the password, and re-arranged the letters on his keyboard to spell W-A-N-K-E-R in the upper-left-hand corner instead of the usual Q-W-E-R-T-Y. And then, for giggles, I thought I'd leave a bootable Linux CDROM in his drive to create the impression that his beloved Win2K install had been replaced. But how to edit a Linux bootable CDROM, when all I had were Solaris and FreeBSD boxes?
I've hacked around with the RIP images before. They're a useful bootable Linux rescue disk that includes filesystem and recovery utilities built in. You can download the ISOs and the docs at http://www.tux.org/pub/people/kent-robotti/looplinux/rip/ .
I googled a bit, and found the docs for the ISOLINUX base setup that RIP uses at http://www.tux.org/pub/people/kent-robotti/looplinux/rip/, by H. Peter Anvin of SYSLINUX fame. Some research on loopback filesystems for Solaris and FreeBSD turned up the 'vnconfig' utility for FreeBSD and the 'lofiadm' utility for Solaris 8. The following qualities between the two clinched my decision:
FreeBSD:- don't have to supply full path to 'vnconfig' for file used with loopback fs, unlike 'lofiadm' for Solaris
- make sure you have a kernel compiled with 'options EXT2FS', or else mount_ext2fs won't work
- need to install the /usr/ports/sysutils/mkisofs port, version 1.15a21 from 4.6-RELEASE works fine
- can use 'lofiadm' for loopback fs mounting
- no easily obtainable, stable ext2fs support for Solaris 8 on SPARC
- mkisofs that's shipped with Solaris 8 is sorely lacking - 1.12b5
I did find some utilities that handled ext2fs support for Solaris 8/x86, but nothing that had been tested on SPARC. Ah well, FreeBSD wins.
So onto the goodies:
- Set up the directory structure for your ISO:
- Mount the 'rescue.gz' ext2fs filesystem and edit it
- Create a non-login script:
- Put the 'rescue.gz' ext2fs back where it came from:
- Set up the bootable ISO to auto-boot:
- I wrote a build-iso.sh script to avoid repetitive typing whilst testing:
- And build your fresh tasty ISO:
# vnconfig -c vn0c /home/staging/rip-52.iso.bin # mount -t cd9660 /dev/vn0c /mnt # cd /mnt # cp isolinux/rescue.gz /home/staging # mkdir /home/staging/root # cp -Rp * /home/staging/root/
# cd /home/staging # umount /mnt # vnconfig -u vn0c # gzip -d rescue # vnconfig -c vn0c /home/staging/rescue # mount -t ext2fs /dev/vn0c /mnt # cd /mnt # cd /etc # vi inittab
edit tty1 thusly:tty1::respawn:/sbin/logincomment out the rest of tty2 - tty6
# vi init.d/rcS
comment out the 'Choose a keymap' section
# vi issue
I changed this to 'Linux 2.4.18'
# vi ../sbin/login
#!/bin/sh
#
# Script to simulate login process
while [ 0 = 0 ]; do
echo ""
echo -n "Login: "
read login
echo -n "Password: "
read password
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo -n "."
echo ""
echo "Invalid login. Wanker. Your password's showing."
echo ""
done
# chmod 755 ../sbin/login
# cd /home/staging # umount /mnt # vnconfig -u vn0c # gzip -9 rescue # cp rescue.gz root/isolinux/
# cd root/isolinux # rm boot.cat # vi isolinux.cfg
change PROMPT to 0 add TIMEOUT 0 remove DISPLAY f1.txt remote F1, F2 lines
# cd /home/staging
# vi build-iso.sh
#!/bin/sh
#
# Script to build bootable Linux iso image
OUTPUT=wanker.iso
ROOT=root
if [ "X${1}" != "X" ]; then
OUTPUT=${1}
fi
if [ "X${2}" != "X" ]; then
ROOT=${2}
fi
mkisofs -o $OUTPUT -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
-boot-info-table $ROOT
# eof
# chmod 755 build-iso.sh
# ./build-iso.sh Size of boot image is 4 sectors -> No emulation Total translation table size: 2048 Total rockridge attributes bytes: 0 Total directory bytes: 2048 Path table size(bytes): 26 Max brk space used f000 2176 extents written (4 Mb)
And then I scp'd wanker.iso over to my laptop, where I burnt it with Nero and tested on a Dell GX150 - worked great! A triple Thanksgiving treat once my cow-orker returns tomorrow. Ought to be fun. :)
If anyone wants to get a copy of the resulting wanker.iso, let me know via email and I can send the image along.
Posted by edobbs at December 3, 2002 06:56 PM
Original content copyright ©1995-2006 Eric Dobbs, except where otherwise noted.
