Skip to content

Instantly share code, notes, and snippets.

@ekojs
Last active October 21, 2023 04:30
Show Gist options
  • Save ekojs/6a79fd571a50e9a151139ad1e4de5700 to your computer and use it in GitHub Desktop.
Save ekojs/6a79fd571a50e9a151139ad1e4de5700 to your computer and use it in GitHub Desktop.
Setup LVM Thin in Centos 8

Setup LUKS 2 in RHEL 9.2

Format block device

cryptsetup luksFormat /dev/sdX

Open Device

cryptsetup open /dev/sdX sdx_crypt

Close Device

cryptsetup close sdx_crypt

Verify and Check Status of Block Device

cryptsetup luksDump /dev/sdX
cryptsetup status sdx_crypt

Change LUKS 2 Passphrase

# Check Key Slot you want to change
cryptsetup luksDump /dev/sdX
# Verify the old passphrase
cryptsetup --verbose open --test-passphrase /dev/sdX
# Change passphrase
cryptsetup luksChangeKey /dev/sdX -S 0
# Verify the new passphrase
cryptsetup --verbose open --test-passphrase /dev/sdX

Setup LVM Thin in Centos 8

Check lvm disk scan

lvmdiskscan

List disk

lsblk

Create Physical Disk LVM

pvcreate /dev/sdb1

Create Volume Group

vgcreate data /dev/sdb1

Create Thin Volume

lvcreate -L 50G -T data/pool01

Create Logical Thin Volume

lvcreate -V50G -T vg001/pool01 -n mydata

Extend LVM Thin in Centos 8

Extend Volume Group

vgextend vgname /dev/sdb1

Extend Logical Thin Volume

lvextend -L+50G vg001/pool01

Extend Logical Volume

lvextend -L+50G /dev/vg/label

Extend XFS Filesystem

xfs_growfs /dev/vg/label

Check XFS Filesystem

xfs_info /dev/vg/label

Extend Ext4 Filesystem

resize2fs /dev/vg/label

Check Ext4 Filesystem

e2fsck /dev/vg/label

Setup LVM Raid in Centos 8

Create Raid 1 Logical Volume with 1 mirror and data integrity

lvcreate --type raid1 -m 1 --raidintegrity y -L 1G -n mylv1 myvg

Check Raid Status

lvs -a -o +raid_sync_action,raid_mismatch_count,devices,segtype vgname

Repair Raid Logical Volume

lvconvert --repair mvg/mylv1

Replace Failed Raid Logical Volume with new PV

lvconvert --repair mvg/mylv1 /dev/sdd1

Remove Failed device from VG

vgreduce --removemissing myvg

Checking Data Coherency from Raid LV

lvchange --syncaction check myvg/mylv1

Refresh from Failed Raid LV

lvchange --refresh myvg/mylv1

Verify LV with the recovered device

lvs -a -o name,devices,lv_attr,lv_health_status myvg

Remove Raid Integrity from Raid LV

lvconvert --raidintegrity n myvg/mylv1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment