Linux:LVM创建和删除

来自WHY42
Riguz留言 | 贡献2024年5月11日 (六) 07:11的版本

创建

pvcreate /dev/sda4
vgcreate vg-linux /dev/sda4 
vgdisolay vg-linux

lvcreate -L 10G vg-linux -n lv-home
lvcreate -L 10G vg-linux -n lv-root
lvcreate -l +100%FREE vg-linux -n lv-data

lvdisplay
lsblk

mkfs.ext4 /dev/vg-linux/lv-home
mkfs.ext4 /dev/vg-linux/lv-root
mkfs.ext4 /dev/vg-linux/lv-data

删除

lvchange -an /dev/vg-linux/lv-home
lvchange -an /dev/vg-linux/lv-root
lvchange -an /dev/vg-linux/lv-data
lvremove /dev/vg-linux/lv-home
lvremove /dev/vg-linux/lv-root
lvremove /dev/vg-linux/lv-data
vgremove /dev/vg-linux
pvremove /dev/sda4

Extend space

sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <928.46 GiB
  PE Size               4.00 MiB
  Total PE              237685
  Alloc PE / Size       25600 / 100.00 GiB
  Free  PE / Size       212085 / <828.46 GiB
  VG UUID               64593D-HLgd-bEGf-Fodu-dXjQ-5G6W-0QbGK4
sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                AcvIuI-xQ60-nddK-1T9Q-4hQq-V4Cw-H1rFpK
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2024-05-08 07:21:53 +0000
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv