Mount error when automounting a LUKS-encrypted USB flashdrive
Solution 1
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.
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
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
(addbs
andcount
arguments as you see fit).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.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
Solution 2
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
Related videos on Youtube
Eddy
Updated on September 18, 2022Comments
-
Eddy almost 2 years
My iOS app stopped receiving push notifications although I upgraded the code as per the documentations and this.
Here's the code I'm using:
In my
AppDelegate's
didFinishLaunchingWithOptions
:if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; [[UIApplication sharedApplication] registerForRemoteNotifications]; } else { [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound]; }
The
didRegisterForRemoteNotificationsWithDeviceToken
method is getting called, as it was before, so everything seems fine.Also, my test device has the notifications enabled.
But when sending a push from
Parse.com
it no longer arrives.EDIT 1:
None of the answers work. I updated my Parse.com framework to version 1.6.2 (the latest) which doesn't help either, and I'm copying my code again - this time the updated version based on the answers:
Inside
didFinishLaunchingWithOptions
:if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound |UIRemoteNotificationTypeAlert) categories:nil]; [application registerUserNotificationSettings:settings]; // [application registerForRemoteNotifications]; } else { UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound; [application registerForRemoteNotificationTypes:myTypes]; }
And these are the delegate methods:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken { NSLog(@"didRegisterForRemoteNotificationsWithDeviceToken CALLED"); // Store the deviceToken in the current installation and save it to Parse. PFInstallation *currentInstallation = [PFInstallation currentInstallation]; [currentInstallation setDeviceTokenFromData:newDeviceToken]; [currentInstallation addUniqueObject:@"Test8Channel" forKey:@"channels"]; if([PFUser currentUser]/* && [[PFUser currentUser] objectId] != nil*/) { [currentInstallation addUniqueObject:[PFUser currentUser] forKey:kOwnerKey]; } [currentInstallation saveInBackground]; } #ifdef IS_OS_8_OR_LATER - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { [application registerForRemoteNotifications]; NSLog(@"didRegisterUserNotificationSettings CALLED"); } - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString*)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler { NSLog(@"handleActionWithIdentifier CALLED"); //handle the actions if ([identifier isEqualToString:@"declineAction"]){ NSLog(@"handleActionWithIdentifier %@", @"declineAction"); } else if ([identifier isEqualToString:@"answerAction"]){ NSLog(@"handleActionWithIdentifier %@", @"answerAction"); } } #endif - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { if (error.code == 3010) { NSLog(@"Push notifications are not supported in the iOS Simulator."); } else { // show some alert or otherwise handle the failure to register. NSLog(@"application:didFailToRegisterForRemoteNotificationsWithError: %@", error); } }
Both
didRegisterUserNotificationSettings
anddidRegisterForRemoteNotificationsWithDeviceToken
are getting called and it seems fine. But the push doesn't arrive.EDIT 2:
I'm noticing that if I call both
[application registerUserNotificationSettings:settings];
and
[application registerForRemoteNotifications];
inside the if
([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
the delegate's
didRegisterForRemoteNotificationsWithDeviceToken
is getting called twice. I'm not sure how meaningful this is.Getting desperate here.
-
soulshined over 9 yearshow are you sending from the console i.e, plain text/json? and are you waiting to receive it will in background or foreground?
-
Eddy over 9 yearsI'm taking the default, which is plain text, and I've tried both in the background and foreground. I also put a printf in the didReceiveRemoteNotification method but it's not getting called.
-
soulshined over 9 yearsAnd the provisioning profiles or certificates haven't been altered?
-
Eddy over 9 yearsNo, nothing changed.
-
bllakjakk over 9 yearsJust wanna do a quick check. while going to background, check result of [[UIApplication sharedApplication] isRegisteredForRemoteNotifications]; and let know the result.
-
Eddy over 9 yearsIt's 1. Thanks for responding, @bllakjakk
-
-
Eddy over 9 yearsI edited the question to reflect the code after the advice here. It's still not working.
-
Eddy over 9 yearsI edited the question to reflect the code after the advice here. It's still not working.
-
emotality over 9 yearsThere must be something wrong, if you try the above code on a different Xcode and still not works it's definitely the device? Have you tried different devices? The above is the only code I got and works 100%. Every time I start my app all the methods are being called.
-
emotality over 9 years"conditional block" It's definitely not a block, and a block isn't even necessary in this case. And your answer is exactly the same as all the other answers, just 10 times more code...
-
oshirowanen about 8 yearsPlease see update 1 above.
-
oshirowanen about 8 yearsWould it be worth DD'ing the device to make a bit identical copy before fsck'ing it?
-
forquare about 8 years@oshirowanen most certainly. It would allow you to try multiple options
-
oshirowanen about 8 yearsMade 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? -
forquare about 8 yearsAh 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 thinkfsck
likes the unencrypted LUKS wrapper. -
oshirowanen about 8 yearsNot sure I fully understand, you mean fsck the DD image? As in mount the DD image using the -o loop option and fsck that?
-
forquare about 8 yearsFrom 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 thesudo 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 tofsck
as this has the EXT4 file system that I believe is corrupt. -
oshirowanen about 8 yearsMaking 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 about 8 yearsIt 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 thissudo 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.
. -
forquare about 8 yearsOK, since that doesn't like it, I wonder if you'll have success doing an
e2fsck
on your DD image ofdm-3
? My like to make acp
of it before you try. -
oshirowanen about 8 yearsCopied 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?
-
forquare about 8 yearsTry mounting with something like
mount -o loop image.dd /mnt
. -
forquare about 8 yearsAwesome! You should be able to DD the image back over dm-3, but I would consider remaking your USB stick without the journal
-
forquare about 8 yearsYou are more than welcome, Best of luck with it going forward
-
PAT-O-MATION about 3 yearsFinally trying
mke2fs -t ext4 -O ^has_journal /dev/device
worked for me While I was getting thebad superblock
error when I was trying to mount. I guess I don't have journaling now correct?