1

I had an encrypted ext4 partition on a Samsung T7 1TB USB drive. It was LUKS (I believe this may be called a LUKS container?) The partition was 850GB. It had about 130GB in use. I also had an unencrypted 100GB NTFS partition and a very small amount of unallocated space.

I tried to use KDE Partition Manager to shrink the encrypted partition to 550GB so that I could expand my 100GB NTFS partition by 300GB. I set up both operations and then clicked Apply. The operation began and was in progress for a couple of minutes (but the percentage did not progress). Then it reported that the operation had failed with an error. Stupidly, I did not save the log of the error, my reason being that as far as I could see, no details of, or reason for the error were provided and I made the assumption that no changes had been made. However, I can now no longer mount this encrypted 850GB ext4 partition, although it is visible in Dolphin and in KDE Partition Manager. When plugging the drive in, it correctly identifies it and gives me the password prompt, which is pre-filled with the password I have asked it to remember, so the system recognises the drive (I've tried re-entering this password, in case there is a problem there). The NTFS partition does not seem to be visible at all.

In the log that I did not save from KDE Partition Manager, I believe it also showed progress as the operations were happening, and I believe the first operation was for it to initially shrink the ext4 partition by a small amount - by 0.04 GB, if I remember correctly. So let's say the size was initially 830.08 GB; I believe the first operation was to shrink it to 830.04 GB, which I believe it succeeded in doing. Please do not take these sizes or the 0.04 size to be the truth - it is only what I seem to remember.

The error message in Dolphin is:

An error occurred while accessing '830.0 GiB Encrypted Drive', the system responded: The requested operation has failed: Error mounting /dev/dm-1 at /media/wesley/WG-T7-E: wrong fs type, bad option, bad superblock on /dev/mapper/luks-5c9cfaa5-0576-4b47-8e65-05f7d8b52d39, missing codepage or helper program, or other error.

In KDE Partition Manager I can see the two partitions and the unallocated space, with sizes and used space correctly reported (or near enough, based on what I know they were. I.e. They are not listed using the new sizes I had chosen).

Properties of the encrypted partition (/dev/sdb1) in KDE Partition Manager show:

Label: WG-T7-E (which is correct)
Mount point: (none found)
Partition type: primary
Status: idle
UUID: 9ffc3bef-5df8-4dd5-b4de-d2ff45aa6322
Partition Label: (none)
Partition UUID: 75E6E7E1-FA4F-0F40-BAB4-85F5F4A5BD30
Size: 830.04 GiB
Available: 84% - 699.21 GiB
Used: 16% - 130.83 GiB
First sector: 2,048
Last sector: 1,740,728,319
Number of sectors: 1,740,726,272
Flags: bios-grub and boot checkboxes shown, but neither checked.

Properties of the unallocated space in KDE Partition Manager show:

Label:
Mount point: (none found)
Partition type: unallocated
Status: idle
Partition Label: (none)
Partition UUID: (none)
Size: 36.00MiB
First sector: 1,740,728,320
Last sector: 1,740,802,047
Number of sectors: 73,728

Properties of the unencrypted partition (/dev/sdb2) in KDE Partition Manager show:

File system: ntfs
Label: WG-T7-U (which is correct)
Mount point: /media/wesley/WG-T7-U
Partition type: primary
Status: idle
UUID: 05DBF9124869C198
Partition Label: (none)
Partition UUID: 8CC612F8-30FA-6449-8FA2-754C82E8B0C3
Size: 101.43 GiB
Available: 99% - 101.37 GiB
Used: 1% - 67.61 MiB
First sector: 1,740,802,048
Last sector: 1,953,523,711
Number of sectors: 212,721,664
Flags: bios-grub and boot checkboxes shown, but neither checked.

dmesg after plugging in USB drive and entering password:

[ 6049.158336] usb 2-4: new SuperSpeed USB device number 8 using xhci_hcd
[ 6049.171380] usb 2-4: New USB device found, idVendor=04e8, idProduct=61fb, bcdDevice= 1.00
[ 6049.171394] usb 2-4: New USB device strings: Mfr=2, Product=3, SerialNumber=1
[ 6049.171400] usb 2-4: Product: PSSD T7 Shield
[ 6049.171405] usb 2-4: Manufacturer: Samsung
[ 6049.171409] usb 2-4: SerialNumber: S6YJNS0TA00012H
[ 6049.180592] scsi host2: uas
[ 6049.181476] scsi 2:0:0:0: Direct-Access     Samsung  PSSD T7 Shield   0    PQ: 0 ANSI: 6
[ 6049.182964] sd 2:0:0:0: Attached scsi generic sg2 type 0
[ 6049.183565] sd 2:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
[ 6049.183710] sd 2:0:0:0: [sdb] Write Protect is off
[ 6049.183717] sd 2:0:0:0: [sdb] Mode Sense: 43 00 00 00
[ 6049.183951] sd 2:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 6049.184282] sd 2:0:0:0: [sdb] Optimal transfer size 33553920 bytes
[ 6049.207124]  sdb: sdb1 sdb2
[ 6049.208449] sd 2:0:0:0: [sdb] Attached SCSI disk
[ 6049.430150] audit: type=1107 audit(1708641903.652:169): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6049.430683] ntfs3: Unknown parameter 'windows_names'
[ 6049.494120] audit: type=1107 audit(1708641903.716:170): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6052.079215] audit: type=1107 audit(1708641906.301:171): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.523583] audit: type=1107 audit(1708641908.745:172): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.598701] audit: type=1107 audit(1708641908.820:173): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.599943] EXT4-fs (dm-1): bad geometry: block count 217599488 exceeds size of device (217590272 blocks)
[ 6054.600795] audit: type=1107 audit(1708641908.822:174): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.798116] audit: type=1107 audit(1708641909.020:175): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'
[ 6054.804803] EXT4-fs (dm-1): bad geometry: block count 217599488 exceeds size of device (217590272 blocks)
[ 6054.809500] audit: type=1107 audit(1708641909.031:176): pid=1274 uid=102 auid=4294967295 ses=4294967295 subj=unconfined msg='apparmor="DENIED" operation="dbus_signal"  bus="system" path="/org/freedesktop/login1" interface="org.freedesktop.DBus.Properties" member="PropertiesChanged" name=":1.2" mask="receive" pid=2912 label="snap.firefox.firefox" peer_pid=1318 peer_label="unconfined"
                exe="/usr/bin/dbus-daemon" sauid=102 hostname=? addr=? terminal=?'

