How to resize ext4 root partition live without umount - LinuxConfig.org


#1
This article will focus on how to resize EXT4 root partition without unmount. This is an easy way for some system where you are unable to unmount root partition and the system can be recovered easily if something goes wrong like for example AWS instance.
This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-resize-ext4-root-partition-live-without-umount

#2

Bouteillier Nicolas

To have the “a” option, (I am under ubuntu Artful) I have to use “x” to have the expert feature, and the “A” to toggle the old boot option


#3

ГГ

last step required for me:

lvextend -r -l +100%FREE /dev/mapper/centos-root


#4

Fen

Thanks, worked mostly as described.
At the end in df -h my old partition sized was printed.
I had to run resize2fs /dev/xvda1 to finally see the whole size in df -h


#5

Gavin Baumanis

Hi there, everything seems to work for me up to the final “write”…
I recreate the partition and make it bootable, too…
Device Boot Start End Sectors Size Id Type
/dev/sda1p1 * 2048 81917951 81915904 39.1G 83 Linux

(it is now 40 GB vs the original 8 GB)

However when I run the final “write” of the partition. I get the following;
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Invalid argument

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

I am not sure what the invalid argument is - but after quitting fdisk and re-running fdisk, I get told that the partition is still set 40GB. So it seems like it is working… but after a reboot, the partition is reverted to only being 8 GB. - kinda…

sudo df -h .
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 7.4G 6.2G 859M 88% /

(it still reads as if it is only 8 GB in size?)

But fdisk reports at as being 40 GB but with only 1 GB free? It all seems a bit weird…
sudo fdisk -l

Disk /dev/sda: 39.1 GiB, 41943040000 bytes, 81920000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x78e64ad4

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 81919999 81917952 39.1G 83 Linux

Any ideas? - Thanks!


#6

Stefan -> Gavin Baumanis

Even if it’s a year since you asked, I’m going to answer, maybe someone will need it:
Just run “resize2fs /dev/sda1” and it will expand to the desired size.


#7

Graeme Evans -> Stefan

helped me! so thanks :smiley: