Skip to content

FixingUSBFlashDrives

Tucker Osman edited this page Feb 14, 2022 · 1 revision

USB Flash Drive Games

Sometimes a USB flash drive will be strange under Linux. The re-partitioning gives strange errors. It will not mount or there are "extra" partitions that you can't get rid of. Welcome to the wonderful world of Windows causing problems with basic devices. What you are seeing is either geometry differences or "special" partitions designed to aid Windows user. Once such mechanism is U3 Smart Drive. These "features" will get in the way and prevent using the USB flash drive in a normal manor under Linux. They must be removed and unfortunatly this normally needs to be performed under Windows.

Other times, the flash geometry is just wrong or very odd-ball. USB flash drives are mass produced and can have different flash components even if the drives are identical in outside appearance.

Here is a guide to change the geometry to something more useful. We use a large amount of USB flash drives at work as the boot drive for an embedded Linux system and this is what we use to "fix" them.

The current USB "Super Flash Drives" are labeled 256MB but are showing 512MB, the real problem is that they have an odd-ball drive geometry together with an strange partition table layout and they don't boot with syslinux.

So to be able to use these drives as bootable with syslinux we need to change the drive geometry to that of USB-ZIP. USB-ZIP drives have a sector size of 32. This guide assumes that the USB pen drive is "/dev/sdc" and has one partition that the Linux distro has auto-mounted. `

unmount all partitions or the below does not work!

umount /dev/sdc1

this wipes the partition table (keeps linux from remounting it)

dd if=/dev/zero of=/dev/sdc bs=1024 count=10

change the drive geometry

sudo sfdisk -f -C1024 -H16 -S32 /dev/sdc enter #take default enter #take default enter #take default enter #take default y #write changes and exit

change the partition type and make it bootable

sudo fdisk /dev/sdc enter "t" #change partition 1 from 83 (linux) to 6 (fat16) enter "6" enter "a" #make bootable enter "1" enter "w" #write changes and exit

check that it looks ok.

sudo sfdisk -d # partition table of /dev/sdc unit: sectors

/dev/sdc1 : start=        1, size=   524287, Id= 6, bootable
/dev/sdc2 : start=        0, size=        0, Id= 0
/dev/sdc3 : start=        0, size=        0, Id= 0
/dev/sdc4 : start=        0, size=        0, Id= 0

name the drive and make a dos filesystem on partition 1

sudo mkdosfs -n USB_DISK /dev/sdc1 `

You can change the above to match your requirements. I use it as is, then re-partition again with parted. This guide might fail with very large flash drives. It would need to be changed from "USB-ZIP" geometry to "USB-HDD" as the zip geometry has a fixed max size.