6

UPDATE 1:

userone@desktop:~$ sudo umount "/media/userone/New Volume"
umount: /media/userone/New Volume: mountpoint not found

userone@desktop:~$ sudo cryptsetup luksClose /dev/mapper/luks-04cb4ea7-7bba-4202-9056-a65006fe52d7
Device /dev/mapper/luks-04cb4ea7-7bba-4202-9056-a65006fe52d7 is not active.

userone@desktop:~$ sudo lsblk 
NAME                    MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sdb                       8:16   1 29.5G  0 disk  
└─sdb1                    8:17   1 29.5G  0 part  
  └─luks_USB            252:3    0 29.5G  0 crypt 
sr0                      11:0    1 1024M  0 rom   

userone@desktop:~$ sudo cryptsetup luksOpen /dev/sdb1 luks_USB
Device luks_USB already exists.

userone@desktop:~$ sudo mkdir /media/userone/luks_USB
mkdir: cannot create directory ‘/media/userone/luks_USB’: File exists

userone@desktop:~$ sudo mount /dev/mapper/luks_USB /media/userone/luks_USB
mount: wrong fs type, bad option, bad superblock on /dev/mapper/luks_USB,
       missing codepage or helper program, or other error

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

userone@desktop:~$ dmesg | tail
[20639.663250] JBD2: no valid journal superblock found
[20639.663257] EXT4-fs (dm-3): error loading journal
[20828.133606] JBD2: no valid journal superblock found
[20828.133613] EXT4-fs (dm-3): error loading journal
[20832.682397] JBD2: no valid journal superblock found
[20832.682405] EXT4-fs (dm-3): error loading journal
[20851.042343] JBD2: no valid journal superblock found
[20851.042349] EXT4-fs (dm-3): error loading journal
[21053.115711] JBD2: no valid journal superblock found
[21053.115718] EXT4-fs (dm-3): error loading journal

userone@desktop:~$ 

ORIGINAL QUESTION:

When I plug in my encrypted USB drive, I get this message in a GNOME dialog:

Error mounting /dev/dm-3 at /media/userone/New Volume: 
Command line 
    mount -t "ext4" \
          -o "uhelper=udisks2,nodev,nosuid" \
          "/dev/dm-3" "/media/userone/New Volume"'
exited with non-zero exit status 32:
    mount: wrong fs type, bad option, bad superblock on
           /dev/mapper/luks-04cb4ea7-7bba-4202-9056-a65006fe52d7,
           missing codepage or helper program, or other error.

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

Anyone know how this can be corrected? It was working fine yesterday.

oshirowanen
  • 2,621

2 Answers2

8

It looks as though the journal has become corrupt, doing some searches over the past few days, this seems to not be uncommon on devices that use LUKS.

You could try running an fsck on the device, acknowledging that any data on the device may not be accessible after - you may like to use dd to make a copy of the drive before this.

A common resolution appears to be to create the EXT4 file system from scratch with journaling disabled using mke2fs -t ext4 -O ^has_journal /dev/device. Obviously you would lose the advantages of having a journaled file system by doing this, and lose any data on the device!


Problem

This problem is that the EXT4 file system’s journal has become corrupt. The problem is perhaps made a little obscure due to the fact that the device is encrypted and the file system resides “inside” the encryption.

Resolution

There is a thread of comments below, however I thought a summary here would be more beneficial to anyone who might come across this in the future.

  1. Unencrypt the device, this allows us to get at the device that the EXT4 file system resides on: sudo cryptsetup luksOpen /dev/sdb1 luks_USB

  2. Create an image of the device that has been created in the previous step. We need to do this because file system checking utils generally won’t work on mounted devices, and although the device with EXT4 on isn’t mounted, it’s “parent” is. sudo dd if=/dev/dm-3 of=/tmp/USBimage.dd (add bs and count arguments as you see fit).

  3. Now we have an image, we can run the file system checks: sudo e2fsck /tmp/USBimage.dd any problems found can be evaluated and fixed as required.

  4. You can check to see if your file system has been fixed by attempting to mount the image: sudo mount -o loop /tmp/USBimage.dd /mnt

At this point the OP was able to gain access to their files.

While I would suggest wiping the USB stick and starting over (back to a known state, etc), I think it would be possible to unmount the image from /mnt and then copy if back onto the device that become corrupt: sudo dd if=/tmp/USBimage.dd of=/dev/dm-3

