Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - Reclaim hard-drive space with LVM

#1
Reclaim hard-drive space with LVM

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes. It is commonly used on Fedora installations (prior to BTRFS as default it was LVM+Ext4). But have you ever started up your system to find a message like the image above, after you logged in? Uh oh, Gnome just said the home volume is almost out of space! Luckily, there is likely some space sitting around in another volume, unused and ready to re-alocate. Here’s how to reclaim hard-drive space with LVM.

The key to easily re-alocate space between volumes is the Logical Volume Manager (LVM). Fedora 32 and before use LVM to divide disk space by default. This technology is similar to standard hard-drive partitions, but LVM is a lot more flexible. LVM enables not only flexible volume size management, but also advanced capabilities such as read-write snapshots, striping or mirroring data across multiple drives, using a high-speed drive as a cache for a slower drive, and much more. All of these advanced options can get a bit overwhelming, but resizing a volume is straight-forward.

LVM basics


The volume group serves as the main container in the LVM system. By default Fedora only defines a single volume group, but there can be as many as needed. Actual hard-drive and hard-drive partitions are added to the volume group as physical volumes. Physical volumes add available free space to the volume group. A typical Fedora install has one formatted boot partition, and the rest of the drive is a partition configured as an LVM physical volume.

Out of this pool of available space, the volume group allocates one or more logical volumes. These volumes are similar to hard-drive partitions, but without the limitation of contiguous space on the disk. LVM logical volumes can even span multiple devices! Just like hard-drive partitions, logical volumes have a defined size and can contain any filesystem which can then be mounted to specific directories.

What’s needed


Confirm the system uses LVM with the gnome-disks application, and make sure there is free space available in some other volume. Without space to reclaim from another volume, this guide isn’t useful. A Fedora live CD/USB is also needed. Any file system that needs to shrink must be unmounted. Running from a live image allows all the volumes on the hard-disk to remain unmounted, even important directories like / and /home.

Use gnome-disks to verify free space.
Use gnome-disks to verify free space

A word of warning


No data should be lost by following this guide, but it does muck around with some very low-level and powerful commands. One mistake could destroy all data on the hard-drive. So backup all the data on the disk first!

Resizing LVM volumes


To begin, boot the Fedora live image and select Try Fedora at the dialog. Next, use the Run Command to launch the blivet-gui application (accessible by pressing Alt-F2, typing blivet-gui, then pressing enter). Select the volume group on the left under LVM. The logical volumes are on the right.

Explore logical volumes in blivet gui.
Explore logical volumes in blivet-gui

The logical volume labels consist of both the volume group name and the logical volume name. In the example, the volume group is “fedora_localhost-live” and there are “home”, “root”, and “swap” logical volumes allocated. To find the full volume, select each one, click on the gear icon, and choose resize. The slider in the resize dialog indicates the allowable sizes for the volume. The minimum value on the left is the space already in use within the file system, so this is the minimum possible volume size (without deleting data). The maximum value on the right is the greatest size the volume can have based on available free space in the volume group.

Use the resize dialog in blivet-gui to set the new volume sizes.
Resize dialog in blivet-gui

A grayed out resize option means the volume is full and there is no free space in the volume group. It’s time to change that! Look through all of the volumes to find one with plenty of extra space, like in the screenshot above. Move the slider to the left to set the new size. Free up enough space to be useful for the full volume, but still leave plenty of space for future data growth. Otherwise, this volume will be the next to fill up.

Click resize and note that a new item appears in the volume listing: free space. Now select the full volume that started this whole endeavor, and move the slider all the way to the right. Press resize and marvel at the new improved volume layout. However, nothing has changed on the hard drive yet. Click on the check-mark to commit the changes to disk.

Review the changes in blivet-gui and then accept to reclaim hard-drive space.
Review changes in blivet-gui

Review the summary of the changes, and if everything looks right, click Ok to proceed. Wait for blivet-gui to finish. Now reboot back into the main Fedora install and enjoy all the new space in the previously full volume.

Planning for the future


