LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 09-10-2013, 11:05 AM   #1
masavini
Member
 
Registered: Jun 2008
Posts: 177

Rep: Reputation: 6
usb stick recovery...


hi,
i was trying to dd my 64GB usb stick with an image file, but i found the transfer/rate VERY slow. it began with 7MB/s, falling to a few KB/s after about 2GB copied. i stopped it (with some pain) in a few minutes...
Code:
pv -tpreb ~/VirtualBox\ VMs/win8pro/win8pro.vhd | dd of=/dev/sdc bs=10M
(i discarded the output message, sorry...)

so i tried and look for some bad blocks, but after a couple of GB the scan became VERY slow and i stopped it in a few hours.
Code:
sudo badblocks -w -s -o usbstick2.log /dev/sdc
(i discarded the output message, sorry again...)

i'm now trying to copy the image with dd_rescue (GNU version) and after about 8GB it has become VERY slow.
Code:
sudo ddrescue -f ~/VirtualBox\ VMs/win8pro/win8pro.vhd /dev/sdc
GNU ddrescue 1.16
Press Ctrl-C to interrupt
rescued:     8512 MB,  errsize:       0 B,  current rate:    65142 B/s
   ipos:     8512 MB,   errors:       0,    average rate:    2123 kB/s
   opos:     8512 MB,     time since last successful read:       0 s
Copying non-tried blocks...
this is my guess:
- the usb drive was for some reason corrupted after the 2nd GB
- badblocks properly reallocated all of the bad sectors found until i stopped it (let's say until the 8th GB)
- dd_rescue went fast until the 8th GB of data, then the bad sectors stopped being reallocated and it was slowed down

the question:
could a badblocks full scan recover the whole usb drive and let it be written full-speed? it could take several of hours, but it would be worth...

Last edited by masavini; 09-10-2013 at 11:08 AM.
 
Old 09-11-2013, 06:38 AM   #2
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbang
Posts: 605
Blog Entries: 1

Rep: Reputation: 139Reputation: 139
Most likely causes of are slow flash drive are;
a.) The flash memory is worn out.
b.) The flash drive is overheating.

I've noticed that usb flash drives seem to be optimised for very short access times. Any long access time causes them to heat up. The transfer speed seems to be inversely proportional to the temperature of the device, causing a slowdown as it warms up.

Try reformatting the drive with Gparted. (I sometimes format twice, using an alternative file system to help 'free up' the drive.)

If you can't manage to format it, you'd best just buy a new one.
 
Old 09-11-2013, 05:26 PM   #3
masavini
Member
 
Registered: Jun 2008
Posts: 177

Original Poster
Rep: Reputation: 6
hi,
i don't think the drive is worn out: it has been used something like 10 times since it was bought...

i tried and put the stick under refrigeration with an usb fan: it doesn't get hot at all, but when the copy process arrives to 8GB it still goes down from 5MB/s to a few KB/s...

i'm now trying and stop the dd process, but it cannot be killed: shall i trash the usb stick?
 
Old 09-11-2013, 10:16 PM   #4
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbang
Posts: 605
Blog Entries: 1

Rep: Reputation: 139Reputation: 139
What brand/model of flash drive is it? Were you able to format it without any problems?
 
Old 09-12-2013, 04:11 AM   #5
masavini
Member
 
Registered: Jun 2008
Posts: 177

Original Poster
Rep: Reputation: 6
here are dmesg relevant lines:
Code:
[ 2781.395937] usb 3-2: new high-speed USB device number 3 using xhci_hcd
[ 2781.412535] usb 3-2: New USB device found, idVendor=5678, idProduct=1234
[ 2781.412542] usb 3-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2781.412546] usb 3-2: Product: Flash Disk      
[ 2781.412550] usb 3-2: Manufacturer: Generic 
[ 2781.412553] usb 3-2: SerialNumber: CCBB1209032156470220217111
[ 2781.442256] Initializing USB Mass Storage driver...
[ 2781.442513] scsi6 : usb-storage 3-2:1.0
[ 2781.442670] usbcore: registered new interface driver usb-storage
[ 2781.442675] USB Mass Storage support registered.
[ 2782.439259] scsi 6:0:0:0: Direct-Access     Generic  Flash Disk       5.00 PQ: 0 ANSI: 2
[ 2782.440982] sd 6:0:0:0: Attached scsi generic sg2 type 0
[ 2782.441375] sd 6:0:0:0: [sdc] 131072000 512-byte logical blocks: (67.1 GB/62.5 GiB)
[ 2782.441512] sd 6:0:0:0: [sdc] Write Protect is off
[ 2782.441518] sd 6:0:0:0: [sdc] Mode Sense: 0b 00 00 08
[ 2782.441642] sd 6:0:0:0: [sdc] No Caching mode page present
[ 2782.441647] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[ 2782.444133] sd 6:0:0:0: [sdc] No Caching mode page present
[ 2782.444139] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[ 2782.446176]  sdc: unknown partition table
[ 2782.446905] sd 6:0:0:0: [sdc] No Caching mode page present
[ 2782.446909] sd 6:0:0:0: [sdc] Assuming drive cache: write through
[ 2782.446913] sd 6:0:0:0: [sdc] Attached SCSI removable disk
i can create a partition table with gnome-disks, but i can't create a partition with gnome-disks nor gparted.
i can easily format it and create a ntfs partition using win8pro.

