Joey Boggs
2009-Oct-22 18:52 UTC
[Ovirt-devel] [PATCH node] merge Root and /boot partitions
This completes the switch to ext3 backed root partitions. /boot is now contained on each Root/RootBackup partition. On install grub is updated to read and boot from the correct partition as well. --- scripts/ovirt-config-boot | 29 ++++++++++++------------ scripts/ovirt-config-storage | 47 +++++++++++---------------------------- scripts/ovirt-config-uninstall | 5 +--- scripts/ovirt-functions | 12 +++++----- 4 files changed, 34 insertions(+), 59 deletions(-) diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot index dd53988..9ab06bd 100755 --- a/scripts/ovirt-config-boot +++ b/scripts/ovirt-config-boot @@ -29,9 +29,9 @@ ovirt_boot_setup() { local disk2 local partN=-1 log "installing the image." - mount_boot + mount_liveos # check that /boot mounted ok and find partition number for GRUB - eval $(readlink -f /dev/disk/by-label/BOOT|awk {' + eval $(readlink -f /dev/disk/by-label/RootBackup|awk {' print "disk=" substr($1,1,length($1)-1); print "disk2=" substr($1,1,length($1)-2); partN=substr($1,length($1),1); partN--; @@ -39,13 +39,13 @@ ovirt_boot_setup() { }') rc=$? if [ $rc -ne 0 -o $partN -lt 0 ]; then - log "unable to determine boot partition" + log "unable to determine Root partition" return 1 fi - mountpoint /boot + mountpoint /liveos if [ $? -ne 0 ] ; then - log "boot partition not available" + log "Root partition not available" return 1 fi @@ -87,12 +87,12 @@ ovirt_boot_setup() { else syslinux fi - rm -rf /boot/grub + rm -rf /liveos/boot/grub rm -rf /liveos/LiveOS - mkdir -p /boot/grub + mkdir -p /liveos/boot/grub mkdir -p /liveos/LiveOS cp -p $live/LiveOS/squashfs.img /liveos/LiveOS \ - && cp -p $live/$syslinux/vmlinuz0 /boot + && cp -p $live/$syslinux/vmlinuz0 /liveos rc=$? if [ $rc -ne 0 ]; then log "image copy failed." @@ -142,14 +142,14 @@ set -e\ find $init_script bin/lvm lib$bit -type f | cpio -H newc --quiet -o | gzip -9 | - cat $live/$syslinux/initrd0.img - > /boot/initrd0.img + cat $live/$syslinux/initrd0.img - > /liveos/initrd0.img version=$(rpm -q --qf '%{version}' ovirt-node) release=$(rpm -q --qf '%{release}' ovirt-node) # reorder tty0 to allow both serial and phys console after installation bootparams="ro root=LABEL=Root roottypefs=ext3 console=tty0 \ $(echo $bootparams | sed s/console=tty0//g)" - cat > /boot/grub/grub.conf << EOF + cat > /liveos/boot/grub/grub.conf << EOF default=0 timeout=5 hiddenmenu @@ -158,11 +158,11 @@ title oVirt Node (${version}-${release}) kernel /vmlinuz0 $bootparams initrd /initrd0.img EOF - echo "(hd0) $disk" > /boot/grub/device.map - ( cd /usr/share/grub/*; cp -p stage? e2fs_stage1_5 /boot/grub ) - grub --device-map=/boot/grub/device.map <<EOF + echo "(hd0) $disk" > /liveos/boot/grub/device.map + ( cd /usr/share/grub/*; cp -p stage? e2fs_stage1_5 /liveos/boot/grub ) + grub --device-map=/liveos/boot/grub/device.map <<EOF root (hd0,$partN) -setup --prefix=/grub (hd0) +setup --prefix=/boot/grub (hd0) EOF rc=$? if [ $rc -ne 0 ]; then @@ -175,7 +175,6 @@ EOF ovirt_store_config /etc/iscsi/initiatorname.iscsi umount /liveos - umount /boot # mark new Root ready to go, reboot() in ovirt-function switches it to active e2label $candidate_dev RootUpdate diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index af13935..77e00d0 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -22,14 +22,12 @@ fi default_overcommit=0.5 -default_boot_size=50 default_root_size=256 default_config_size=5 default_logging_size=2048 # -1 indicates data partition should use remaining disk default_data_size=-1 -boot_min_size=50 root_min_size=256 config_min_size=5 logging_min_size=5 @@ -90,7 +88,7 @@ check_partition_sizes() get_drive_size $DRIVE SPACE disk_size=$SPACE need_size=$(echo "scale=0;" \ - "$BOOT_SIZE + $SWAP_SIZE + $ROOT_SIZE * 2" \ + "$SWAP_SIZE + $ROOT_SIZE * 2" \ "+ $CONFIG_SIZE + $LOGGING_SIZE + $min_data_size" | bc -l) if [ $need_size -gt $disk_size ]; then @@ -213,7 +211,7 @@ do_configure() fi local space_left=$SPACE - for part in boot swap root config logging data ; do + for part in swap root config logging data ; do part_regexp="^0$" if [ "$part" = "data" ]; then part_regexp="^\-1|0$" @@ -259,7 +257,6 @@ do_configure() # save input variables augtool <<EOF set /files$OVIRT_DEFAULTS/OVIRT_INIT $DRIVE -set /files$OVIRT_DEFAULTS/OVIRT_VOL_BOOT_SIZE $BOOT_SIZE set /files$OVIRT_DEFAULTS/OVIRT_VOL_SWAP_SIZE $SWAP_SIZE set /files$OVIRT_DEFAULTS/OVIRT_VOL_ROOT_SIZE $ROOT_SIZE set /files$OVIRT_DEFAULTS/OVIRT_VOL_CONFIG_SIZE $CONFIG_SIZE @@ -277,7 +274,7 @@ do_review() local data_size_display="$DATA_SIZE MB" if [ "$DATA_SIZE" = -1 ]; then - local remaining_mb=$(( $SPACE - $BOOT_SIZE - $SWAP_SIZE \ + local remaining_mb=$(( $SPACE - $SWAP_SIZE \ - $ROOT_SIZE * 2 - $CONFIG_SIZE - $LOGGING_SIZE )) data_size_display="$remaining_mb MB" fi @@ -287,7 +284,6 @@ do_review() The local disk will be repartitioned as follows: =============================================== Physical Hard Disk: $(get_drive_size $DRIVE) - Boot partition size: $BOOT_SIZE MB Swap partition size: $SWAP_SIZE MB Installation partition size: $ROOT_SIZE * 2 MB Configuration partition size: $CONFIG_SIZE MB @@ -335,28 +331,22 @@ perform_partitioning() partprobe -s $DRIVE MEM_SIZE_MB=$(echo "scale=0; $MEM_SIZE_MB / 1024;" | bc -l) - local boot_size_si=$(echo "scale=0; $BOOT_SIZE * (1024 * 1024) / (1000 * 1000)" | bc -l) log "Labeling Drive" parted $DRIVE -s "mklabel ${LABEL_TYPE}" - log "Creating boot partition" - parted $DRIVE -s "mkpartfs primary ext2 0M ${boot_size_si}M" log "Creating Root and RootBackup Partitions" - let root1_end=${boot_size_si}+${ROOT_SIZE} - let root2_end=${root1_end}+${ROOT_SIZE} - parted $DRIVE -s "mkpartfs primary ext2 ${boot_size_si}M ${root1_end}M" - parted $DRIVE -s "mkpartfs primary ext2 ${root1_end}M ${root2_end}M" + let RootBackup_end=${ROOT_SIZE}*2 + parted $DRIVE -s "mkpartfs primary ext2 0M ${ROOT_SIZE}M" + parted $DRIVE -s "mkpartfs primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M" # sleep to ensure filesystems are created before continuing sleep 10 - e2label ${DRIVE}2 Root - e2label ${DRIVE}3 RootBackup + e2label ${DRIVE}1 Root + e2label ${DRIVE}2 RootBackup + tune2fs -c 0 -i 0 ${DRIVE}1 tune2fs -c 0 -i 0 ${DRIVE}2 - tune2fs -c 0 -i 0 ${DRIVE}3 log "Creating LVM partition" - parted $DRIVE -s "mkpart primary ext2 ${root2_end}M -1" - log "Toggling boot on" - parted $DRIVE -s "set 1 boot on" + parted $DRIVE -s "mkpart primary ext2 ${RootBackup_end}M -1" log "Toggling LVM on" - parted $DRIVE -s "set 4 lvm on" + parted $DRIVE -s "set 3 lvm on" parted $DRIVE -s "print" udevadm settle 2> /dev/null || udevsettle @@ -366,12 +356,10 @@ perform_partitioning() gptsync $DRIVE fi - partboot=${DRIVE}1 - partpv=${DRIVE}4 + partpv=${DRIVE}3 if [ ! -e "$partpv" ]; then # e.g. /dev/cciss/c0d0p2 - partboot=${DRIVE}p1 - partpv=${DRIVE}p4 + partpv=${DRIVE}p3 fi log "Creating physical volume" if [ ! -e "$partpv" ]; then @@ -383,15 +371,7 @@ perform_partitioning() log "Creating volume group" vgcreate /dev/HostVG "${partpv}" - log "Creating boot filesystem" - if [ ! -e "$partboot" ]; then - log "$partboot is not available!" - exit 1 - fi - mke2fs -j "${partboot}" -L "BOOT" - tune2fs -c 0 -i 0 "${partboot}" mkdir -p /dev/disk/by-label - ln -snf "${partboot}" /dev/disk/by-label/BOOT if [ "$SWAP_SIZE" -gt 0 ]; then log "Creating swap partition" @@ -512,7 +492,6 @@ fi CALC_SWAP_SIZE=$(echo "scale=0; ${BASE_SWAP_SIZE} + ${OVERCOMMIT_SWAP_SIZE};" | bc -l) SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$CALC_SWAP_SIZE} -BOOT_SIZE=${OVIRT_VOL_BOOT_SIZE:-$default_boot_size} ROOT_SIZE=${OVIRT_VOL_ROOT_SIZE:-$default_root_size} CONFIG_SIZE=${OVIRT_VOL_CONFIG_SIZE:-$default_config_size} LOGGING_SIZE=${OVIRT_VOL_LOGGING_SIZE:-$default_logging_size} diff --git a/scripts/ovirt-config-uninstall b/scripts/ovirt-config-uninstall index 22633a0..820eead 100755 --- a/scripts/ovirt-config-uninstall +++ b/scripts/ovirt-config-uninstall @@ -34,16 +34,13 @@ if ask_yes_or_no "Do you wish to continue and uninstall this node ([Y]es/[N]o)?" unmount_logging log "Removing volume group" wipe_volume_group "HostVG" - partition=$(findfs LABEL=BOOT) + partition=$(findfs LABEL=Root) if [ -n "$partition" ]; then - log "Unmounting boot partition" - umount $partition log "Removing partitions" drive=$(echo $partition | awk '{ print substr($0, 1, length($0) - 1) }') parted -s $drive "rm 1" parted -s $drive "rm 2" parted -s $drive "rm 3" - parted -s $drive "rm 4" fi printf "Finished uninstalling node." else diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index f24cb07..6e76ce3 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -260,14 +260,14 @@ mount_live() { mount -r $live_dev /live || mount $live_dev /live } -# mount boot partition -# boot loader + kernel + initrd -mount_boot() { - if grep -q " /boot " /etc/mtab; then +# mount root partition +# boot loader + kernel + initrd + LiveOS +mount_liveos() { + if grep -q " /liveos " /etc/mtab; then return 0 fi - mkdir -p /boot - mount /dev/disk/by-label/BOOT /boot + mkdir -p /liveos + mount /dev/disk/by-label/Root /liveos } # mount config partition -- 1.6.2.5
Maybe Matching Threads
- [PATCH node] RESEND: split root file systems out of HostVG onto separate partitions
- [PATCH node] split root filesystems out of HostVG and onto their own partitions
- [PATCH node] Handle space in storage wwid
- [PATCH node] iscsi remote root basework This lays most of the groundwork for iscsi installation and configuration. At this time configuring iscsi is disabled due to multiple issues with dependent pieces.
- [PATCH node] add ability to select separate disks for Root and HostVG in o-c-storage