Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.