3.
Update all references to the old name in any other files on the system. These include
/etc/
fstab
for mounted file systems or swap devices and existing mapfiles from a
vgexport
command.
Removing a Logical Volume
CAUTION:
Removing a logical volume makes its contents unavailable and likely to be overwritten.
In particular, any file system contained in the logical volume is destroyed.
To remove a logical volume, follow these steps:
1.
Make sure that the logical volume is not in use either as a file system or as raw disk space for
an application. Use the
fuser
command as follows:
# fuser -cu /dev/vg01/lvol5
If the logical volume is in use, confirm that the underlying applications no longer need it. You
might need to stop the applications.
2.
Use the
lvremove
command to remove the logical volume. For example:
# lvremove /dev/vg01/lvol5
You can now use this space to extend an existing logical volume or build a new logical volume.
3.
For volume group Version 2.2 and higher, a snapshot and all its predecessors can be removed
using a single
lvremove
command, with the new
-F
option. See lvremove(1M) for more
information.
NOTE:
A logical volume with associated snapshots cannot be removed. First, all of its snapshots
have to be deleted, then the original logical volume can be deleted.
Exporting a Volume Group
Exporting a volume group removes all data concerning the volume group from the system, while
leaving the data on the disks intact. The disks of an exported volume can be physically moved or
connected to another system, and the volume group can be imported there.
Exporting a volume group removes information about the volume group and its associated physical
volumes from
/etc/lvmtab
and
/etc/lvmtab_p
, and removes the volume group's directory
with device files in the
/dev
directory.
1.
Make sure that none of the logical volumes in the volume group are in use. You might need
to stop applications using any logical volumes in the volume group, and unmount file systems
contained in the volume group.
Use the
fuser
command on each logical volume. For example:
# fuser -cu /dev/vgnn/lvoln
2.
Deactivate the volume group. For example:
# vgchange -a n vgnn
3.
Use the
vgexport
command to export the volume group. For example:
# vgexport -v -m /tmp/vgnn.map vgnn
If you are planning to move the volume group to another system, use the
-m
option to
vgexport
to create a
mapfile
. This ASCII file contains the logical volume names because
they are not stored on the disks. You must create a mapfile if you do not use the default names
/dev/vgnn/lvoln
for the logical volumes in the volume group.
If there are several disks in the volume group, use the
-s
option with
vgexport
; this option
adds the volume group identifier (VGID) to the mapfile. When the volume group is imported,
you can avoid specifying all the disks by name. See
“Importing a Volume Group” (page 58)
.
Common LVM Tasks
57