[SOLVED] LVM2 on F10 - reduce LVM size and remove 2 HDDs
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
The system never uses more than about 250GB of HDD at any one time, so I would like to remove /dev/sdd1 and /dev/sdc1 from the LV and then from the machine and leave /dev/sda and /dev/sdb alone.
Does anyone know that if I use the command "system-config-lvm" to reduce the total LVM size to say 580GB, whether all data is preserved (I don't have any way at this stage to backup up 250GB of data, unless I buy more HDDs and that is the whole point of this exercise anyway - remove the two terrabyte drives to be used as backup disks).
Once I am happy that the data is safe, I will use "pvmove" and "vgreduce" to remove both terrabyte drives. Thanks in advance.
You've painted yourself into a bit of a corner by allocating all of your extents. You should be able to get around that, but it's a bit involved.
The following is just a guide. I expect you to look for any issues that may endanger your data (obviously, I can't see your system from here).
Unmount the filesystem you want to shrink.
Run fsck against it just to make sure it's in a good state.
Run resize2fs (I'm assuming ext2/3/4 here) to shrink your filesystem to a size slightly smaller than you want it to be (-16 or -32MB would probably be ok). Obviously, you can't shrink it smaller than the amount of data remaining in your filesystem, but make sure you shrink it enough to fit on the two remaining disks your system will have.
Run fsck again to make sure nothing bad happened.
Run lvreduce to reduce the size of the LV containing the filesystem to the size you would like it to be. Make sure the size is larger than that you used above on the resize2fs.
Run resize2fs again without specifying any size to allow your filesystem to grow to fill the exact size of the new lv.
Run fsck again to make sure nothing bad has happened.
mount your filesystem read-only, have a good look around at it.
Hopefully now you should have enough free extents in the volume group to migrate the logical volume off of the disks you wish to remove. 'pvmove' is the command to use.
Once you've got the PVs you wish to remove to be completely empty you can vgreduce them from the volume-group and remove them from your system.
Obviously, doing anything like this has to be considered high-risk, but it's either this or leave your 4 disks in there. You pays your money, you makes your choice.
Please remember, this is just a rough guide. It's your responsibility to make sure you fully understand what each command does at each step and that it is safe and makes sense on your system.
Hopefully, that gives you a starting point to work from. Best of luck.
Thanks GazL. I have done some more reading and found the LDP to be useful too (http://tldp.org/HOWTO/LVM-HOWTO/. It basically describes the same method as you have outlined. I will need to set aside a fair amount of time before I begin this task on a day when the box isn't recording any tv programmes.
I am still curious however, as to whether anyone has used the Redhat/Fedora "system-config-lvm" GUI successfully in a similar situation.
I had 4 disks two (sdc and sdd) of which I wanted to completely remove from a machine running MythTV. All disks were initially used in the logical volume setup.
I had one volume group VolGroup00 and two logical volumes LogVol00 and LogVol01. (approx 2.5 TB all up)
/ was mounted on LogVol00 and /storage was mounted on LogVol01.
I did this over two days because I still wanted my MythTV setup running later each day.
This is what I did :-
Day one
1. booted to runlevel 3
2. stopped several services in Mythtv - mythbackend, mysqld, httpd, LCDd, lcdproc and lircd
3. umount /storage
4. e2fsck -f -c0 -v /dev/VolGroup00/LogVol01 to check the file system for consistency
5. resize2fs -p /dev/VolGroup00/LogVol01 1000G resized to 1GB
6. reran step 4
7. ran system-config-lvm (F10 gui)chose LogVol01 (in logical view). Reduced to 1000.00 GB. This ran step 4 for me anyway, then it ran /sbin/resize2fs /dev/VolGroup00/LogVol01 1049624576K.
8. pvmove -v /dev/sdd1 (NB very slow - this took about 3-4 hours)
9. vgreduce VolGroup00 /dev/sdd1
10. using system-config-lvm gui again I removed /dev/sdd1 from the LVM.
11. rebooted to make sure everything was still OK.
Day two
1. booted to runlevel 3
2. stopped several services in Mythtv - mythbackend, mysqld, httpd, LCDd, lcdproc and lircd
3. umount /storage
4. e2fsck -f -c0 -v /dev/VolGroup00/LogVol01 to check the file system for consistency
5. resize2fs -p /dev/VolGroup00/LogVol01 500G (resized to 500GB)
6 e2fsck -f /dev/VolGroup00/LogVol01
6. ran system-config-lvm gui and using the previous method reduced the size of LogVol01 ro 501.0 GB. The gui first runs
/sbin/e2fsck -f -p /dev/VolGroup00/LogVol01 then runs
/sbin/resize2fs /dev/VolGroup00/LogVol01 525336576K
7. pvmove -v /dev/sdc1 (about 3-4 hours)
8. vgreduce VolGroup00 /dev/sdc1
9. system-config-lvm to remove sdc1 from LVM
10. rebooted - all OK.
All good. I haven't yet added the extra free space left over back into the LVM and probably never will. I've never used more than about 320GB all up, but have 2 x 320 GB HDDs sitting there.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.