CREATIVE CHAOS   ▋ blog

Snapshot on LVM

PUBLISHED ON 06/06/2017 — EDITED ON 01/10/2024 — SYSOPS

Quick and dirty.

Add disk.

Use the SCSI rediscovery trick if you can’t reboot the machine:

Check on which host the new drive is located:

   # grep mpt /sys/class/scsi_host/host?/proc_name
   /sys/class/scsi_host/host2/proc_name:mptspi
   # echo "- - -" > /sys/class/scsi_host/host2/scan

http://www.golinuxhub.com/2014/07/how-to-detect-new-hard-disk-attached.html

   # fdisk -l
   # fdisk /dev/sdb
   n
   p
   1
   enter
   enter
   t
   8e
   w
   
   # pvcreate /dev/sdb1
   
   # vgextend VM_Name /dev/sdb1
   
   # lvcreate -s -n snapshot -L 10G /dev/VM_Name/root
   
   # mkdir /mnt/snapshot
   
   # mount -o ro /dev/VM_Name/snapshot /mnt/snapshot

Do stuff if you screw up.

   # umount /mnt/snapshot
   
   # lvremove /dev/VM_Name/snapshot
   
   # pvmove /dev/sdb1
   
   # vgreduce VM_Name /dev/sdb1
TAGS: HACK, LINUX, LVM