How to safely remove the disk from LVM


Learn how to safely remove the disk from LVM, a disk when the disk volumes have appeared, it is very useful when a disk problem or want to re-use the disk volume. This tutorial will focus on the following issues:

  • How to safely remove the disk from LVM
  • How to remove a disk from a VG Online
  • How to copy data in the physical disk level
  • How to replace a failed disk LVM Online in
  • How to move the disk partition to another disk at the physical level
  • How to free up disk capacity in order to reduce the VG
  • How to safely reduce VG

First, we need to look at the situation of the server. To understand the server disk, you can use lsblka command, command execution results as shown below:

Can be seen, having two current host LVM, which rootis generated at the time of installation of the system, mounted to the root directory; the other Lv01is newly added LVM, mounted to /mydatathe directory. In addition, the host also installed a blank disk "sdc", we will do is to use "sdc" disk replacement Lv01in the "sdb" disk, in order to achieve the purpose of safe removal LVM disk. Note that all operations are carried out online, the system will not have any effect.

To replace a disk, then obviously it must first new disk "sdc" is added to the vg01. Using the pvcreatecommand "/ dev / sdc" can generate a new pv, and then use the vgextendcommand "/ dev / sdc" added to the vg01. The command execution steps as shown below:

Now, we are going to remove the disk "/ dev / sdb" disk and replace "/ dev / sdc" are in the same vg01, you can use pvsto view the command:

 

pvmove-pvs-result.jpguploading.4e448015.gifDump failed to re-upload canceled

You can see, a partition "/ dev / sdb" disk "sdb1" is added to the vg01, now need to do is to move the disk partition "/ dev / sdc" in a new installation. Use pvmovecommand to complete the above work.

As shown in FIG, "/ dev / sdb1" line of data has been moved to the "/ dev / sdc", so, that can prepare a removable disk. If you need to move more data, this command could be executed for a long time, in order not to affect other operations, you can use the following command to execute in the background:

 pvmove /dev/sdb1 2>error.log >normal.log &

The above command will pvmovecommand in the background, and outputs the result to the implementation of the "normal.log", the standard error output to "error.log".

Before removing the original data disk, also you need to remove the disk from its belonging to the VG, so as not to affect the system. Delete the slave disk from vg01 not use the "remove" command, but the use of vgreducethe command, the command execution as shown below:

Now, "/ dev / sdb1" partition has been removed from vg01, if the other partition and disk is not mounted, then this disk can be removed from the system.

And that we use the pvmovecommand to complete the whole process of removing LVM volume disk, this command-line data can be easy to move. Of course, this command also provides a number of optional parameters, "- v" command parameters can be output more implementation details:

The "-i" parameter allows pvmovecommand as the number of seconds "-i" followed by the interval to show the progress in the implementation of the update command, the command example is as follows:

# Pvmove -i 1 / dev / sdc 


Transfer: https://www.daehub.com/archives/8560.html
Published 136 original articles · won praise 38 · views 260 000 +

Guess you like

Origin blog.csdn.net/Pipcie/article/details/105060333