LVM: Difference between revisions

From 太極
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
= Resource =
* [http://www.linuxjournal.com/content/lvm-demystified LVM Demystified]
* [http://www.linuxjournal.com/content/lvm-demystified LVM Demystified]
* [https://www.itzgeek.com/post/how-to-install-ubuntu-20-04-lts/ How To Install Ubuntu 20.04 LTS (Focal Fossa) On UEFI and Legacy BIOS System]
* [https://www.itzgeek.com/post/how-to-install-ubuntu-20-04-lts/ How To Install Ubuntu 20.04 LTS (Focal Fossa) On UEFI and Legacy BIOS System]
Line 7: Line 9:
* [https://www.answertopia.com/ubuntu/adding-a-new-disk-to-an-ubuntu-volume-group-and-logical-volume/ Adding a New Disk to an Ubuntu 20.04 Volume Group and Logical Volume]
* [https://www.answertopia.com/ubuntu/adding-a-new-disk-to-an-ubuntu-volume-group-and-logical-volume/ Adding a New Disk to an Ubuntu 20.04 Volume Group and Logical Volume]
* [https://www.makeuseof.com/how-to-set-up-flexible-file-system-storage-with-lvm-in-linux/ How to Set Up Flexible File System Storage With LVM in Linux]
* [https://www.makeuseof.com/how-to-set-up-flexible-file-system-storage-with-lvm-in-linux/ How to Set Up Flexible File System Storage With LVM in Linux]
* '''LVM Layout''' & [https://manjaro.site/arch-linux-tutorial-configure-lvm-arch-linux-2017/ Arch Linux Tutorial – Configure LVM on Arch Linux 2017]
 
= Some examples =
<ul>
<li>[https://www.smarthomebeginner.com/setup-lvm-pool-hard-drive-ubuntu/ Setup LVM and pool hard drives in Ubuntu or Kodibuntu]
<syntaxhighlight lang='bash'>
# Step 1 Find your drive names
# lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
NAME        FSTYPE        SIZE MOUNTPOINT  LABEL
sda                      223.6G             
├─sda1                    1007K             
├─sda2      vfat          512M /boot/efi   
└─sda3      LVM2_member 223.1G             
  ├─pve-swap swap            8G [SWAP]     
  └─pve-root ext4        215.1G /           
nvme0n1                  465.8G             
└─nvme0n1p1  ext4        465.8G /mnt/pve/vm1
 
# Step 2 Format your drives
fdisk /dev/sdX
 
# Step 3 Create physical volume
pvcreate /dev/sd[bcd]
pvdisplay
 
# Step 4 Adding the VG (Volume Group) to the LVM
vgcreate {VG_NAME} /dev/sd[bcd]
vgdisplay
 
# Step 5 Adding the LV (Logical Volume) to the LVM VG (Volume Group)
lvcreate -l 100%FREE -n {LV_NAME} {VG_NAME}
lvdisplay
 
# Step 6 FORMATTING OUR NEW LVM LV (LOGICAL VOLUME)
mkfs.ext4 {LV_PATH}
 
# Step 7 MOUNT LVM LV (LOGICAL VOLUME) ON BOOT
blkid
# Grab the UUID of your storage space,
# it will be after the /dev/mapper/{VG_NAME}-{LV_NAME}
nano /etc/fstab
mount -a
 
# Step 8 ENABLE SMART DRIVE MONITORING
nano /etc/defaults/smartmontools
nano /etc/smartd.conf
</syntaxhighlight>
</li>
<li>
'''LVM Layout''' & [https://manjaro.site/arch-linux-tutorial-configure-lvm-arch-linux-2017/ Arch Linux Tutorial – Configure LVM on Arch Linux 2017]
<syntaxhighlight lang='bash'>
# Step 0 See available physical disks
fdisk
 
# Step 1 Create new Physical Volume
pvcreate /dev/vdb
pvcreate /dev/vdc
pvdisplay
 
# Step 2 Create new Volume Group (VG)
vgcreate archVG /dev/vdb /dev/vdc
vgdisplay
 
# Step 3 Logical Volume
lvcreate -L 5G archVG -n archLV01
lvcreate -L 15G archVG -n archLV02
lvdisplay
lsblk
 
# Step 4 Format the new volume
mkfs.ext4 /dev/mapper/archVG-archLV01
 
# Step 5 Mount
mount /dev/mapper/archVG-archLV01 /mnt
</syntaxhighlight>
</li>
<li>[https://manjaro.site/how-to-extend-lvm-disk-on-ubuntu-20-04/ How to Extend LVM Disk on Ubuntu 20.04]
<syntaxhighlight lang='bash'>
# Step 1. Check the file system list
sudo df -h /home/
 
# Step 2. Check the Physical Volume (pv)
sudo pvs
sudo vgdisplay
sudo lvdisplay
 
# Step 3. Create a New Physical Volume
sudo fdisk -l
sudo lvmdiskscan
sudo pvcreate /dev/sdb
sudo lvmdiskscan -l
 
# Step 4. Add the new Physical Volume (pv) to Existing Logical Volume (lv)
sudo vgextend ubuntu-vg /dev/sdb
sudo lvm lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
 
sudo resize2fs -p /dev/mapper/ubuntu--vg-ubuntu--lv
sudo df -h
</syntaxhighlight>
</li>
<li>[https://manjaro.site/add-new-disk-existing-volume-group/ How to add new disk to existing Volume Group]
<syntaxhighlight lang='bash'>
# Step 1 Create Physical Volume
pvcreate /dev/vdc
 
# Step 2 Add Physical Volume to Existing Volume Group
vgdisplay
vgextend manjaro_lvm /dev/vdc
vgdisplay
</syntaxhighlight>
</li>
</ul>

Revision as of 19:49, 21 February 2022

Resource

Some examples

  • Setup LVM and pool hard drives in Ubuntu or Kodibuntu
    # Step 1 Find your drive names
    # lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
    NAME         FSTYPE        SIZE MOUNTPOINT   LABEL
    sda                      223.6G              
    ├─sda1                    1007K              
    ├─sda2       vfat          512M /boot/efi    
    └─sda3       LVM2_member 223.1G              
      ├─pve-swap swap            8G [SWAP]       
      └─pve-root ext4        215.1G /            
    nvme0n1                  465.8G              
    └─nvme0n1p1  ext4        465.8G /mnt/pve/vm1 
    
    # Step 2 Format your drives
    fdisk /dev/sdX
    
    # Step 3 Create physical volume
    pvcreate /dev/sd[bcd]
    pvdisplay
    
    # Step 4 Adding the VG (Volume Group) to the LVM
    vgcreate {VG_NAME} /dev/sd[bcd]
    vgdisplay
    
    # Step 5 Adding the LV (Logical Volume) to the LVM VG (Volume Group)
    lvcreate -l 100%FREE -n {LV_NAME} {VG_NAME}
    lvdisplay
    
    # Step 6 FORMATTING OUR NEW LVM LV (LOGICAL VOLUME)
    mkfs.ext4 {LV_PATH}
    
    # Step 7 MOUNT LVM LV (LOGICAL VOLUME) ON BOOT
    blkid
    # Grab the UUID of your storage space, 
    # it will be after the /dev/mapper/{VG_NAME}-{LV_NAME}
    nano /etc/fstab
    mount -a
    
    # Step 8 ENABLE SMART DRIVE MONITORING
    nano /etc/defaults/smartmontools
    nano /etc/smartd.conf
  • LVM Layout & Arch Linux Tutorial – Configure LVM on Arch Linux 2017
    # Step 0 See available physical disks
    fdisk
    
    # Step 1 Create new Physical Volume
    pvcreate /dev/vdb
    pvcreate /dev/vdc
    pvdisplay 
    
    # Step 2 Create new Volume Group (VG)
    vgcreate archVG /dev/vdb /dev/vdc
    vgdisplay
    
    # Step 3 Logical Volume
    lvcreate -L 5G archVG -n archLV01
    lvcreate -L 15G archVG -n archLV02
    lvdisplay
    lsblk 
    
    # Step 4 Format the new volume
    mkfs.ext4 /dev/mapper/archVG-archLV01
    
    # Step 5 Mount
    mount /dev/mapper/archVG-archLV01 /mnt
  • How to Extend LVM Disk on Ubuntu 20.04
    # Step 1. Check the file system list
    sudo df -h /home/
    
    # Step 2. Check the Physical Volume (pv)
    sudo pvs
    sudo vgdisplay
    sudo lvdisplay
    
    # Step 3. Create a New Physical Volume
    sudo fdisk -l
    sudo lvmdiskscan
    sudo pvcreate /dev/sdb
    sudo lvmdiskscan -l
    
    # Step 4. Add the new Physical Volume (pv) to Existing Logical Volume (lv)
    sudo vgextend ubuntu-vg /dev/sdb
    sudo lvm lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
    
    sudo resize2fs -p /dev/mapper/ubuntu--vg-ubuntu--lv
    sudo df -h
  • How to add new disk to existing Volume Group
    # Step 1 Create Physical Volume
    pvcreate /dev/vdc
    
    # Step 2 Add Physical Volume to Existing Volume Group
    vgdisplay
    vgextend manjaro_lvm /dev/vdc
    vgdisplay