My question is similar to this but I could not find a satisfactory answer there.

I have dual boot system with Fedora 23 and Windows. My root partition is running out of space.

Here is df -h output :-

Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G   42M  3.9G   2% /dev/shm
tmpfs                    3.9G  1.7M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/fedora-root   50G   46G  972M  98% /
tmpfs                    3.9G   24K  3.9G   1% /tmp
/dev/sda8                477M  162M  286M  37% /boot
/dev/sda2                256M   36M  221M  14% /boot/efi
/dev/mapper/fedora-home  189G  179G  769M 100% /home
tmpfs                    790M   60K  790M   1% /run/user/1000


$ fdisk -l

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 3A525B39-F4F8-4711-BBD8-1361A413A29B

Device          Start        End   Sectors   Size Type
/dev/sda1        2048    2050047   2048000  1000M Windows recovery environment
/dev/sda2     2050048    2582527    532480   260M EFI System
/dev/sda3     2582528    4630527   2048000  1000M Lenovo boot partition
/dev/sda4     4630528    4892671    262144   128M Microsoft reserved
/dev/sda5     4892672  277522431 272629760   130G Microsoft basic data
/dev/sda6   319465472  721424383 401958912 191.7G Microsoft basic data
/dev/sda7   721426432 1350572031 629145600   300G Microsoft basic data
/dev/sda8  1350572032 1351596031   1024000   500M Linux filesystem
/dev/sda9  1874862080 1927290879  52428800    25G Microsoft basic data
/dev/sda10 1927290880 1953523711  26232832  12.5G Windows recovery environment
/dev/sda11 1351596032 1874862079 523266048 249.5G Linux LVM

Partition table entries are not in disk order.

Disk /dev/mapper/fedora-root: 50 GiB, 53687091200 bytes, 104857600 sectors

Disk /dev/mapper/fedora-swap: 7.8 GiB, 8321499136 bytes, 16252928 sectors

Disk /dev/mapper/fedora-home: 191.8 GiB, 205898383360 bytes, 402145280 sectors

I have 20GB unallocated space enter image description here and want to extend root partition to it.

Is it possible to do so with above partition? I read somewhere resize2fs can extend the root partition automatically with unallocated space for lvm partition. Is it possible without losing data?

Update:- I found this answer, but I am not sure which command to execute to do so.


Is it possible to do so with above partition? I read somewhere resize2fs can extend the root partition automatically with unallocated space for lvm partition. Is it possible without losing data?

Yes and yes. The resize2fs part doesn't need much explanation, but let me provide a concrete recipe for the LVM part.

LVM works like this: partitions are turned into physical volumes (PV), which are then grouped into volume groups (VG), which can then be partitioned into logical volumes (LV). The latter get formatted and are used just like DOS partitions are.

Right now, you have a partition /dev/sda11 which holds one physical volume, which is grouped into one volume group (called "fedora"), on top of which you seem to have at least two logical volumes ("root" and "home").

All you need to do is:

  1. add another physical volume;
  2. extend your volume group with this new volume;
  3. extend your "root" logical volume to use the space;
  4. resize the filesystem in the "root" LV.

CAUTION! Root partition is one of those things that shouldn't be messed with while the system is running. Boot from a LiveUSB and perform all operations from there. SystemRescueCD is a good option, but you can use anything as long as it has parted (or equivalent), lvm2, e2fsck and resize2fs.

First, turn your unallocated 20 gigs into a partition. You seem to have GParted or something; do it there, it's intuitive and easy. I'll assume the resulting partition is called /dev/sda12.

Now create a PV on top of that partition:

# pvcreate /dev/sda12

That's step one done. Now on to step two:

# vgextend fedora /dev/sda12

(note how PVs don't have their own names—they're named after the partitions they reside on. But VGs have their own names; I found out how yours is called from the GParted screenshot and the name of the /dev/mapper entries.)

With volume group ready, it's time to execute step three. This will resize the "root" LV on "fedora" VG to use all the available space. You can use -L to specify a concrete size (in megabytes, gigabytes etc.) instead.

# lvextend -l+100%FREE /dev/fedora/root

Finally, resize the partition to actually use all that free space:

# e2fsck -f /dev/fedora/root
# resize2fs /dev/fedora/root
# e2fsck -f /dev/fedora/root

e2fsck ensures your filesystem isn't corrupted to begin with, and it's not corrupted afterwards. You can omit the second invocation, but the first one is essential—I believe resize2fs won't run unless you have your filesystem checked.

  • thanks, @Alesander, for the detailed explanation. It worked like charm. Now Fedora is working very smoothly than before.
    – Om Prakash
    Jul 30 '17 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.