# generate initrd
if [ -n "$INITRD" ] ; then
- if [ "$RELEASE" = 'sarge' ] ; then
- echo "Release sarge detected, will not create an initrd."
- else
- echo "Generating initrd."
- update-initramfs -c -t -k $KERNELVER
- if [ -f "/boot/initrd.img-$KERNELVER" ] ; then
- GRUBINITRD="initrd /boot/initrd.img-$KERNELVER"
- LILOINITRD=" initrd=/boot/initrd.img-$KERNELVER"
- fi
- fi
+ echo "Generating initrd."
+ update-initramfs -c -t -k $KERNELVER
fi
}
# }}}
# grub configuration/installation {{{
-grub() {
- if [ -z "$GROOT" ] ; then
- echo "Warning: \$GROOT is not defined, will not adjust grub configuration therefore."
+grub_config() {
+ if [ -z "$GRUB" ] ; then
+ echo "Warning: \$GRUB is not defined, will not adjust grub configuration therefore."
else
- echo "Adjusting grub configuration for use on ${GROOT}."
-
- # copy stage-files to /boot/grub/
- [ -d /boot/grub/ ] || mkdir /boot/grub
- # i386 specific:
- [ -d /usr/lib/grub/i386-pc ] && cp /usr/lib/grub/i386-pc/* /boot/grub/
- # amd64 specific:
- [ -d /usr/lib/grub/x86_64-pc ] && cp /usr/lib/grub/x86_64-pc/* /boot/grub/
- # sarge ships grub files in another directory
- [ "$RELEASE" = 'sarge' ] && cp /lib/grub/i386-pc/* /boot/grub/
+ echo "Adjusting grub configuration for use on ${GRUB}."
# finally install grub
if [ -x /usr/sbin/update-grub ] ; then
else
UPDATEGRUB='/sbin/update-grub'
fi
- $UPDATEGRUB -y
-
- # grub1:
- if [ -f /boot/grub/menu.lst ] ; then
- sed -i "s/^# groot=.*/# groot=(${GROOT})/g" /boot/grub/menu.lst
- case "$TARGET" in
- # do NOT use uuid with SW-RAID
- /dev/md*)
- sed -i "s|^# kopt=root=.*|# kopt=root=${TARGET} ro ${BOOT_APPEND}|g" /boot/grub/menu.lst
- ;;
- *)
- if [ -n "$TARGET_UUID" ] ; then
- sed -i "s|^# kopt=root=.*|# kopt=root=UUID=${TARGET_UUID} ro ${BOOT_APPEND}|g" /boot/grub/menu.lst
- else
- sed -i "s|^# kopt=root=.*|# kopt=root=${TARGET} ro ${BOOT_APPEND}|g" /boot/grub/menu.lst
- fi
- ;;
- esac
-
- # not sure why savedefault does not work for me; any ideas?
- sed -i "s/^savedefault.*/# &/g" /boot/grub/menu.lst
- $UPDATEGRUB -y
- fi
# grub2:
- if [ -f /etc/default/grub ] ; then
- # create a copy of the original:
- cp /etc/default/grub /etc/default/grub.orig
-
- case "$TARGET" in
- # do NOT use uuid with SW-RAID
- /dev/md*)
- GRUB_CMDLINE="root=${TARGET} ro ${BOOT_APPEND}"
- ;;
- *)
- if [ -n "$TARGET_UUID" ] ; then
- GRUB_CMDLINE="root=UUID=${TARGET_UUID} ro ${BOOT_APPEND}"
- else
- GRUB_CMDLINE="root=${TARGET} ro ${BOOT_APPEND}"
- fi
- ;;
- esac
-
- cat > /etc/default/grub << EOF
-# Note: this file has been generated by chroot-script of grml-debootstrap.
-# This configuration file is a workaround being necessary as the device.map
-# generated by the live system might not correspond with your harddisk
-# installation.
-#
-# Please restore the original Debian configuration executing the following
-# commands when running your harddisk installation:
-#
-# grub-mkdevicemap
-# mv /etc/default/grub.orig /etc/default/grub
-# update-grub
-#
-GRUB_DEFAULT=0
-GRUB_TIMEOUT=5
-GRUB_DISTRIBUTOR=Debian
-# GRUB_DISABLE_LINUX_UUID=true
-GRUB_CMDLINE_LINUX="$GRUB_CMDLINE"
-EOF
-
- [ -n "$INSTALL_NOTES" ] && echo "
-
-The grub2 configuration has been adjusted so you should
-be able to boot into your Debian installation now.
-After rebooting into your Debian installation please execute:
-
- grub-mkdevicemap
- mv /etc/default/grub.orig /etc/default/grub
- update-grub
-
-to finalise configuration. This instructions are available
-in the header of /etc/default/grub as well.
-" >> $INSTALL_NOTES
-
- $UPDATEGRUB
- fi
+ $UPDATEGRUB
fi
}
# }}}
# execute the functions {{{
for i in chrootmirror grmlrepos kernelimg_conf makedev install_policy_rcd \
kernel packages extrapackages mkinitrd reconfigure hosts interfaces \
- timezone fstab hostname initrd grub passwords custom_scripts services ; do
+ timezone fstab hostname initrd grub_config passwords custom_scripts \
+ services ; do
if stage $i ; then
$i && stage $i done || exit 1
fi
#
# Usually you want to use a partition. If you specify a string *without* /dev/
# in the beginning, grml-debootstrap assumes you want to install Debian into a
-# directory. If so then MKFS, TUNE2FS, GRUB, GROOT and FSCK won't apply, no
-# matter of the configuration variables. Make sure the TARGET-directory is on a
-# partition with present dev and exec mount options.
+# directory. If so then MKFS, TUNE2FS, GRUB and FSCK won't apply, no matter of
+# the configuration variables. Make sure the TARGET-directory is on a partition
+# with present dev and exec mount options.
#
# usage examples:
# TARGET='/dev/hda1'
# TARGET='/mnt/grml'
TARGET=''
-## Do you want to install grub? Then adjust the variables GRUB and GROOT.
-## If you do not set the variables grub will not be installed.
-# Where do you want to install grub to? Use grub syntax for specifying
-# hints: hd0,0 is the first partition on the first disk
-# hd0 is the MBR of the first disk
-# usage example:
-# GRUB='hd0'
+## Do you want to install grub? Just specify the device you'd like to use.
+## Example: Specify /dev/sda to install into MBR (master boot record) of
+## /dev/sda. If you do not set the variable grub will not be installed.
+## Please note that grub can NOT be installed into a partition (like /dev/sda2)
+## but in the master boot record only (/dev/sda, /dev/sdb,...).
+# Usage example:
+# GRUB='/dev/sda'
GRUB=''
-# specify root device for usage in grub (corresponds with $TARGET)
-# notice: if you install Debian for example to /dev/hda1 use hd0,0
-# hd0,0 is the first partition on the first disk
-# hd0 is the MBR of the first disk
-# usage example:
-# GROOT='hd0,0'
-GROOT=''
-
# specifiy additional bootparameters for usage in grub
# e.g. "pci=nomsi"
BOOT_APPEND=''
+grml-debootstrap (0.32) unstable; urgency=low
+
+ * Drop support for old-stable/etch.
+ * Simplify usage for grub handling, now it's just GRUB="/dev/sdX[#]".
+
+ -- Michael Prokop <mika@grml.org> Wed, 28 Oct 2009 21:40:46 +0100
+
grml-debootstrap (0.31) unstable; urgency=low
* Adjust grub handling and install grub-pc package for
--debopt <params> Extra parameters passed to the debootstrap command.
--interactive Use interactive mode (frontend).
--nodebootstrap Skip debootstrap, only do configuration to the target.
- --groot <device> Root device for usage in grub, corresponds with
- \$TARGET in grub syntax, like hd0,0 for /dev/sda1.
- --grub <device> Target for grub installation. Use grub syntax for
- specifying, like hd0 for /dev/sda.
+ --grub <device> Target for grub installation. Usage example: /dev/sda
--arch <arch> Architecture to use. Currently only i386 is supported.
Configuration options:
[ "$_opt_hostname" ] && HOSTNAME=$_opt_hostname
[ "$_opt_password" ] && ROOTPASSWORD=$_opt_password
[ "$_opt_bootappend" ] && BOOT_APPEND=$_opt_bootappend
-[ "$_opt_groot" ] && GROOT=$_opt_groot
[ "$_opt_grub" ] && GRUB=$_opt_grub
[ "$_opt_arch" ] && ARCH=$_opt_arch
[ "$_opt_verbose" ] && VERBOSE="-v"
mbr)
# /dev/md0: has to be installed in MBR of /dev/md0 and not in /dev/md:
if echo "$TARGET" | grep -q "/dev/md" ; then
- BOOT_PARTITION="$TARGET"
+ # using sw-raid:
+ if [ -n "$SELECTED_PARTITIONS" ] ; then
+ GRUB=$(echo ${SELECTED_PARTITIONS} | awk '{print $1}') # use first disk only
+ else
+ GRUB="$TARGET"
+ fi
else
- BOOT_PARTITION="$MBRDISK"
+ GRUB="$MBRDISK"
fi
;;
partition)
- BOOT_PARTITION="$TARGET"
+ GRUB="$TARGET"
;;
hda)
- BOOT_PARTITION="/dev/hda"
+ GRUB="/dev/hda"
;;
sda)
- BOOT_PARTITION="/dev/sda"
+ GRUB="/dev/sda"
;;
nowhere)
- BOOT_PARTITION=''
+ GRUB=''
;;
esac
}
[ -n "$RELEASE" ] && DEFAULT_RELEASE="$RELEASE" || DEFAULT_RELEASE='lenny'
RELEASE="$(dialog --stdout --title "${PN}" --default-item $DEFAULT_RELEASE --menu \
"Please enter the Debian release you would like to use for installation:" \
- 0 50 4 \
- etch Debian/old-stable \
+ 0 50 3 \
lenny Debian/stable \
squeeze Debian/testing \
sid Debian/unstable)"
}
# }}}
-# get grub's syntax for /dev/ice {{{
-# usage example: 'grubdevice /dev/sda2' returns 'hd0,1'
-grubdevice() {
- if [ -z "$1" ] ; then
- echo "Usage: grubdevice <device>">&2
- return 1
- fi
-
- device="$1"
- device_map=$(mktemp)
-
- # create device.map
- if which grub >/dev/null 2>&1 ; then
- echo 'quit' | grub --device-map="$device_map" >/dev/null 2>&1
- elif which grub-mkdevicemap >/dev/null 2>&1 ; then
- grub-mkdevicemap --no-floppy --device-map="$device_map" >/dev/null 2>&1
- else
- echo "Error: neither grub nor grub-mkdevicemap command found." >&2
- return 1
- fi
-
- # based on code from d-i's trunk/packages/arch/i386/grub-installer/grub-installer:
- tmp_disk=$(echo "$device" | sed -e 's%\(\(s\|h\|v\|xv\)d[a-z]\)[0-9]*$%\1%' \
- -e 's%\(fd[0-9]*\)$%\1%' \
- -e 's%/part[0-9]*$%/disc%' \
- -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
- -e 's%\(mmcblk[0-9]d[0-9]*\).*$%\1%' \
- -e 's%\(/mapper/mpath[0-9]\+\)-part[0-9]\+$%\1%')
- tmp_part=$(echo "$device" | sed -e 's%.*/\(s\|h\|v\|xv\)d[a-z]\([0-9]*\)$%\2%' \
- -e 's%.*/fd[0-9]*$%%' \
- -e 's%.*/floppy/[0-9]*$%%' \
- -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
- -e 's%.*c[0-7]d[0-9]*p*%%' \
- -e 's%.*mmcblk[0-9]d[0-9]*p%%' \
- -e 's%.*/mapper/mpath[0-9]\+-part\([0-9]\+\)%\1%')
- tmp_drive=$(grep -v '^#' $device_map | grep "$tmp_disk *$" | sed 's%.*\([hf]d[0-9][a-g0-9,]*\).*%\1%')
-
- if [ -z "$tmp_drive" ]; then
- echo "Error: $device does not have any corresponding BIOS drive." >&2
- return 1
- fi
-
- case $1 in
- /dev/[sh]d[a-z]) # we expect something like 'hd0'
- echo "$tmp_drive"
- ;;
- *) # we expect something like 'hd0,0'
- echo "$tmp_drive" | sed "s%$%,$(expr $tmp_part - 1)%" # FIXME => md0
- ;;
- esac
- rm -f "$device_map"
-}
-# }}}
-
# software raid setup {{{
config_swraid_setup()
{
prompt_for_password
- # use first disk of sw-raid for grub by default, install grub on
- # all involved disks later on
- if echo "$TARGET" | grep -q '/dev/md' ; then
- if [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
- # use hdX and not hdX,Y for $GRUB
- TMPDEVICE=$(echo ${SELECTED_PARTITIONS} | awk '{print $1}') # use first disk only
- GRUB="$(grubdevice ${TMPDEVICE%%[0-9]})" # like: hd0
- GROOT="$(grubdevice ${TMPDEVICE})" # like: hd0,0
- fi
- else
- [ -n "$BOOT_PARTITION" ] && GRUB="$(grubdevice $BOOT_PARTITION)"
- [ -n "$TARGET" ] && GROOT="$(grubdevice $TARGET)"
- fi
-
prompt_for_mirror
}
TUNE2FS=''
FSCK=''
GRUB=''
- GROOT=''
;;
esac
# }}}
chmod 600 $CHROOT_VARIABLES # make sure nobody except root can read it
echo "# Configuration of ${PN}" > $CHROOT_VARIABLES
[ -n "$ARCH" ] && echo "ARCH=$ARCH" >> $CHROOT_VARIABLES
- [ -n "$GROOT" ] && echo "GROOT=$GROOT" >> $CHROOT_VARIABLES
[ -n "$GRUB" ] && echo "GRUB=$GRUB" >> $CHROOT_VARIABLES
[ -n "$HOSTNAME" ] && echo "HOSTNAME=$HOSTNAME" >> $CHROOT_VARIABLES
[ -n "$INSTALL_NOTES" ] && echo "INSTALL_NOTES=$INSTALL_NOTES" >> $CHROOT_VARIABLES
sed -i "s#RELEASE=.*#RELEASE=\"$RELEASE\"#" $MNTPOINT/etc/debootstrap/config
sed -i "s#TARGET=.*#TARGET=\"$TARGET\"#" $MNTPOINT/etc/debootstrap/config
sed -i "s#GRUB=.*#GRUB=\"$GRUB\"#" $MNTPOINT/etc/debootstrap/config
- sed -i "s#GROOT=.*#GROOT=\"$GROOT\"#" $MNTPOINT/etc/debootstrap/config
# install notes:
if [ -n "$INSTALL_NOTES" ] ; then
if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then
mount_target
fi
+
if [ -x "$MNTPOINT/bin/chroot-script" ] ; then
einfo "Executing chroot-script now"
- chroot "$MNTPOINT" /bin/chroot-script
- eend $?
+ mount --bind /dev "$MNTPOINT"/dev
+ chroot "$MNTPOINT" /bin/chroot-script ; RC=$?
+ umount "$MNTPOINT"/dev
+ eend $RC
else
eerror "Fatal: $MNTPOINT/bin/chroot-script could not be found."
eend 1
# install booloader grub {{{
grub_install() {
- if [ -z "$GRUB" -o -z "$GROOT" ] ; then
- echo "Notice: \$GRUB or \$GROOT not defined, will not install grub therefor."
- elif [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
+ if [ -z "$GRUB" ] ; then
+ echo "Notice: \$GRUB not defined, will not install grub therefore."
+ return 0
+ fi
+
+ if [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
for device in $SELECTED_PARTITIONS ; do
- # TMPDEVICE=$(echo ${SELECTED_PARTITIONS} | awk '{print $1}')
- # GRUB="$(grubdevice ${TMPDEVICE})"
- # GRUB="$(grubdevice ${TMPDEVICE%%[0-9]})"
- # GRUB=$(grubdevice $device)
- GRUB="$(grubdevice ${device%%[0-9]})"
+ GRUB="${device%%[0-9]}"
einfo "Installing grub on ${GRUB}:"
[ -x /usr/sbin/grub-install ] && GRUBINSTALL="/usr/sbin/grub-install --no-floppy" || GRUBINSTALL="/sbin/grub-install --no-floppy"
- $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
+ $GRUBINSTALL --root-directory="$MNTPOINT" "$GRUB"
eend $?
done
else
einfo "Installing grub on ${GRUB}:"
[ -x /usr/sbin/grub-install ] && GRUBINSTALL="/usr/sbin/grub-install --no-floppy" || GRUBINSTALL="/sbin/grub-install --no-floppy"
- $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
+ $GRUBINSTALL --root-directory="$MNTPOINT" "$GRUB"
eend $?
fi
}
Extra parameters passed to the debootstrap command.
-*--groot* <_device_>::
-
- Specify root device for usage in grub (corresponds with $TARGET).
- Again, use grub syntax for specifying.
- Corresponding with configuration variable GROOT.
-
*--grub* <_device_>::
- Where do you want to install grub to? Use grub syntax for specifying.
- Do not forget to set groot as well. Leave empty to avoid installation of grub.
+ Device where grub should be installed to. Note that only the MBR (master
+ boot record) can be used (/dev/sda, /dev/sdb,...). Partitions (like
+ /dev/sda1, /dev/sdb2,...) are NOT supported because grub2 doesn't support
+ installation into the PBR (partition boot record) anymore. Usage example:
+ '--grub /dev/sda'. Note: just do not set this option to avoid installation
+ of grub.
*--help*, *-h*::
*-r*, *--release* <_releasename_>::
- Specify release of new Debian system. Supported releases names: etch, lenny,
+ Specify release of new Debian system. Supported releases names: lenny,
squeeze (note: requires current version of debootstrap) and sid.
Corresponding with configuration variable RELEASE.
*-t*, *--target* <_target_>::
Target partition (/dev/...) or directory (anything else without /dev at the
- beginning). To install grub using *--grub* and *--groot*, make sure to
- use a _device_ instead of a directory as _target_ (installation of
- grub as bootloader when using directories is NOT supported).
+ beginning). To install grub using *--grub* make sure to use a _device_
+ instead of a directory as _target_ (installation of grub as bootloader when
+ using directories is NOT supported).
*-v*, *--verbose*::
Increase verbosity.
Usage examples
---------------
- grml-debootstrap --target /dev/sda1 --grub hd0 --groot hd0,0
+ grml-debootstrap --target /dev/sda1 --grub /dev/sda
Install default Debian release (stable/lenny) on /dev/sda1 and install bootmanager
Grub in MBR (master boot record) of /dev/sda and use /dev/sda1 as system partition.
- grml-debootstrap --target /dev/sda6 --grub hd0 --groot hd0,5 --release sid
+ grml-debootstrap --target /dev/sda6 --grub /dev/sda --release sid
-Install Debian unstable/sid on /dev/sda6, install bootmanager
-Grub in MBR (master boot record) of /dev/sda and use /dev/sda6 as system partition.
+Install Debian unstable/sid on /dev/sda6, install bootmanager Grub in MBR
+(master boot record) of /dev/sda and use /dev/sda6 as system partition.
mount /dev/sda1 /data/chroot
grml-debootstrap --target /data/chroot
Install default Debian release (stable/lenny) in directory /data/chroot (without
any bootloader).
- grml-debootstrap --target /dev/sda3 --grub hd0 --groot hd0,2 --mirror ftp://ftp.tugraz.at/mirror/debian
+ grml-debootstrap --target /dev/sda3 --grub /dev/sda --mirror ftp://ftp.tugraz.at/mirror/debian
Install default Debian release (stable/lenny) on /dev/sda3 and install bootmanager
Grub in MBR (master boot record) of /dev/sda and use /dev/sda3 as system partition.
Use specified mirror instead of the default (ftp://ftp.debian.de/debian) one.
mount -o loop /mnt/sda6/debian-40r0-i386-CD-1.iso /mnt/iso
- grml-debootstrap --target /dev/sda1 --grub hd0 --groot hd0,0 --iso file:/mnt/iso/debian/
+ grml-debootstrap --target /dev/sda1 --grub /dev/sda --iso file:/mnt/iso/debian/
Install Debian stable/lenny on /dev/sda1 using the loopback mounted Debian-ISO
for the base-system and install bootmanager Grub in MBR (master boot record) of
grub=...
-Where do you want to install grub to? Use grub syntax for specifying.
-Usage example: grub=hd0
-
- groot=...
-
-Specify root device for usage in grub (corresponds with $TARGET).
-Again, use grub syntax for specifying. Usage example: groot=hd0,0
+Where do you want to install grub to? Usage example: grub=/dev/sda
release=...
Specify release of new Debian system. Defaults to Debian stable. Supported
-relases: etch, lenny, squeeze and sid. Usage example: release=sid
+relases: lenny, squeeze and sid. Usage example: release=sid
mirror=...
Usage example for automatic installation:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- debian2hd target=/dev/sda1 grub=hd0 groot=hd0,0 mirror=ftp://ftp.tugraz.at/mirror/debian password=foobar
+ debian2hd target=/dev/sda1 grub=/dev/sda mirror=ftp://ftp.tugraz.at/mirror/debian password=foobar
You have to enter this commandline at the bootprompt of grml. Please make sure
that /dev/sda1 is the partition where you really want to install your new Debian
locales console-data console-common
initramfs-tools mdadm lvm2
-grub grub-pc
+grub-pc
bzip2 dhcp3-client file less lsof most pciutils resolvconf screen ssh strace sysfsutils usbutils vim w3m zsh
postfix
'---------.-----------------.---------------
Release / Tool debootstrap cdebootstrap
--------------------------------------------
-Etch works works
Lenny works works
Squeeze works works
Sid works works
'(-p --mntpoint)'{-p,--mntpoint}'[mountpoint for the target system]:mount point:_path_files' \
'(-r --release)'{-r,--release}'[specify the release name of the new system]:release' \
'(-t --target)'{-t,--target}'[target partition or directory]:device or directory:_path_files' \
- '--grub[installation device for grub]:grub syntax' \
- '--groot[root device for usage in grub]:grub syntax' \
+ '--grub[installation device for grub]' \
'--password[specify password for root user]' \
'--bootappend[appendline for kernel]'