LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to create physical volume using UUIDs? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-physical-volume-using-uuids-4175581229/)

fanoflq 06-01-2016 08:23 PM

How to create physical volume using UUIDs?
 
Code:

[user1@localhost dev]$ blkid
/dev/block/8:2: UUID="9GDPNw-xTSk-1eAL-ykft-fpli-0sJf-5fUIzg" TYPE="LVM2_member"
/dev/block/253:0: UUID="07331e84-c8cd-480c-ae26-4bddcc469d52" TYPE="xfs"
/dev/block/8:1: UUID="d3d5cb23-fcdf-4bb5-8336-83f1c6fea777" TYPE="xfs"
/dev/block/253:1: UUID="158845f7-2af5-417f-b09b-f3ee465fd097" TYPE="swap"
/dev/sr0: UUID="2016-03-04-16-45-10-00" LABEL="VBOXADDITIONS_5.0.16_105871" TYPE="iso9660"
/dev/sda5: UUID="8aa209c9-8550-4e76-9d1c-878fc6f5b160" TYPE="ext4"
/dev/sda7: UUID="359a9846-9ffb-4fa6-aae4-62c1ec3348e9" TYPE="swap"
/dev/sda8: UUID="4fef6531-858f-47e8-ba20-89b01e824696" TYPE="ext4"
/dev/sda6: UUID="4b87b251-652b-4966-9f60-e487487cc411" TYPE="ext4"

[user1@localhost dev]$ sudo pvdisplay
[sudo] password for user1:
  --- Physical volume ---
  PV Name              /dev/sda2
  VG Name              centos
  PV Size              10.21 GiB / not usable 3.00 MiB
  Allocatable          yes
  PE Size              4.00 MiB
  Total PE              2612
  Free PE              1
  Allocated PE          2611
  PV UUID              9GDPNw-xTSk-1eAL-ykft-fpli-0sJf-5fUIzg

Create physical volume, pv1, using UUID for /dev/sda5:
Code:

[user1@localhost dev]$ sudo pvcreate --norestorefile -u 8aa209c9-8550-4e76-9d1c-878fc6f5b160 pv1
  Device pv1 not found (or ignored by filtering).

[user1@localhost dev]$ sudo pvcreate --norestorefile -u 8aa209c9-8550-4e76-9d1c-878fc6f5b160
  Can only set uuid on one volume at once
  Run `pvcreate --help' for more information.

Not able to create pv1.
What did I missed?
Thanks.

sundialsvcs 06-01-2016 08:31 PM

Well, I don't do this too much, but it certainly appears that you're trying to assign the same UUID to two volumes.

Every volume must have a unique UUID. While you can use the -u option to specify the UUID that is to be assigned, instead of letting pvcreate coin one for you at random, the ID that is finally assigned must be unique. It must refer to one, and only one, volume.

You do not need to specify a UUID unless you particularly want to ...

michaelk 06-01-2016 08:59 PM

You need to specify the physical device i.e.
Code:

sudo pvcreate --norestorefile -u 8aa209c9-8550-4e76-9d1c-878fc6f5b160 /dev/sda5
pvcreate will automatically generate a random UUID. I see no reason why the existing uuid can not be reused. You might want to change the partition ID to LVM for /dev/sda5.

Backup any existing data on sda5 if necessary.

fanoflq 06-01-2016 10:53 PM

I misunderstood the purpose of UUID in the command line.
I thought if I specify the UUID of the physical device, then pvcreate will
look for the physical device and label it a physical volume.

Instead, it is using the UUID provided in the command line as the new UUID
for the newly created physical volume.

Addendum:
UUID for physical volume can be the same as its associated physical device.

Thanks.

rknichols 06-01-2016 11:01 PM

Quote:

Originally Posted by fanoflq (Post 5554348)
UUID for physical volume can be the same as its associated physical device.

"Can be" in the sense that nothing checks whether you are doing that. That doesn't change the fact that it's a really bad idea.


All times are GMT -5. The time now is 08:20 AM.