Does pvcreate /dev/sdb write any metadata to /dev/sdb? if so what is written?
If you pass a -vv
flag to the pvcreate
command it makes the command more verbose and you will see that pvcreate creates a metadata area on the disk.
Writing physical volume data to disk "/dev/sdc1"
lvmcache: /dev/sdc1: now in VG #orphans_lvm2 (#orphans_lvm2) with 0 mdas
Creating metadata area on /dev/sdc1 at sector 8 size 2040 sectors
Opened /dev/sdc1 RW O_DIRECT
/dev/sdc1: block size is 1024 bytes
/dev/sdc1: physical block size is 512 bytes
/dev/sdc1: Preparing PV label header xxx.xxxxx.xxxxxxxxxxxxxxx
/dev/sdc1: Writing label to sector 1 with stored offset 32.
What is written to the metadata area?
I am not aware of a command that you can use to view the metadata, but the command vgcfgbackup
can be used to backup the metadata and you can open a backup file thus created to view the metadata
vgcfgbackup -f /path/of/your/choice/file <your_vg_name>
The /path/of/your/choice/file
created by the above command will contain the PV, VG and LVM metadata. One of the sections will look like below:
physical_volumes {
pv0 {
id = "abCDe-TuvwX-DEfgh-daEb-Xys-6Efcgh-LkmNo"
device = "/dev/sdc1" # Hint only
status = ["ALLOCATABLE"]
flags = []
dev_size = 10477194 # 4.99592 Gigabytes
pe_start = 2048
pe_count = 1278 # 4.99219 Gigabytes
}
}
I suggest you take a look at the contents of the directory /etc/lvm
and the output of the command lvm dumpconfig
Suppose I have machine with 2 disks configured into a logical volume can I just take those disks out the machine and put them in another machine and expect that the logical volume will work in the new machine?
Yes, you can.
You can migrate Volume Groups to another host. Though its not exactly plug-and-play, the procedure to do this is pretty straight-forward. There are dozens of tutorials available online how to do this.
This serverfault thread discusses about moving an LVM partition to another host using the dd
command.