[Ovirt-devel] RESEND: [PATCH node 1/3] enables ability for a common shared root

Joey Boggs jboggs at redhat.com
Mon Apr 5 16:15:57 UTC 2010


---
 scripts/ovirt-config-boot    |   13 +++++-
 scripts/ovirt-config-storage |  111 ++++++++++++++++++++++++------------------
 2 files changed, 75 insertions(+), 49 deletions(-)

diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot
index d545878..8cc127b 100755
--- a/scripts/ovirt-config-boot
+++ b/scripts/ovirt-config-boot
@@ -29,6 +29,12 @@ ovirt_boot_setup() {
     local disk2
     local partN=-1
     log "installing the image."
+
+    if [ "$OVIRT_ROOT_INSTALL" == "n" ]; then
+        log "done."
+        return
+    fi
+
     local found_boot=false
     if findfs LABEL=Boot 2>&1 >/dev/null ; then
         found_boot=true
@@ -212,7 +218,12 @@ if [ -z "$doreboot" ]; then
 fi
 
 start_log
-ovirt_boot_setup "$live" "$bootparams"
+if [ "$OVIRT_ROOT_INSTALL" =="n" ]; then
+    log "done."
+    return
+else
+    ovirt_boot_setup "$live" "$bootparams"
+fi
 rc=$?
 if [ $rc -eq 0 -a "$doreboot" = "yes" ]; then
     disable_firstboot
diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
index 8d59a6b..c91b0ea 100755
--- a/scripts/ovirt-config-storage
+++ b/scripts/ovirt-config-storage
@@ -172,7 +172,7 @@ check_partition_sizes()
         HOSTVG_NEED_SIZE=$(echo "scale=0;" \
                          "$SWAP_SIZE + $CONFIG_SIZE + $LOGGING_SIZE + $min_data_size" | bc -l)
 
-        if [ $ROOTDRIVE == $HOSTVGDRIVE ]; then
+        if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then
             drive_list="ROOT"
             ROOT_NEED_SIZE=$(echo "scale=0; $ROOT_SIZE * 2 + $HOSTVG_NEED_SIZE"| bc -l)
         else
@@ -204,7 +204,7 @@ check_partition_sizes()
     # check if an existing HostVG exists on a device other than the target
     if [ "$OVIRT_ISCSI_ENABLED" != "y" ]; then
         devices="$(pvs -o pv_name,vg_name --noheadings | \
-            grep "HostVG"|grep -v $HOSTVGDRIVE|awk '{ print $1 }')"
+            grep "HostVG"|grep -v "$HOSTVGDRIVE"|awk '{ print $1 }')"
         rc=0
         if [ -n "$devices" ]; then
             printf "\n"
@@ -357,11 +357,27 @@ do_configure()
         printf "\n\nPlease select the disk to use for the Root.\n\n"
         ROOTDRIVE=$(get_dev_name) || return 0
         get_drive_size "$ROOTDRIVE" ROOTDRIVESPACE
+        if ask_yes_or_no "Will Root be shared with other nodes ([Y]es/[N]o)?"; then
+            OVIRT_SHARED_ROOT="y"
+            if ask_yes_or_no "Partition and install Root?"; then
+                OVIRT_ROOT_INSTALL="y"
+            else
+                OVIRT_ROOT_INSTALL="n"
+            fi
+        else
+            OVIRT_SHARED_ROOT="n"
+            OVIRT_ROOT_INSTALL="y"
+        fi
+
+    augtool <<EOF
+        set /files$OVIRT_DEFAULTS/OVIRT_SHARED_ROOT $OVIRT_SHARED_ROOT
+        set /files$OVIRT_DEFAULTS/OVIRT_ROOT_INSTALL $OVIRT_ROOT_INSTALL
+EOF
 
         printf "\n\nPlease select the disk to use for the HostVG.\n\n"
         HOSTVGDRIVE=$(get_dev_name) || return 0
         local skipped=false