Financial reward offered to the person, or split between the persons, who can help me successfully recover this. Thank you.

7
  • If your data's worth a reward, it's worth backing up. Keep the reward and spend it on a spare drive, so that next time, you can make a backup before you begin.
    – Jim L.
    Commented Feb 22 at 22:28
  • 1
    Even now, if you want to try recovering the data on the drive, the first step is to make a copy of it somewhere safe. Commented Feb 22 at 22:30
  • it depends on what that kde manager really did to your data... what does it say in dmesg after the mount attempt? (always check dmesg when you get the useless generic wrong fs type or other error message). Commented Feb 22 at 22:32
  • if you're very lucky, and its just ext4 complaining about too small device size, it might work if you reclaim that unpartitioned space with parted, unit s, print free, resizepart ... but that's a wild guess at this point and I'm assuming the partition was not relocated at all since it's already the first partition at 1MiB offset Commented Feb 22 at 22:41
  • @frostschutz dmesg log added
    – Code83
    Commented Feb 22 at 22:48

1 Answer 1

0

To recap, after resizing partitions, you got this mount error:

wrong fs type, bad option, bad superblock on /dev/mapper/luks-5c9cfaa5-0576-4b47-8e65-05f7d8b52d39, missing codepage or helper program, or other error.

Getting this far already means there is no issue with the LUKS header itself.

According to dmesg, the real error message is:

EXT4-fs (dm-1): bad geometry: block count 217599488 exceeds size of device (217590272 blocks)

This seems to be a standard case of shrinking partition without shrinking the filesystem first and the discrepancy is just a few thousand blocks of data (9216 4K-blocks = 73728 512-byte sectors).

And it seems you have exactly the necessary unallocated space in your partition table.

According to your partition manager outputs, in parted it should roughly look like this.

# parted /dev/sdb unit s print free
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start        End          Size         File system  Name  Flags
        34s          2047s        2014s        Free Space
 1      2048s        1740728319s  1740726272s               luks
        1740728320s  1740802047s  73728s       Free Space
 2      1740802048s  1953523711s  212721664s                ntfs

Partition numbers, names, flags may be different - Start End Size should match. If all assumptions are correct then the fix is to reclaim free space behind partition 1.

Make sure the LUKS container is closed first and the drive unmounted or re-reading partition table might fail (alternatively, reboot).

# cryptsetup close luks-5c9cfaa5-0576-4b47-8e65-05f7d8b52d39
# umount /dev/sdb*

Since there is unallocated space in the partition table, you can reclaim it using parted's resizepart command.

# parted /dev/sdb resizepart 1 1740802047s

This will only alter the partition table without altering any data.

With any luck, the filesystem will just work normally afterwards.

1
  • 1
    Thank you very much indeed! Everything was exactly as you said, except that if I really did have 67MB of data in the NTFS partition, it is gone - but I know it was nothing important. I realize I made a VERY stupid mistake by attempting the partition alterations without first making a backup. Even more stupid - I hadn't really checked what data was on that disk. I now know it was all data that I had another copy of, but the relief of finding out I haven't lost anything is worth a reward for you, which I shall duly give. So if you are on buymeacoffee or anything similar, please provide details.
    – Code83
    Commented Feb 24 at 0:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .