Formatting a USB stick

Stuff that plugs in via USB, FireWire, eSATA, PS/2, etc.

Formatting a USB stick

Postby michaelrmgreen » 05 Feb 2010, 09:52

Someone has given me a Kingston Mini Slim Datatraveller 8Gb flash memory stick to 'fix'.

She complains that it 'doesn't work under Vista but works OK under XP'. She has tried multiple systems.

I've been here before with USB sticks with a funny format. Sure enough FBSD 8.0 reports:
Code: Select all
ugen1.3: <Kingston> at usbus1
umass0: <Kingston DT Mini Slim, class 0/0, rev 2.00/2.00, addr 3> on usbus1
umass0: SCSI over Bulk-Only; quirks = 0x0000
umass0:0:0:-1: Attached to scbus0
da0 at umass-sim0 bus 0 target 0 lun 0
da0: <Kingston DT Mini Slim 1.00> Removable Direct Access SCSI-2 device
da0: 1.000MB/s transfers
da0: 7696MB (15761408 512 byte sectors: 255H 63S/T 981C)
GEOM: da0: partition 1 does not start on a track boundary.
GEOM: da0: partition 1 does not end on a track boundary.


and, with the Mtools installed and /dev/da0s1 configured as u:

Code: Select all
mdir u:
Total number of sectors (15759336) not a multiple of sectors per track (63)!


Hmmm, wonky formatting, "bad Kingston, bad". What to do? Well the first thing I tried was copious Googling. Lots of matches but little constructive advice. Next try, reformatting with the HP tool using XP. Some improvement, no complaints about the partition start, but still a problem with the partition end. Mtools still complains about the number of sectors (now slightly different) not being a multiple of the number of sectors-per-track.

Maybe the problem with Vista is fixed, maybe not. I won't be happy until there are no error messages. I'm difficult like that.

So, long story short (tl;dr as they say) how do I format a USB stick with a 'tidy' FAT32 format that starts and ends on a track boundary?
User avatar
michaelrmgreen
Member
 
Posts: 204
Joined: 16 Nov 2008, 21:49
Location: The Peoples Republic of Couch

Postby michaelrmgreen » 05 Feb 2010, 10:42

Additional information.

Using another Widnows utility 'Swissknife' or using the 'format f: /FS:FAT32' command line utility in XP creates formats which don't have a partition/slice on them as recognised by FBSD 8.0. In other words, with the HP utility I get da0 AND da0s1 in /dev, but with Swissknife and 'format ...' I only get da0 in /dev, no da0s1!

Further additional information.

The free version of Paragon Partition Manager can create and format a slice/partiton that doesn't prompt any error messages from GEOM or Mtools! Go Paragon!.

Lesson? USB factory formats are all the rubbish. Kill them with fire.
User avatar
michaelrmgreen
Member
 
Posts: 204
Joined: 16 Nov 2008, 21:49
Location: The Peoples Republic of Couch

Postby J65nko » 05 Feb 2010, 17:34

I just wonder why did not check the USB disk with fdisk ;)
J65nko
Member
 
Posts: 422
Joined: 17 Nov 2008, 00:06
Location: Budel, Netherlands

Postby Ruler2112 » 05 Feb 2010, 17:41

First off, dude, you're showing your windoze-ness - one does not 'format' a drive, one partitions it and then creates a file system inside the partition. :) 'Format' is a term invented by M$ so that the masses might semi-understand what's going on. (It's not really accurate in reflecting actual reality, but this really isn't at all unusual for M$ either...) Also, mtools is for people who don't want to learn a real OS. ;) :e

I've run into problems with this type of thing before. Being very unimpressed with the FreeBSD fdisk utility, I use the System Rescue CD for stuff like this, which is Gentoo based. (Don't get me wrong - FreeBSD is a fantastic OS and much more stable and easier to administer than my Linux boxes, but I find that a tool like this is more appropriate for tasks like this. Pretty much any Linux LiveCD will work with what I describe here, except for gParted, which is optional.) First off, boot from the CD and it'll bring up a shell. If you want a GUI, start X and run gParted. If not, simply use [cmd=]fdisk /dev/sdx[/cmd] - I find the actual fdisk to be easier and it's certainly much faster. Either way, delete all current partitions. If you want to be 100% certain that everything is gone before doing this, and save the step of deleting the existing partitions, do [cmd=]dd if=/dev/zero of=/dev/sdx bs=1M[/cmd] beforehand - this will wipe the entire drive with all 0s. Then create a new partition (or more, depending on your needs). This will be type 83 by default - change it to type 0Bh. Write out the partition table, then do a [cmd=]mkfs -t vfat /dev/sdx1[/cmd] to create a FAT32 file system. Repeat as needed if you created more than one partition.

