[Ovirt-devel] [PATCH ovirt-node] standalone mode - configure local storage (DESTRUCTIVE)
Jim Meyering
jim at meyering.net
Fri Nov 7 14:56:57 UTC 2008
Alan Pevec <apevec at redhat.com> wrote:
> From: Darryl L. Pierce <dpierce at redhat.com>
> ---
> scripts/ovirt-config-storage | 112 ++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 112 insertions(+), 0 deletions(-)
>
> diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
> index 8b13789..91d50de 100755
> --- a/scripts/ovirt-config-storage
> +++ b/scripts/ovirt-config-storage
> @@ -1 +1,113 @@
> +#!/bin/bash
> +#
> +# All sizes are in gigabytes
>
> +DRIVE=$(sfdisk -s | awk '/\/dev\/([sh]da)/ { match($0, "^(.*):.*", data); printf data[1] }')
Hi Darryl,
Is the block count from "sfdisk -s" always using a 1024-byte block?
I.e., is it possible that the partition will have a different block size?
Even after a quick glance through sfdisk documentation, I couldn't say.
...
> +function do_review
> +{
> + printf "\n"
> + printf "The local disk will be repartitioned as follows:\n"
> + printf "================================================\n"
> + printf " Physical Hard Disk: ${DRIVE}\n"
> + printf " Boot partition size: ${BOOT_SIZE} GB\n"
> + printf " Swap partition size: ${SWAP_SIZE} GB\n"
> + printf " Installation partition size: ${INSTALL_SIZE} GB\n"
> + printf " Configuration partition size: ${CONFIG_SIZE} GB\n"
> + printf " Logging partition size: ${LOGGING_SIZE} GB\n"
> + printf "\n"
> +}
> +
> +function do_partitioning
> +{
> + while true; do
> + printf "\n"
All the warning code below is hard to read in source form,
and the output wraps on my 80-column console, so how about
something like this instead?
sp=' '
w='!!WARNING'
wb="$w"'!!'
w8="$w$w$w$w$w$w$w$w"
printf '%s!!\n' \
"$w8" \
"$w8" \
"$wb$sp$w" \
"$wb$sp$w" \
"$wb If you proceed, this will destroy all data on your local " \
"$wb system, and your hard disk will be irreversably reconfigured " \
"$wb$sp$w" \
"$wb$sp$w" \
"$w8" \
"$w8"
> + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n"
> + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n"
> + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n"
> + printf "!!WARNING!! !!WARNING!!\n"
> + printf "!!WARNING!! !!WARNING!!\n"
> + printf "!!WARNING!! If you proceed this will destroy all data on your local system, and !!WARNING!!\n"
> + printf "!!WARNING!! your hard disk will be irreversably reconfiguration. !!WARNING!!\n"
> + printf "!!WARNING!! !!WARNING!!\n"
> + printf "!!WARNING!! !!WARNING!!\n"
> + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n"
> + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n"
> + printf "\n"
> + printf "\tContinue? (Y/n) "
> + read
> + case $REPLY in
> + Y|y)
> + {
> + dd if=/dev/zero of=/dev/sda bs=1K count=1
> + blockdev --rereadpt /dev/sda
> + # Boot partition
> + # /dev/sda1 = Boot partition
> + # /dev/sda2 = Swap partition
> + # /dev/sda4 = LVM
> + echo -e "n\np\n1\n\n+$(( $BOOT_SIZE * 1024))M\na\n1\n
> + n\np\n2\n\n+$(( $SWAP_SIZE * 1024))M\nt\n2\n82\n
> + n\np\n4\n\n\nt\n4\n8e\n
> + w\n" | fdisk $DRIVE
Please use printf rather than echo -e.
Then you can make the above more readable/maintainable, e.g.,
printf '%s\n' \
n p 1 '' "+$(( $BOOT_SIZE * 1024))M" a 1 '' \
n p 2 '' "+$(( $SWAP_SIZE * 1024))M" t 2 82 '' \
n p 4 '' '' t 4 8e '' \
w '' \
| fdisk $DRIVE
[caution, I've merely ensured that the printf-based code
produces exactly the same code as produced by the echo -e.
I haven't actually run fdisk. ]
I see you use $DRIVE for partitioning, yet there are also hard-coded uses
of /dev/sda above, and below there are uses of /dev/sda1 and /dev/sda4.
Is this a work in progress?
> + pvcreate /dev/sda4
> + vgcreate /dev/VolGroup00 /dev/sda4
> +
> + lvcreate --name Ovirt /dev/VolGroup00 --size ${INSTALL_SIZE}G
> + lvcreate --name Config /dev/VolGroup00 --size ${CONFIG_SIZE}G
> + lvcreate --name Logging /dev/VolGroup00 --size ${LOGGING_SIZE}G
> +
> + mkfs -t ext3 /dev/sda1
> + mkfs -t ext3 /dev/VolGroup00/Ovirt
> + mkfs -t ext3 /dev/VolGroup00/Config
> + mkfs -t ext3 /dev/VolGroup00/Logging
> +
> + } > partition.log
> + break ;;
> + N|n) return ;;
> + esac
> + done
> +}
> +
> +while true; do
> + OPTIONS="Configure Review Partition Quit"
> + PS3="Choose an option: "
> +
> + printf "\n"
> +
> + select OPTION in $OPTIONS
> + do
> + case "$OPTION" in
> + "Configure") do_configure ; break ;;
> + "Review") do_review ; break ;;
> + "Partition") do_partitioning ; break ;;
> + "Quit") exit ;;
> + esac
> + done
> +done
More information about the ovirt-devel
mailing list