On 10/09/11 08:05, Steffen Möller wrote:
On 09/10/2011 12:09 AM, Sam Tygier wrote:
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.
so it looks like we have 3 distinct fdisk version. gnu fdisk, old
util-linux-ng, and new util-linux-ng.
also it looks like the current install.sh depends on the util-linux-ng
interactive behaviour. on uln-fdisk asks for a partition number (n,p,1) whereas
gnu-fdisk does not (n,p). gnu-fdisk would assume that 1 is the start cylinder.
I think the full logic is something like:
#!/bin/bash
fdiskVersion=`/sbin/fdisk -v` # util-linux-ng fdisk does not recognise
--version
fdiskFlags=""
fdiskUsePartNumbers=false # gnu fdisk does not ask for partition numbers
if [[ $fdiskVersion == GNU* ]] ; then
echo "I am a GNU: $fdiskVersion "
#fdiskFlags="-u" # sectors
fdiskFlags="" # cylinders
fdiskUsePartNumbers=false
elif [[ $fdiskVersion == *util-linux-ng*2.17* ]] ; then
echo "I am a util-linux-ng fdisk (defaulting to cylinders): $fdiskVersion
"
#fdiskFlags="-u" # sectors
fdiskFlags="" # cylinders
fdiskUsePartNumbers=true
elif [[ $fdiskVersion == *util-linux-ng*2.18* ]] ; then
echo "I am a util-linux-ng fdisk (defaulting to sectors): $fdiskVersion
"
#fdiskFlags="-u=sectors" # sectors
fdiskFlags="-u=cylinders" # cylinders
fdiskUsePartNumbers=true
else
echo "Unrecognised fdisk version: $fdiskVersion"
echo "Please check if your fdisk defaults to cyclinders or sectors and
report to the mailing list"
exit
fi
echo "The flags to use are: $fdiskFlags"
echo "Use partition numbers: $usePartNumbers"
does anyone know of any other fdisks likely to be encountered on an openmoko?
sam
_______________________________________________
Smartphones-userland mailing list
Smartphones-userland@linuxtogo.org
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/smartphones-userland