0

I have a computer with a ~58GB partition reserved for Fedora 30. I just got a warning that I am running out of space on /home.

I ran df -h and I got this:

Filesystem                               Size  Used Avail Use% Mounted on
devtmpfs                                 3.9G     0  3.9G   0% /dev
tmpfs                                    3.9G  167M  3.7G   5% /dev/shm
tmpfs                                    3.9G  1.9M  3.9G   1% /run
tmpfs                                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/fedora_localhost--live-root   35G   13G   20G  40% /
tmpfs                                    3.9G   20M  3.9G   1% /tmp
/dev/mapper/fedora_localhost--live-home   17G   15G  847M  95% /home
/dev/sda8                                976M  164M  746M  18% /boot
/dev/sda2                                256M  140M  117M  55% /boot/efi
tmpfs                                    789M   11M  778M   2% /run/user/1000

I know that / and /home aren't actually on separate partitions, but why are they separated? And how can I allocate more space to /home?

EDIT:

pvdisplay:

  WARNING: Failed to connect to lvmetad. Falling back to device scanning.                    
  --- Physical volume ---                                                                    
  PV Name               /dev/sda9                                                            
  VG Name               fedora_localhost-live                                                
  PV Size               <57.79 GiB / not usable 4.00 MiB                                     
  Allocatable           yes (but full)                                                       
  PE Size               4.00 MiB                                                             
  Total PE              14793                                                                
  Free PE               0                                                                    
  Allocated PE          14793                                                                
  PV UUID               YnWhfZ-jzxO-1QbU-k756-YisP-qjuW-Cnf0oC  

vgdisplay:

  WARNING: Failed to connect to lvmetad. Falling back to device scanning.                    
  --- Physical volume ---                                                                    
  PV Name               /dev/sda9                                                            
  VG Name               fedora_localhost-live                                                
  PV Size               <57.79 GiB / not usable 4.00 MiB                                     
  Allocatable           yes (but full)                                                       
  PE Size               4.00 MiB                                                             
  Total PE              14793                                                                
  Free PE               0                                                                    
  Allocated PE          14793                                                                
  PV UUID               YnWhfZ-jzxO-1QbU-k756-YisP-qjuW-Cnf0oC  

lvdisplay:
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  --- Logical volume ---
  LV Path                /dev/fedora_localhost-live/swap
  LV Name                swap
  VG Name                fedora_localhost-live
  LV UUID                JGCKLU-3O7s-lNZU-HjZi-mTn2-HV3J-u376VH
  LV Write Access        read/write
  LV Creation host, time localhost-live, 2019-07-21 19:25:06 -0700
  LV Status              available
  # open                 2
  LV Size                5.88 GiB
  Current LE             1506
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/fedora_localhost-live/home
  LV Name                home
  VG Name                fedora_localhost-live
  LV UUID                QJpqdd-ZzT3-QJ2P-8E6d-oIlW-LiDI-T9KafK
  LV Write Access        read/write
  LV Creation host, time localhost-live, 2019-07-21 19:25:06 -0700
  LV Status              available
  # open                 1
  LV Size                <17.03 GiB
  Current LE             4359
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Path                /dev/fedora_localhost-live/root
  LV Name                root
  VG Name                fedora_localhost-live
  LV UUID                AtjCQZ-a26R-RR8c-IRmo-INqb-rzad-sDuJ9O
  LV Write Access        read/write
  LV Creation host, time localhost-live, 2019-07-21 19:25:09 -0700
  LV Status              available
  # open                 1
  LV Size                <34.88 GiB
  Current LE             8928
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  • "why are they separated?" only because the system was setup that way when installed. When installing a Linux distribution you choose (or you let the installer choose for you) on which disk(s) and partitions to install them. You can find many passionated debates depending on a lot of stuff to see if it is good to have things in separate partitions or not. Your case shows one of the drawbacks of partitions. – Patrick Mevzek Aug 13 at 22:54
  • You don't have partitions mounted / and /home. You have logical volumes. Add the output of pvdisplay, vgdisplay, and lvdisplay to your question. – Nasir Riley Aug 13 at 23:11
  • 1
    @NasirRiley I have updated my question – Neil Chowdhury Aug 13 at 23:30
2

You have one physical volume, /dev/sda9, one volume group, fedora_localhost-live, and three logical volumes root, home, and swap.

The first two logical volumes are mounted at / and /home and your swap isn't mounted anywhere as swap doesn't have a mountpoint but it's still using the space allocated to it.

From your df -h, you can see that the logical volume for root which is /dev/mapper/fedora_localhost--live-root has 35G of total space with 20GB free and the logical volume for home which is /dev/mapper/fedora_localhost--live-home has 17G of total space with only 847MB free which is why it is almost full. You can also see that the space in your volume group is all used up via these lines in vgdisplay:

Total PE              14793                                                                
Free PE               0                                                                    
Allocated PE          14793  

With that being said, you can't increase the size of /home as it is because there is no space in its volume group to allocate to it. The only things that you can do are:

1) If there is space on another physical disk in that machine, you can use fdisk to create another partition and logical volume and then add it to the volume group and extend the space to the home logical volume.

2) If the filesystem on the logical volumes is ext4 then you can shrink the root logical volume and then give the extra space to the home logical volume. You can find the type of filesystem with the command lsblk -f' orfindmnt -o source,fstype. If the filesystem type isxfs` then this won't work.

3) You can add another physical disk to your machine, use fdisk to set it up, and then create a physical volume, add it to the volume group, and extend the space to the home logical volume.

As you have chosen to go with the second option:

1) Before you begin, back up your data. This is important in case something goes wrong. I can't stress this enough.

2) You will need to boot from a Fedora Live USB or CD/DVD.

3) Once in your live session, become root and install the lvm2 package with dnf install lvm2 if it isn't already there.

4) Run lvs to make sure that the root logical volume is showing up. If it's not, run vgchange -a y fedora_localhost-live and then run lvs again.

5) Check the root logical volume for errors with e2fsck -f /dev/mapper/fedora_localhost--live-root.

6) As it won't be mounted, you can then reduce the size of the root logical volume with resize2fs /dev/mapper/fedora_localhost--live-root 25G and the shrink it with lvresize -L 25G /dev/mapper/fedora_localhost--live-root.

7) Run vgs and you should now see your fedora_localhost-live volume group with 10G free.

8) Next, extend the home logical volume to the rest of the space with lvresize -l +100%FREE /dev/mapper/fedora_localhost--live-home and resize it with resize2fs /dev/mapper/fedora_localhost--live-home.

9) Run lvs again and you'll be able to see your home logical volume with 10G of free space.

10) Reboot.

  • I would like to go with option 2. How should I shrink the root logical volume safely? Is it ok to do it when I'm logged in (i.e. the filesystem is mounted)? – Neil Chowdhury Aug 14 at 16:17
  • @Neil Chowdhury What filesystem are the logical volumes using? – Nasir Riley Aug 14 at 16:33
  • Do you mean ext4? That is what they are using. – Neil Chowdhury Aug 14 at 16:35
  • 1
    @NeilChowdhury I have updated my answer with resizing instructions. – Nasir Riley Aug 14 at 22:16
  • I think in step 8 it should just be resize2fs /dev/mapper/fedora_localhost--live-home. (without -M to expand) Also you will need to run e2fsck on the home LV before that. But otherwise, your instructions worked well. Thanks for the help! – Neil Chowdhury Aug 15 at 17:02

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.