+#----------------------------------------------------------------------
+# De-activate all volume groups and switch to new dm-only LVM config.
+log deactivating volume groups
+
+vgchange -a n
+mv /etc/lvm/lvm.conf /etc/lvm/lvm.conf.old
+mv /etc/lvm/lvm.conf.new /etc/lvm/lvm.conf
+rm -f /etc/lvm/cache/.cache
+
+# Snapshot the block devices.
+for d in $devices_to_send; do
+ snap_name $d
+ log snapshotting block device /dev/$d to $dname ...
+
+ snapshot $d $dname
+
+ # The block devices are whole disks. Use kpartx to repartition them.
+ log running kpartx -a /dev/mapper/$dname ...
+ kpartx -a /dev/mapper/$dname
+done
+
+# Rescan for LVs.
+log running vgscan
+vgscan
+vgchange -a y
+
+# Mount the root filesystem on /mnt/root. If it's a physical
+# device then we want to mount (eg) /dev/mapper/snap_sda2.
+# If it's a LVM device then we can just mount the LVM partition.
+
+log mount $root_filesystem as /mnt/root
+
+snap_name $root_filesystem
+root_filesystem_dname="$dname"
+
+if [ -b /dev/mapper/$root_filesystem_dname ]; then
+ mount /dev/mapper/$root_filesystem_dname /mnt/root
+else
+ mount /dev/$root_filesystem /mnt/root
+fi
+
+#----------------------------------------------------------------------