Most USB sticks use the PC partitioning format, and have a single partition. That means the first sector (512 bytes) of the disk contains a partition table (and optionally a bootloader), and the rest of the disk contains the partition.
You could have rescued just the partition with
ddrescue -f -n /dev/sda1 /dev/sdb8 logfile
ddrescue -d -f -r3 /dev/sda1 /dev/sdb8 logfile
But now that you have the whole disk, you can get at its partition.
losetup -o 512 /dev/loop0 /dev/sdb8
mount -r /dev/loop0 /mnt
If /dev/loop0
is already in use, you may have to choose another number. The command losetup -f
will return the number of a free loop device.
However, manipulating partitions on a live system is error-prone, so rather than do this, I recommend moving the data from the USB stick to an ordinary file. Either copy the whole disk, then use losetup
on the disk image (16M × 130 is calculated to be larger than the size of the USB stick):
dd bs=16M count=130 </dev/sdb8 >/var/tmp/usb-stick.disk
Or copy just the partition, and mount the partition image directly:
tail -c +513 </dev/sdb8 | dd bs=16M count=130 >/var/tmp/usb-stick.partition
mount -o loop,ro /var/tmp/usb-stick.partition /mnt
And for future reference, you might as well have passed an output file, rather than an output partition, to ddrescue
in the first place.
hi! Cannot mount -r /dev/loop0 /mnt mount: you must specify the filesystem type so I gave mount -r -t usbfs /dev/loop0 /mnt a try and it worked, but the content was weired...four folders 001 002 003 004 and a textfile 'devices' ? – panny – 2010-11-13T22:21:23.087
@panny:
usbfs
is a pseudo-filesystem (likeproc
andsysfs
); it ignores the device. What you have is probably avfat
filesystem, but ifmount
didn't figure out the filesystem automatically, there's probably something wrong elsewhere. How exactly did you create the loop device? What doesfile - </dev/loop0
show? What aboutfile - </what/you/ran/losetup/on
? – Gilles 'SO- stop being evil' – 2010-11-13T22:29:46.120file - </dev/loop0 shows /dev/stdin: DOS executable (device driver) and file - </dev/sdb8 shows /dev/stdin: DOS executable (device driver). I would ddrescue the whole 2gb again with proper arguments etc., but it took - don't know why - nearly two days to finish :/ – panny – 2010-11-13T22:40:57.743
#parted /dev/sdb8 unit B print Warning: GNU Parted has detected libreiserfs interface version mismatch. Found 1-1, required 0. ReiserFS support will be disabled. Error: /dev/sdb8: unrecognised disk label – panny – 2010-11-13T22:42:33.700
I created the loop filesystem like: losetup -o 512 /dev/loop0 /dev/sdb8 – panny – 2010-11-13T22:45:10.267
@panny: The first explanation that comes to me is that the very beginning of the disk is corrupt, so the filesystem structures are damaged. Does the ddrescue log show errors in the first kilobyte or so? If that's so, you'll have to turn to other repair techniques, such as looking for known patterns to try and recover files. Was this a FAT filesystem? If so, try
dosfsck
(on a copy (into a regular file) of what you have now in/dev/sdb8
). – Gilles 'SO- stop being evil' – 2010-11-13T23:21:59.533you mean the beginning of /dev/sdb? That sounds impossible since I can mount all partitions (except for /dev/sdb8 now) and read and write. I can't spot any errors in the logfile: – panny – 2010-11-14T01:06:13.867
>current_pos current status 0x7CFF0200 + # pos size status 0x00000000 0x7D000000 +< – panny – 2010-11-14T01:07:40.323
dosfsck /dev/sdb8 dosfsck 3.0.10, 12 Sep 2010, FAT32, LFN Logical sector size (65535 bytes) is not a multiple of the physical sector size. returned: 1 – panny – 2010-11-14T01:09:42.240
@panny: I meant that I suspected that the beginning of the USB stick is corrupt (but there may be another explanation). What you have now at the beginning of
/dev/sdb8
(i.e. what you had on the USB stick) doesn't look like a filesystem or like a disk image with PC partition. Try adding the output ofhead -c 1024 </dev/sdb8 | hd
to your question, so human beings can have a go at guessing what you have there (I don't promise results, but it's worth a try). – Gilles 'SO- stop being evil' – 2010-11-14T10:32:35.703