LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   unable to mount a usb flash drive and an SD card after changing mount directory name (https://www.linuxquestions.org/questions/linux-newbie-8/unable-to-mount-a-usb-flash-drive-and-an-sd-card-after-changing-mount-directory-name-4175556446/)

remn 10-17-2015 03:39 PM

unable to mount a usb flash drive and an SD card after changing mount directory name
 
I'm not sure exactly what I did, but after messing with some directory names I'm unable to mount both a usb drive and an SD card. When I try to mount them I get this error:

* wrong fs type, bad option, bad superblock on /dev/sdb1,
missing codepage or helper program, or other error
*
I tried mounting them in Windows and it said the drive needs to be formatted. I didn't mess with the partition table or try to format these devices. I think what I did was change the name of the directory it was mounted to while it was mounted, then I started having this problem. One more thing: when I run *lsblk -f* I notice that these devices no longer have UUIDs. All the other devices have UUIDs listed but the field is blank on these devices. I have some data on these drives I don't want to loose so I'd appreciate any help getting these devices to mount without having to re-format.

ferrari 10-17-2015 04:39 PM

You haven't told us which file system was in use, but since you mentioned windows, are we to assume vfat or ntfs?

How is it reported by the following?
Code:

fdisk -l
Report back with the output so that others can offer advice.

Before attempting any further possible corruption during any data recovery exercise, it is a good idea to back the devicde up completely using 'dd' to low-level (bit-by-bit) copy eg
Code:

dd if=/dev/sdb1 of=backup.img
This will work regardless of file system.

dutchy013 10-17-2015 04:49 PM

Quote:

Originally Posted by remn (Post 5436097)
I'm not sure exactly what I did, but after messing with some directory names I'm unable to mount both a usb drive and an SD card. When I try to mount them I get this error:

looks like you changed a directory name in /mnt and now fstab doesn't know where to mount a mass storage device. my fstab says:

Code:

jan@oxygen ~/Data/Dox/2015$ cat /etc/fstab
/dev/sda1        swap            swap        defaults        0  0
/dev/sda5        /                ext4        defaults        1  1
/dev/sda6        /home            ext4        defaults        1  2
/dev/sda7        /home/data      ext4        defaults        1  2
/dev/cdrom      /mnt/cdrom      auto        noauto,owner,ro,comment=x-gvfs-show 0  0
/dev/fd0        /mnt/floppy      auto        noauto,owner    0  0
devpts          /dev/pts        devpts      gid=5,mode=620  0  0
proc            /proc            proc        defaults        0  0
tmpfs            /dev/shm        tmpfs      defaults        0  0

if I were to change the name of /mnt/cdrom into /mnt/dvd, fstab would have no mountpoint anymore for /dev/cdrom so either change back the directory names to the default ones or change fstab and that should do the trick.

if you insert a usb stick that is formatted in ext4 in a windows machine, windows will reformat the disk to help you.

remn 10-17-2015 04:52 PM

Thanks for the reply. Yes I believe it was formatted ntfs. Here's the output from fdisk -l:

Device Boot Start End Sectors Size Id Type
/dev/sdb1 63 15240575 15240513 7.3G 83 Linux


I'll be sure to back up the drive before trying anything.

yancek 10-17-2015 05:22 PM

Quote:

I'm not sure exactly what I did, but after messing with some directory names I'm unable to mount both a usb drive and an SD card.
It would be useful to know exactly how you tried to mount the partition. Were you using a terminal? If so, what exact command did you use?

Quote:

I tried mounting them in Windows and it said the drive needs to be formatted
Windows doesn't recognize Linux filesystems so that's it's response to something unknown. It will suggest re-formatting to a windows filesystem.

Did you or do you actually have an entry for sdb1 in /etc/fstab? If you do or did, you would not need to mount it as it should mount on boot.

Your fdisk output for that partition shows it as a Linux filesystem.

remn 10-17-2015 05:36 PM

I looked at my fstab file and it doesn't have an entry for sdb1. But when I plug in another usb drive it shows as sdb1 and it mounts without issues. Do I need to add a line to fstab?

I may have mispoke when I said it was ntfs. Maybe I re-formatted it to ext4 awhile ago and forgot.

I was trying to mount it from terminal, using the mount command.

ferrari 10-17-2015 06:01 PM

No, you don't need an en entry in /etc/fstab. Typically, removable media with a valid system are handled by udev and UDisks2. The fact that a bad super block is reported suggests an ext3/ext4 file system. You could execute following (eg assuming ext3) to get a bit more info about

Code:

sudo fsck.ext3 -v /dev/sdb1
or maybe
Code:

sudo fsck-v /dev/sb1
I assuming this will confirm a bad/corrupted superblock. There are additional superblock copies kept thankfully. Locate them with
Code:

sudo mke2fs -n /dev/sb1
and report back with the output.

Hopefully, it should be possible to use a superblock copy to repair using something like

Code:

sudo e2fsck -b super_block_copy_location /dev/sdb1
*replace super_block_copy_location with actual block number

ferrari 10-17-2015 06:05 PM

If you're certain it was ext4, then check status with
Code:

sudo fsck.ext4 -v /dev/sdb1

ferrari 10-17-2015 06:10 PM

If you can't recover the file system, all hope is not lost. You can work with the device or backup you created to try to recover the files using a utility like foremost.

Read this excellent data recovery guide
https://help.ubuntu.com/community/DataRecovery

This might help too
http://www.levlafayette.com/node/20

remn 10-17-2015 06:25 PM

ext2fs_open2: Bad magic number in super-block
fsck.ext3: Superblock invalid, trying backup blocks...
fsck.ext3: Bad magic number in super-block while trying to open /dev/sdb1

Ran *sudo fsck.ext3 -v /dev/sdb1*, here's the output:

***************************************************************************************

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>

********************************************************************************

When I ran *sudo mke2fs -n /dev/sb1* to find superblock copies, I got this:

"The file /dev/sb1 does not exist and no size was specified."

ferrari 10-17-2015 06:35 PM

Sorry, that was a typo. It should have been
Code:

sudo mke2fs -n /dev/sdb1

remn 10-17-2015 06:56 PM

Haha, I didn't catch the typo, just copied and pasted. It worked this time, here's the output:

Creating filesystem with 1905064 4k blocks and 476720 inodes
Filesystem UUID: 5a3dd860-724f-45a2-8ebc-351b25f9321c
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

ferrari 10-17-2015 07:08 PM

Okay, now try the following to use the backup superblock
Code:

sudo e2fsck -b 98304 /dev/sdb1
or perhaps you could try mounting using the backup superblock with
Code:

sudo mkdir -p /mnt/data
Code:

sudo mount -o sb=98304 /dev/sdb1 /mnt/data

remn 10-17-2015 07:25 PM

Neither of those worked. For the first command I get:

*****************************************************************************

e2fsck: Bad magic number in super-block while trying to open /dev/sdb1

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
or
e2fsck -b 32768 <device>


******************************************************************************

For the second one I get:

********************************************************************************

mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.


********************************************************************************

I tried each command with a a few different blocks from those listed in the output from *sudo mke2fs -n /dev/sdb1*, none of them worked. I'm looking over the data recover tutorial you linked to. I'll try some of those methods.

ferrari 10-17-2015 07:28 PM

Review the data recovery suggestions in post #9


All times are GMT -5. The time now is 04:06 PM.