It is challenging to know how much space any particular volume will need in the future. Instead of immediately allocating all available free space, consider leaving it free in the volume group. In fact, Fedora Server reserves space in the volume group by default. Extending a volume is possible while it is online and in use. No live image or reboot needed. When a volume is almost full, easily extend the volume using part of the available free space and keep working. Unfortunately the default disk manager, gnome-disks, does not support LVM volume resizing, so install blivet-gui for a graphical management tool. Alternately, there is a simple terminal command to extend a volume:

lvresize -r -L +1G /dev/fedora_localhost-live/root 

Wrap-up


Reclaiming hard-drive space with LVM just scratches the surface of LVM capabilities. Most people, especially on the desktop, probably don’t need the more advanced features. However, LVM is there when the need arises, though it can get a bit complex to implement. BTRFS is the default filesystem, without LVM, starting with Fedora 33. BTRFS can be easier to manage while still flexible enough for most common usages. Check out the recent Fedora Magazine articles on BTRFS to learn more.



https://www.sickgaming.net/blog/2020/11/...-with-lvm/
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Fedora - Getting started with Fedora CoreOS xSicKxBot 0 11 11-27-2020, 11:41 PM
Last Post: xSicKxBot
  Fedora - Podman with capabilities on Fedora xSicKxBot 0 16 11-17-2020, 02:07 AM
Last Post: xSicKxBot
  Fedora - Using Fedora 33 with Microsoft’s WSL2 xSicKxBot 0 25 11-11-2020, 10:30 PM
Last Post: xSicKxBot
  Fedora - How to rebase to Fedora 33 on Silverblue xSicKxBot 0 40 10-31-2020, 12:26 AM
Last Post: xSicKxBot
  Fedora - What’s new in Fedora 33 Workstation xSicKxBot 0 35 10-28-2020, 11:24 PM
Last Post: xSicKxBot
  Fedora - Fedora 33 is officially here! xSicKxBot 0 35 10-27-2020, 09:34 PM
Last Post: xSicKxBot
  Fedora - Contribute at the Fedora Test Week for Kernel 5.9 xSicKxBot 0 41 10-25-2020, 12:22 AM
Last Post: xSicKxBot
  Fedora - Announcing the release of Fedora 33 Beta xSicKxBot 0 78 09-29-2020, 09:01 PM
Last Post: xSicKxBot
  Fedora - Now available: Fedora on Lenovo laptops! xSicKxBot 0 67 09-25-2020, 07:51 PM
Last Post: xSicKxBot
  Fedora - Ankur Sinha: How do you Fedora? xSicKxBot 0 77 09-11-2020, 02:22 PM
Last Post: xSicKxBot

Forum Jump:

[-]
Active Threads
News - Atelier Ryza Developer Clarifies ...
Last Post: xSicKxBot
Today 05:30 AM
» Replies: 0
» Views: 0
News - Doom Eternal Update 4 Adds New Ma...
Last Post: xSicKxBot
Today 05:30 AM
» Replies: 0
» Views: 9
Unreal Engine Asset Giveaway For Decembe...
Last Post: xSicKxBot
Today 04:15 AM
» Replies: 0
» Views: 4
[Tut] Searching The Parse Tree Using Bea...
Last Post: xSicKxBot
Yesterday 10:53 PM
» Replies: 0
» Views: 4
News - PixelJunk Eden 2 Coming Very Soon
Last Post: xSicKxBot
Yesterday 10:53 PM
» Replies: 0
» Views: 65
(Indie Deal) Black Friday Weekend Round-...
Last Post: xSicKxBot
Yesterday 08:48 PM
» Replies: 0
» Views: 5
Xbox Wire - How to Buy a Digital Game as...
Last Post: xSicKxBot
Yesterday 06:00 PM
» Replies: 0
» Views: 4
News - Video: A look at Insomniac Games’...
Last Post: xSicKxBot
Yesterday 06:00 PM
» Replies: 0
» Views: 69
News - Saudi Arabian charity Misk acquir...
Last Post: xSicKxBot
Yesterday 06:00 PM
» Replies: 0
» Views: 89
News - Net Neutrality-Repealing FCC Chai...
Last Post: xSicKxBot
Yesterday 03:20 PM
» Replies: 0
» Views: 66

[-]
Twitter

[-]
Sponsored
Get the Deal of the Week at RefurBees.com

Copyright © SickGaming.net 2012-2020