!!!WARNING!!! The above will erase EVERYTHING on the drive. Be ABSOLUTELY POSITIVELY CERTAIN that you are operating on the correct device node! [cmd=]fdisk -l[/cmd] will show a list of partitions without changing anything - I suggest using it before and after plugging your flash drive in and comparing the results to determine which node to use. !!!WARNING!!!
User avatar
Ruler2112
Member
 
Posts: 419
Joined: 15 Sep 2009, 16:23
Location: Michigan, USA

Postby barberry » 08 Feb 2010, 04:19

I've used the FreeBSD install cd to format a thumb drive with
FAT.
barberry
Junior Member
 
Posts: 2
Joined: 06 Dec 2009, 17:51

Postby michaelrmgreen » 10 Feb 2010, 13:47

Stung by Ruler2112s criticism "First off, dude, you're showing your windoze-ness" I determined to discover the 'right' way to solve my USB stick problem.

First I reviewed the Handbook, and (as per barberry above) used sysinstall to create a new slice. During that successful proceedure I noticed that it would be easy to operate on the wrong disk.

With that in mind I decieded to use fdisk(8). Long story short, fdisk failed with the message:
fdisk: Class not found.

Googling lead me to a message suggesting I should have used gpart(8).

Perusal of man 8 gpart doesn't immediately indicate how it should be used to create a new slice.

OK, still with me? How do I use gpart to create a new slice on a USB drive (/dev/da0)? Am I even on the right track? TIA
User avatar
michaelrmgreen
Member
 
Posts: 204
Joined: 16 Nov 2008, 21:49
Location: The Peoples Republic of Couch

Tada is a very important thing. Do not cornfuse with Tata or Tatu.

Postby fronclynne » 10 Feb 2010, 18:55

I have had success with the following method:

[cmd=#]dd if=/dev/zero of=/dev/da0 bs=2m[/cmd] (this zeros the whole drive. if you're worried about wearing it out, just append count=1)
[cmd=#]fdisk -i /dev/da0[/cmd] change the partition type to 12, & accept the rest of the defaults that it hands you. [red]you will get the "fdisk: Class not found." error. you can safely ignore it[/red]
[cmd=#]newfs_msdos -F32 /dev/da0s1[/cmd]
Tada.

Notes: [man=8]newfs_msdos[/man], [man=8]fdisk[/man], [man=1]dd[/man], Tada!
[color="DimGray"]Quid habemus reliquum?
Nutrimentum anatum![/color]
[color="Teal"]Внимание: лифт вниз не поднимает[/color]
User avatar
fronclynne
Senior Member
 
Posts: 1297
Joined: 09 Feb 2009, 04:47
Location: Lunch Time

Postby michaelrmgreen » 12 Feb 2010, 13:13

Alright fronclynne, your advice was bang on. I've taken the liberty of making them into a How-To.
User avatar
michaelrmgreen
Member
 
Posts: 204
Joined: 16 Nov 2008, 21:49
Location: The Peoples Republic of Couch

Postby Ruler2112 » 12 Feb 2010, 18:37

michaelrmgreen wrote:Stung by Ruler2112s criticism "First off, dude, you're showing your windoze-ness" I determined to discover the 'right' way to solve my USB stick problem.


It wasn't meant as criticism, more a gentle jab at your using the 'format' terminology intended to be humorous. 'Formatting' a drive is really just creating a file system on it with a rudimentary surface scan included. (Unless doing a 'quick format', which is a term that indicates that the surface scan should be skipped.)

It's just a difference in saying what's really happening versus the M$ way of hiding it behind not-so-clever terms.
User avatar
Ruler2112
Member
 
Posts: 419
Joined: 15 Sep 2009, 16:23
Location: Michigan, USA


Return to Peripheral Hardware

Who is online

Users browsing this forum: No registered users and 0 guests