]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - lfs/xen-image
xen-image: fix firstrun.
[people/pmueller/ipfire-2.x.git] / lfs / xen-image
index 4da844c65384ed08f0e755e69fe927a1c0b4effb..caef9725fcff60332758f086cf6a0d4ecff37829 100644 (file)
@@ -47,14 +47,23 @@ md5 :
 IMGinst  := /install/images/$(SNAME)-$(VERSION).xen.$(MACHINE)-$(ED)-core$(CORE).tar.bz2
 MNThdd   := /install/harddisk
 
-IMGroot  := /install/images/$(SNAME)/$(SNAME).img
-IMGswap  := /install/images/$(SNAME)/swap.img
-SIZEroot := 1024
+IMGboot  := /install/images/$(SNAME)/$(SNAME)-boot.img
+IMGswap  := /install/images/$(SNAME)/$(SNAME)-swap.img
+IMGroot  := /install/images/$(SNAME)/$(SNAME)-root.img
+IMGvar   := /install/images/$(SNAME)/$(SNAME)-var.img
+
+SIZEboot := 30
 SIZEswap := 512
+SIZEroot := 512
+SIZEvar  := 950
 
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        rm -rf $(MNThdd) $(IMGinst) $(IMGroot) && mkdir -p $(MNThdd)
-       mkdir -p /install/images/$(SNAME)/boot
+       mkdir -p /install/images/$(SNAME)   # /boot
+
+       #Create bootimage
+       dd bs=1M if=/dev/zero of=$(IMGboot) count=$(SIZEboot)
+       mkfs.ext2 -F $(IMGboot)
 
        #Create swapimage
        dd bs=1M if=/dev/zero of=$(IMGswap) count=$(SIZEswap)
@@ -64,14 +73,20 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        dd bs=1M if=/dev/zero of=$(IMGroot) count=$(SIZEroot)
        mkfs.ext3 -F $(IMGroot)
 
-       # Mount Images (ext3 mount create a inaccessible ".journal"
-       mount -o loop -t ext2 $(IMGroot) $(MNThdd)
+       #Create varimage
+       dd bs=1M if=/dev/zero of=$(IMGvar) count=$(SIZEvar)
+       mkfs.ext3 -F $(IMGvar)
+
+       # Mount Images
+       mount -o loop $(IMGroot) $(MNThdd)
        mkdir $(MNThdd)/boot
        mkdir $(MNThdd)/var
        mkdir $(MNThdd)/var/log
+       mount -o loop $(IMGboot) $(MNThdd)/boot
+       mount -o loop $(IMGvar) $(MNThdd)/var
 
        # Install IPFire without kernel modules
-       tar -C $(MNThdd)/ -xvjf /install/cdrom/$(SNAME)-$(VERSION).tbz2 \
+       tar -C $(MNThdd)/ -xvf /install/cdrom/$(SNAME)-$(VERSION).tlz --lzma \
                --exclude=lib/modules* --exclude=boot*
 
        #Install Xen Kernel
