1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How-To repartiton (format) a USB flash drive.

Discussion in 'Howtos and FAQs (Moderated)' started by michaelrmgreen, Feb 12, 2010.

  1. michaelrmgreen

    michaelrmgreen Member

    Messages:
    210
    Thanks Received:
    15
    The partition and formatting on a USB flash memory drive is sometimes a bit faulty.

    Symptoms include (but are not limited to) FreeBSD complaining about the start and/or end of the partiton not being on a track boundary, the total number of sectors not being a multiple of the number of tracks, the drive not being recognised especially in MS Vista and errors when saving files in Windows.

    If you have a malfunctioning USB stick try this:

    Copy off any files you want to keep. (important)

    Plug in the stick and check what device it is recognised as. It's usually da0 if you don't have any SCSI drives. But CHECK.

    Now remove the existing partiton information:
    # dd if=/dev/zero of=/dev/da0 bs=2m count=1

    Create a new slice/partiton
    # fdisk -i /dev/da0
    In the interactive section accept the defaults except for sysid, which is 165 for FreeBSD but for FAT32 is 12.
    Ignore the 'fdisk: Class not found' error.

    Create a new file system ('format')
    # newfs_msdos -F32 /dev/da0s1

    Enjoy working USB drive.
     
    Huckey and bebuxe thanked for this.
  2. graudeejs

    graudeejs Well-Known Member

    Messages:
    4,594
    Thanks Received:
    633
    Why would one want to partition usb flash?
    Simply run newfs_msdos /dev/da0, and it works well :D
     
    uzsolt thanks for this.
  3. michaelrmgreen

    michaelrmgreen Member

    Messages:
    210
    Thanks Received:
    15
    Hmmm, now I'm going to have to find another USB drive with a wonky filesystem to try that on.
     
  4. Ruler2112

    Ruler2112 New Member

    Messages:
    421
    Thanks Received:
    24
    I've seen a flash drive get a corrupted partition table before. No idea how it got that way, but the above is exactly how I was able to make it usable again. (After playing with it to recover the data off of it of course, but that's another discussion.)
     
  5. fronclynne

    fronclynne New Member

    Messages:
    1,297
    Thanks Received:
    167
    not to have some secret install that I use for unsavoury activities

    8g flash drive, don't need 8G of fat32 storage*, would like to also have a small install of freebsd (for testing, obviously).



    *okay, I didn't need an 8G flash drive at all, but the dang thing was on sale for less than a 4G drive
     
  6. ikbendeman

    ikbendeman Member

    Messages:
    262
    Thanks Received:
    8
    I know this was a few years ago, and sorry to revive a dead thread. But you didn't mention what you paid for that 8g 8 GB flash drive. I just wanted to point out I got a 64 GB USB 2.0 flash drive for $11 US yesterday (I couldn't justify the price increase for USB 3.0, especially when I don't know exact speeds, I'm pretty sure a 2.0 will give me about 15 MB/s which is enough to test drive the other BSDs (a reason to partition, as somebody asked why above).