Skip to content

Instantly share code, notes, and snippets.

@181192
Last active March 1, 2024 03:24
Show Gist options
  • Save 181192/cf7eb42a25538ccdb8d0bb7dd57cf236 to your computer and use it in GitHub Desktop.
Save 181192/cf7eb42a25538ccdb8d0bb7dd57cf236 to your computer and use it in GitHub Desktop.
How to increase the root partition size on Fedora

How to increase the root partition size on Fedora

Boot up with an Fedora Live USB stick.

  1. Run vgs to check if there's any space:
$ sudo vgs
  VG     #PV #LV #SN Attr   VSize    VFree
  fedora   1   3   0 wz--n- <237.28g    0 
  1. If there is you can just run:
lvresize -L +5G --resizefs /dev/mapper/fedora-root

NB: Remember to check where your fedora root and home partition is mounted by running fdisk -l.

  1. If you don't have any free VFree space, you can shrink your home partition and then extend your root partition afterwards.

To scrink your home partition run:

lvresize -L -10G --resizefs /dev/mapper/fedora-home

And then to extend your root partition run:

lvresize -L +10G --resizefs /dev/mapper/fedora-root
@bcrnkovic
Copy link

Just what I was looking for... thanks for this!

@Ben1980
Copy link

Ben1980 commented Mar 29, 2019

Thanks for the tip. But unfortunately it seems not to work with Fedora 29 on VMWare Workstation. VFree is always 0 but there should be additional 10G available.

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 41943039 39843840 19G 8e Linux LVM

VG #PV #LV #SN Attr VSize VFree
fedora 1 2 0 wz--n- <19.00g 0

@kamalmeh
Copy link

kamalmeh commented May 11, 2019

Thanks! Similar issue faced while upgrading my server from fedora 29 to 30.
Downloading failed due to root partition was 100% full after downloading 1.4G our of 1.9G. I was stuck in middle.
I had space available and simply executed the below command my problem was fixed.

