Tuesday, August 17, 2010

USB Pen Drive Mishap

J_Boner - USB flash drives, installing Linux
This is a guest post by J_Boner.

I was in the process of trying new things with my pen drives and installing different operating systems. In this quest so far I have been very successfull with Windows Vista, Windows 7, and many various Linux installs using the pen drive as my install medium. I have a PNY 8G Attache, a Geek Squad 8G, and a Kingston 2G.

I took my PNY 8G and plugged it into my usb and decided to format that puppy to hfs+ to try to do a Mac OSX drive to see if I could take another empty drive and make a dual-boot system with Linux and OSX.

I followed a certain tutorial, with some mods of my own, and came out with the pen drive where I wanted it. It had 2 partitions of hfs+ and all the files in the second partition and the proper file system I needed. I was all excited. I then told my beast of a computer to boot to the usb pen drive. It started to and then locked up. Not quite sure why yet. I tried several times to get it to boot, changing different options in the bios, nothing worked. Fail.

This then leads us into my quest to learn more on the pen drive because after I reformatted it and set it up to do a usb install of Ubuntu 10.04 LTS for a friend, it would not boot even tho I had specified boot flags on the drive. I thought I "bricked" it for good!

I let the project hang for a few days and then I got a chance to run into some friends with windows computers and asked them to reformat it for me. (Thanks Raivyn and Louie!) We did two attempts on two seperate machines, two seperate OS'es. Windows XP Pro and Windows 7 Ultimate to no avail.

I let it hang for another week or so, and thought about it some more and decided to check PNY's site for support. I went to the support tab and saw they had a low level format utility for the drive and I thought "hmm". I downloaded the zip file with the utility in it and opened it up to see a Windows executable. (I hate Windows.) I then remembered an article I read somewhere about low level formatting in general. There is no need to low level format a drive. All you really need to do is "zero" the damn thing. BINGO!

On Mon. 08/16/2010 the solution to this issue presented itself with my use of a small unix based command line called "dd". DD is built into all linux flavors I have played with. I am not saying it is built into all, just saying the ones I have dealt with. The command I used in terminal was:

# sudo dd if=/dev/zero of=/dev/sdX

  • The "X" in this scenario is the variable for your drive letter. In my case whenever I plug in my usb drive, the first one inserted is sdc. I usually use GParted to find my drive letters by size of the drive. Simple.
  • I did not specify any block size here just because I forgot. You can probably state a block size to use and make it go faster, but I took my time.

After the zero on the drive, I then used GParted to reformat the drive into fat32 and added the boot flag to it and BINGO it was fixed. Tested and verified.

I put on another Linux OS and booted to it. Fixed.

Things to remember here:
  • Make sure not to mix your if's and of's. You could possibly do something wrong/detrimental to your system.
  • Using GParted, if you're looking at your drive and there is a pic of "keys" there, the drive is locked. This is ok. Solution: Right-click on the "keys" and then in drop down menu left click "Unmount". This will unmount the current file system and let you alter/erase said file system.

Hope you have enjoyed this little exerpt from Boner Labs.

J_Boner