forquare
  • 3,496
  • Would it be worth DD'ing the device to make a bit identical copy before fsck'ing it? – oshirowanen May 11 '16 at 11:27
  • @oshirowanen most certainly. It would allow you to try multiple options – forquare May 11 '16 at 11:29
  • Made a DD and have not tried fsck, but I get this message user1@laptop:~$ sudo fsck /dev/sdb1 fsck from util-linux 2.20.1 fsck: fsck.crypto_LUKS: not found fsck: error 2 while executing fsck.crypto_LUKS for /dev/sdb1 user1@laptop:~$. Any idea why? – oshirowanen May 13 '16 at 15:05
  • Ah ha, perhaps try a copy/DD of the dm-3 device (might have changed, but what was shown in your example above) and then try fsck'ing that? I don't think fsck likes the unencrypted LUKS wrapper. – forquare May 13 '16 at 15:12
  • Not sure I fully understand, you mean fsck the DD image? As in mount the DD image using the -o loop option and fsck that? – oshirowanen May 13 '16 at 15:21
  • 1
    From the looks of things, you DD'd and fsck'd the partition that is encrypted (/dev/sdb1). What I think you need to do is run the sudo cryptsetup luksOpen /dev/sdb1 luks_USB, which then creates /dev/dm-3 and it is this device that you want to backup with DD and try to fsck as this has the EXT4 file system that I believe is corrupt. – forquare May 13 '16 at 15:52
  • Making DD of /dev/dm-3, Then will test fsck on /dev/dm-3. DD taking it's time. Will report back soon. Thanks for the help so far. – oshirowanen May 14 '16 at 17:02
  • It finally finished DD, but when I do fsck I get: sudo fsck /dev/dm-3 fsck from util-linux 2.27.1 e2fsck 1.42.13 (17-May-2015) /dev/mapper/luks-7bf56e6e-a29e-43d1-9f2f-34310d5c9db1 is mounted. e2fsck: Cannot continue, aborting..

    I tried unmounting and I got this sudo cryptsetup luksClose /dev/mapper/luks-7bf56e6e-a29e-43d1-9f2f-34310d5c9db1 device-mapper: remove ioctl on luks-7bf56e6e-a29e-43d1-9f2f-34310d5c9db1 failed: Device or resource busy Device /dev/mapper/luks-7bf56e6e-a29e-43d1-9f2f-34310d5c9db1 is still in use..

    – oshirowanen May 14 '16 at 18:50
  • 1
    OK, since that doesn't like it, I wonder if you'll have success doing an e2fsck on your DD image of dm-3? My like to make a cp of it before you try. – forquare May 15 '16 at 07:48
  • Copied and e2fsck found some issues and fixed them apparently. How would I now go about checking the image to make sure it's all good? – oshirowanen May 15 '16 at 09:46
  • 1
    Try mounting with something like mount -o loop image.dd /mnt. – forquare May 15 '16 at 09:49
  • Awesome! You should be able to DD the image back over dm-3, but I would consider remaking your USB stick without the journal – forquare May 15 '16 at 09:52
  • You are more than welcome, Best of luck with it going forward – forquare May 15 '16 at 09:59
  • Finally trying mke2fs -t ext4 -O ^has_journal /dev/device worked for me While I was getting the bad superblock error when I was trying to mount. I guess I don't have journaling now correct? – PAT-O-MATION May 19 '21 at 05:54
  • For me, after trying with fsck, I fixed the issue with resize2fs /dev/mapper/disk – rfmoz Jan 08 '24 at 12:09
1

I often get errors like this for no apparent reason and often simply unmounting and remounting fixes it. You can do this with the following commands.

unmount - I know it never mounted in the first place, and will likely throw an error, but I would run to ensure a clean state for running luksClose

sudo umount "/media/userone/New Volume"

lukClose

sudo cryptsetup luksClose /dev/mapper/luks-04cb4ea7-7bba-4202-9056-a65006fe52d7

now remount, first obtain the partition number that the luks container is on with:

sudo lsblk 

or

sudo fdisk -l

then use that partition here, from the looks of your error message your partition may be
/dev/dm-3, but I would confirm first with sudo lsblk

sudo cryptsetup luksOpen </dev/luks_partition_here> luks_USB

sudo mkdir /media/userone/luks_USB
sudo mount /dev/mapper/luks_USB /media/userone/luks_USB