Andrea,
I see what your at here...
If you try to use the $flags variable in the sections just above, does it not do the right thing?
sorry... I think I've not understood well what you mean...
If it does, then I think that would be a cleaner way to go.
If it doesn't, then go ahead and commit this.
And can you send an example autoinstallscript.conf && master.script with the code you decide on?
I've attached an autoinstallscript.conf with lvm definitions and the associated master script.
Thanks, -Brian
Bye, -Andrea
<config>
<disk dev="/dev/sda" label_type="msdos" unit_of_measurement="MB">
<part num="1" size="24" p_type="primary" fs="ext2" p_name="-" flags="-" />
<part num="2" size="256" p_type="primary" fs="linux-swap" p_name="-"
flags="-" />
<part num="3" size="3000" p_type="primary" p_name="-" flags="lvm"
lvm_group="user" />
<part num="4" size="end_of_disk" p_type="primary" p_name="-" flags="lvm"
lvm_group="system" />
</disk>
<disk dev="/dev/sdb" label_type="msdos" unit_of_measurement="MB">
<part num="1" size="1500" p_type="primary" fs="ext2" p_name="-" flags="-"
/>
<part num="2" size="1500" p_type="primary" p_name="-" flags="lvm"
lvm_group="system" />
<part num="3" size="end_of_disk" p_type="primary" p_name="-" flags="lvm"
lvm_group="user" />
</disk>
<lvm>
<lvm_group name="system">
<lv name="usrlv" size="500" />
<lv name="optlv" size="1500" />
<lv name="varlv" size="256" />
</lvm_group>
<lvm_group name="user">
<lv name="homelv" size="5000" />
<lv name="scratchlv" size="2000" />
</lvm_group>
</lvm>
<fsinfo line="10" real_dev="/dev/sdb1" mp="/" fs="ext3"
options="defaults,errors=remount-ro" />
<fsinfo line="20" real_dev="/dev/sda1" mp="/boot" fs="ext3"
options="defaults,ro,noexec" dump="0" pass="2" />
<fsinfo line="30" real_dev="/dev/system/usrlv" fs="ext3" mp="/usr"
options="defaults,rw,user,exec" />
<fsinfo line="40" real_dev="/dev/system/optlv" fs="reiserfs" mp="/opt"
options="defaults,rw,user" />
<fsinfo line="50" real_dev="/dev/system/varlv" fs="ext3" mp="/var"
options="defaults,rw,user,noexec" />
<fsinfo line="60" real_dev="/dev/user/homelv" fs="xfs" mp="/home"
options="defaults,rw,user,exec" />
<fsinfo line="70" real_dev="/dev/system/scratchlv" fs="ext3" mp="/scratch"
options="defaults,rw,user,noexec" />
<fsinfo line="80" real_dev="/dev/sda2" mp="swap" fs="swap" options="defaults"
/>
<fsinfo line="90" real_dev="/dev/fd0" mp="/floppy" fs="auto"
options="defaults,user,noauto" dump="0" pass="0" format="no" />
<fsinfo line="100" real_dev="proc" mp="/proc" fs="proc" options="defaults"
dump="0" pass="0" />
</config>
#!/bin/sh
#
# "SystemImager"
#
# Copyright (C) 1999-2004 Brian Elliott Finley
#
# $Id: autoinstallscript.template,v 1.18 2005/01/25 18:12:23 righiandr Exp $
#
# This master autoinstall script was created with SystemImager
vSYSTEMIMAGER_VERSION_STRING
# Load functions and other variables
. /etc/init.d/functions
get_arch
if [ -z $NO_LISTING ]; then
VERBOSE_OPT="v"
else
VERBOSE_OPT=""
fi
# Pull in variables left behind by the linuxrc script.
# This information is passed from the linuxrc script on the autoinstall media
# via /tmp/variables.txt. Apparently the shell we use in BOEL is not
# intelligent enough to take a "set -a" parameter.
#
. /tmp/variables.txt || shellout
[ -z $IMAGENAME ] && IMAGENAME=default
[ -z $OVERRIDES ] && OVERRIDES="default"
### BEGIN Check to be sure this not run from a working machine ###
# Test for mounted SCSI or IDE disks
mount | grep [hs]d[a-z][1-9] > /dev/null 2>&1
[ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
# Test for mounted software RAID devices
mount | grep md[0-9] > /dev/null 2>&1
[ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
# Test for mounted hardware RAID disks
mount | grep c[0-9]+d[0-9]+p > /dev/null 2>&1
[ $? -eq 0 ] && echo Sorry. Must not run on a working machine... && shellout
### END Check to be sure this not run from a working machine ###
################################################################################
#
# Stop RAID devices before partitioning begins
#
# Q1) Why did they get started in the first place?
# A1) So we can pull a local.cfg file off a root mounted software RAID system.
# They may not be started on your system -- they would only be started if
# you did the stuff in Q3 below.
#
# Q2) Why didn't my local.cfg on my root mounted software RAID work for me
# with the standard kernel flavour?
# A2) The standard kernel flavour uses modules for the software RAID drivers --
# therefore, software RAID is not available at the point in the boot process
# where BOEL needs to read the local.cfg file. They are only pulled over
# when this script is run, which is, of course, only runnable if it was
# pulled over the network using the settings that you would have wanted it
# to get from the local.cfg file, which it couldn't. Right?
#
# Q3) Whatever. So how do I make it work with a local.cfg file on my root
# mounted software RAID?
# A3) Compile an autoinstall kernel with software RAID, and any other drivers
# you might need built in (filesystem, SCSI drivers, etc.).
#
if [ -f /proc/mdstat ]; then
RAID_DEVICES=` cat /proc/mdstat | grep ^md | sed 's/ .*$//g' `
# raidstop will not run unless a raidtab file exists
echo "" >> /etc/raidtab || shellout
# turn dem pesky raid devices off!
for RAID_DEVICE in ${RAID_DEVICES}
do
DEV="/dev/${RAID_DEVICE}"
# we don't do a shellout here because, well I forgot why, but we don't.
echo "raidstop ${DEV}" && raidstop ${DEV}
done
fi
#
################################################################################
### BEGIN partition /dev/sda ###
echo "Partitioning /dev/sda..."
echo "Old partition table for /dev/sda:"
parted -s -- /dev/sda print
# Create disk label. This ensures that all remnants of the old label, whatever
# type it was, are removed and that we're starting with a clean label.
echo "parted -s -- /dev/sda mklabel msdos || shellout"
parted -s -- /dev/sda mklabel msdos || shellout
# Get the size of the destination disk so that we can make the partitions fit
properly.
DISK_SIZE=`parted -s /dev/sda print | grep 'Disk geometry for' | sed
's/^.*-//g' | sed 's/\..*$//' `
[ -z $DISK_SIZE ] && shellout
if [ "$ARCH" = "alpha" ]; then
END_OF_LAST_PRIMARY=1
else
END_OF_LAST_PRIMARY=0
fi
echo "Creating partition /dev/sda1."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + 24)" | bc)
echo "parted -s -- /dev/sda mkpart primary ext2 $START_MB $END_MB || shellout"
parted -s -- /dev/sda mkpart primary ext2 $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB
echo "Creating partition /dev/sda2."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + 256)" | bc)
echo "parted -s -- /dev/sda mkpart primary ext2 $START_MB $END_MB || shellout"
parted -s -- /dev/sda mkpart primary ext2 $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB
echo "Creating partition /dev/sda3."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + 3000)" | bc)
echo "parted -s -- /dev/sda mkpart primary ext2 $START_MB $END_MB || shellout"
parted -s -- /dev/sda mkpart primary ext2 $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB
echo parted -s -- /dev/sda set 3 lvm on || shellout
parted -s -- /dev/sda set 3 lvm on || shellout
echo "Creating partition /dev/sda4."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + end_of_disk)" | bc)
echo "parted -s -- /dev/sda mkpart primary ext2 $START_MB $END_MB || shellout"
parted -s -- /dev/sda mkpart primary ext2 $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB
echo parted -s -- /dev/sda set 4 lvm on || shellout
parted -s -- /dev/sda set 4 lvm on || shellout
echo "New partition table for /dev/sda:"
echo "parted -s -- /dev/sda print"
parted -s -- /dev/sda print
### END partition /dev/sda ###
### BEGIN partition /dev/sdb ###
echo "Partitioning /dev/sdb..."
echo "Old partition table for /dev/sdb:"
parted -s -- /dev/sdb print
# Create disk label. This ensures that all remnants of the old label, whatever
# type it was, are removed and that we're starting with a clean label.
echo "parted -s -- /dev/sdb mklabel msdos || shellout"
parted -s -- /dev/sdb mklabel msdos || shellout
# Get the size of the destination disk so that we can make the partitions fit
properly.
DISK_SIZE=`parted -s /dev/sdb print | grep 'Disk geometry for' | sed
's/^.*-//g' | sed 's/\..*$//' `
[ -z $DISK_SIZE ] && shellout
if [ "$ARCH" = "alpha" ]; then
END_OF_LAST_PRIMARY=1
else
END_OF_LAST_PRIMARY=0
fi
echo "Creating partition /dev/sdb1."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + 1500)" | bc)
echo "parted -s -- /dev/sdb mkpart primary ext2 $START_MB $END_MB || shellout"
parted -s -- /dev/sdb mkpart primary ext2 $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB
echo "Creating partition /dev/sdb2."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + 1500)" | bc)
echo "parted -s -- /dev/sdb mkpart primary ext2 $START_MB $END_MB || shellout"
parted -s -- /dev/sdb mkpart primary ext2 $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB
echo parted -s -- /dev/sdb set 2 lvm on || shellout
parted -s -- /dev/sdb set 2 lvm on || shellout
echo "Creating partition /dev/sdb3."
START_MB=$END_OF_LAST_PRIMARY
END_MB=$(echo "scale=3; ($START_MB + end_of_disk)" | bc)
echo "parted -s -- /dev/sdb mkpart primary ext2 $START_MB $END_MB || shellout"
parted -s -- /dev/sdb mkpart primary ext2 $START_MB $END_MB || shellout
END_OF_LAST_PRIMARY=$END_MB
echo parted -s -- /dev/sdb set 3 lvm on || shellout
parted -s -- /dev/sdb set 3 lvm on || shellout
echo "New partition table for /dev/sdb:"
echo "parted -s -- /dev/sdb print"
parted -s -- /dev/sdb print
### END partition /dev/sdb ###
echo "Load additional filesystem drivers."
modprobe reiserfs
modprobe ext2
modprobe ext3
modprobe jfs
modprobe xfs
echo "Load device mapper driver (for LVM)."
grep "dm-mod" /proc/modules > /dev/null
if [ $? -eq 1 ]; then modprobe dm-mod; fi
### BEGIN LVM initialization commands -AR- ###
echo "Initializing partition /dev/sda3 for use by LVM."
echo "pvcreate /dev/sda3 || shellout"
pvcreate /dev/sda3 || shellout
echo "Initializing partition /dev/sda4 for use by LVM."
echo "pvcreate /dev/sda4 || shellout"
pvcreate /dev/sda4 || shellout
echo "Initializing partition /dev/sdb2 for use by LVM."
echo "pvcreate /dev/sdb2 || shellout"
pvcreate /dev/sdb2 || shellout
echo "Initializing partition /dev/sdb3 for use by LVM."
echo "pvcreate /dev/sdb3 || shellout"
pvcreate /dev/sdb3 || shellout
### END LVM initialization commands ###
### BEGIN LVM groups creation commands -AR- ###
echo "vgcreate system /dev/sda4 /dev/sdb2 || shellout"
vgcreate system /dev/sda4 /dev/sdb2 || shellout
echo "vgcreate user /dev/sda3 /dev/sdb3 || shellout"
vgcreate user /dev/sda3 /dev/sdb3 || shellout
### END LVM groups creation commands ###
### BEGIN LVM volumes creation commands -AR- ###
echo "lvcreate -L500 -n usrlv system || shellout"
lvcreate -L500 -n usrlv system || shellout
echo "lvcreate -L1500 -n optlv system || shellout"
lvcreate -L1500 -n optlv system || shellout
echo "lvcreate -L256 -n varlv system || shellout"
lvcreate -L256 -n varlv system || shellout
echo "lvcreate -L5000 -n homelv user || shellout"
lvcreate -L5000 -n homelv user || shellout
echo "lvcreate -L2000 -n scratchlv user || shellout"
lvcreate -L2000 -n scratchlv user || shellout
### END LVM volumes creation commands ###
### BEGIN swap and filesystem creation commands ###
echo "mke2fs -j /dev/sdb1 || shellout"
mke2fs -j /dev/sdb1 || shellout
echo "mkdir -p /a/ || shellout"
mkdir -p /a/ || shellout
echo "mount /dev/sdb1 /a/ -t ext3 -o defaults || shellout"
mount /dev/sdb1 /a/ -t ext3 -o defaults || shellout
echo "mke2fs -j /dev/sda1 || shellout"
mke2fs -j /dev/sda1 || shellout
echo "mkdir -p /a/boot || shellout"
mkdir -p /a/boot || shellout
echo "mount /dev/sda1 /a/boot -t ext3 -o defaults,rw,noexec || shellout"
mount /dev/sda1 /a/boot -t ext3 -o defaults,rw,noexec || shellout
echo "mke2fs -j /dev/system/usrlv || shellout"
mke2fs -j /dev/system/usrlv || shellout
echo "mkdir -p /a/usr || shellout"
mkdir -p /a/usr || shellout
echo "mount /dev/system/usrlv /a/usr -t ext3 -o defaults,rw,user,exec ||
shellout"
mount /dev/system/usrlv /a/usr -t ext3 -o defaults,rw,user,exec || shellout
echo "echo y | mkreiserfs /dev/system/optlv || shellout"
echo y | mkreiserfs /dev/system/optlv || shellout
echo "mkdir -p /a/opt || shellout"
mkdir -p /a/opt || shellout
echo "mount /dev/system/optlv /a/opt -t reiserfs -o defaults,rw,user ||
shellout"
mount /dev/system/optlv /a/opt -t reiserfs -o defaults,rw,user || shellout
echo "mke2fs -j /dev/system/varlv || shellout"
mke2fs -j /dev/system/varlv || shellout
echo "mkdir -p /a/var || shellout"
mkdir -p /a/var || shellout
echo "mount /dev/system/varlv /a/var -t ext3 -o defaults,rw,user,noexec ||
shellout"
mount /dev/system/varlv /a/var -t ext3 -o defaults,rw,user,noexec || shellout
echo "mkfs.xfs -f -q /dev/user/homelv || shellout"
mkfs.xfs -f -q /dev/user/homelv || shellout
echo "mkdir -p /a/home || shellout"
mkdir -p /a/home || shellout
echo "mount /dev/user/homelv /a/home -t xfs -o defaults,rw,user,exec ||
shellout"
mount /dev/user/homelv /a/home -t xfs -o defaults,rw,user,exec || shellout
echo "mke2fs -j /dev/system/scratchlv || shellout"
mke2fs -j /dev/system/scratchlv || shellout
echo "mkdir -p /a/scratch || shellout"
mkdir -p /a/scratch || shellout
echo "mount /dev/system/scratchlv /a/scratch -t ext3 -o defaults,rw,user,noexec
|| shellout"
mount /dev/system/scratchlv /a/scratch -t ext3 -o defaults,rw,user,noexec ||
shellout
echo "mkswap -v1 /dev/sda2 || shellout"
mkswap -v1 /dev/sda2 || shellout
echo "swapon /dev/sda2 || shellout"
swapon /dev/sda2 || shellout
### END swap and filesystem creation commands ###
### BEGIN mount proc in image for tools like System Configurator ###
echo "mkdir -p /a/proc || shellout"
mkdir -p /a/proc || shellout
echo "mount proc /a/proc -t proc -o defaults || shellout"
mount proc /a/proc -t proc -o defaults || shellout
### END mount proc in image for tools like System Configurator ###
################################################################################
#
# Lay the image down on the freshly formatted disk(s)
#
if [ ! -z $FLAMETHROWER_DIRECTORY_PORTBASE ]; then
# Use multicast
MODULE_NAME="${IMAGENAME}"
DIR=/a
RETRY=7
flamethrower_client
else
# Use rsync
if [ $NO_LISTING ]; then
echo "Quietly installing image... "
start_spinner
fi
if [ "${TMPFS_STAGING}" = "yes" ]; then
# Deposit image into tmpfs
DIR=/tmp/tmpfs_staging
echo
echo "TMPFS_STAGING=${TMPFS_STAGING} -- Staging in ${DIR}"
mkdir -p ${DIR}
echo "rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids
${IMAGESERVER}::${IMAGENAME}/ ${DIR}/"
rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids
${IMAGESERVER}::${IMAGENAME}/ ${DIR}/ || shellout
# Move from staging in tmpfs to disk
rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids ${DIR}/ /a/
else
echo "rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids
${IMAGESERVER}::${IMAGENAME}/ /a/"
rsync -aHS${VERBOSE_OPT} --exclude=lost+found/ --numeric-ids
${IMAGESERVER}::${IMAGENAME}/ /a/ || shellout
fi
fi
beep
#
################################################################################
if [ $NO_LISTING ]; then
stop_spinner
fi
# Leave notice of which image is installed on the client
echo $IMAGENAME > /a/etc/systemimager/IMAGE_LAST_SYNCED_TO || shellout
### BEGIN generate new fstab file from autoinstallscript.conf ###
cat <<'EOF' > /a/etc/fstab
/dev/sdb1 / ext3 defaults,errors=remount-ro
/dev/sda1 /boot ext3 defaults,ro,noexec 0 2
/dev/system/usrlv /usr ext3 defaults,rw,user,exec
/dev/system/optlv /opt reiserfs defaults,rw,user
/dev/system/varlv /var ext3 defaults,rw,user,noexec
/dev/user/homelv /home xfs defaults,rw,user,exec
/dev/system/scratchlv /scratch ext3 defaults,rw,user,noexec
/dev/sda2 swap swap defaults
/dev/fd0 /floppy auto defaults,user,noauto 0 0
proc /proc proc defaults 0 0
EOF
### END generate new fstab file from autoinstallscript.conf ###
################################################################################
#
# Process override directories
#
for OVERRIDE in $OVERRIDES
do
if [ ! -z $FLAMETHROWER_DIRECTORY_PORTBASE ]; then
# Use multicast
MODULE_NAME="override_${OVERRIDE}"
DIR=/a
RETRY=7
flamethrower_client
else
# Use rsync
echo "rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/"
rsync -av --numeric-ids $IMAGESERVER::overrides/$OVERRIDE/ /a/ || echo
"Override directory $OVERRIDE doesn't seem to exist, but that may be OK."
fi
done
beep
#
################################################################################
##################################################################
#
# Uncomment the line below to leave your hostname blank.
# Certain distributions use this as an indication to take on the
# hostname provided by a DHCP server. The default is to have
# SystemConfigurator assign your clients the hostname that
# corresponds to the IP address the use during the install.
# (If you used to use the static_dhcp option, this is your man.)
#
#HOSTNAME=""
################################################################################
#
# mount /dev /a/dev -o bind if needed
#
#not needed for this image
#
################################################################################
################################################################################
#
# System Configurator
#
# Configure the client's hardware, network interface, and boot loader.
#
chroot /a/ systemconfigurator
--excludesto=/etc/systemimager/systemconfig.local.exclude --configsi --stdin <<
EOL || shellout
[NETWORK]
HOSTNAME = $HOSTNAME
DOMAINNAME = $DOMAINNAME
[INTERFACE0]
DEVICE = eth0
TYPE = dhcp
EOL
#
################################################################################
################################################################################
#
# Post Install Scripts
#
run_post_install_scripts
#
################################################################################
################################################################################
#
# Unmount filesystems
#
echo "umount /a/var || shellout"
umount /a/var || shellout
echo "umount /a/usr || shellout"
umount /a/usr || shellout
echo "umount /a/scratch || shellout"
umount /a/scratch || shellout
echo "umount /a/proc || shellout"
umount /a/proc || shellout
echo "umount /a/opt || shellout"
umount /a/opt || shellout
echo "umount /a/home || shellout"
umount /a/home || shellout
echo "umount /a/boot || shellout"
umount /a/boot || shellout
echo "umount /a/ || shellout"
umount /a/ || shellout
#
################################################################################
################################################################################
#
# Tell the image server we're done
#
rsync $IMAGESERVER::scripts/imaging_complete > /dev/null 2>&1
#
################################################################################
# Take network interface down
ifconfig eth0 down || shellout
# Announce completion (even for non beep-incessantly --post-install options)
beep 3
beep_incessantly
