#! /bin/bash # Usually a disk_config file has to provide all details in order to set up # the disk device. If a different filesystem is to be used or the name for # the volume group changes, then that requires a new class (because the # name of the disk_config file is tied to a class. # I don't like that, because it's too strict. If lvm2 binaries are too be # installed only on hosts that actually use LVM, then either they have to # be specified for DISKlvm_xfs, DISKlvm_reiserfs, DISKlvm_ext3 or a new # "superclass" must be introduced. If the name for the volumegroup changes # then that also requires a new class. # Instead use a template, fill it with user specified data or apply # defaults if nothing else is given. Want a change? Define a variable. # Don't care? Don't want to consider? Do nothing. # create a working directory tmpdir=$(mktemp -d) ## first step - fetch appropriate values from /tmp/fai/IDENTITY or use defaults ## ROOTFS="ext2" ROOTFSOPTS="-b 2048" VGNAME="vg_system" LVFS="reiserfs" LVFSOPTS="-q" if [ -r /tmp/fai/IDENTITY ] ; then source /tmp/fai/IDENTITY fi if [[ $verbose = 1 ]] ; then echo "Make sure filesystem and filesystem options match up." echo " root: $ROOTFS / ${ROOTFSOPTS}" echo " root: $LVFS / ${LVFSOPTS}" fi ## second step - transform disk layout template into valid config file ## read defaults from file ## LAYOUTFILE=$(basename $0|cut -d"." -f2) # e.g. DISKlvm # first cat is unnecessary, I use it anyway to make the code more readable cat ${FAI}/disk_config/${LAYOUTFILE} |\ grep -v "^ROOTFS" |\ grep -v "^VGNAME" |\ grep -v "^LVFS" |\ sed -e "s/#ROOTFS#/${ROOTFS}/g" |\ sed -e "s/#ROOTFSOPTS#/${ROOTFSOPTS}/g" |\ sed -e "s/#VGNAME#/${VGNAME}/g" |\ sed -e "s/#LVFS#/${LVFS}/g" |\ sed -e "s/#LVFSOPTS#/${LVFSOPTS}/g" > ${tmpdir}/${LAYOUTFILE} ## third step - partition the disc # # Normally setup-storage selects an appropriate configuration from # $FAI/disk_config/ by picking comparing classes and available files. # If however -f is given the configuration in filename is used. # this code is copied from /usr/lib/fai/subroutines-linux # the only modification is the addition of "-f ${tmpdir}/${LAYOUTFILE}" if [ X$USE_SETUP_STORAGE = X1 ]; then echo "Partitioning local harddisks using setup-storage" [ ! -s $LOGDIR/disk_var.sh ] && setup-storage -f ${tmpdir}/${LAYOUTFILE} -X 2>&1 | tee $LOGDIR/format.log else echo "Partitioning local harddisks using setup_harddisks" [ ! -s $LOGDIR/disk_var.sh ] && setup_harddisks -f ${tmpdir}/${LAYOUTFILE} -d -X 2>&1 | tee $LOGDIR/format.log fi # partitioning tool must create $LOGDIR/disk_var.sh file if [ ! -s $LOGDIR/disk_var.sh ]; then task_error 710 cat $LOGDIR/format.log sendmon "TASKERROR partition 21" die "Partitioning tool did not create $LOGDIR/disk_var.sh file." fi # now define variable for root and boot partition and boot device . $LOGDIR/disk_var.sh # clean up rm -rf ${tmpdir} # now skip the original code skiptask task_partition