0

I am trying to access a USB pendrive on my system having OS Ubuntu 16.04. I could not see the drive symbol. I have searched for the solution and have tried this solution: Sandisk USB not detected by Ubuntu 14.04 but detected by Windows 7
But it doesn't worked for me. Even the USB drive is not getting accessed on any Windows Platform too. It shows a message to format the drive recursively and do not let me access the drive on Windows.
But my primary issue is with respect to Ubuntu as I always use this OS only.
I have seen that when I insert the pendrive the drive menus blink, but I could not see the drive.
Kindly, help me how to make the drive visible and even workable for me. I do not want to format the drive as it has a much important data and there is no backup currently. Please let me know your advice. If anyone has the same problem and have solved it previously, kindly let me know the answer.
After Typing command dmesg

[79536.075479] sd 18:0:0:0: [sdb] Assuming drive cache: write through
[79536.081868] sd 18:0:0:0: [sdb] Attached SCSI removable disk

This is the output I get but I do not see the drive in the list after opening folder structure. On windows system it shows that is is write protected too. i don't know why this happening. Do share your thoughts.

  • Please add the output of dmesg (last lines) after connecting the pendrive. If the drive is recognized and connected to some device (like /dev/sdn), you may install (sudo apt install testdisk) and run sudo testdisk /dev/sdn on that device. – ridgy Nov 29 '16 at 10:32
  • @ridgy Please check the output and edited question once. Is this what you were talking about? and the testdisk I do not know what for it is as it did nothing and I don't know how it will help in fixing my problem. – Jaffer Wilson Nov 29 '16 at 10:53
  • The drive is recognized as sdb. You first may find out if there are any partitions by issuing sudo fdisk -l or sudo fdisk /dev/sdb and then enter p to list the partition(s) and q to quit. If a partition is recognized, try sudo mount /dev/sdb1 /mnt and if there are no errors, issue mount to see filesystem etc. If there are errors (no partitions, mount not able) you may need testdisk (see my first comment). – ridgy Nov 29 '16 at 11:33
  • When I tried your command I got this `aims@aims:~$ sudo fdisk /dev/sdb

    [sudo] password for aims:

    Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.

    fdisk: cannot open /dev/sdb: Read-only file system `

    – Jaffer Wilson Nov 29 '16 at 11:36
  • Try to turn write protection off using hdparm - see usb-turn-write-protection-off. One comment there suggests that it may also be because of connection defects (try different USB connector?). – ridgy Nov 29 '16 at 11:46
  • Your above comment reference link doesn't work either in my case. That's why I have posted this question here. I have gone through many article and blogs in search of a solution for my problem but all was in waste. So I would like to whether there is any solution or not – Jaffer Wilson Nov 29 '16 at 12:04

1 Answers1

0

If there are important files on the drive, you should at first make a block copy of the drive. In some place on your harddisk with enough space left try

sudo dd if=/dev/sdb of=sdb.img bs=4M

which means: Make a bytewise copy of the pendrive (if=/dev/sdb) to a local file named sdb.img (of=sdb.img) in blocks of 4M (bs=4M). The blocksize 4M should work in most cases and speed up the copy.

This should complete with no errors and give you the information about the records copied, size and speed of the copy process. You may then remove the pendrive; we will work with the copy further.

If there are I/O-errors at that stage the drive is damaged and I don't know any means to solve with software tools. If part of the drive could be copied, maybe part of the files could be saved.

If there were no errors so far, issue

fdisk -l sdb.img

which will show you the partitioning of the drive. This should look like

Disk sdb.img: 29.8 GiB, 32015679488 bytes, 62530624 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa114f2b8

Device     Boot    Start      End  Sectors  Size Id Type
sdb.img1            2048 20973567 20971520   10G 83 Linux
sdb.img2        20973568 62530623 41557056 19.8G 83 Linux

In my case the pendrive was of size 29.8 GiB and had two partitions of Linux Type. Yours may be only one partition of type 'W95 FAT32'.

If this was successful, you can try to mount the partition. You need the information about the partition start (here: 2048) and the sector size (here: 512). You can then do a loop mount by

sudo mount sdb.img /mnt -o loop,offset=1048576

where the offset in bytes here is 2048*512=1048576; could be different in your case. If no errors occur, you will find your files in /mnt, from where you may copy them to some other place.

If you have come so far and there are errors with the mount command, just post the output of the former steps and the error message, so I could help further.

ridgy
  • 2,356