From 59737fb0190d04f95b2f9fd5eb1b518a710886a4 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 3 Oct 2015 16:50:37 +0200 Subject: [PATCH] Fix mbr_size() for older versions of util_linux --- hashboot.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hashboot.sh b/hashboot.sh index 39fe4e3..d7efc2e 100755 --- a/hashboot.sh +++ b/hashboot.sh @@ -49,8 +49,13 @@ read_config () mbr_size () { # Find out where the first partition starts returns(prints) size in KiB - sectorsize=$(LC_ALL=C fdisk -l /dev/sda | grep '^Units:' | awk '{print $8}') - startsector=$(LC_ALL=C fdisk -l /dev/sda | grep -A1 '^Device' | tail -n1 | awk '{print $3}') + sectorsize=$(LC_ALL=C fdisk -l ${MBR_DEVICE} | grep '^Units' | awk '{print $8}') + if [ "${sectorsize}" == "=" ] # Older versions of util-linux + then + sectorsize=$(LC_ALL=C fdisk -l ${MBR_DEVICE} | grep '^Units' | awk '{print $9}') + fi + startsector=$(LC_ALL=C fdisk -l ${MBR_DEVICE} | grep -A1 'Device' | tail -n1 | awk '{print $3}') + expr ${sectorsize} \* ${startsector} / 1024 }