Score:1

Lost /home partition after resizing with kde partition manager

na flag

The disk name is /dev/sdd and the partition table was as it follows:

Partition Type Label Size Used First Sector Last Sector Number of sectors
/dev/sdd1 unknown Microsoft reserved 15.98MiB ---- 34 32767 32734
/dev/sdd2 ntfs Kingston (Data partition) 270.63GiB 252.94GiB 32768 567590911 567558144
/dev/sdd5 ext4 Kubuntu Root 44.09GiB 19.18GiB 567590912 660049919 92459008
/dev/sdd7 ext4 Old Ubuntu Root 49.71GiB 21.77GiB 660049920 764305407 104255488
/dev/sdd6 ext4 Kubuntu /home 61.61GiB ?* 764305408 893501439 129196032
/dev/sdd4 linuxswap 20.58GiB --- 893501440 936650751 43149312
/dev/sdd3 fat32 Efi 513.00MiB 3.40MiB 936650752 937701375 1050624

* This value is no longer showing but I remember that my home was about 20-30GiB.

I needed to increase the size of /dev/sdd2 because that's where I store my steam library. I figured out I could reduce my swap partition because I was no longer using hibernation, and the old ubuntu root had like 20Gb of free space, so I performed these steps from the Kde Partition Manager booting from a USB Stick with Kubuntu:

  1. Shrink partition '/dev/sdd4' from 20.58GiB to 4.53GiB (This was actually done before going to the USB Live Image, I turned off the swap with swapoff and then shrank the partition, then I could not continue shrinking things because I was in the same system that I wanted to change).

  2. Move partition '/dev/sdd6' to the right by 16.05GiB

  3. Move partition '/dev/sdd7' to the right by 16.05GiB

  4. Move partition '/dev/sdd5' to the right by 16.05GiB

  5. Grow partition '/dev/sdd2' from 270.63GiB to 286.68GiB

  6. Shrink partition '/dev/sdd7' from 49.71GiB to 23.16GiB

  7. Move partition '/dev/sdd7' to the right by 26.56GiB

  8. Move partition '/dev/sdd5' to the right by 26.56GiB

  9. Grow partition '/dev/sdd2' from 286.68GiB to 313.24GiB

And after waiting several minutes, I look at the result and It said they were errors in the last operations (I don't remember which exactly but I think that the first half had no errors and some of the last had errors, sadly I have no record of this log).

But the result was the loss of the entire /dev/sdd6 filesystem (my /home directory). This is a photo of the partition table after the operation:

Link

It seems that the swap did shrink but the unallocated space remained in its original location. The other partitions are still accesible and with normal data (The data ntfs partition and the two root partitions).

But for some reason, the /home partition is now marked as "unknown" and I can't mount it/change filesystem to ext4/do anything.

AT THIS POINT, I MADE A BACKUP (.img file) USING DD, just in case.

When I tried to boot to my regular Kubuntu (GRUB worked fine), I landed on just a terminal with "emergency mode" and with the "root" user.

I tried to run 'fsck' and got:

root@pc:~# fsck /dev/sdd6
fsck from util-linux 2.37.2
e2fsck 1.46.5 (30-Dec-2021)
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/sdd6

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>

Then, after a little google, I ran the following:

root@pc:~# mke2fs -n /dev/sdd6
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 16149504 4k blocks and 4038656 inodes
Filesystem UUID: 54d63d54-bc82-4017-96a0-012e76d54fc1
Superblocks backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 

And then I tried to run 'fsck' again but with those superblocks with the -b option. Nothing.

Is there anything I can do? Windows 10 (which is in another disk and working fine) detects the partition with the photorec tool and it lets me recover files but it's just a bunch of txt/png/wav/etc... files with no directory structure and it's not useful for me.

I did not have much of important 'regular' files in the partition (like photos, pdf, videos or audios), but a lot of configuration files, history files of bash, preferences of applications, etc...

And regarding testdisk, it detects something really weird when it does the scan (I will upload the photo later but it's something like two very identical /dev/sdd2 partitions at the beginning, but with different start/end sectors) and when I write the new partition table that it suggests, the /home is still unaccesible.

Anything to try? Can I recover my Kubuntu installation using the untouched Root partition and using another partition or disk to mount an empty /home? Or should I install everything from scratch? Beyond of that, I would still like to recover my /dev/sdd6 partition as it was before this happened.

Thanks!!!

David avatar
cn flag
Sorry I find it very hard to even follow what you did. I do believe the end result is you have lost that partition and all the data that was in it.
oldfred avatar
cn flag
Testdisk finds all old versions of partitions, so if changed, it will find multiples. Often only one combination of partitions is correct. Does deeper search in testdisk show files. If so immediately back those up. I would still run photorec as then you have data, but have to manually rename them. Some of that can be automated.
Bogdan Mart avatar
it flag
Same problem occured with me. Just lost my home partition on SteamDeck thanks to KDE Partition Manager. Thanks god I didn't have anything important there.
Score:0
na flag

Thanks for the answers, I solved it and I will write it here so if anyone has the same problem can try this.

What I was did was actually very simple. As I said, as soon as I knew I messed up, I instantly made a backup of the entire disk , using:

dd if=/dev/sdX of=/path/to/other/disk/backup.img

So after trying all kinds of crazy stuff (all while panicking, it's very hard to remain calm when you do something like this...), I went to sleep. And the next day, I sat down and restored the image with:

dd if=/path/to/other/disk/backup.img of=/dev/sdX

Then, I just ran testdisk from a LiveUSB and it worked. Just followed the instructions of the program, and examined carefully each of the partitions in the partition table that it found. It worked and now my system is back as it was.

Thanks and good luck!

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.