-        if check_existing_hostvg $HOSTVGDRIVE devs; then
+        if check_existing_hostvg "$HOSTVGDRIVE" devs; then
             for dev in $devs
             do
                 printf "Removing HostVG on $dev will erase the drive and cannot be undone\n"
@@ -402,6 +418,8 @@ do_configure()
     if [ "$OVIRT_ISCSI_ENABLED" == "y" ]; then
         partlist="boot" # swap root config logging data"
         local space_left=$BOOTDRIVESPACE
+    elif [ "$OVIRT_ROOT_INSTALL" == "n" ]; then
+        partlist="swap config logging data"
     else
         partlist="swap root config logging data"
     fi
@@ -459,7 +477,7 @@ set /files$OVIRT_DEFAULTS/OVIRT_VOL_LOGGING_SIZE $LOGGING_SIZE
 set /files$OVIRT_DEFAULTS/OVIRT_VOL_DATA_SIZE $DATA_SIZE
 EOF
 
-   if [ -n $BOOTDRIVE ]; then
+   if [ -n "$BOOTDRIVE" ]; then
        augtool <<EOF
 set /files$OVIRT_DEFAULTS/OVIRT_BOOT_INIT $BOOTDRIVE
 EOF
@@ -478,7 +496,7 @@ do_review()
         local data_size_display="$DATA_SIZE MB"
         if [ "$DATA_SIZE" = -1 ]; then
 
-            if [ $ROOTDRIVE == $HOSTVGDRIVE ]; then
+            if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then
                 local remaining_mb=$(( $ROOTDRIVESPACE - $SWAP_SIZE \
                         - $ROOT_SIZE * 2 - $CONFIG_SIZE - $LOGGING_SIZE ))
                 test $remaining_mb -lt 0 && is_negative=1
