Thursday, April 30, 2009

SD Card Partitioning

A week or so ago my wife mentioned that she was having a problem with her digital camera. Given the importance of the requester I stopped what I was doing and listened to her describe the problem.

It seemed that the camera was having problems writing to the SD Card and after turning the camera off and on it wanted to reformat the card. This is not a new camera or card so this is something that should not be happening at this point.

I popped the card into my pc and Windows showed that it as a One Gig partition. This was strange because it is a Two Gig card. Opening up Disk Manager showed that indeed there was a One Gig partition and the rest was unused space. I attempted to resize the partition and even create a second partition in that unused space but Disk Manager wasn't going to let me do it.

So I tried inserting the card into my Linux laptop to see what I could do. Mandriva detected the card and auto mounted it as "NEW VOLUME". That was a good sign so dropped to the shell and issued a "fdisk -l" to see what was there but only the hard drive ( sda ) showed up. Then I poked around in /dev/ to see what I can find and didn't notice anything. I issued a "ls" on /mnt and there was nothing there.

After a moment of inspiration I checked /media and there was NEW VOLUME and then after a bit of googling I issued a"cat /etc/mtab" and was rewarded with:

/dev/mmcblk0p1 /media/NEW\040VOLUME vfat rw,nosuid,nodev,uhelper=hal,uid=501,utf-8

Now I was able to unmount using "unmount /dev/mmcblk01p1"

Then I used "fdisk /dev/mmcblk01p1" and selected "d" to delete the partition

Then "w" to write the table to the card.

Then I selected "n" for new partition.

Then "p" for primary.

Then "1" to make it the first partition.

Then "enter" to accept the default first cylinder.

Then "enter" again to accept the default last cylinder.

Then "w" to write the table.

Now the card is partitioned into one partition again and after formatting and putting it back in the camera and taking a few pictures my wife is happily taking pictures again.