class LinuxAdmin::PhysicalVolume

Attributes

device_name[RW]

physical volume device name

size[RW]

physical volume size in kilobytes

volume_group[RW]

volume group name

Public Class Methods

create(device) click to toggle source

specify disk or partition instance to create physical volume on

# File lib/linux_admin/physical_volume.rb, line 36
def self.create(device)
  self.scan # initialize local physical volumes
  Common.run!(Common.cmd(:pvcreate),
      :params => { nil => device.path})
  pv  = PhysicalVolume.new(:device_name  => device.path,
                           :volume_group => nil,
                           :size => device.size)
  @pvs << pv
  pv
end
new(args = {}) click to toggle source

other fields available internal physical volume number (obsolete) physical volume status physical volume (not) allocatable current number of logical volumes on this physical volume physical extent size in kilobytes total number of physical extents free number of physical extents allocated number of physical extents

# File lib/linux_admin/physical_volume.rb, line 22
def initialize(args = {})
  @device_name  = args[:device_name]
  @volume_group = args[:volume_group]
  @size         = args[:size]
end
scan() click to toggle source
# File lib/linux_admin/physical_volume.rb, line 47
def self.scan
  @pvs ||= begin
    scan_volumes(Common.cmd(:pvdisplay)) do |fields, vg|
      PhysicalVolume.new(:device_name  => fields[0],
                         :volume_group => vg,
                         :size         => fields[2].to_i)
     end
  end
end

Public Instance Methods

attach_to(vg) click to toggle source
# File lib/linux_admin/physical_volume.rb, line 28
def attach_to(vg)
  Common.run!(Common.cmd(:vgextend),
      :params => [vg.name, @device_name])
  self.volume_group = vg
  self
end