@@ -557,7 +575,7 @@ check_existing_hostvg()
 # - remove LVM volumes and groups
 wipe_lvm_on_disk()
 {
-    local dev=${1-$HOSTVGDRIVE}
+    local dev=${1-"$HOSTVGDRIVE"}
     unmount_logging
     local part_delim="p"
     if [[ "$dev" =~ "/dev/sd" ]]; then
@@ -604,8 +622,8 @@ perform_partitioning()
     unmount_config /etc/default/ovirt
 
     log "Removing old LVM partitions"
-    wipe_lvm_on_disk $HOSTVGDRIVE
-    wipe_lvm_on_disk $ROOTDRIVE
+    wipe_lvm_on_disk "$HOSTVGDRIVE"
+    wipe_lvm_on_disk "$ROOTDRIVE"
 
     # begin critical section
     set -e
@@ -635,62 +653,59 @@ perform_partitioning()
         return
     fi
 
-    log "Starting partitioning of $ROOTDRIVE"
-    log "Partitioning drive: $ROOTDRIVE"
- # FIXME: save a backup copy, just in case?
-    log "Wiping old boot sector"
-    dd if=/dev/zero of=$ROOTDRIVE bs=1024K count=1
-    reread_partitions $ROOTDRIVE
-    partprobe -s $ROOTDRIVE
-    log "Labeling Drive: $ROOTDRIVE"
-    parted $ROOTDRIVE -s "mklabel ${LABEL_TYPE}"
+    if [ "$OVIRT_ROOT_INSTALL" == "y" ]; then
+        log "Starting partitioning of $ROOTDRIVE"
+        log "Partitioning drive: $ROOTDRIVE"
+     # FIXME: save a backup copy, just in case?
+        log "Wiping old boot sector"
+        dd if=/dev/zero of=$ROOTDRIVE bs=1024K count=1
+        blockdev --rereadpt $ROOTDRIVE
+        partprobe -s $ROOTDRIVE
+        log "Labeling Drive: $ROOTDRIVE"
+        parted $ROOTDRIVE -s "mklabel ${LABEL_TYPE}"
+        log "Creating Root and RootBackup Partitions"
+        let RootBackup_end=${ROOT_SIZE}*2
+        parted $ROOTDRIVE -s "mkpart primary ext2 0M ${ROOT_SIZE}M"
+        parted $ROOTDRIVE -s "mkpart primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M"
+        # sleep to ensure filesystems are created before continuing
+        sleep 10
+        mke2fs ${ROOTDRIVE}1 -L Root
+        mke2fs ${ROOTDRIVE}2 -L RootBackup
+        tune2fs -c 0 -i 0 ${ROOTDRIVE}1
+        tune2fs -c 0 -i 0 ${ROOTDRIVE}2
+    fi
 
-    if [ $ROOTDRIVE != $HOSTVGDRIVE ]; then
+    if [ "$ROOTDRIVE" != "$HOSTVGDRIVE" ]; then
         log "Labeling Drive: $HOSTVGDRIVE"
-        parted $HOSTVGDRIVE -s "mklabel ${LABEL_TYPE}"
-    fi
-    log "Creating Root and RootBackup Partitions"
-    let RootBackup_end=${ROOT_SIZE}*2
-    parted $ROOTDRIVE -s "mkpart primary ext2 0M ${ROOT_SIZE}M"
-    parted $ROOTDRIVE -s "mkpart primary ext2 ${ROOT_SIZE}M ${RootBackup_end}M"
-    reread_partitions $ROOTDRIVE
-    partroot=${ROOTDRIVE}1
-    partrootbackup=${ROOTDRIVE}2
-    if [ ! -e $partroot ]; then
-        partroot=${ROOTDRIVE}p1
-        partrootbackup=${ROOTDRIVE}p2
-    fi
-    # sleep to ensure filesystems are created before continuing
-    sleep 10
-    mke2fs ${partroot} -L Root
-    mke2fs ${partrootbackup} -L RootBackup
-    tune2fs -c 0 -i 0 ${partroot}
-    tune2fs -c 0 -i 0 ${partrootbackup}
+        parted "$HOSTVGDRIVE" -s "mklabel ${LABEL_TYPE}"
+    fi
     log "Creating LVM partition"
 
-    if [ $ROOTDRIVE == $HOSTVGDRIVE ]; then
-        parted $HOSTVGDRIVE -s "mkpart primary ext2 ${RootBackup_end}M -1"
+    if [ "$ROOTDRIVE" == "$HOSTVGDRIVE" ]; then
+        parted "$HOSTVGDRIVE" -s "mkpart primary ext2 ${RootBackup_end}M -1"
         hostvgpart="3"
     else
-        parted $HOSTVGDRIVE -s "mkpart primary ext2 0M -1"
+        parted "$HOSTVGDRIVE" -s "mkpart primary ext2 0M -1"
         hostvgpart="1"
     fi
     log "Toggling LVM on"
-    parted $HOSTVGDRIVE -s "set $hostvgpart lvm on"
-    parted $ROOTDRIVE -s "print"
+    parted "$HOSTVGDRIVE" -s "set $hostvgpart lvm on"
+    parted "$ROOTDRIVE" -s "print"
     udevadm settle 2> /dev/null || udevsettle
-    reread_partitions $HOSTVGDRIVE
+    reread_partitions "$HOSTVGDRIVE"
 
     # sync GPT to the legacy MBR partitions
-    if [ "gpt" == "$LABEL_TYPE" ]; then
-        log "Running gptsync to create legacy mbr"
-        gptsync $ROOTDRIVE
+    if [ "$OVIRT_ROOT_INSTALL" == "y" ]; then
+        if [ "gpt" == "$LABEL_TYPE" ]; then
+            log "Running gptsync to create legacy mbr"
+            gptsync "$ROOTDRIVE"
+        fi
     fi
 
-    partpv=${HOSTVGDRIVE}${hostvgpart}
+    partpv="${HOSTVGDRIVE}"${hostvgpart}
     if [ ! -e "$partpv" ]; then
         # e.g. /dev/cciss/c0d0p2
-        partpv=${HOSTVGDRIVE}p${hostvgpart}
+        partpv="${HOSTVGDRIVE}"p${hostvgpart}
     fi
     log "Creating physical volume"
     if [ ! -e "$partpv" ]; then
-- 
1.6.6.1




More information about the ovirt-devel mailing list