after the new partion has been created with win8pro, i can delete it with gparted, but i can't create a new one as mkfs gets stuck here:
[img=http://s24.postimg.org/8mfcpg3f5/gparted.jpg]

Last edited by masavini; 09-12-2013 at 09:24 AM.
 
Old 09-12-2013, 08:12 AM   #6
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbang
Posts: 605
Blog Entries: 1

Rep: Reputation: 139Reputation: 139
Okay, that looks like your dmesg output, not lsusb. (but not a problem)
You seem to have an unbranded flash drive. That could be why it's not working very well. (although some unbranded devices work better than the popular brands)

Anyhow, what I would try next is, in gparted, select 'Device' from the menu at the top, then select 'Create partition table'

That should set up a new partition table altogether.

Next, select the unallocated space and make a new fat32 partition.

If that succeeds, delete that partition and create an ext4 partition.

It's a bit of a roundabout way to do things, but I've found that this is what I've had to do on corrupted flash drives.

P.S: ntfs is an unusual file system for flash drives. Usually a flash drive will have fat32 as it's file system for compatibility with the widest range of operating systems. (although you can use any file system you want in theory)
 
Old 09-12-2013, 09:34 AM   #7
masavini
Member
 
Registered: Jun 2008
Posts: 177

Original Poster
Rep: Reputation: 6
Quote:
Originally Posted by qlue View Post
Okay, that looks like your dmesg output, not lsusb. (but not a problem)
you right, i edited the previous post.

Quote:
Originally Posted by qlue View Post
Anyhow, what I would try next is, in gparted, select 'Device' from the menu at the top, then select 'Create partition table'
That should set up a new partition table altogether.
-> DONE

Quote:
Originally Posted by qlue View Post
Next, select the unallocated space and make a new fat32 partition.
-> DONE (took a few seconds)

Quote:
Originally Posted by qlue View Post
delete that partition
-> DONE

Quote:
Originally Posted by qlue View Post
and create an ext4 partition.
-> FAILED: it's been running for some minutes, and still not completed:
[img=http://s23.postimg.org/84ksrk1dz/gparted.jpg]


Quote:
Originally Posted by qlue View Post
P.S: ntfs is an unusual file system for flash drives. Usually a flash drive will have fat32 as it's file system for compatibility with the widest range of operating systems. (although you can use any file system you want in theory)
i'm not an expert at all, but shouldn't the filesystem type be irrelevant when using commands like dd or ddrescue?
 
Old 09-12-2013, 10:04 AM   #8
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,645

Rep: Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250
dd of=/dev/sdc will destroy everything on that pendrive, even the partition table. Either you need to use of=/dev/sdca or similar or try different block sizes. Probably yout pendirve is damaged, or it has no 64GB space on it at all (but 8 GB or less???)
 
Old 09-12-2013, 11:33 AM   #9
masavini
Member
 
Registered: Jun 2008
Posts: 177

Original Poster
Rep: Reputation: 6
Quote:
Originally Posted by pan64 View Post
dd of=/dev/sdc will destroy everything on that pendrive, even the partition table. Either you need to use of=/dev/sdca or similar or try different block sizes. Probably yout pendirve is damaged, or it has no 64GB space on it at all (but 8 GB or less???)
what is /dev/sdca?

how to guess if capacity is lower than expected or if the drive is just dmaged?
after the 8th GB transfer rate was very low, but never 0KB/s... is this behaviour compatible with the idea that there was no space left on the (fake) 64GB drive?
 
Old 09-12-2013, 11:46 AM   #10
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: infinity; (randomly born:) Milwaukee, WI, US, Earth
Distribution: any UNIXish that works well on my cheapest with mostly KDE, Xfce, JWM or CLI but open ;-)
Posts: 1,345
Blog Entries: 2

Rep: Reputation: 349Reputation: 349Reputation: 349Reputation: 349
I usually delete everything (i.e. unallocated as no partitions) before I dd .img but if the drive is bad then?

Do you have Disk Utility (Ubuntu does) installed? I use this to find my sd /~ e.g. /dev/sda1 as well as for all but dd (here anyhow) plus it has S.M.A.R.T.

Last edited by jamison20000e; 08-14-2014 at 11:13 PM.
 
Old 09-12-2013, 02:47 PM   #11
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbang
Posts: 605
Blog Entries: 1

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by pan64 View Post
dd of=/dev/sdc will destroy everything on that pendrive, even the partition table. Either you need to use of=/dev/sdca or similar or try different block sizes. Probably yout pendirve is damaged, or it has no 64GB space on it at all (but 8 GB or less???)
Since the OP appears to be trying to copy a full virtual drive to the stick, I suspect that of=/dev/sdc is the correct path to use.
What is strange though, is that dd seems to be slowing down but not exiting with an error. If the drive had insufficient space, dd should exit with an error when the drives capacity is reached.
And gparted won't let you format more than the drive's capacity.




I suspect that there could be a compatibility problem involved here. Maybe there is some low-level instruction that is needed by dd and ext2 type file systems, but not needed by fat32? (this is pure conjecture on my part as I've never come across this before)


P.S: Are you sure you're not been too hasty in deciding that it's not working? 62GiB can take more than half an hour with dd
I've personally waited over 20 minutes for a mere 8GB flash drive to copy using dd to make an image file.

Last edited by qlue; 09-12-2013 at 03:15 PM. Reason: added postscript
 
Old 09-13-2013, 12:16 AM   #12
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,645

Rep: Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250Reputation: 1250
Quote:
Originally Posted by masavini View Post
what is /dev/sdca?

how to guess if capacity is lower than expected or if the drive is just dmaged?
after the 8th GB transfer rate was very low, but never 0KB/s... is this behaviour compatible with the idea that there was no space left on the (fake) 64GB drive?
/dev/sdc is the 3rd device, /dev/sdc1, /dev/sdc2 are the first and second partition on that device. (mistyped, not sdca)
I have a 1 TB (yes!) pendrive from sony but I could never write more than a few GBs onto it. It is definitely a fake 1 TB device but all the tools I have tried reported that size and I was never able to use that drive - that means writing was almost always ok but never could read the data written. I can't remember the speed.
 
Old 09-13-2013, 04:50 AM   #13
masavini
Member
 
Registered: Jun 2008
Posts: 177

Original Poster
Rep: Reputation: 6
Quote:
Originally Posted by qlue View Post
P.S: Are you sure you're not been too hasty in deciding that it's not working? 62GiB can take more than half an hour with dd
I've personally waited over 20 minutes for a mere 8GB flash drive to copy using dd to make an image file.
i can't be 100% sure, but if you clone a 25GB image @ ~7MB/s it takes about one hour... but if after 20 minutes the transfer rate goes to 32KB/s, it would take about 148 hours... i guess it's a bit too much, isn't it?
 
Old 09-13-2013, 08:49 AM   #14
qlue
Member
 
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbang
Posts: 605
Blog Entries: 1

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by pan64 View Post
I have a 1 TB (yes!) pendrive from sony
Ouch! You did suspect that it was fake before you bought it right?



Well, I've had some time to think about what could be causing the issues described. USB flash drives, especially high capacity flash drives, have a static ram buffer to help speed up writing to them. It is possible that the bottle neck that is been reached after 8GB is due to the buffer reaching it's limit. In that case, what is happening is that the control chip on the flash drive is frantically trying to copy data from the buffer to the flash memory while still accepting more data from the host device as soon as space is available in the buffer.

Of course, it could be a fake size, in which case the way to check would be to format it. (it accepts a fat32 format)
Then make a large file of around 3.5GB (fat32 has a max file size of 4GB) Save that file multiple times, but with a different file name until the drive is full.

At this point, reformat it and then use photorec (comes with testdisk) to recover the files.
Photorec will only recover files that it can physically detect. Add up the total size of all the recovered files, and that's the capacity of the disk, regardless of what capacity it claims to report.


But the best thing to do is try a different flash drive, and avoid unbranded flash drives altogether.
I usually use Kingston ,Verbatim or Transcend. Most people recommend Sandisk for some reason.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hauppauge wintv-hvr h006 - dvb-t tuner - usb-stick - hybrid tv stick Xeratul Linux - Hardware 5 12-23-2012 09:47 AM
how to create usb recovery boot stick? gunzzz5930 Slackware 3 05-18-2010 08:54 PM
Need Recovery Boot from USB stick NFFCReds1 Linux - Hardware 1 12-11-2009 04:16 PM
recovery mkfs.ext2 formatted USB-Stick eriche Linux - General 1 03-30-2009 02:52 PM
mount/umount usb stick - PQI Intelligent Stick 2.0 sandbag Linux - Software 5 05-06-2005 11:12 AM


All times are GMT -5. The time now is 11:30 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration