#! /bin/sh # # Install and run Fedora Core 4 with qemu. # # Kickstart file to use: KS=/var/www/html/mirror/ks.cfg test -f $KS || KS=/home/mirror/ks/ks.cfg # Image file to use as harddisk IMAGE=fc4.vmdk # Directory where to find Fedora Core: FEDORA=/var/www/html/mirror/fedora/4/i386/os test -d $FEDORA || FEDORA=/home/mirror/fedora/4/i386/os # Install FC5: test "$1" = "fc5" && { shift IMAGE=fc5.vmdk FEDORA=/var/www/html/mirror/fedora/5/i386/os test -d $FEDORA || FEDORA=/home/mirror/fedora/5/i386/os } # Install the development tree: test "$1" = "devel" && { shift IMAGE=fc-devel.vmdk FEDORA=/var/www/html/mirror/fedora/development/i386/os test -d $FEDORA || FEDORA=/home/mirror/fedora/development/i386/os } # PXE files within the tree: PXE=$FEDORA/images/pxeboot # Qemu options to use: OPTS="-net nic -net tap -hda $IMAGE" # Install params for a serial console: APPEND="initrd=initrd.img ramdisk_size=8192 text console=ttyS0,115200n8" APPEND="$APPEND utf8 selinux=0 clock=pit ks=cdrom://ks.cfg" # Load kernel acceleration module: test -c /dev/kqemu || /sbin/modprobe kqemu # Do we want to start a new installation? if test "$1" = "install" ; then # Sanity check: test -d $FEDORA -a -d $PXE -a -f $KS || exit 1 test -x /usr/bin/mkisofs || exit 1 # Create an empty harddisk image: test -f $IMAGE || qemu-img create $IMAGE 7G # Installation needs more RAM then the running system: if test `hostname` = dudweiler.stuttgart.redhat.com ; then OPTS="$OPTS -m 384" else OPTS="$OPTS -m 576" fi # The following is not working for me, not sure why: #qemu $OPTS -nographic -kernel $PXE/vmlinuz \ # -initrd $PXE/initrd.img -append "$APPEND" # Use this for normall install options with a real console: #qemu $OPTS -cdrom $FEDORA/images/boot.iso -boot d # Copy boot data into a new directory: BOOTDIR=`mktemp -d bootdirXXXXXX` BOOTISO=`mktemp bootXXXXXX.iso` cp -ar $FEDORA/isolinux $BOOTDIR/ cp -a $KS $BOOTDIR/ chmod 644 $BOOTDIR/isolinux/* sed -i -e "s/^timeout .*/timeout 5/" $BOOTDIR/isolinux/isolinux.cfg sed -i -e "s#^ append .*# append $APPEND#" $BOOTDIR/isolinux/isolinux.cfg #cat $BOOTDIR/isolinux/isolinux.cfg /usr/bin/mkisofs -quiet -o $BOOTISO -b isolinux/isolinux.bin \ -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \ -boot-info-table -R -J -V "serial console install" -T $BOOTDIR rm -rf $BOOTDIR time qemu $OPTS -nographic -cdrom $BOOTISO -boot d rm -f $BOOTISO exit 0 fi time qemu $OPTS -m 256 -nographic exit 0 # Things todo within the installed system (some of these are already done # from anaconda for an install over serial line): # - Modify /etc/inittab to start a serial getty: # s0:12345:respawn:/sbin/agetty 9600 ttyS0 linux # s0:12345:respawn:/sbin/mgetty -r -s 9600 /dev/ttyS0 linux # - Modify /boot/grub/grub.conf: # #splashimage=(hd0,0)/grub/splash.xpm.gz # serial –unit=0 –speed=9600 # terminal –timeout=10 --dump --lines=24 --silent serial console # - Modify grub.conf to have "console=tty0 console=ttyS0,9600n8" # to output kernel messages on both consoles, last entry is # also used for keyboard input. # - Modify /etc/securetty to include your serial device. # Further configuration for the machine running qemu: # - "echo 1 > /proc/sys/net/ipv4/ip_forward" or # "net.ipv4.ip_forward = 1" in /etc/sysctl.conf. # - ip masquerading for a new network: # "/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE" # - /etc/qemu-ifup: # "#!/bin/sh # /sbin/ifconfig ${1##/*/} 172.20.0.1" # - Maybe full /etc/qemu-ifup: # #!/bin/sh # /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # echo 1 > /proc/sys/net/ipv4/ip_forward # /sbin/ifconfig ${1##/*/} 172.20.0.1