Rescuing a Damaged USB Stick

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Mon Dec 19 14:55:21 UTC 2011


On Mon, Dec 19, 2011 at 02:13:21AM -0500, William Park wrote:
> Odd that it doesn't have partition table.  Windows always creates the
> first partition.  Unless it was created from Linux to use the whole
> device.  In any case, you can take a peek into the image:
> 
>     # losetup usb.img
> 	-- check /proc/partition to see that "loop0" is created
> 
>     # fdisk -u -l /dev/loop0
> 	-- if you see partitions, say loop0p1, then create loop device
> 	for that.  Calculate the offset into the first partition, like
> 	    # losetup usb.img -o $((2048*512))
> 		-- check /proc/partitions to see "loop1"
> 	    # mount /dev/loop1 /mnt
> 
> 	-- if you don't see partition, then it's probably using the
> 	whole device.  Then, just mount it.
> 	    # mount /dev/loop0 /mnt
> 
>     # losetup -d /dev/loop0
>     # losetup -d /dev/loop1
> 	-- delete the loop devices

Simpler yet:

modprobe -r losetup
modprobe losetup max_parts=16

Now you get /dev/loopXpY devices for whatever partition table your
image has.

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list