Archive for the tag 'Physical'

Removing Physical Volumes from a Volume Group

To remove unused physical volumes from a volume group, use the vgreduce command. The vgreduce command shrinks a volume group’s capacity by removing one or more empty physical volumes. This frees those physical volumes to be used in different volume groups or to be removed from the system.

Before removing a physical volume from a volume group, you can make sure that the physical volume is not used by any logical volumes by using the pvdisplay command.

# pvdisplay /dev/hda1

If the physical volume is still being used you will have to migrate the data to another physical volume using the pvmove command. Then use the vgreduce command to remove the physical volume:

The following command removes the physical volume /dev/hda1 from the volume group my_volume_group.

# vgreduce my_volume_group /dev/hda1
SBDavid

Resizing & Removing Physical Volumes

Resizing & Removing Physical Volumes

If you need to change the size of an underlying block device for any reason, use the pvresizecommand to update LVM with the new size. You can execute this command while LVM is using the physical volume.

If a device is no longer required for use by LVM, you can remove the LVM label with the pvremovecommand. Executing the pvremove command zeroes the LVM metadata on an empty physical volume. If the physical volume you want to remove is currently part of a volume group, you must remove it from the volume group with the vgreduce command.

# pvremove /dev/sdd5

Preventing Allocation on a Physical Volume

You can prevent allocation of physical extents on the free space of one or more physical volumes with the pvchange command. This may be necessary if there are disk errors, or if you will be removing the physical volume.

The following command disallows the allocation of physical extents on /dev/sdk1.

# pvchange -x n /dev/sdk1

We can also use the -xy arguments of the pvchange command to allow allocation where it had previously been disallowed.

SBDavid

Displaying Physical Volumes

Displaying Physical Volumes

There are three commands you can use to display properties of LVM physical volumes: pvs,pvdisplay, and pvscan.

The pvs command provides physical volume information in a configurable form, displaying one line per physical volume. The pvs command provides a great deal of format control, and is useful for scripting.

The pvdisplay command provides a verbose multi-line output for each physical volume. It displays physical properties (size, extents, volume group, etc.) in a fixed format.

The following example shows the output of the pvdisplay command for a single physical volume.

# pvdisplay

Removing Physical Volumes from a Volume Group

DESCRIPTION

vgreduce allows you to remove one or more unused physical volumes from a volume group.

To remove unused physical volumes from a volume group, use the vgreduce command. The vgreduce command shrinks a volume group’s capacity by removing one or more empty physical volumes. This frees those physical volumes to be used in different volume groups or to be removed from the system.

Before removing a physical volume from a volume group, you can make sure that the physical volume is not used by any logical volumes by using the pvdisplay command.

If the physical volume is still being used you will have to migrate the data to another physical volume using the pvmove command. Then use the vgreduce command to remove the physical volume:

The following command removes the physical volume /dev/hda1 from the volume group my_volume_group.

# vgreduce my_volume_group /dev/hda1

It’s a good idea to run this option with –test first to find out what it would remove before running it for real.

Next »