#!/bin/bash # # GRML-Inst_Plain_Deb # # "Install (plain) Debian via GRML"-script # # Based on the HowTo: # http://wiki.grml.org/doku.php?id=tips#install_plain_debian_via_grml # # by O. La Rosa & P. Richardson - 05-03-2006, # # published under the GNU General Public License: # http://www.gnu.org/licenses/gpl.html # # Contact/feedback: 'olr _at_ brlspeak _dot_ net' # # Cf. README for details and/or update-info. # # It is not only possible to install GRML via grml2hd but to install a # plain(!) Debian system via GRML. This might be useful for example if # Debian does not boot on your hardware while GRML does. This is possible # via running debootstrap (or cdebootstrap). You need network access for # downloading the Debian packages and at least ~500MB of free harddisk # space. P. Richardson and I wrote this script to help you with installing # such a plain Debian very easily. Hope this helps! # Osvaldo La Rosa. # # Variables: # - Debian mirror-site: #MM="ftp://ftp.tugraz.at/mirror/debian" MM="http://http.us.debian.org/debian" KIM="kernel-image-2.6.8-2-386" #KIM="kernel-image-2.6.8-2-686" #KIM="kernel-image-2.6.8-2-686-smp" #KIM="kernel-image-2.6.8-2-k7" #KIM="kernel-image-2.6.8-2-k7-smp" # Functions: stepcounter () { STEP=$((STEP + 1)) echo " -- step $STEP --" } # Running grml-inst_plain_deb: setleds +num clear echo "Running grml-inst_plain_deb . . . " echo " Current defaults: Debian mirror-site = $MM Kernel = $KIM " echo -ne "Press ENTER to continue, CTRL+C to abort ..." read clear # Lets GRML detect our partitions partprobe 2> /dev/null fdisk -l | grep Linux$ stepcounter until read -p"Specify hdXX: you want to install Debian Sarge on partition /dev/" PP [ -b /dev/$PP ] do echo -e "error\a" done until read -p"Specify hdYY for a separate home partition. Hit enter to use the same as / /dev/" HP [ -b /dev/$HP ] || [ -z $HP ] do echo -e "error\a" done echo -e "\a" echo -ne "It will erase all selected partitions. Press ENTER to continue or CTRL+C to abort ..." read stepcounter echo "Making an EXT3 filesystem on /dev/$PP" mkfs.ext3 /dev/$PP stepcounter if ! [ -d /mnt/test ]; then mkdir /mnt/test ; fi echo "Mounting the new partition on /mnt/test" mount -t ext3 /dev/$PP /mnt/test stepcounter echo "Now running debootstrap and getting main packages from Debian-mirror:" debootstrap sarge /mnt/test $MM stepcounter echo "Mounting /proc ..." mount -t proc none /mnt/test/proc stepcounter if [ -b /dev/$HP ] then echo "Making an EXT3 filesystem on /dev/$HP" mkfs.ext3 /dev/$HP echo "Creating fstab entry" FSTBHP="/dev/$HP /home ext3 defaults 0 0" echo "Mounting /home partition" mount -t ext3 /dev/$HP /mnt/test/home fi stepcounter ### Trying to detect a swap partion" #SP=$(cat /proc/swaps | awk '/partition/{ print $1}') SP=$( fdisk -l | awk '/Linux swap/{ print $1}' | tail -n1 ) ### If exists ... if [ -b $SP ] then echo "Found $SP" mkswap $SP ### If not, we create a file based swap. else SizeOfSwap=$(cat /proc/meminfo | grep MemTotal | awk '{ print $2 }') echo "Making a $SizeOfSwap kbytes Swap file on /dev/$PP" SP="/.swp" dd if=/dev/zero of=/mnt/test$SP bs=1024 count=$SizeOfSwap mkswap /mnt/test$SP chmod 600 /mnt/test$SP fi stepcounter echo "Creating fstab ..." mkdir /mnt/test/media/floppy mkdir /mnt/test/media/cdrom cat > /mnt/test/etc/fstab << CONFIGFSTAB /dev/$PP / ext3 defaults 0 1 /proc /proc proc defaults 0 0 $SP none swap sw 0 0 $FSTBHP /dev/fd0 /media/floppy auto noauto,rw,sync,user,exec 0 0 /dev/cdrom /media/cdrom iso9660 noauto,ro,user,exec 0 0 CONFIGFSTAB stepcounter echo "Extracting hard disk name" HD=${PP:0:3} echo "Using $HD" echo "Creating /dev/$HD for GRUB" cd /mnt/test/dev ; ./MAKEDEV -v $HD ; cd - stepcounter echo "Installing grub and a kernel ..." echo "do_initrd = Yes" >> /mnt/test/etc/kernel-img.conf echo "deb $MM stable main" > /mnt/test/etc/apt/sources.list chroot /mnt/test apt-get update chroot /mnt/test apt-get install -y $KIM chroot /mnt/test apt-get install -y grub discover udev until read -p"Specify hdXX if you don't want grub to be installed on your Hard disk's MB (expert), hit enter to continue /dev/" GP [ -b /dev/$GP ] || [ -z $GP ] do echo -e "error\a" done echo "Installing Grub." if [ -z $GP ] then GP=$HD fi grub-install --root-directory=/mnt/test /dev/$GP chroot /mnt/test update-grub -y stepcounter echo "Making a basic DHCP network configuration" echo "Extracting network interface name" NETIF=$(ifconfig | awk '/HWaddr/{print $1}') echo "Using $NETIF" cat > /mnt/test/etc/network/interfaces << CONFIGNET auto lo iface lo inet loopback auto $NETIF iface $NETIF inet dhcp CONFIGNET stepcounter echo "Keyboard configuration" chroot /mnt/test/ dpkg-reconfigure console-data stepcounter echo "Installing a few packages" chroot /mnt/test apt-get install locales #If brltty is present on GRML, we install the package.Thanks to William Windels ps -A | grep brltty if [ $? -eq 0 ] then chroot /mnt/test apt-get install brltty else echo "brltty is not present" fi stepcounter echo "Running base-config" #Be sure to be in stable version chroot /mnt/test echo "set mirror/suite stable" | chroot /mnt/test debconf-communicate mknod /mnt/test/dev/ptyp0 c 2 0 mknod /mnt/test/dev/ttyp0 c 3 0 chroot /mnt/test base-config stepcounter echo "Configuring hosts file" HN=$(hostname) echo $HN > /mnt/test/etc/hostname cat > /mnt/test/etc/hosts << CONFIGHOSTS 127.0.0.1 localhost localhost.localdomain $HN CONFIGHOSTS stepcounter echo "Adding a few modules" cat > /mnt/test/etc/modules << CONFIGMODULES pcspkr lp floppy ide-cd ide-disk ide-generic mousedev CONFIGMODULES stepcounter echo "Unmounting proc ..." umount /mnt/test/proc echo "Unmounting partition ..." umount /mnt/test stepcounter echo " ENTER to reboot, CTRL+C to reboot later ..." read stepcounter echo " Rebooting . . . " reboot # # End of script.