@@ -79,6 +94,22 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        chroot $(MNThdd) /opt/pakfire/tmp/install.sh
        rm -rf $(MNThdd)/opt/pakfire/tmp/*
 
+       #Create grub menuentry for pygrub
+       mkdir $(MNThdd)/boot/grub
+       echo "timeout 10"                          > $(MNThdd)/boot/grub/grub.conf
+       echo "default 0"                          >> $(MNThdd)/boot/grub/grub.conf
+       echo "title IPFire (XEN-Kernel)"          >> $(MNThdd)/boot/grub/grub.conf
+       echo "  kernel /vmlinuz-$(KVER)-ipfire-xen root=/dev/xvda3 rootdelay=10 panic=10 console=xvc0 ro" \
+                                                 >> $(MNThdd)/boot/grub/grub.conf
+       echo "  initrd /ipfirerd-$(KVER)-xen.img" >> $(MNThdd)/boot/grub/grub.conf
+       echo "# savedefault 0" >> $(MNThdd)/boot/grub/grub.conf
+
+       ln -s grub.conf $(MNThdd)/boot/grub/menu.lst
+
+       #Copy the meta-info of linux-xen package
+       cp -f /install/packages/meta-linux-xen $(MNThdd)/opt/pakfire/db/installed
+       cp -f /install/packages/meta-linux-xen $(MNThdd)/opt/pakfire/db/meta
+
        #Set default configuration
        echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings
        echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings
@@ -90,36 +121,49 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        mount --bind /dev  $(MNThdd)/dev
        mount --bind /sys  $(MNThdd)/sys
        chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
-       sed -i -e "s|DEVICE1|#boot-disabled|g" $(MNThdd)/etc/fstab
-       sed -i -e "s|DEVICE2|/dev/xvdb1|g" $(MNThdd)/etc/fstab
-       sed -i -e "s|DEVICE3|/dev/xvda1|g" $(MNThdd)/etc/fstab
-       sed -i -e "s|DEVICE4|#var-disabled|g" $(MNThdd)/etc/fstab
+       sed -i -e "s|DEVICE1|/dev/xvda1|g" $(MNThdd)/etc/fstab
+       sed -i -e "s|DEVICE2|/dev/xvda2|g" $(MNThdd)/etc/fstab
+       sed -i -e "s|DEVICE3|/dev/xvda3|g" $(MNThdd)/etc/fstab
+       sed -i -e "s|DEVICE4|/dev/xvda4|g" $(MNThdd)/etc/fstab
 
        sed -i -e "s|FSTYPE|ext3|g" $(MNThdd)/etc/fstab
-       cp -f $(MNThdd)/etc/mkinitcpio.conf $(MNThdd)/etc/mkinitcpio.conf.org
-       sed -i -e "s| autodetect | |g" $(MNThdd)/etc/mkinitcpio.conf
-
-       #Remove File System modules because they are included to kernel
-       sed -i -e "s|reiser4 reiserfs ext3| |g" $(MNThdd)/etc/mkinitcpio.conf
 
-       chroot $(MNThdd) /sbin/mkinitcpio -g /boot/ipfirerd-$(KVER)-xen.img -k $(KVER)-ipfire-xen
-       cp -f $(MNThdd)/etc/mkinitcpio.conf.org $(MNThdd)/etc/mkinitcpio.conf
-
-       # Create a script for rebuild-initrd and setup
-       echo "#!/bin/bash"                                   > $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
-       echo "/usr/local/sbin/setup /dev/null INSTALL"      >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
-       echo "rm -f /etc/rc.d/rcsysinit.d/S75firstsetup \\" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
-       echo "&& /sbin/reboot"                              >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
-       chmod +x $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
+       chroot $(MNThdd) /sbin/dracut --force --verbose /boot/ipfirerd-$(KVER)-xen.img $(KVER)-ipfire-xen
 
        #Remove root / fstab check
        rm -rf $(MNThdd)/etc/rc.d/rcsysinit.d/S19checkfstab
+       #Remove console init
+       rm -rf $(MNThdd)/etc/rc.d/rcsysinit.d/S70console
+
+       #Add xvc0 to securetty
+       echo xvc0 >> $(MNThdd)/etc/securetty
+
+       #Add getty for xvc0
+       echo "#Enable login for XEN" >> $(MNThdd)/etc/inittab
+       echo "8:2345:respawn:/sbin/agetty xvc0 9600" >> $(MNThdd)/etc/inittab
+
+       #Disable some initskripts
+       echo "#!/bin/sh" > $(MNThdd)/etc/rc.d/init.d/setclock
+       echo "#!/bin/sh" > $(MNThdd)/etc/rc.d/init.d/keymap
+
+       #Remove autoload of acpi modules
+       sed -i -e "s|^ac|#ac|g" $(MNThdd)/etc/sysconfig/modules
+       sed -i -e "s|^battery|#battery|g" $(MNThdd)/etc/sysconfig/modules
+       sed -i -e "s|^button|#button|g" $(MNThdd)/etc/sysconfig/modules
+       sed -i -e "s|^fan|#fan|g" $(MNThdd)/etc/sysconfig/modules
+       sed -i -e "s|^processor|#processor|g" $(MNThdd)/etc/sysconfig/modules
+       sed -i -e "s|^thermal|#thermal|g" $(MNThdd)/etc/sysconfig/modules
+       sed -i -e "s|^video|#video|g" $(MNThdd)/etc/sysconfig/modules
+
+       #Change pakfire trunk
+       sed -i -e "s|$(VERSION)|$(VERSION)-xen|g" \
+               $(MNThdd)/opt/pakfire/etc/pakfire.conf
 
        #Copy initramdisk, kernel and config
-       cp -f $(MNThdd)/boot/ipfirerd-$(KVER)-xen.img \
-               /install/images/$(SNAME)/boot
-       cp -f $(MNThdd)/boot/vmlinuz-$(KVER)-ipfire-xen \
-               /install/images/$(SNAME)/boot
+       #cp -f $(MNThdd)/boot/ipfirerd-$(KVER)-xen.img \
+       #       /install/images/$(SNAME)/boot
+       #cp -f $(MNThdd)/boot/vmlinuz-$(KVER)-ipfire-xen \
+       #       /install/images/$(SNAME)/boot
        cp $(DIR_SRC)/config/xen-image/* \
                /install/images/$(SNAME)
        sed -i -e "s|KVER|$(KVER)|g" /install/images/$(SNAME)/ipfire.cfg
@@ -128,8 +172,15 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        umount $(MNThdd)/proc
        umount $(MNThdd)/dev
        umount $(MNThdd)/sys
+       umount $(MNThdd)/var
+       umount $(MNThdd)/boot
        umount $(MNThdd)
 
+       # Zerofree ext3 images to get better compression
+       zerofree $(IMGboot)
+       zerofree $(IMGroot)
+       zerofree $(IMGvar)
+
        # Compress Image
        cd /install/images/ && tar -cvjf $(IMGinst) $(SNAME)