Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Partition Shrink Gone Wrong?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Crimjob
Tux's lil' helper
Tux's lil' helper


Joined: 04 Dec 2006
Posts: 111

PostPosted: Tue Sep 22, 2020 4:27 am    Post subject: [SOLVED] Partition Shrink Gone Wrong? Reply with quote

Hello All,

I tried to follow manuals to shrink an ext4 partition from 1000GB to 900GB.

I booted into a live CD and ran
Code:
e2fsck -f /dev/sda4
followed by
Code:
resize2fs /dev/sda4 900G


I then used
Code:
parted resizepart 4 904GB


The commands all executed successfully and I went to run e2fsck again but received errors:

Code:
[root@sysresccd ~]# e2fsck -f /dev/sda4
e2fsck 1.45.0 (6-Mar-2019)
The filesystem size (according to the superblock) is 235929600 blocks
The physical size of the device is 220538517 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? no
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
Error reading block 220725248 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error reading block 221249536 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error reading block 221773824 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error reading block 222298112 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error reading block 222822400 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error reading block 223346688 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error reading block 223870976 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error reading block 224395264 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 220725248 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 224919552 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 221249536 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 225443840 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 221773824 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 225968128 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 222298112 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 226492416 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 222822400 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 227016704 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 223346688 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 227540992 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 223870976 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 228065280 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 224395264 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 228589568 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 224919552 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 229113856 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 225443840 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 229638144 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 225968128 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 230162432 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 226492416 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 230686720 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 227016704 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 231211008 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 227540992 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 231735296 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 228065280 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 232259584 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 228589568 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 232783872 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 229113856 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 233308160 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 229638144 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 233832448 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 230162432 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 234356736 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 230686720 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 234881024 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 231211008 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 235405312 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Error writing block 231735296 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Error reading block 235405327 (Invalid argument) while reading inode and block bitmaps.  Ignore error<y>? yes
Force rewrite<y>? yes
Block bitmap differences:  +220725248 +220725264 +(220725280--220725791) +221249536 +221249552 +(221249568--221250079) +221773824 +221773840 +(221773856--221774367) +222298112 +222298128 +(222298144--222298655) +222822400 +222822416 +(222822432--222822943) +223346688 +223346704 +(223346720--223347231) +223870976 +223870992 +(223871008--223871519) +224395264 +224395280 +(224395296--224395807) +224919552 +224919568 +(224919584--224920095) +225443840 +225443856 +(225443872--225444383) +225968128 +225968144 +(225968160--225968671) +226492416 +226492432 +(226492448--226492959) +227016704 +227016720 +(227016736--227017247) +227540992 +227541008 +(227541024--227541535) +228065280 +228065296 +(228065312--228065823) +228589568 +228589584 +(228589600--228590111) +229113856 +229113872 +(229113888--229114399) +229638144 +229638160 +(229638176--229638687) +230162432 +230162448 +(230162464--230162975) +230686720 +230686736 +(230686752--230687263) +231211008 +231211024 +(231211040--231211551) +231735296 +231735312y +(231735328--231735839) +232259584 +232259600 +(232259616--232260127) +232783872 +232783888 +(232783904--232784415) +233308160 +233308176 +(233308192--233308703) +233832448 +233832464 +(233832480--233832991) +234356736 +234356752 +(234356768--234357279) +234881024 +234881040 +(234881056--234881567) +235405312 +(235405327--235405328) +(235405343--235405855) +(235413024--235413535)
Fix<y>? yes
Error writing block 235405327 (Invalid argument).  Ignore error<y>? yes
Error writing block 235405312 (Invalid argument).  Ignore error<y>? yes
Error writing block 232259584 (Invalid argument).  Ignore error<y>? yes
Error writing block 233308160 (Invalid argument).  Ignore error<y>? yes
Error writing block 233832448 (Invalid argument).  Ignore error<y>? yes
Error writing block 232783872 (Invalid argument).  Ignore error<y>? yes
Error writing block 234881024 (Invalid argument).  Ignore error<y>? yes
Error writing block 234356736 (Invalid argument).  Ignore error<y>? yes
Error writing block 220725248 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 221249536 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 221773824 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 222298112 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 222822400 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 223346688 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 223870976 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 224395264 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 224919552 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 225443840 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 225968128 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 226492416 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 227016704 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 227540992 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 228065280 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 228589568 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 229113856 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 229638144 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 230162432 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 230686720 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 231211008 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 231735296 (Invalid argument) while writing block and inode bitmaps.  Ignore error<y>? yes
Error writing block 232259584 (Invalid argument).  Ignore error<y>? yes
Error writing block 235405327 (Invalid argument).  Ignore error<y>? yes
Error writing block 232783872 (Invalid argument).  Ignore error<y>? yes
Error writing block 233832448 (Invalid argument).  Ignore error<y>? yes
Error writing block 234356736 (Invalid argument).  Ignore error<y>? yes
Error writing block 233308160 (Invalid argument).  Ignore error<y>? yes
Error writing block 235405312 (Invalid argument).  Ignore error<y>? yes
Error writing block 234881024 (Invalid argument).  Ignore error<y>? yes
/dev/sda4: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda4: 416983/58982400 files (0.5% non-contiguous), 47732938/235929600 blocks