[kmehta@dev ~]$ date
Sat May 11 19:28:42 IST 2019
[root@dev ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.5G 0 1.5G 0% /dev/shm
tmpfs 1.5G 1.2M 1.5G 1% /run
tmpfs 1.5G 0 1.5G 0% /sys/fs/cgroup
/dev/mapper/fedora00-root 15G 15G 45M 100% /
tmpfs 1.5G 32K 1.5G 1% /tmp
/dev/sda1 976M 205M 705M 23% /boot
/dev/sdb5 150G 70M 149G 1% /mnt/nas001
/dev/sdc1 1.9T 99G 1.8T 6% /mnt/nas000
tmpfs 288M 0 288M 0% /run/user/1000
[root@dev ~]# lvresize -L +5G --resizefs /dev/mapper/fedora-root
Volume group "fedora" not found
Cannot process volume group fedora
[root@dev ~]# vgs
VG #PV #LV #SN Attr VSize VFree
fedora00 1 2 0 wz--n- <148.05g 130.11g
[root@dev ~]# lvresize -L +35G --resizefs /dev/mapper/fedora00-root
[root@dev ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.5G 0 1.5G 0% /dev/shm
tmpfs 1.5G 1.2M 1.5G 1% /run
tmpfs 1.5G 0 1.5G 0% /sys/fs/cgroup
/dev/mapper/fedora00-root 50G 15G 36G 30% /
tmpfs 1.5G 32K 1.5G 1% /tmp
/dev/sda1 976M 205M 705M 23% /boot
/dev/sdb5 150G 70M 149G 1% /mnt/nas001
/dev/sdc1 1.9T 99G 1.8T 6% /mnt/nas000
tmpfs 288M 0 288M 0% /run/user/1000

Thanks once again.

Regards
Kamal Mehta
https://www.smiansh.com

@mwolski89
Copy link

worked for me, thanks a lot 👍

@voneAbides
Copy link

Thank you. Worked.

@vbasarkar
Copy link

Worked for me with Fedora 25.

@luke-h1
Copy link

luke-h1 commented Apr 18, 2020

thanks for this.

@dubst3pp4
Copy link

Thank you very much! Works perfectly :-)

@whernandez
Copy link

Works perfectly, booting from fedora 32. Thanks!

@LeonelSoriano
Copy link

I love man :D

@MadBomber
Copy link

MadBomber commented Dec 5, 2020

Trying this under Fedora 31 ... Ran into a problem with /home not being able to be unmounted.

[root@frank ~]# vgs
  VG       #PV #LV #SN Attr   VSize    VFree
  fedora     1   3   0 wz--n- <930.51g    0
  fedora00   1   3   0 wz--n-   <1.82t    0
[root@frank ~]# lvresize -L -20G --resizefs /dev/mapper/fedora-home
Do you want to unmount "/home" ? [Y|n] y
umount: /home: target is busy.
fsadm: Cannot proceed with mounted filesystem "/home".
  /usr/sbin/fsadm failed: 1
  Filesystem resize failed.
[root@frank ~]# lvresize -L -20G --resizefs /dev/mapper/fedora-home
Do you want to unmount "/home" ? [Y|n] n
fsadm: Cannot proceed with mounted filesystem "/home".
  /usr/sbin/fsadm failed: 1
  Filesystem resize failed.
[root@frank ~]#

@cankarales
Copy link

Thank you sir, this worked great. However sudo vgs returned an empty result on my laptop, I'm guessing because the drive is encrypted. I used gparted to unlock it, then I was able to resize partitions :)

@AkashRajpurohit
Copy link

AkashRajpurohit commented Mar 1, 2021

Trying this under Fedora 31 ... Ran into a problem with /home not being able to be unmounted.

[root@frank ~]# vgs
  VG       #PV #LV #SN Attr   VSize    VFree
  fedora     1   3   0 wz--n- <930.51g    0
  fedora00   1   3   0 wz--n-   <1.82t    0
[root@frank ~]# lvresize -L -20G --resizefs /dev/mapper/fedora-home
Do you want to unmount "/home" ? [Y|n] y
umount: /home: target is busy.
fsadm: Cannot proceed with mounted filesystem "/home".
  /usr/sbin/fsadm failed: 1
  Filesystem resize failed.
[root@frank ~]# lvresize -L -20G --resizefs /dev/mapper/fedora-home
Do you want to unmount "/home" ? [Y|n] n
fsadm: Cannot proceed with mounted filesystem "/home".
  /usr/sbin/fsadm failed: 1
  Filesystem resize failed.
[root@frank ~]#

If you are still facing this issue, login with root user and try it again.
Please note that login with root means logging out as your non root user and login with credentials root and <YOUR_PASSWORD>. If you are trying the sudo su command to switch the user you still would get this error.

Reason: The non root user has mounted /home directory and possibly the applications running are accessing the file contents inside of /home so that's why we cannot unmount it. Login with root user will solve this problem.

I will post a detailed blog about this on my blogging site as well.
Regards.

Edit:
Written post for this process -

@AlexandreBiondi
Copy link

Great ! Thanks for sharing !

@Darmanitan
Copy link

working on fedora 36, thanks a lot 😸

@bjahns
Copy link

bjahns commented May 11, 2022

Once I figured out that I'll never see the BIOS screen over HDMI through my KVM (and needed to find a stupid VGA cable....) This worked great on Fedora 35 booting off a Fedora 36 live USB key. Thanks so much for posting!

@linZHank
Copy link

linZHank commented Aug 8, 2022

Still works on Fedora 36. Thank you so much!

@padys
Copy link

padys commented Nov 26, 2022

Works fine on Fedora 37. Thanks!

In case of encrypted disk, unlocking is a must first. I've followed this article: https://thequantitative.medium.com/resize-an-encrypted-partition-without-breaking-your-linux-system-6ef475619745

@FatCatLikesBeer
Copy link

This is exactly what I needed. I just ran into this issues while updating my 4 month old machine. I built my Fedora Server with a brand new 1TB drive, but apparently I only had 15GB assigned to root. Ran just the above code and it worked just fine! Thank you thank you!

@shakib98
Copy link

thank you worked in fedora 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment