[SOLVED] cryptsetup luksFormat produces bad magic numbers - not exactly ... missed a step

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
alanharrison
Level 1
Level 1
Posts: 40
Joined: Mon Apr 25, 2022 9:36 am

[SOLVED] cryptsetup luksFormat produces bad magic numbers - not exactly ... missed a step

Post by alanharrison »

I am running Una on both my laptops. On one of them, I just reinstalled. It should be the same version of both, bc I have been upgrading the other laptop as well.

I AM STILL ABLE TO OPEN and MOUNT a luksFormat .img that I made several weeks ago (May 9, specifically).

However, I cannot MOUNT any luksFormat .img that I now make using cryptsetup. I consistently get a "bad magic number" error on these.

E.g.,

Code: Select all

alan@harrisons-lenovo:~$ sudo mount /dev/mapper/Documentsvault Documents
mount: /home/alan/Documents: wrong fs type, bad option, bad superblock on /dev/mapper/Documentsvault, missing codepage or helper program, or other error.
and

Code: Select all

alan@harrisons-lenovo:~$ sudo fsck /dev/mapper/Documentsvault
fsck from util-linux 2.34
e2fsck 1.45.5 (07-Jan-2020)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/mapper/Documentsvault

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>
I have version-checked fsck, cryptsetup, mount using apt-get upgrade. They're all most recent version.

Again, the OLD .img still will open and mount.

Thoughts?

Edit to add: I am having this problem on both laptops with new .img. I haven't tried copying the old .img from one laptop to the other bc it is pretty big (90G). The newer ones are smaller, and I have learned from making test .imgs that luksFormat has a minimum size it can work with - not sure what, but it's more than 10M.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
alanharrison
Level 1
Level 1
Posts: 40
Joined: Mon Apr 25, 2022 9:36 am

Re: On fresh install of 20.3 Una, cryptsetup luksFormat produces bad magic numbers

Post by alanharrison »

I'm thinking maybe I missed a step in setting up the new .img files.

Is there a step where I'm supposed to format them ext4, before doing the cryptsetup luksFormat?
alanharrison
Level 1
Level 1
Posts: 40
Joined: Mon Apr 25, 2022 9:36 am

Re: On fresh install of 20.3 Una, cryptsetup luksFormat produces bad magic numbers

Post by alanharrison »

dammit, no, that didn't help!
alanharrison
Level 1
Level 1
Posts: 40
Joined: Mon Apr 25, 2022 9:36 am

Re: On fresh install of 20.3 Una, cryptsetup luksFormat produces bad magic numbers

Post by alanharrison »

AHHA.

Read the man for cryptsetup, carefully, and realized that the following order of operations applies:

1. cryptsetup open --type luks X.img X

2. mkfs.ext4 /dev/mapper/X

THEN

3. mount /dev/mapper/X vaultdir

of course sudo'ing as needed.
Locked

Return to “Other topics”