Robert wrote:
Robert Nichols wrote:
The first thing I do with every USB flash drive I buy is figure
out a geometry that uses all of the sectors reported by fdisk
(I have a shell script that does that in a pretty much brute force
way.) and then repartition and re-format the drive using that
geometry. I've never experienced any problem with that.
That's interesting. Would you consider sharing your script?
Sure. I'll try it as a small attachment here. It that doesn't
work, and I suspect it won't, I'll have to find some spot where
I can upload it. I don't have anything like that set up just now.
--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.
#!/bin/bash
########
#Brute force searches for the CHS geometry that can best utilize a
#device with a given total sector count. For each cylinder count,
#starting with the minimum possible and continuing until the
#cylinder size is reduced to just 8 sectors, it finds the best H
#and S count. A line is written st stdout each time a geometry is
#found that is at least as good as the best one seen so far.
#(Sometimes a later geometry that yields the same sector count is
#in some way "nicer".)
#
#The "-d" option adjusts the calculation to account for the track
#that is wasted for the MBR in DOS compatibility mode. Sometimes a
#smaller track size that wastes fewer sectors will be slightly
#better, though the maximum savings is minimal (55 sectors).
#
#For a large device, you will probably want to interrupt this
#before it runs to completion. Evaluating geometries with millions
#of tiny cylinders can take hours, and those are not likely to be
#considered desirable.
#
#Released to the public domain 15 June 2009 by Robert Nichols
# AT comcast.net I am rnicholsNOSPAM
# (Yes, NOSPAM really is part of my email address.)
########
restrk=0
if [ "$1" = -d ]; then
restrk=1
echo "Loss due to DOS compatibility mode considered"
shift
fi
if [ -z "$1" -o "$1" = "-h" -o "$1" = "--help" ]; then
echo "Usage: ${0##*/} [-d] total_sectors" >&2
echo " (Integer expression allowed for total_sectors)" >&2
exit 1
fi
tsec=$(( ($1) + 0 )) # Evaluate the input expression
maxspcyl=$((63*255)) # Max possible sectors per cylinder
mincyl=$(($tsec/$maxspcyl))
[ $mincyl -lt 1 ] && mincyl = 1
best_cap=0
cyl=$mincyl
full=
trap "echo \"Interrupted at cyl count = \$cyl\"; exit" 2
echo " H * S * C for $tsec total sectors:"
while [ $cyl -le $(($tsec/8)) ]; do
cylsize_p=$(($tsec/$cyl))
minspt=$(($cylsize_p/255))
[ $minspt -gt 63 ] && minspt=63
[ $minspt -lt 1 ] && minspt=1
spt=$minspt
while [ $spt -le 63 ]; do
hd=$(($cylsize_p/$spt))
[ $hd -gt 255 ] && hd=255
cap=$(($spt*$hd*$cyl))
pcap=$(($spt*($hd*$cyl - $restrk)))
if [ $pcap -ge $best_cap ]; then
best_cap=$pcap
[ $best_cap = $tsec ] && full=" 100%"
echo "$hd * $spt * $cyl = $pcap ($(($pcap*512)))$full"
fi
spt=$(($spt+1))
done
cyl=$((cyl+1))
done
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos