lvm: support for dynamic LVM SNAPSHOT root volume
authorJames Laska <jlaska@redhat.com>
Wed, 22 Sep 2010 14:28:59 +0000 (16:28 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 22 Sep 2010 14:39:51 +0000 (16:39 +0200)
commitb2dff45423ec768f7ad6c4f85db99d5835941ee1
treef6a9759b695909fca56d3632abfde9fc4297e120
parent1f9de919e01c1563753f74d3f2fd6bac1aeac556
lvm: support for dynamic LVM SNAPSHOT root volume

I'm looking for a way to have a system with disposable storage that can be
rebooted and all filesystem changes are thrown away.  After reboot, the system
starts with a fresh root volume again.  The use case is for automated testing.
We run test scripts that could potentially not clean up after themselves.

This is almost like stateless, but the storage is local to the system (not
iSCSI, NFS or NBB).

1. Install Fedora 13 using default partition layout
  NOTE: modify the layout to leave extra room in the LVM volume group
2. Apply attached patch
3. Update grub.conf to enable dracut LVM snapshot support.  Add the following
boot arguments

 rd_LVM_SNAPSHOT=vg_test1055/lv_snap (note the VG name will depend on your
system).
 rd_LVM_SNAPSIZE= (optional, defaults to size of volume specified with by
rd_LVM_SNAPSHOT)

4. Adjust grub.conf and fstab to use LVM snapshot
 $ sed -i -e 's|lv_root|lv_snap|' /boot/grub/grub.conf
 $ sed -i -e 's|lv_root|lv_snap|' /etc/fstab
5. Reboot system

Expected results (no value provided for rd_LVM_SNAPSIZE):

  dracut: Starting plymouth daemon
  dracut: rd_NO_DM: removing DM RAID activation
  dracut: rd_NO_MD: removing MD RAID activation
  dracut: Removing existing LVM snapshot vg_test1055/lv_snap
  dracut: Logical volume "lv_snap" successfully removed
  dracut: No LVM snapshot size provided, using size of vg_test1055/lv_root (
9024.00m)
  dracut: Creating LVM snapshot vg_test1055/lv_snap  (  9024.00m)
  dracut: Logical volume "lv_snap" created
  dracut: Scanning devices sda2  for LVM logical volumes vg_test1055/lv_root
vg_test1055/lv_swap
  dracut: inactive Original '/dev/vg_test1055/lv_root' [8.81 GiB] inherit
  dracut: inactive '/dev/vg_test1055/lv_swap' [1.00 GiB] inherit
  dracut: inactive Snapshot '/dev/vg_test1055/lv_snap' [8.81 GiB] inherit
  dracut: Mounted root filesystem /dev/mapper/vg_test1055-lv_snap
  dracut: Loading SELinux policy
  dracut: Switching root

Expected results (rd_LVM_SNAPSIZE=100m):

  dracut: Starting plymouth daemon
  dracut: rd_NO_DM: removing DM RAID activation
  dracut: rd_NO_MD: removing MD RAID activation
  dracut: Removing existing LVM snapshot vg_test1055/lv_snap
  dracut: Logical volume "lv_snap" successfully removed
  dracut: Creating LVM snapshot vg_test1055/lv_snap  (100m )
  dracut: Rounding up size to full physical extent 128.00 MiB
  dracut: Logical volume "lv_snap" created
  dracut: Scanning devices sda2  for LVM logical volumes vg_test1055/lv_root
vg_test1055/lv_swap
  dracut: inactive Original '/dev/vg_test1055/lv_root' [8.81 GiB] inherit
  dracut: inactive '/dev/vg_test1055/lv_swap' [1.00 GiB] inherit
  dracut: inactive Snapshot '/dev/vg_test1055/lv_snap' [128.00 MiB] inherit
  dracut: Mounted root filesystem /dev/mapper/vg_test1055-lv_snap
  dracut: Loading SELinux policy
  dracut: Switching root
modules.d/90lvm/lvm_scan.sh