LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   LVM2 on F10 - reduce LVM size and remove 2 HDDs (http://www.linuxquestions.org/questions/linux-general-1/lvm2-on-f10-reduce-lvm-size-and-remove-2-hdds-762222/)

ArfaSmif 10-15-2009 05:29 PM

LVM2 on F10 - reduce LVM size and remove 2 HDDs
 
Hello all,

I have the following HDDs in an LVM2 configuration on an F10 box running Mythtv :-

# pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [297.88 GB / 0 free]
PV /dev/sdd1 VG VolGroup00 lvm2 [931.50 GB / 0 free]
PV /dev/sdb1 VG VolGroup00 lvm2 [298.06 GB / 0 free]
PV /dev/sdc1 VG VolGroup00 lvm2 [931.50 GB / 0 free]
Total: 4 [2.40 TB] / in use: 4 [2.40 TB] / in no VG: 0 [0 ]

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.

smeezekitty 10-15-2009 08:22 PM

why?

ArfaSmif 10-15-2009 08:38 PM

Quote:

Originally Posted by smeezekitty (Post 3721020)
why?

why what?

smeezekitty 10-15-2009 08:40 PM

why remove space? you may need it in the future.

ArfaSmif 10-15-2009 09:19 PM

I appreciate your concern for my well being, but do you have anything to contribute about my LVM question?

smeezekitty 10-15-2009 09:59 PM

i still dont see your logic but this may help
http://ubuntuforums.org/showthread.php?t=451605

GazL 10-16-2009 04:34 AM

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.

ArfaSmif 10-16-2009 09:20 PM

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.

ArfaSmif 04-12-2010 01:55 AM

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.


All times are GMT -5. The time now is 03:21 AM.