LVM NotesΒΆ

Existing volume Group:

|  pvcreate - pvremove  A
|  vgcreate - vgremove  |
|  vgextend - vgreduce  |
V  lvcreate - lvremove  |

Clone an LV:

#!/bin/bash
# Usage: ./clone_lv SOURCE TARGET_VG TARGET_LV_NAME
set -euo pipefail

src=$1
dest_vg=$2
dest_name=$3

target=/dev/${dest_vg}/${dest_name}
# make sure target does not exist, because dd is destructive :>
[[ ! -f $target ]]

bytes=$(lvs --noheadings --units b -o seg_size $src | awk '{ print $1 }')

lvcreate --name $dest_name --size $bytes $dest_vg
time dd if=$src of=$target bs=4M