Ask Your Question
0

unable to add physical volume

asked 2014-11-14 04:22:37 -0600

Chutki gravatar image

Hi,

I want to create physical volume. Below is my code

    class lvm::crelvm {

   physical_volume { '/dev/sdb2':
      ensure    => present
    }

     volume_group { 'vg_cas':
         ensure  => present,
         physical_volumes  => '/dev/sdb2',
        }

  }

But I am getting the below error

Error: Execution of '/sbin/pvcreate /dev/sdb2' returned 5: Device /dev/sdb2 not found (or ignored by filtering).
Error: /Stage[main]/Lvm::Crelvm/Physical_volume[/dev/sdb2]/ensure: change from absent to present failed: Execution of '/sbin/pvcreate /dev/sdb2' returned 5: Device /dev/sdb2 not found (or ignored by filtering).
Error: Execution of '/sbin/vgcreate vg_cas /dev/sdb2' returned 5: Physical volume /dev/sdb2 not found
  Device /dev/sdb2 not found (or ignored by filtering).
  Unable to add physical volume '/dev/sdb2' to volume group 'vg_cas'.
Error: /Stage[main]/Lvm::Crelvm/Volume_group[vg_cas]/ensure: change from absent to present failed: Execution of '/sbin/vgcreate vg_cas /dev/sdb2' returned 5: Physical volume /dev/sdb2 not found
  Device /dev/sdb2 not found (or ignored by filtering).
  Unable to add physical volume '/dev/sdb2' to volume group 'vg_cas'.

Already '/dev/sdb1' was created and volume group also created under /dev/sdb1/vg03'

So I changed my code like blow

class lvm::crelvm {

  volume_group { 'vg_cas':
     ensure  => present,
     physical_volumes  => '/dev/sdb1',
    }

When I compile, I get

Error: Execution of '/sbin/vgcreate vg_cas /dev/sdb1' returned 5: Physical volume '/dev/sdb1' is already in volume group 'vg03'
  Unable to add physical volume '/dev/sdb1' to volume group 'vg_cas'.

So how can I create new physical volume and add vg_cas volume group on this.

I am newbie to puppet and unix admin.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-11-16 15:26:58 -0600

Stefan gravatar image

In LVM (logical volume manager) you have three different objects:

  1. a physical volume that in most cases represents real disks, e.g. /dev/sdb1
  2. a volume group that can be seen as a storage pool and is build off one ore more physical volumes
  3. a logical volume that you finally mount. You can create one or more logical volumes off a volume group and you can easily change the size of logical volumes. The data that you write on the logical volume can end up on any physical volume of that volume group

The puppet_lvm module lets you treat all objects as puppet resources, so let's walk through the error messages:

physical_volume { '/dev/sdb2':
  ensure    => present
}

Error: Execution of '/sbin/pvcreate /dev/sdb2' returned 5: Device /dev/sdb2 not found (or ignored by filtering).

The physical_volume makes sure that an actual volume can be used by LVM and the pvcreate command writes the proper LVM metadata on the device. Puppet can of course not magically install a new phyiscal disk in your server so you the device has to exist beforehand. It looks like you do not have a /dev/sdb2. Changing your code to /dev/sdb1 should work and should reproduce no action because according to your second message there is a disk /dev/sdb1 and it is already used by LVM, so the desired state matches the current state.

volume_group { 'vg_cas':
  ensure  => present,
  physical_volumes  => '/dev/sdb1',
}

Error: Execution of '/sbin/vgcreate vg_cas /dev/sdb1' returned 5: Physical volume '/dev/sdb1' is already in volume group 'vg03'

With the puppet manifest you want to make sure that a volume group vg_cas is present. Because this does not seem to be the case, puppet tries to create the volume group. But the physical volume /dev/sdb1 is already a member of a different volume group, so your desired state cannot be archived. You'd have to manually remove the volume group vg03 before to be able to assign the /dev/sdb1 device to your new volume group.

So if you want to express in puppet what's already on the server you can write:

physical_volume { '/dev/sdb1':
  ensure => present
}

volume_group { 'vg03':
  ensure            => present,
  physical_volumes  => '/dev/sdb1',
}

If you want to have a second volume group (your initial manifest) you have to make sure that you have physical disks available in your server.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-11-14 04:22:37 -0600

Seen: 1,327 times

Last updated: Nov 16 '14