LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   pvmove question (https://www.linuxquestions.org/questions/linux-server-73/pvmove-question-4175458191/)

Raiyan 04-15-2013 09:04 AM

pvmove question
 
Hello

This is not any server in my office, just a virtual machine in my home that is helping me to go through RHCE certification.

I have 2 disks (excluding sda1 + sda2 for RHEL installation), /dev/sdb and /dev/sdc 8G each, 1 vg and 1 lv.

I have found that I can use pvmove /dev/sdb /dev/sdc cmd only when my lv size is less than 8G.

So, if the size of lv is 16G and I want to move all of my data from sdb to sdc (target is to drop the pv sdb from vg), then I need to reduce the size of lv
to less than 8G.

My question is if my total data volume is 4G, then when reducing the size of the lv is it guaranteed that the data will remain intact? if no, then how this thing is accomplished in real world scenario?

evo2 04-15-2013 10:08 AM

Hi,
Quote:

Originally Posted by Raiyan (Post 4931843)
I have 2 disks (excluding sda1 + sda2 for RHEL installation), /dev/sdb and /dev/sdc 8G each, 1 vg and 1 lv.

I have found that I can use pvmove /dev/sdb /dev/sdc cmd only when my lv size is less than 8G.

Yes, because sdc is only 8G: you can't put more that 8G on an 8G disk..

Quote:

So, if the size of lv is 16G and I want to move all of my data from sdb to sdc (target is to drop the pv sdb from vg), then I need to reduce the size of lv
to less than 8G.

My question is if my total data volume is 4G, then when reducing the size of the lv is it guaranteed that the data will remain intact?
There are never any guarantees, but in principle it should work. Presumably you need to resize your file system too (before shrinking the lv). Exactly how to do that will depend on what filesystem you are using.
Quote:

if no, then how this thing is accomplished in real world scenario?
In the real world, people (should) make backups of important data.

Evo2.

Raiyan 04-16-2013 07:37 AM

Not clear about resizing the file system, I have only configured pv, vg and lv here. I have formatted the file system as ext4.

Could you please explain the procedure for ext4 file system? If the lv is 16G, then isn't it that the data in it can be anything upto 16G?

Thanks in advance.

BR//R

evo2 04-16-2013 09:48 AM

Hi,

Quote:

Not clear about resizing the file system, I have only configured pv, vg and lv here. I have formatted the file system as ext4.
Presumably your current ext4 filesystem uses the full 8G of the lv. If you want to shrink the lv, you'll first need to shrink the filesystem. You can use the resize2fs command for this.

Quote:


Could you please explain the procedure for ext4 file system? If the lv is 16G, then isn't it that the data in it can be anything upto 16G?
Sure, and presumably you ext4 filesystem is now 16G using all of the lv, but the point is that you plan to reduce the lv to only 8G, and therefore your filesystem will have to be shrunk so that it will fit on the smaller lv.

So the steps to remove /dev/sdb would be something like..
Code:

umount /mount/point/
e2fsck -f /dev/vg0/lv0
resize2fs /dev/vg0/lv0 4G
lvreduce -L 4G /dev/vg0/lv0
pvmove -b /dev/sdb /dev/sdc # The -b makes this run in the background
# You can watch the status of the pvmove with:
lvs --all --options +devices
# Once you think the pvmove is finished confirm that the disk is not being used
pvdisplay /dev/sdb
vgreduce vg0 /dev/sdb
pvremove /dev/sdb

Unmounting the filesystem is only for the fsck operation, since ext4 can be resized while mounted, and the lvm operations don't care if the fs is mounted or not.

There are *many* lvm tutorials that describe this sort of process. Have a search and feel free to post back if you have any more questions.

Evo2.


All times are GMT -5. The time now is 08:21 PM.