Difference between revisions of "Logical Volume Manager (Linux)"
Jump to navigation
Jump to search
(→See also: * <code>lvmcheck</code>) |
|||
(26 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | [[ | + | Logical Volume Manager ([[wikipedia:Logical_Volume_Manager_(Linux)|LVM]])<ref>http://man7.org/linux/man-pages/man8/lvm.8.html</ref> available in Linux allows manage multiple physical volumes or entire hard disks. It supports among other functionalities: |
* Create single logical volumes of multiple physical volumes or entire hard disks | * Create single logical volumes of multiple physical volumes or entire hard disks | ||
* Add or remove volumes/disk dynamically | * Add or remove volumes/disk dynamically | ||
Line 5: | Line 5: | ||
* Create snapshots | * Create snapshots | ||
− | LVM introduces the concept of Volume | + | LVM introduces the concept of [[Volume Group]]s (VGs) and [[Logical Volume]]s (LVs). |
− | Configuration file: <code>/etc/lvm/[[lvm.conf]]</code> | + | * Configuration file: <code>/etc/lvm/[[lvm.conf]]</code> |
+ | |||
+ | == Components == | ||
+ | * <code>[[lvmetad]]</code> [[LVM]] metadata cache daemon | ||
== Basic commands == | == Basic commands == | ||
− | * List Volume Groups:<code>[[ | + | * List Volume Groups:<code>[[vgs]]</code><ref>http://man7.org/linux/man-pages/man8/vgs.8.html</ref> |
** <code>[[vgscan]]</code>, <code>[[vgextend]]</code>, <code>[[vgdisplay]]</code> | ** <code>[[vgscan]]</code>, <code>[[vgextend]]</code>, <code>[[vgdisplay]]</code> | ||
− | * List logical volumes: <code>[[ | + | * List logical volumes: <code>[[lvs]]</code><ref>http://man7.org/linux/man-pages/man8/lvs.8.html</ref>, [[lvdisplay]] |
* Resize LV: | * Resize LV: | ||
** <code>[[lvresize]]</code> | ** <code>[[lvresize]]</code> | ||
Line 23: | Line 26: | ||
::<code>[[lvdisplay]]</code> | ::<code>[[lvdisplay]]</code> | ||
::<code>[[vgdisplay]]</code> | ::<code>[[vgdisplay]]</code> | ||
+ | |||
* Create commands: | * Create commands: | ||
::<code>[[pvcreate]]</code><ref>http://man7.org/linux/man-pages/man8/pvcreate.8.html</ref> | ::<code>[[pvcreate]]</code><ref>http://man7.org/linux/man-pages/man8/pvcreate.8.html</ref> | ||
::<code>[[lvcreate]]</code><ref>http://man7.org/linux/man-pages/man8/lvcreate.8.html</ref> | ::<code>[[lvcreate]]</code><ref>http://man7.org/linux/man-pages/man8/lvcreate.8.html</ref> | ||
::<code>[[vgcreate]]</code> | ::<code>[[vgcreate]]</code> | ||
+ | ::<code>[[vgreduce]]</code> | ||
+ | |||
* Ls commands: <code>[[pvs]]</code>, <code>[[lvs]]</code><ref>http://man7.org/linux/man-pages/man8/lvs.8.html</ref>, <code>[[vgs]]</code> | * Ls commands: <code>[[pvs]]</code>, <code>[[lvs]]</code><ref>http://man7.org/linux/man-pages/man8/lvs.8.html</ref>, <code>[[vgs]]</code> | ||
− | * Scan commands: <code>[[ | + | * Scan commands: <code>[[pvscan]]</code><ref>http://man7.org/linux/man-pages/man8/pvscan.8.html</ref>, <code>[[vgscan]]</code> |
− | * PV commands: <code>[[ | + | * PV commands: <code>[[pvdisplay]]</code><ref>http://man7.org/linux/man-pages/man8/pvdisplay.8.html</ref>, <code>pvresize</code>, <code>[[pvscan]]</code>, <code>[[pvcreate]]</code> or <code>[[pvcreate]] -vv</code> |
− | * LV commands: <code>[[ | + | * LV commands: <code>[[lvcreate]]</code><ref>http://man7.org/linux/man-pages/man8/lvcreate.8.html</ref>, [[lvconvert]] |
− | * VG commands: <code>[[ | + | * VG commands: <code>[[vgdisplay]]</code>, <code>[[vgcreate]]</code>, <code>[[vgcfgbackup]]</code>, <code>[[vgscan]]</code> |
− | * LVM commands: <code>lvm dumpconfig</code> | + | * LVM commands: <code>[[lvm dumpconfig]]</code> |
=== Advanced commands === | === Advanced commands === | ||
* <code>lvchange</code><ref>http://man7.org/linux/man-pages/man8/lvchange.8.html</ref> — Change attributes of the Logical Volume Manager. | * <code>lvchange</code><ref>http://man7.org/linux/man-pages/man8/lvchange.8.html</ref> — Change attributes of the Logical Volume Manager. | ||
− | * <code>lvmdiskscan</code> | + | * <code>[[lvmdiskscan]]</code>. Deprecated: used <code>[[pvs]]</code>. Scan for all devices visible to LVM2. |
− | * <code>lvmdump</code> — Create lvm2 information dumps for diagnostic purposes. | + | * <code>[[lvmdump]]</code> — Create lvm2 information dumps for diagnostic purposes. |
== Activities == | == Activities == | ||
=== Basic === | === Basic === | ||
# Read StackOverflow LVMs questions: https://superuser.com/questions/tagged/lvm?tab=Votes | # Read StackOverflow LVMs questions: https://superuser.com/questions/tagged/lvm?tab=Votes | ||
+ | # Read Configuring and Managing Logical Volumens in [[RHEL 8]]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_logical_volumes/index | ||
# Configure an [[Linux Administration/Devices and Filesystems/LVM|LVM]] Volume with an ext File Sytem: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/high_availability_add-on_administration/s1-lvmsetupnfs-haaa | # Configure an [[Linux Administration/Devices and Filesystems/LVM|LVM]] Volume with an ext File Sytem: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/high_availability_add-on_administration/s1-lvmsetupnfs-haaa | ||
Line 47: | Line 54: | ||
Before doing these exercises make your you have a backup of your data. | Before doing these exercises make your you have a backup of your data. | ||
# Convert a Linear Device to a [[RAID]] device: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_logical_volumes/index#proc_converting-linear-to-raid-configure-manage-raid | # Convert a Linear Device to a [[RAID]] device: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_logical_volumes/index#proc_converting-linear-to-raid-configure-manage-raid | ||
+ | # Read LVM [[Changelog]]: sourceware.org/git/?p=lvm2.git;a=blame;f=WHATS_NEW;hb=9cad26be321844868a904c7b07bebe37be4e0169 | ||
== See also == | == See also == | ||
+ | * {{LVM}} | ||
* [[linux/mdadm|mdadm]] and [[Linux Administration/Devices and Filesystems/ZFS|ZFS]] | * [[linux/mdadm|mdadm]] and [[Linux Administration/Devices and Filesystems/ZFS|ZFS]] | ||
− | * resize2fs<ref>https://manpages.debian.org/stretch/e2fsprogs/resize2fs.8.en.html</ref> file system resizer for ext2/ext3/ext4 (resize2fs /dev/mapper/VolGroup-lv_root) (for ext4 only).<ref>https://www.technomenace.com/2014/08/how-to-extend-lvm-on-qcow2-images/</ref>. Code: https://github.com/tytso/e2fsprogs/blob/master/resize/resize2fs.c | + | * [[resize2fs]]<ref>https://manpages.debian.org/stretch/e2fsprogs/resize2fs.8.en.html</ref> file system resizer for ext2/ext3/ext4 (resize2fs /dev/mapper/VolGroup-lv_root) (for ext4 only).<ref>https://www.technomenace.com/2014/08/how-to-extend-lvm-on-qcow2-images/</ref>. Code: https://github.com/tytso/e2fsprogs/blob/master/resize/resize2fs.c |
− | * [[ | + | * [[Ansible]] LV module: https://docs.ansible.com/ansible/latest/modules/lvol_module.html#lvol-module |
− | + | * {{dmsetup}} | |
− | * | + | * [[UUID]] |
− | * | + | * {{kpartx}} |
Latest revision as of 10:05, 20 September 2020
Logical Volume Manager (LVM)[1] available in Linux allows manage multiple physical volumes or entire hard disks. It supports among other functionalities:
- Create single logical volumes of multiple physical volumes or entire hard disks
- Add or remove volumes/disk dynamically
- Increase or decrease size of Logical Volumes (LVs)
- Create snapshots
LVM introduces the concept of Volume Groups (VGs) and Logical Volumes (LVs).
- Configuration file:
/etc/lvm/lvm.conf
Contents
Components[edit]
Basic commands[edit]
- Display commands:
- Create commands:
- Ls commands:
pvs
,lvs
[7],vgs
- Scan commands:
pvscan
[8],vgscan
- PV commands:
pvdisplay
[9],pvresize
,pvscan
,pvcreate
orpvcreate -vv
- LV commands:
lvcreate
[10], lvconvert - VG commands:
vgdisplay
,vgcreate
,vgcfgbackup
,vgscan
- LVM commands:
lvm dumpconfig
Advanced commands[edit]
lvchange
[11] — Change attributes of the Logical Volume Manager.lvmdiskscan
. Deprecated: usedpvs
. Scan for all devices visible to LVM2.lvmdump
— Create lvm2 information dumps for diagnostic purposes.
Activities[edit]
Basic[edit]
- Read StackOverflow LVMs questions: https://superuser.com/questions/tagged/lvm?tab=Votes
- Read Configuring and Managing Logical Volumens in RHEL 8: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_logical_volumes/index
- Configure an LVM Volume with an ext File Sytem: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/high_availability_add-on_administration/s1-lvmsetupnfs-haaa
Advanced[edit]
Before doing these exercises make your you have a backup of your data.
- Convert a Linear Device to a RAID device: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_logical_volumes/index#proc_converting-linear-to-raid-configure-manage-raid
- Read LVM Changelog: sourceware.org/git/?p=lvm2.git;a=blame;f=WHATS_NEW;hb=9cad26be321844868a904c7b07bebe37be4e0169
See also[edit]
- scan:
pvscan
vgscan
- LVM:
lvs
lvmscan
lvm fullreport
lvmreport
lvmconfig
lvmdump
lvmcheck
lvm dumpconfig
- Scan:
pvs
vgs
lvs
pvscan
vgscan
- PV:
pvcreate
pvremove
pvscan
pvremove
pvscan
pvs
pvchange
pvck
pvdisplay
pvresize
- LV:
lvdisplay
lvcreate
lvremove
,lvresize
,lvextend
,lvreduce
,lvrename
- VG:
vgdisplay
,vgcreate
,vgremove
,vgextend
,vgreduce
,vgscan
,vgchange
,vgrename
,vgcfgbackup
,vgcfgrestore
,vgimportclone
,vgck
- Check commands:
pvck
vgck
- mdadm and ZFS
- resize2fs[12] file system resizer for ext2/ext3/ext4 (resize2fs /dev/mapper/VolGroup-lv_root) (for ext4 only).[13]. Code: https://github.com/tytso/e2fsprogs/blob/master/resize/resize2fs.c
- Ansible LV module: https://docs.ansible.com/ansible/latest/modules/lvol_module.html#lvol-module
- Device mapper:
dmsetup
,dmsetup ls
, LVM,/dev/mapper/
,vgcreate
- UUID
kpartx
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.
Original Source: https://en.wikiversity.org/wiki/Linux_Administration/Devices_and_Filesystems/LVM
- ↑ http://man7.org/linux/man-pages/man8/lvm.8.html
- ↑ http://man7.org/linux/man-pages/man8/vgs.8.html
- ↑ http://man7.org/linux/man-pages/man8/lvs.8.html
- ↑ http://man7.org/linux/man-pages/man8/pvdisplay.8.html
- ↑ http://man7.org/linux/man-pages/man8/pvcreate.8.html
- ↑ http://man7.org/linux/man-pages/man8/lvcreate.8.html
- ↑ http://man7.org/linux/man-pages/man8/lvs.8.html
- ↑ http://man7.org/linux/man-pages/man8/pvscan.8.html
- ↑ http://man7.org/linux/man-pages/man8/pvdisplay.8.html
- ↑ http://man7.org/linux/man-pages/man8/lvcreate.8.html
- ↑ http://man7.org/linux/man-pages/man8/lvchange.8.html
- ↑ https://manpages.debian.org/stretch/e2fsprogs/resize2fs.8.en.html
- ↑ https://www.technomenace.com/2014/08/how-to-extend-lvm-on-qcow2-images/
Advertising: