[arch-releng] [PATCH 0/2] Fixes to disc capacity detection and automatic partitioning
First patch fixes a possible issue with SCSI drives (needs testing) Related bug report: http://bugs.archlinux.org/task/12949 Second patch modifies the automatic partition preparation step of the installer to use MiB instead of MB, because most users (myself included) are more familiar with MiB (2^20 bytes) than with MB (10^6 bytes) and because that's what sfdisk (used for the actual partitioning) is expecting.
Signed-off-by: Evangelos Foutras <foutrelis@gmail.com> --- setup | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) diff --git a/setup b/setup index 6e6ba4a..6f119c6 100755 --- a/setup +++ b/setup @@ -337,14 +337,25 @@ _umountall() umount $(mount | grep "${DESTDIR} " | sed 's|\ .*||g') >/dev/null 2>&1 } +# _getdisccapacity() +# +# parameters: device file +# outputs: disc capacity in bytes +_getdisccapacity() +{ + fdisk -l $1 | sed -n '2p' | cut -d' ' -f5 +} + # Get a list of available disks for use in the "Available disks" dialogs. This -# will print the disks as follows, getting size info from hdparm: +# will print the disks as follows, getting size info from _getdisccapacity(): # /dev/sda: 640133 MBytes (640 GB) # /dev/sdb: 640135 MBytes (640 GB) _getavaildisks() { - # NOTE: to test as non-root, stick in a 'sudo' before the hdparm call - for i in $(finddisks); do echo -n "$i: "; hdparm -I $i | grep -F '1000*1000' | sed "s/.*1000:[ \t]*\(.*\)/\1/"; echo "\n"; done + for DISC in $(finddisks); do + DISC_SIZE=$(_getdisccapacity $DISC) + echo "$DISC: $((DISC_SIZE / 10**6)) MBytes ($((DISC_SIZE / 10**9)) GB)\n" + done } autoprepare() @@ -362,8 +373,8 @@ autoprepare() SWAP_PART_SET="" ROOT_PART_SET="" CHOSEN_FS="" - # get just the disk size in 1000*1000 MB - DISC_SIZE=$(hdparm -I $DISC | grep -F '1000*1000' | sed "s/^.*:[ \t]*\([0-9]*\) MBytes.*$/\1/") + # disk size in MB + DISC_SIZE=$(($(_getdisccapacity $DISC) / 10**6)) while [ "$SET_DEFAULTFS" = "" ]; do FSOPTS="ext2 ext2 ext3 ext3 ext4 ext4" [ "$(which mkreiserfs 2>/dev/null)" ] && FSOPTS="$FSOPTS reiserfs Reiser3" -- 1.6.1.1
This effectively makes the installer pass correct values to sfdisk during automatic partition preparation (sfdisk expects MiB, not MB) Signed-off-by: Evangelos Foutras <foutrelis@gmail.com> --- setup | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/setup b/setup index 6f119c6..82f5687 100755 --- a/setup +++ b/setup @@ -348,13 +348,13 @@ _getdisccapacity() # Get a list of available disks for use in the "Available disks" dialogs. This # will print the disks as follows, getting size info from _getdisccapacity(): -# /dev/sda: 640133 MBytes (640 GB) -# /dev/sdb: 640135 MBytes (640 GB) +# /dev/sda: 625000 MiB (610 GiB) +# /dev/sdb: 476940 MiB (465 GiB) _getavaildisks() { for DISC in $(finddisks); do DISC_SIZE=$(_getdisccapacity $DISC) - echo "$DISC: $((DISC_SIZE / 10**6)) MBytes ($((DISC_SIZE / 10**9)) GB)\n" + echo "$DISC: $((DISC_SIZE / 2**20)) MiB ($((DISC_SIZE / 2**30)) GiB)\n" done } @@ -373,15 +373,15 @@ autoprepare() SWAP_PART_SET="" ROOT_PART_SET="" CHOSEN_FS="" - # disk size in MB - DISC_SIZE=$(($(_getdisccapacity $DISC) / 10**6)) + # disk size in MiB + DISC_SIZE=$(($(_getdisccapacity $DISC) / 2**20)) while [ "$SET_DEFAULTFS" = "" ]; do FSOPTS="ext2 ext2 ext3 ext3 ext4 ext4" [ "$(which mkreiserfs 2>/dev/null)" ] && FSOPTS="$FSOPTS reiserfs Reiser3" [ "$(which mkfs.xfs 2>/dev/null)" ] && FSOPTS="$FSOPTS xfs XFS" [ "$(which mkfs.jfs 2>/dev/null)" ] && FSOPTS="$FSOPTS jfs JFS" while [ "$BOOT_PART_SET" = "" ]; do - DIALOG --inputbox "Enter the size (MB) of your /boot partition. Minimum value is 16.\n\nDisk space left: $DISC_SIZE MB" 10 65 "32" 2>$ANSWER || return 1 + DIALOG --inputbox "Enter the size (MiB) of your /boot partition. Minimum value is 16.\n\nDisk space left: $DISC_SIZE MiB" 10 65 "32" 2>$ANSWER || return 1 BOOT_PART_SIZE="$(cat $ANSWER)" if [ "$BOOT_PART_SIZE" = "" ]; then DIALOG --msgbox "ERROR: You have entered an invalid size, please enter again." 0 0 @@ -395,7 +395,7 @@ autoprepare() done DISC_SIZE=$(($DISC_SIZE-$BOOT_PART_SIZE)) while [ "$SWAP_PART_SET" = "" ]; do - DIALOG --inputbox "Enter the size (MB) of your swap partition. Minimum value is > 0.\n\nDisk space left: $DISC_SIZE MB" 10 65 "256" 2>$ANSWER || return 1 + DIALOG --inputbox "Enter the size (MiB) of your swap partition. Minimum value is > 0.\n\nDisk space left: $DISC_SIZE MiB" 10 65 "256" 2>$ANSWER || return 1 SWAP_PART_SIZE=$(cat $ANSWER) if [ "$SWAP_PART_SIZE" = "" -o "$SWAP_PART_SIZE" -le "0" ]; then DIALOG --msgbox "ERROR: You have entered an invalid size, please enter again." 0 0 @@ -409,7 +409,7 @@ autoprepare() done DISC_SIZE=$(($DISC_SIZE-$SWAP_PART_SIZE)) while [ "$ROOT_PART_SET" = "" ]; do - DIALOG --inputbox "Enter the size (MB) of your / partition. The /home partition will use the remaining space.\n\nDisk space left: $DISC_SIZE MB" 10 65 "7500" 2>$ANSWER || return 1 + DIALOG --inputbox "Enter the size (MiB) of your / partition. The /home partition will use the remaining space.\n\nDisk space left: $DISC_SIZE MiB" 10 65 "7500" 2>$ANSWER || return 1 ROOT_PART_SIZE=$(cat $ANSWER) if [ "$ROOT_PART_SIZE" = "" -o "$ROOT_PART_SIZE" -le "0" ]; then DIALOG --msgbox "ERROR: You have entered an invalid size, please enter again." 0 0 @@ -417,7 +417,7 @@ autoprepare() if [ "$ROOT_PART_SIZE" -ge "$DISC_SIZE" ]; then DIALOG --msgbox "ERROR: You have entered a too large size, please enter again." 0 0 else - DIALOG --yesno "$(($DISC_SIZE-$ROOT_PART_SIZE)) MB will be used for your /home partition. Is this OK?" 0 0 && ROOT_PART_SET=1 + DIALOG --yesno "$(($DISC_SIZE-$ROOT_PART_SIZE)) MiB will be used for your /home partition. Is this OK?" 0 0 && ROOT_PART_SET=1 fi fi done -- 1.6.1.1
On Sat, Jan 31, 2009 at 10:30 AM, Evangelos Foutras <foutrelis@gmail.com> wrote:
First patch fixes a possible issue with SCSI drives (needs testing) Related bug report: http://bugs.archlinux.org/task/12949
Second patch modifies the automatic partition preparation step of the installer to use MiB instead of MB, because most users (myself included) are more familiar with MiB (2^20 bytes) than with MB (10^6 bytes) and because that's what sfdisk (used for the actual partitioning) is expecting.
Just to be clear here - we are planning on replacing the old installer with AIF in the near future (maybe even the next ISO), so fixes for the old installer are probably not going to get merged unless they're showstoppers for the release.
Aaron Griffin wrote:
Just to be clear here - we are planning on replacing the old installer with AIF in the near future (maybe even the next ISO), so fixes for the old installer are probably not going to get merged unless they're showstoppers for the release.
That's understandable. I haven't really looked much into AIF yet, but I'm sure Dieter has done a great job developing it. :)
participants (2)
-
Aaron Griffin
-
Evangelos Foutras