Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I use a 16 GB MicroSDHC and a USB 2.0 card reader as a flash drive. It recently got corrupted by a windows machine that had a few viruses.
I immediately used dd to backup the disk image, then I copied off all of my files. Thankfully, they are all safe. I zeroed the disk using:
Code:
dd if=/dev/zero of=/dev/sdc
After that, I used gparted to create a primary fat32 partition that used up the "entire" card.
This is where things get interesting. Gparted reports that the size of the card is 14.83 GB, not the 15.9 GB that I expected. The card functions properly in linux, as far as I can tell. It's just smaller.
Strangely, the output from fdisk gives the correct size of the device as 15.9 GB:
Code:
root@bt:~# fdisk -lu /dev/sdc
Disk /dev/sdc: 15.9 GB, 15931539456 bytes
255 heads, 63 sectors/track, 1936 cylinders, total 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xc04a730c
Device Boot Start End Blocks Id System
/dev/sdc1 63 31101839 15550888+ b W95 FAT32
Something seems wrong. The first partition is not using the entire card! In fact...
Code:
root@bt:~# fdisk /dev/sdc
The number of cylinders for this disk is set to 1936.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): v
14510 unallocated sectors
Command (m for help): q
The unallocated sectors could account for the storage space I'm missing, right?
So, this is where I am stuck at. I can't figure out how to get it to use the remaining unallocated sectors. I already have my files, now I want my card back.
If there is any more information I can provide, just ask. Thanks!
Last edited by entropic; 05-03-2009 at 08:53 AM.
Reason: Solution
After using that command, I used fdisk to create a new primary partition:
Code:
root@bt:~# fdisk /dev/sdc
The number of cylinders for this disk is set to 15193.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): v
31116287 unallocated sectors
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (32-31116287, default 32):
Using default value 32
Last sector, +sectors or +size{K,M,G} (32-31116287, default 31116287):
Using default value 31116287
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
It let me use more sectors this time! Now I only have 31 unallocated sectors, which is perfectly normal. After that, I rebooted because it told me to.
However... Gparted now reports that the size of the device is 14.84 GB. At least it's a step in the right direction.
I am going to continue repeating this process in order to see if I can recover more space. If anyone has any more ideas, don't hesitate to share!
EDIT: No additional space can be recovered using this method.
Last edited by entropic; 05-02-2009 at 08:54 AM.
Reason: more info
fdisk won't show info on the disk because the disk is actually a partition itself. That's no problem, you should be able to mount and use the disk just fine. This is how it has always worked with flash disks, AFAIK. This is the only way most cameras will accept anyway.
Okay, when I mount the card it still shows up as having a size of 14.8 GB (in Windows too). I can't change the volume label or flip the removable media bit. If I try to format using windows logical disk manager it fails at 100%.
If it helps, the card had one 16 GB partition before it got corrupted. This means it would mount to /mnt/sdc1 because the device was /dev/sdc1.
It seems you are experiencing cell damage. It is not caused by viruses. The cell damage is caused by too many writes. Actually Flash memory is a poor storage medium investment because it has very limited writes, the oldest data can not be more than 10 years old, and it is easily damaged by power fluctuations. Use hard drives for data storage because the medium it self can hold the data close to a century and the amount of writes is close to infinite.
I have had my card for 5-6 months with moderate use. Could damage set in that quickly?
Mkdosfs didn't tell me anything, so I assume there are no bad blocks.
I found a program (for windows) called SDFormatter on sdcard.org which might be helpful to others with a similar problem. This gives me a primary partition (/dev/sdc1) of 14.83 GB with 4 MB of unallocated space at the beginning of the device. Apparently this is the standard for sd/microsd cards. It's nice to know that I can always use this if I mess up. It would be even better if it gave me back that extra 1.2 GB!
Thanks for you help everyone, I definitely learned many things along the way.
I fixed the corruption using the SD Formatter found on Panasonic's site (windows only ). This formats the card to sd/sdhc standards.
As for the "smaller" size of my card... That was a mistake on my part . When the manufacturer says "16 GB" they actually mean ~14.83 GB. It has to do with measuring megabytes as 10^x instead of 2^x.
All of my files fit perfectly onto my card. I guess I never noticed the total size of my card was 14.83 GB the entire time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.