I went back to review the resize2fs output but it's of course off my screen now. I'm not sure what I could have done wrong. I'm not too sure how to recover as resize2fs needs the fsck to complete but every time I run it I get the same. Am I missing a flag?
_________________
"Who are you to judge the life I live? I know I'm not perfect and I don't live to be, but before you start pointing fingers... make sure your hands are clean." ~Bob Marley


Last edited by Crimjob on Tue Sep 22, 2020 4:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7576
Location: almost Mile High in the USA

PostPosted: Tue Sep 22, 2020 4:47 am    Post subject: Reply with quote

Well, there was the warning to backup your filesystem before trying to resize, so no data loss, right?

Yep looks like something screwed up:
resize2fs looks like it deals with Gibibytes and parted uses Gigabytes, so you need to use the equivalent gigabytes of 900 GiB.

If you have a 1TB disk = 1000GB disk, that's around 931 GiB. 900GiB is around 966GB, so math accordingly...

I'm so paranoid of these mistakes so I backup, and use the gparted livecd to do the math for me.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 46272
Location: 56N 3W

PostPosted: Tue Sep 22, 2020 8:41 am    Post subject: Reply with quote

Crimjob,

Code:
[root@sysresccd ~]# e2fsck -f /dev/sda4
e2fsck 1.45.0 (6-Mar-2019)
The filesystem size (according to the superblock) is 235929600 blocks
The physical size of the device is 220538517 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort<y>? no


Oops. Your filesystem extends beyond the end of the partition. eccerr0r told you about that.

Move the end of the partition back where it came from and see if your data is still intact.
If not, well that's why you have a backup.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Crimjob
Tux's lil' helper
Tux's lil' helper


Joined: 04 Dec 2006
Posts: 111

PostPosted: Tue Sep 22, 2020 4:45 pm    Post subject: Reply with quote

Well that makes things fun and interesting lol. I tried a few bootable GUI live CD's but couldn't get past the mouse pointer in X. Unfortunately I'm limited to a Hyper-V host with my Gentoo Guest so it probably isn't the best with GUI's. I was unable to find any solid instructions online for doing exactly what I wanted, so I went back to basics and RTFM. The only helpful note I could find online was doing the resize2fs first (when shrinking as I am) which I did so I was very confused when things went south.

Somewhat luckily this is a fairly new system - I have not yet backed up any of the configurations etc., however the data I was copying was what would have been important (backed up) and the issues I ran into were related to the size of the data I was copying. I removed all that data to change my plans so there was really only a base system install with some configuration left on the partition. So if anything, the data I was copying (and have now removed) I'm thinking would have been the only affected data by my partition mishap.

I combined eccerr0r's maths with NeddySeagoon's suggestion and I seem to be back up and running with no issues or errors to see. Expanded the partition with parted back to it's original size, ran the resize2fs /dev/sda4 838G, re-ran parted resizepart to 905GB (a few GB wiggle room won't hurt), ran e2fsck, test mounted, and booted.

The reason I went to resize the part was ultimately the same - for some reason (fairly unlike me) I oversubscribed the host disk based off the advertised size (GiB) when the hypervisor was working in GB. Hopefully lesson learned this time!

Thanks for the help gents! Definitely saved me a few more hours of headache & re-install.
_________________
"Who are you to judge the life I live? I know I'm not perfect and I don't live to be, but before you start pointing fingers... make sure your hands are clean." ~Bob Marley
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 46272
Location: 56N 3W

PostPosted: Tue Sep 22, 2020 6:00 pm    Post subject: Reply with quote

Crimjob,

resize2fs will grow the filesystem to fill the partition.
Online growing is safe and justworks. Its key to using lvm and adding space to a logical volume that getting full.

No reboot required.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15967

PostPosted: Tue Sep 22, 2020 6:04 pm    Post subject: Reply with quote

It is good that you were able to save the filesystem, and that you did not have much at risk if you had been unable to save it. As a bit of general advice, when you do a resize like this, you should expect the e2fsck to come back clean. If it reports any problems you cannot explain, abort it without making any changes. Undo your changes to that point (that is, grow the block device back to its former size) or seek external guidance (such as with a forum post). Allowing e2fsck to modify a filesystem in this state risks causing more problems, such as forgetting the blocks that are outside the device, which could prevent you accessing their data even after you regrow the block device.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum