[Home] [Networking] [Crypto] [Linux kernel patches] [Userspace] [Docs] [CV/Resume] [Links]
Content: LVM online replace a hard drive; dynamic add/remove physical volumes Author: Catalin(ux) M BOIE URL: http://kernel.embedromix.ro/docs/ Version: 0.1 . Prepare "physical" volumes dd if=/dev/zero of=disk1.img bs=1M count=200 losetup /dev/loop1 disk1.img pvcreate /dev/loop1 pvdisplay /dev/loop1 vgcreate vg1 /dev/loop1 pvdisplay /dev/loop1 vgdisplay vg1 lvcreate --size 50MB --name test1 vg1 lvdisplay vg1 . Replace a hard drive, on-line dd if=/dev/zero of=disk2.img bs=1M count=200 losetup /dev/loop2 disk2.img pvcreate /dev/loop2 # extend vg1 with the new drive vgextend vg1 /dev/loop2 vgdisplay vg1 # migrate data from disk1 to disk2 pvmove [--verbose] /dev/loop1 /dev/loop2 # remove physical volume from volume group vgreduce --verbose vg1 /dev/loop1 # Remove old disk pvremove /dev/loop1 # Done! . Take a snapshot lvcreate --name snapshot1 --size 100M --snapshot vg1/test1 mount /dev/vg1/snapshot1 /mountpoint lvdisplay vg1 . Remove a snapshot lvremove vg1/snapshot1 . Resize a lv lvresize /dev/vg1/test2 -L newsize . Remove a logical volume lvremove vg1/test1 . Remove a volumegroup vgremove vg1 |