[pkg-fso-maint] debian install.sh giving wrong partitioning sizes

Steffen Möller steffen_moeller at gmx.de
Sat Sep 10 07:05:21 UTC 2011


Dear Sam,

On 09/10/2011 12:09 AM, Sam Tygier wrote:
> I am having trouble at the partitioning stage of install.sh, the partitions are not created the size I ask for.  I have tried
> variouscombinations of the env vars, and command line args.
> 
> # TASKS="ALL" QI=true ./install.sh --part1-size 4000 --swap-size 256  partition
> gives:
> 
> Disk /dev/mmcblk0: 8166 MB, 8166309888 bytes
> 4 heads, 16 sectors/track, 249216 cylinders, total 15949824 sectors
> Units = sectors of 1 * 512 = 512 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0x2940d389
>         Device Boot      Start         End      Blocks   Id  System
> /dev/mmcblk0p1            2048      241404      119678+  83  Linux
> /dev/mmcblk0p2          241405    15949823     7854209+  82  Linux swap / Solaris
> 
> a ~100 MB /dev/mmcblk0p1 and 7GB /dev/mmcblk0p2 for swap.
> 
> install.sh calculates the size of the first partition in cyclinders, by subtracting the size of swap. It then uses the sizes in
> cylinders to create the partitions.
> 
> SHR has fdisk (util-linux-ng 2.18), which defaults to working in sectors. so fdisk asks for sectors, and install.sh replies in
> cylinders.
> 
> the quick fix on SHR seems to be to call fdisk with "fdisk /dev/mmcblk0 -u=cylinders", but this will probably give an error if you
> do it on other fdisks. I could make a patch to to try to detect which fdisk is being used, and conditionally add the flag.
> 
> it looks like in the future fdisk will use sectors, so the real solution is probably do the calculations in sectors. The "-u"
> should make sure any fdisk version uses sectors.

I recall many contributions from many sides to that part of install.sh. A varying behaviour of fdisk indeed explains a lot to me.
This is why my desktop's fdisk (GNU Fdisk 1.2.4) gives me:

	-u, --sector-units
              use sectors, instead of cylinders for a default unit.
	-C, --cylinders=CYLINDERS
              Specify the number of cylinders of the disk. Currently does nothing, it is left for Linux fdisk compatibility.

So this is somewhat different, -u does not need any extra options, -C means something different. This sniplet works for me

	b=`/sbin/fdisk --version`
	fdiskFlags=""
	if echo $b|grep -q ^GNU; then
	        echo "I am a GNU: $b"
	        #fdiskFlags="-u" # sectors
	        fdiskFlags=""    # cylinders
	else
	        echo "Who am I, util-linux-ng maybe?"
	        fdiskFlags=""             # sectors
	        fdiskFlags="-u=cylinders" # cylinders
	fi
	
	echo "The flags to use are: $fdiskFlags"


I think we should prefer an explicit failure over an unsupported fdisk option over presuming any default unit. If it is not too
cumbersome, could you please prepare a patch that works for you and introduces the explicit unit setting through some extra magic
like outlined above? This would be great.

Many thanks and regards,

Steffen




More information about the pkg-fso-maint mailing list