Ext4 fs corrupted after shrunken by parted

2

I was trying to make room for an Arch Linux installation and I ran parted and shrunk my main Ubuntu partition.

I made a new one in the new space but after I rebooted it put me in a grub prompt.

I found out how to manually boot but it dropped me to an initramfs busybox. I looked for information online and found something about the superblock saying the fs is too big which makes sense so I used mke2fs and fsck to fix it.

However there were a bunch of errors and after it fixed the fs most of my stuff was missing and I still boot into the initramfs busybox.


Can this be fixed? Should I go to a professional?


Any help would be greatly appreciated.

Duncan X Simpson

Posted 2016-05-13T03:20:42.340

Reputation: 1 171

Answers

3

Apparently it's because parted only shrunk your partition but not the ext4 filesystem on it. Unlike gparted, parted no longer does anything with the filesystem layer. So you need to shrunk the ext4 with resize2fs first.

made a new one in its space

If you only created a partition (but not formatted it with any mkfs.* yet), you can probably delete the new partition, and extend the shrunk partition again. If it mounts again correctly, then you can shrink it again with the aforementioned proper procedures. You may also want to run fsck first before you mount it.

However, if the new partition has been formatted already, there is almost certainly data lost. For that you may need a more "professional" approach to rescue it.

Tom Yan

Posted 2016-05-13T03:20:42.340

Reputation: 4 744

Is it likely that data was lost even though the partition was 51% full and I only cut off the last 20%? – Duncan X Simpson – 2016-05-13T03:54:08.600

@VirtualDXS Hard to tell. But I suppose the lost is probably more trivial in that case. – Tom Yan – 2016-05-13T03:57:26.913

Thanks a ton. I'll get professional help over the weekend. I'll accept your answer if you add a huge warning to back everything up because there can never be enough of those. – Duncan X Simpson – 2016-05-13T03:59:37.507

Once you add the backup warning I'll accept. – Duncan X Simpson – 2016-05-14T02:59:39.707

One should never never ever run fsck after mistake like this. Even if only a partition was created, running fsck on the first half of the filesystem dealt the final blow to the FS and now most of the links to the lost half are lost too. Though it might be possible to recover something, lot of it will be just a mess, like fragments of files. – Martian – 2016-05-19T09:58:37.437

@Martian Well, I suggested to run fsck (only) after he deleted the new partition and extend the old one again before mount... – Tom Yan – 2016-05-19T11:39:02.697

1@TomYan, yes, you did. But sadly VirtualDXS did run it as the first step after reboot :-( – Martian – 2016-05-19T11:52:52.817