I just ended up having a similar problem and could resolve it. I didn't use the KDE partition manager but the command lvresize
to resize my logical volume:
DO NOT RUN THIS COMMAND: lvresize --verbose -L -40G /dev/mapper/vgubuntu-root
My question is basically how much damage I did, is the problem recoverable or did I loose all of my data?
What happened?
The following description is my assumption and could partially be wrong, please feel free to edit/comment to clarify misunderstandings.
First of all, a logical volume is just THAT, a volume similar to a hard drive, NOT a partition table or a file system.
The file system resides inside the logical volume, so to my understanding the logical volume does not have a partition table. (Creating a filesystem on a whole disk rather than a partition is possible, but unusual)
Shrinking the volume without shrinking the filesystem is like cutting out sectors of a hard drive. Probably because of the missing partition table, the KDE partition manager thought the volume was empty, letting the user edit it freely.
NOW the volume shrunk BUT the filesystem still has blocks that are beyond of the volume scope, that is why e2fsck
can not read block 126877728
, it is beyond the scope of the volume.
Although e2fsck
wanted to rewrite
, it could NOT because the block is simply not accessible.
Because the information about the volume size, as well as the filesystem, are stored at the BEGINNING of the overlying partition on the physical hard drive, NO DATA IS ACTUALLY LOST, at least on HDDs (probably on SSDs to). Again e2fsck
could NOT rewrite the blocks, bits and bytes are basically untouched somewhere on the actual hard drive.
So quite logical UNDO the shrinking by simply increasing the logical volume size WITHOUT touching the file system should resolve the issue.
TL;DR
Increase the volume back to its original size should resolve the issue without data loss:
lvresize --verbose -L +SIZE /dev/mapper/vgubuntu-root
# SIZE you shrunk the volume
# `lvresize` <volume> => resize a logical volume
# --verbose => Give more info.
# --resizefs => Resize filesystem AND LV with fsadm(8).
# -L => Specifies the new size of the LV,
# +/- add/subtracts to/from current size, e.g. g|G is GiB.
e2fsck -f /dev/mapper/vgubuntu-root
# e2fsck
<fs-path> => Check a Linux ext2/ext3/ext4 file system
# -f => Force checking even if the file system seems clean.
# Output should look like this:
# Pass 1: Checking inodes, blocks, and sizes
# Pass 2: Checking directory structure
# Pass 3: Checking directory connectivity
# Pass 4: Checking reference counts
# Pass 5: Checking group summary information
IF YOU DON'T KNOW THE ORIGINAL SIZE, you can subsequently increase the volume size (within the boundary of the overlying partition), e2fsck
should subsequently have less blocks in its error report:
lvresize --verbose -L +1G /dev/mapper/vgubuntu-root
e2fsck -f /dev/mapper/vgubuntu-root
# Block bitmap differences: +121110528 +(121110532--121110533) +(121110537--121111049) +(121112586--121113097)
lvresize --verbose -L +1G /dev/mapper/vgubuntu-root
e2fsck -f /dev/mapper/vgubuntu-root
# Block bitmap differences: +(121110537--121111049) +(121112586--121113097)
lvresize --verbose -L +1G /dev/mapper/vgubuntu-root
e2fsck -f /dev/mapper/vgubuntu-root
# Pass 5: Checking group summary information
How to shrink the logical volume AND the file system
Use lvresize
with the --resisefs
option (which will resize the filesystem - Captain Obvious):
# Shrink logical root volume AND filesystem
lvresize --verbose --resizefs -L -SIZE /dev/mapper/vgubuntu-root