SCIENTIFIC-LINUX-USERS Archives

January 2016

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Graham Allan <[log in to unmask]>
Reply To:
Graham Allan <[log in to unmask]>
Date:
Wed, 13 Jan 2016 14:42:31 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (138 lines)
On 01/13/2016 01:30 PM, Konstantin Olchanski wrote:
>>
>>> and the same "you *must* use the disk partition tool designed by
>>> dummies for dummies".
>>
>> likewise solved by kickstart.
>>
>
> The kickstart disk partitioning tool is even dumber than they new GUI tool,
> only useful for "one-size-fits-all" cases where you also do not mind accidentally
> deleting the contents of all disks. (yes, open the machine, disconnect disks,
> install, reconnect disks, close the machine, thanks, but no thanks).

Using %pre in the kickstart file is the way to fix this, but you do need
to do all the work yourself. I suppose I could share our %pre section 
which examines disks and decides which to install on (it waits for 
confirmation if it can't determine the drive itself). The logic is 
simply to look for the first drive which either has no partition table 
or has a /boot directory (ie reinstall). No claims that this is perfect 
in any way, we hacked it together over the years and it works for us 
(with SL6).

For the post-config stuff we use %post to set our configuration 
management system (cfengine) to run after reboot.

> ##################
> # Figure out where to install to
>
> # make sure USB storage devices are GONE
> modprobe -r usb_storage
>
> mkdir /mnt/tmp
>
> for i in `ls /dev/sd?`; do
>     CANDIDATE_DISK="$i"
>
>     echo "Checking $CANDIDATE_DISK for partition table" | tee -a /tmp/ks.log >> /dev/tty3
>
>     if parted -s "$CANDIDATE_DISK" print >/dev/null; then
>         echo "parted found a partition table" | tee -a /tmp/ks.log >> /dev/tty3
>         if mount "${CANDIDATE_DISK}1" /mnt/tmp; then
>             if [ -d /mnt/tmp/boot ]; then
>                 INSTALL_DISK=$CANDIDATE_DISK
>                 echo "Found /boot on ${CANDIDATE_DISK}1, using $CANDIDATE_DISK as system disk" | tee -a /tmp/ks.log >> /dev/tty3
>                 umount /mnt/tmp
>                 break
>             else
>                 echo "Couldn't find /boot on ${CANDIDATE_DISK}1, moving on to next disk..." | tee -a /tmp/ks.log >> /dev/tty3
>                 umount /mnt/tmp
>             fi
>         else
>             echo "Failed to mount ${CANDIDATE_DISK}1, moving on to next disk..." | tee -a /tmp/ks.log >> /dev/tty3
>         fi
>     else
>         echo "parted found no partition table, using $CANDIDATE_DISK as system disk" | tee -a /tmp/ks.log >> /dev/tty3
>         INSTALL_DISK="$CANDIDATE_DISK"
>         break
>     fi
> done
>
> if [ "${INSTALL_DISK}x" = "x" ]; then
>     echo "****************************************************" >> /dev/tty1
>     echo "Initial check failed to find a suitable system disk!" >> /dev/tty1
>     echo "****************************************************" >> /dev/tty1
>     for i in `ls /dev/sd?`; do
>         CANDIDATE_DISK="$i"
>         if mount "${CANDIDATE_DISK}1" /mnt/tmp; then
>             if ! [ -d /mnt/tmp/boot ]; then
>                 echo -e "\n\nCouldn't find /boot on ${CANDIDATE_DISK}1" >> /dev/tty1
>                 echo -n "Partition table for ${CANDIDATE_DISK}:" >> /dev/tty1
>                 fdisk -l ${CANDIDATE_DISK} >> /dev/tty1
>                 doit="default"
>                 while ! echo "$doit" | grep -P "([Y|y]es|[N|n]o)" > /dev/null 2>&1; do
>                     echo -n "Install linux on ${CANDIDATE_DISK}? [Yes/No] " >> /dev/tty1
>                     read doit
>                 done
>                 if echo "$doit" | grep -P "[Y|y]es" > /dev/null 2>&1; then
>                     INSTALL_DISK="$CANDIDATE_DISK"
>                     umount /mnt/tmp
>                     break
>                 else
>                     echo "moving on to next disk..." >> /dev/tty1
>                 fi
>                 umount /mnt/tmp
>             fi
>         else
>             echo -ne "\n\nPartition table for ${CANDIDATE_DISK}:" >> /dev/tty1
>             fdisk -l ${CANDIDATE_DISK} >> /dev/tty1
>             doit="default"
>             while ! echo "$doit" | grep -P "([Y|y]es|[N|n]o)" > /dev/null 2>&1; do
>                 echo -n "Install linux on ${CANDIDATE_DISK}? [Yes/No] " >> /dev/tty1
>                 read doit
>             done
>             if echo "$doit" | grep -P "[Y|y]es" > /dev/null 2>&1; then
>                 INSTALL_DISK="$CANDIDATE_DISK"
>                 break
>             else
>                 echo "moving on to next disk..." >> /dev/tty1
>             fi
>         fi
>     done
>
>     if [ "${INSTALL_DISK}x" = "x" ]; then
>         echo -e "\n****************************************************" >> /dev/tty1
>         echo "Failed to find a suitable system disk" >> /dev/tty1
>         echo "The system will be rebooted when you press Ctrl-C or Ctrl-Alt-Delete." >> /dev/tty1
>         echo "****************************************************" >> /dev/tty1
>         while true; do
>             sleep 1
>         done
 >     fi
 > fi
>
> echo "Installing linux to $INSTALL_DISK" | tee -a /tmp/ks.log >> /dev/tty3
> echo "Installing linux to $INSTALL_DISK" >> /dev/tty1
> echo "****************************************************" >> /dev/tty1
> # Done figuring out where to install
> ###################
>
>
> #Write a file out to be included below for disk config
> cat << EOF > /tmp/partitions
> clearpart --drives=$INSTALL_DISK --initlabel --all
> zerombr yes
> part swap --recommended --ondisk=$INSTALL_DISK
> part /    --size=25600 --ondisk=$INSTALL_DISK
> part /var --size=4096   --ondisk=$INSTALL_DISK
> part /export/scratch --size=128 --grow --ondisk=$INSTALL_DISK
> EOF


Graham
-- 
-------------------------------------------------------------------------
Graham Allan
School of Physics and Astronomy - University of Minnesota
-------------------------------------------------------------------------

ATOM RSS1 RSS2