mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-21 02:10:11 +08:00
commit
588749540f
@ -1,90 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Reclaim hard-drive space with LVM)
|
||||
[#]: via: (https://fedoramagazine.org/reclaim-hard-drive-space-with-lvm/)
|
||||
[#]: author: (Troy Curtis Jr https://fedoramagazine.org/author/troycurtisjr/)
|
||||
|
||||
Reclaim hard-drive space with LVM
|
||||
======
|
||||
|
||||
![Hard drive image][1]
|
||||
|
||||
Photo by Frank R @ Unsplash.com
|
||||
|
||||
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 out that 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)][2]. 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][3] 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][4]
|
||||
|
||||
### 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][5]
|
||||
|
||||
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_.
|
||||
|
||||
![Resize dialog in blivet-gui][6]
|
||||
|
||||
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 changes in blivet-gui][7]
|
||||
|
||||
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][8]_ 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][9] is the default filesystem, without LVM, starting with [Fedora 33][10]. BTRFS can be easier to manage while still flexible enough for most common usages. Check out the recent [Fedora Magazine articles on BTRFS][11] to learn more.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/reclaim-hard-drive-space-with-lvm/
|
||||
|
||||
作者:[Troy Curtis Jr][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/troycurtisjr/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/lvm-resize-816x345.jpg
|
||||
[2]: http://sourceware.org/lvm2/
|
||||
[3]: https://getfedora.org/en/workstation/download/
|
||||
[4]: https://fedoramagazine.org/wp-content/uploads/2020/11/gnome-disks.png
|
||||
[5]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-overview.png
|
||||
[6]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-resize-1024x525.png
|
||||
[7]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-summary-1024x525.png
|
||||
[8]: https://fedoraproject.org/wiki/Blivet-gui
|
||||
[9]: https://fedoramagazine.org/btrfs-coming-to-fedora-33/
|
||||
[10]: https://fedoramagazine.org/whats-new-fedora-33-workstation/
|
||||
[11]: https://fedoramagazine.org/btrfs-snapshots-backup-incremental/
|
@ -0,0 +1,90 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Reclaim hard-drive space with LVM)
|
||||
[#]: via: (https://fedoramagazine.org/reclaim-hard-drive-space-with-lvm/)
|
||||
[#]: author: (Troy Curtis Jr https://fedoramagazine.org/author/troycurtisjr/)
|
||||
|
||||
使用 LVM 回收硬盘空间
|
||||
======
|
||||
|
||||
![Hard drive image][1]
|
||||
|
||||
照片:Frank R @ Unsplash.com
|
||||
|
||||
LVM 是一个逻辑卷管理工具,包括分配磁盘、区代化、镜像和调整逻辑卷的大小。它在 Fedora 安装中被普遍使用(在 BTRFS 作为默认之前是 LVM+Ext4)。但是你是否曾经遇到过启动系统时,Gnome 提示主卷几乎没有空间了!幸运的是,很有可能有一些空间在另一个卷中,而未被使用,并准备重新分配。下面就来看看如何用 LVM 回收硬盘空间。
|
||||
|
||||
在卷之间轻松重新分配空间的关键是[逻辑卷管理器 (LVM)][2]。Fedora 32 及以前的系统默认使用 LVM 来划分磁盘空间。这种技术类似于标准的硬盘分区,但 LVM 更加灵活。LVM 不仅可以实现灵活的卷大小管理,还可以实现一些高级功能,比如读写快照、在多个硬盘上进行数据区带化或镜像、将高速硬盘作为慢速硬盘的缓存等等。所有这些高级选项可能会让人有点不知所措,但调整卷的大小很直接的。
|
||||
|
||||
### LVM 基础
|
||||
|
||||
_卷组_作为 LVM 系统中的主要容器。默认情况下,Fedora 只定义了一个卷组,但你可以根据需要定义多个卷组。实际的硬盘和硬盘分区被添加到 _卷组_中作为_物理卷_。_物理卷_会将可用的空间添加到_卷组_中。一个典型的 Fedora 安装有一个格式化的启动分区,其余的硬盘是一个配置为 LVM _物理卷_的分区。
|
||||
|
||||
从这个可用空间池中,_卷组_分配了一个或多个_逻辑卷_。这些卷类似于硬盘分区,但没有磁盘上连续空间的限制。LVM 的_逻辑卷_甚至可以跨越多个设备!就像硬盘分区一样,_逻辑卷_有一个定义的大小,可以包含任何文件系统,然后可以挂载到特定的目录。
|
||||
|
||||
### 需要什么
|
||||
|
||||
在 gnome-disks 应用中确认系统使用 LVM ,并确保其他卷中有可用的空间。如果没有从另一个卷中回收的空间,这个指南就没有用。还需要一个 [Fedora live CD/USB][3]。任何需要收缩的文件系统都必须卸载。从 Live 镜像运行可以让硬盘上的所有卷保持未挂载状态,甚至包括像 _/_ 和 _/home_ 这样的重要目录。
|
||||
|
||||
![Use gnome-disks to verify free space][4]
|
||||
|
||||
### 一句话警告
|
||||
|
||||
按照这个指南,应该不会丢失任何数据,但它确实会使用一些非常底层和强大的命令。一个错误可能会破坏硬盘上的所有数据。所以要先备份磁盘上的所有数据!
|
||||
|
||||
### 调整 LVM 卷的大小
|
||||
|
||||
开始时,启动 Fedora Live 镜像并在对话框中选择 _Try Fedora_。接下来,使用 _Run Command_ 启动 _blivet-gui_ 应用(按 _Alt-F2_,输入 _blivet-gui_,然后按_回车_)。选择左侧 _LVM_ 下的卷组。逻辑卷在右边。
|
||||
|
||||
![Explore logical volumes in blivet-gui][5]
|
||||
|
||||
逻辑卷标签由卷组名称和逻辑卷名称组成。在本例中,卷组是 “fedora_localhost-live”,分配了 “home”、“root” 和 “swap” 逻辑卷。要找到完整的卷,选择每一个卷,点击_齿轮_图标,然后选择 _resize_。调整大小对话框中的滑块表示卷的允许大小。左边的最小值是文件系统中已经使用的空间,所以这是最小可能的体积大小(不删除数据)。右边的最大值是基于_卷组_中的最大可用空间。
|
||||
|
||||
![Resize dialog in blivet-gui][6]
|
||||
|
||||
灰色的 _resize_ 选项意味着该卷已经满了,而且卷组中没有可用空间。现在可以更改大小了!查看所有的卷,就像上面的截图那样,找到一个有足够空间的卷。并像上面的截图那样,在所有的卷中找到一个有大量额外空间的卷。向左移动滑块来设置新的大小。腾出足够的空间对整个卷有用,但仍然为未来的数据增长留出足够的空间。否则,这个卷将是下一个被填满的卷。
|
||||
|
||||
点击 _resize_,注意卷列表中出现了一个新项目:_空闲空间_。现在选择这次要调整的卷,并将滑块一直向右移动。按 _resize_ 键,并查看新改进的卷的布局。然而,硬盘驱动器上的任何东西都还没有改变。点击_勾选按钮_将更改提交到磁盘。
|
||||
|
||||
![Review changes in blivet-gui][7]
|
||||
|
||||
查看更改的摘要,如果一切看起来都是正确的,点击 _Ok_ 继续。等待 _blivet-gui_ 完成。现在重新启动回到 Fedora ,享受之前被充满的卷上的新空间。
|
||||
|
||||
### 为未来计划
|
||||
|
||||
要知道任何特定卷在未来需要多少空间是很困难的。与其立即分配所有可用的空闲空间,不如考虑在卷组中留出空闲空间。事实上,Fedora Server 默认在卷组中保留空间。当一个卷处于在线和使用中时,扩展卷是可能的。不需要 Live 镜像或重启。当一个卷几乎满的时候,可以使用部分可用空间轻松扩展卷并继续工作。遗憾的是,默认的磁盘管理器 _gnome-disks_ 不支持 LVM 卷的大小调整,所以安装 _[blivet-gui][8]_ 作为图形化管理工具。另外,还有一个简单的终端命令来扩展卷。
|
||||
|
||||
```
|
||||
lvresize -r -L +1G /dev/fedora_localhost-live/root
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
用 LVM 回收硬盘空间只是 LVM 功能的表面。大多数人,特别是在桌面中,可能不需要更高级的功能。然而,当需要的时候,LVM 就在那里,尽管它的实现可能会变得有点复杂。从 [Fedora 33][10] 开始,[BTRFS][9] 是默认的文件系统,没有 LVM。BTRFS 可以更容易管理,同时对于大多数常见的使用来说也足够灵活。查看最近 [Fedora Magazine 关于 BTRFS 的文章][11]了解更多。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/reclaim-hard-drive-space-with-lvm/
|
||||
|
||||
作者:[Troy Curtis Jr][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/troycurtisjr/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/lvm-resize-816x345.jpg
|
||||
[2]: http://sourceware.org/lvm2/
|
||||
[3]: https://getfedora.org/en/workstation/download/
|
||||
[4]: https://fedoramagazine.org/wp-content/uploads/2020/11/gnome-disks.png
|
||||
[5]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-overview.png
|
||||
[6]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-resize-1024x525.png
|
||||
[7]: https://fedoramagazine.org/wp-content/uploads/2020/11/blivet-summary-1024x525.png
|
||||
[8]: https://fedoraproject.org/wiki/Blivet-gui
|
||||
[9]: https://fedoramagazine.org/btrfs-coming-to-fedora-33/
|
||||
[10]: https://fedoramagazine.org/whats-new-fedora-33-workstation/
|
||||
[11]: https://fedoramagazine.org/btrfs-snapshots-backup-incremental/
|
Loading…
Reference in New Issue
Block a user