Parted returning a decimal point for start size in Kb
-
Hi folks, me again.
fog 1.1.1, SL6.5 base, fresh install not upgrade.
Yesterday I posted about getting into debug mode to try to figure out why an upload I was trying was failing.
Thanks for the clue!!I think I have figured out the cause of the problem, but I am not 100% about my solution.
In the init filesystem bin/fog.upload line 139ish $win7part1start is set via the output of a parted command.
In my case the returned value after the parted | sed pipeline was 32.3So when that gets used to:
adjustedfdsize=
expr $sizefd '+' $win7part1start
;expr returns: expr: non-numeric argument
and adjustedfdsize is blank…
so later when the partition is “adjusted” (IE deleted and recreated) the recreate fails so when
it trys to partclone, partclone fails to find $part ( /dev/sda1 in my case)Im thinking a wipe of decimal place and beyond could be the fix
Line 139 changed to:
win7part1start=
parted -s $hd u kB print | sed -e '/^.1/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//' -e 's/\..*$//'
and line 148 too.
Thoughts?
-
And a follow up. Ran into another issue, perhaps related… For windows 7 images (osid 5) it seems to think partitions
always start at 2048sector (line 145) But my windows 7 partiton in this case starts at 63…So after the recreate partclone.ntfs doesn’t see a ntfs filesystem on sda1 (starting at sector 2048)
If I set it back to 63 it works.Why 2048 and not ${partitionStart}s sectors?
Or maybe osid 5 should not be in that if statement at line 137, just do the fancy resize stuff for win8/8.1 ?
Or maybe I have a goofy win7 system? (the system in question is a virtual box VM)
Any clue bat application woul be appreciated. Im very far from a windows grue, so my understanding of what is normal or abnormal in the partition set up is quite sparse…
-
Normally, advanced format disks use start sector 2048. I’m going to guess your hdd is setup as IDE?
-
Yep, it is a IDE disk in a VirtualBox vm.
So I am wondering why not just use the partitionStart variable when having parted resize the disk. IE make no assumptions about what/where the single partition starts. (not sure about multi-partition setups, we don’t use them here)
Here is a diff for fog.upload that fixes this and the decimal point problem mentioned earlier. When doing the steps “manually” this seems to work. Ill be trying a full script run upload later this morning.
(don’t know if this is a good place to send bug fix diffs, so enlighten me if there is a better way)
E
— fog.upload.dist 2014-06-19 09:07:10.000000000 -0400
+++ fog.upload 2014-06-19 09:32:02.000000000 -0400
@@ -94,8 +94,8 @@
fi
fi
diskSize=parted -s $hd u kB print | grep "Disk" | grep -v "Flags" | sed 's/Disk \/dev\/[a-zA-Z0-9]*: //' | sed 's/kB//'
;-
partitionStart=`fdisk -lu | grep $part | awk '{print $3}'`; if [ "$osid" == "1" ]; then
-
partitionStart=`fdisk -lu | grep $part | awk '{print $3}'`; if [ "$partitionStart" == "" ]; then partitionStart="63"; fi
@@ -136,22 +136,22 @@
echo “Done”;
if [ “$osid” == “5” ] || [ “$osid” == “6” ] || [ “$osid” == “7” ]; then
if [ “$win7partcnt” == “1” ]; then-
win7part1start=`parted -s $hd u kB print | sed -e '/^.1/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//'`;
-
win7part1start=`parted -s $hd u kB print | sed -e '/^.1/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//' -e 's/\..*$//'`; if [ "$win7part1start" == "" ]; then handleError "Unable to determine disk start location."; fi adjustedfdsize=`expr $sizefd '+' $win7part1start`; parted -s $hd u kB rm 1 &>/dev/null;
-
parted -s $hd -a opt u kB mkpart primary ntfs 2048s ${adjustedfdsize}kB &>/dev/null;
-
parted -s $hd u kB set 1 boot on &>/dev/null
-
parted -s $hd -a opt u kB mkpart primary ntfs ${partitionStart}s ${adjustedfdsize}kB &>/dev/null;
-
parted -s $hd u kB set 1 boot on &>/dev/null elif [ "$win7partcnt" == "2" ]; then
-
win7part2start=`parted -s $hd u B print | sed -e '/^.2/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//'`;
-
win7part2start=`parted -s $hd u B print | sed -e '/^.2/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//' -e 's/\..*$//'`; if [ "$win7part2start" == "" ]; then handleError "Unable to determine disk start location."; fi adjustedfdsize=`expr $sizefd '+' $win7part2start`; parted -s $hd -a opt u kB mkpart primary ntfs ${defaultpart2start}B ${adjustedfdsize}kB &>/dev/null;
-
parted -s $hd u kB set 1 boot on &>/dev/null
-
parted -s $hd u kB set 1 boot on &>/dev/null else handleError "Invalid partition count."; fi
-
-
Well… that diff post didn’t work too well eh? Ill try a file upload…
[url=“/_imported_xf_attachments/1/1022_diff.txt?:”]diff.txt[/url]
-
[quote=“Eric Johnson, post: 30794, member: 24659”]Well… that diff post didn’t work too well eh? Ill try a file upload…[/quote]
I’ll take a look when I get home tonight.
Thanks for the info
in the future, to add snippets of code use the [ c o d e ] [ / c o d e ] tags to wrap the code. It will come out much nicer. Remove the spaces of course for it to work properly. -
Ok, testing
[code]
— fog.upload.dist 2014-06-19 09:07:10.000000000 -0400
+++ fog.upload 2014-06-19 09:32:02.000000000 -0400
@@ -94,8 +94,8 @@
fi
fi
diskSize=parted -s $hd u kB print | grep "Disk" | grep -v "Flags" | sed 's/Disk \/dev\/[a-zA-Z0-9]*: //' | sed 's/kB//'
;-
partitionStart=`fdisk -lu | grep $part | awk '{print $3}'`; if [ "$osid" == "1" ]; then
-
partitionStart=`fdisk -lu | grep $part | awk '{print $3}'`; if [ "$partitionStart" == "" ]; then partitionStart="63"; fi
@@ -136,22 +136,22 @@
echo “Done”;
if [ “$osid” == “5” ] || [ “$osid” == “6” ] || [ “$osid” == “7” ]; then
if [ “$win7partcnt” == “1” ]; then-
win7part1start=`parted -s $hd u kB print | sed -e '/^.1/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//'`;
-
win7part1start=`parted -s $hd u kB print | sed -e '/^.1/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//' -e 's/\..*$//'`; if [ "$win7part1start" == "" ]; then handleError "Unable to determine disk start location."; fi adjustedfdsize=`expr $sizefd '+' $win7part1start`; parted -s $hd u kB rm 1 &>/dev/null;
-
parted -s $hd -a opt u kB mkpart primary ntfs 2048s ${adjustedfdsize}kB &>/dev/null;
-
parted -s $hd u kB set 1 boot on &>/dev/null
-
parted -s $hd -a opt u kB mkpart primary ntfs ${partitionStart}s ${adjustedfdsize}kB &>/dev/null;
-
parted -s $hd u kB set 1 boot on &>/dev/null elif [ "$win7partcnt" == "2" ]; then
-
win7part2start=`parted -s $hd u B print | sed -e '/^.2/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//'`;
-
win7part2start=`parted -s $hd u B print | sed -e '/^.2/!d' -e 's/^ [0-9]*[ ]*//' -e 's/kB .*//' -e 's/\..*$//'`; if [ "$win7part2start" == "" ]; then handleError "Unable to determine disk start location."; fi adjustedfdsize=`expr $sizefd '+' $win7part2start`; parted -s $hd -a opt u kB mkpart primary ntfs ${defaultpart2start}B ${adjustedfdsize}kB &>/dev/null;
-
parted -s $hd u kB set 1 boot on &>/dev/null
-
parted -s $hd u kB set 1 boot on &>/dev/null else handleError "Invalid partition count."; fi
[/code]
-