Flash-Restore/Recover
From Linux Solutions
One reason that flashs (USB Sticks or Storage) are not working anymore is, that the partetion-table was damaged. Here is, what you could do about it:
Contents |
Try to Mount the Flash
If there is data on it, you want to save, you can try to mount the file system with offset:
determine, were file-system starts
look for the VFAT-file-system-signature
dd if=/dev/sda bs=1M count=1 | hexdump /dev/stdin -C | grep -i "55 AA "
You will get something like this:
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............Uª| 000041f0 00 41 bb 00 07 80 7e 02 0e e9 40 ff 00 00 55 aa |.A»...~..é@ÿ..Uª| 00007df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............Uª| 00007ff0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............Uª| 000089f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............Uª| 1+0 records in 1+0 records out 1048576 bytes transferred in 0.331127 seconds (3166688 bytes/sec)
The first number on each line gives you the offset in hexadecimal. This offset is wrong for 0x1F0, so you have to subtract this number. Do not forget, that this numbers are hexadecimal values, you have to convert them into decimal numbers:
echo $[0xHEXADECIMALNUMBER]
try mounting the filesystem with
mount /dev/sda /mnt -o ro,offset=$[0x00007df0-0x1F0]
You may need to try the offsets of all lines which where found.
Here a typical offset was given as example. The part in brackets
specifies the offset. Just put "0x" (Zero+x) and the offset you want to
try (first number of eacht line of the last command) and than "-0x1F0"
to correct the little error.
Then try to look into /mnt. If you data is there, copy it. If not, do not forget
umount /mnt
and then try the next one.
The file-system is mounted read-only!
After you saved you data, you should format the flash!
Format the Flash
Creating Partetion Table
with cfdisk
cfdisk /dev/sda
This program controlled by the keyboard only. Use the arrow-keys to select a command.
- There should be a lot of Free Space. If not, just select "Delete" to delete existing partitions.
- Just select "New",
- than "Primary",
- then enter the size of the partition (the biggest possible size is the default value, so you can just press Enter if you want just one partition).
- Then you should set the type of the Partition to FAT.
- Just select "Type",
- and then enter "0B". Before you can enter this, you may have to press enter, because the program lists all possible types.
- After all you have to save you changes with "Write",
- you have to confirm this with entering "Yes".
with fdisk
fdisk /dev/sda
- You can alway list the partitions with "p"
- Use "d" to delete partitions if there are some
- Use "n" for a new partition
- than "p" for a primary one
- then "1" for the first one
- then enter for the default start sector (first possible)
- then enter again for the last possible sector (biggest possible size)
- Change partition type to "W95 FAT32": use "t"
- then enter "b"
- Write your changes with "w"
After this remove the flash and put it in again.
Now create a vfat-file-system with
mkdosfs /dev/sda1
or
mkfs.msdos /dev/sda1
or also: You could use a windows computer to format the flash at this point.
If there are may be some broken sectors on the flash, add the parameter -c for doing a sector-test as well.