Notes by Peter Galonza(Пётр Галонза)
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

LVM

Physical volumes

View information about pv

pvs

Initialize physical volume

pvcreate /dev/sda

Move extents from one physical volume to another report progress and only the extents belonging to the named LV

pvmove -i 10 -n /dev/pv_name /dev/sda /dev/sdb

Resize physical volume

pvresize /dev/sda

Volume groups

View information about vg

vgs

Add physical volumes to a volume group

vgextend fg_name /dev/sda

Display volume group information

vgdisplay vg_name -v

Remove physical volume

vgreduce fg_name /dev/sda

Create a volume group

vgcreate vg_name /dev/sda

Logical volumes

Create a logical volume

lvcreate -l 100%FREE -n lv_name vg_name

View information about lv

lvs
lvs -a -o+devices

Add space to a logical volume

lvextend -l +50%FREE /dev/vg_name/lv_name
lvextend -l +100%FREE /dev/vg_name/lv_name

Resize LVM

Add new disk

Connect to disk

fdisk /dev/sdX

Create the partition

: n

Type primary

: p

Type of partition

:t : 8e

Write changes

: w

Update info about size

partprobe

Create the volume

pvcreate /dev/sdXX

Add to volume group

vgdisplay
vgextend volume_group /dev/sdXX

Expend the space

lvdisplay
lvextend -l +100%FREE /dev/volume_group/logical_volume

Resize the volume group

resize2fs /dev/volume_group/logical_volume

Extend

Resize

(parted) resizepart

Resize physical volume

pvresize /dev/sdX

Expend the space

lvextend -l +100%FREE /dev/volume_group/logical_volume

Resize the volume group

resize2fs /dev/volume_group/logical_volume

Move partition on new disk

Create similar partitions on a new disk

fdisk
parted

Copy the boot partition

dd if=/dev/sdX1 of=/dev/sdX1

Create the volume

pvcreate /dev/sdbx

Add to volume group

vgextend volume_group /dev/sdX

Move the partition

pvmove /dev/sdax /dev/sdbX

Remove from volume group

vgreduce volume_group-vg /dev/sdXX

Remove from lvm

premove /dev/sdXX

Install the grub2

grub-install --target=x86_64-efi /dev/sdX

Expend the space

lvdisplay
lvextend -l +100%FREE /dev/volume_group/logical_volume

Resize the volume group

resize2fs /dev/volume_group/logical_volume