[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

LVM + USB drive

I'd like to set up a USB drive using LVM. Could someone knowledgable confirm that the following recipe should allow me to hot-plug the USB drive without rendering the LVM file-systems inaccessible?

Many thanks.

Recipe follows:

Set up:
#  (Actual number of partitions, etc., is not important here.)

# Assume attached disk is /dev/sdc and it has an extended partition #+ that covers that whole disk.

#  Prepare partitions for LVM (say, 2 partitions)
	$ parted /dev/sdc mkpart logical START1 END1
	$ parted /dev/sdc mkpart logical START2 END2
#  Create Physical Volumes
	$ pvcreate /dev/sdc1
	$ pvcreate /dev/sdc2
#  Identify the Physical Volumes' UUIDs
	$ blkid
#  Create Volume Groups using  PVs **UUIDs**
	$ vgcreate [options] myVG /dev/disk/by-uuid/UUID-OF-PART-1
	$ vgexted  [options] myVG /dev/disk/by-uuid/UUID-OF-PART-2
# From this point I can "forget" that I deal with a USB drive, and #+ continue the set up as with built in drives; right?


#  (Based on advice here:
#  http://blogs.sourceallies.com/2009/12/unplugging-an-lvm-partitioned-usb-drive/
#  )

#  Before unplugging
	$ umount /mnt/point/of/lvm
	$ lvchange -an /dev/myVG
	$ vgexport -a
#  After plugging-in
	$ vgimport -a
	$ lvchange -ay /dev/myVG
	$ mount [options] /mnt/point/of/lvm

# (Question: vgexport/import is needed if volume groups are identified # by UUID?)


Reply to: