how to increase cylinders on USB Flash Drive

Hello All,

I faced a unique issue. I have written a script for transferring backup data on my host machine to a USB Flash drive. The Flash drive must be of 16GB size. So, my script creates two primary partitionon the USB flash drive. I require approx 5900 cylinders for the first partition on the Flash drive. Most USB flash drive have sufficient cylinders to create two primary partitions as required by my script.

However recently I used a CENTON flash drive which has 2785 cylinders. Hence, my script is not able to create partitions on it as the number of cylinders is less than required.

Anyone has any idea how to resolve this issue?? Please find below the failure

Disk /dev/sdc: 16.0 GB, 16095641600 bytes   [ USB Flash drive ]
217 heads, 52 sectors/track, 2785 cylinders
Units = cylinders of 11284 * 512 = 5777408 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        2786    15714304    c  W95 FAT32 (LBA)

partitioning failure

First cylinder (1-2785, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2785, default 2785): 5917
Value out of range.

Cheers,
Sachin

There's a very very simple solution to this: don't use a fixed amount of cylinders (a concept which doesn't apply to any modern disk anymore), but use the +xM notion instead, eg. +16384M.

Thanks Pludi.

Could you be a bit more specific.

Cheers,
Sachin

You'll have to be more specific on what I should be more specific about. Why the cylinders concept is obsolete? Why it's possible to declare a partition by size instead of cylinders? How one could enter the size instead of the cylinders?

Yes Pludi. I want to know how to declare a partition by size instead of cylinders.

I am pasting the script which creates partition on Flash drive.

create_partitions_on_USB()
{
    PARTITION1=$1
    PARTITION2=$2
    fdisk /dev/sdc << EOF
o
n
p
1
${PARTITION1}
t
83
a
1
n
p
2
${PARTITION2}
t
2
83
w
EOF
}

what changes are required to this script??

Regards,
Sachin

First, learn how to use code tags.

Second, there's nothing to be changed in this "script", only what you pass along as the first and second parameter.

All right. I pass 5917 and 654 as the two parameters to this script. These are basically system engineered values and are sizes of the partition in MB instead of cylinders.

Still, why am I facing this issue??

No. As seen in your posts above, 5917 and 654 are a cylinder count, NOT the size in MB. For that you'd have to pass +xyzM as a parameter to create a partition of xyz MB size.

How many cylinders your flash drive has depends on how how many its boot sector says it has and nothing else. This is because 'cylinders' are wholly imaginary on any device which supports modern logical block addressing.

You're not "missing" cylinders either. If you have fewer cylinders on the same sized device, they must be larger cylinders too.

If they really are MB, stick a + on the front, an M on the end, and fdisk will understand them as sizes in megabytes and figure out the right number of cylinders for you no matter what the cylinder size.