LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 10-15-2009, 05:29 PM   #1
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Fedora, Centos, Manjaro
Posts: 317

Rep: Reputation: 70
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.
 
Old 10-15-2009, 08:22 PM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
why?
 
Old 10-15-2009, 08:38 PM   #3
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Fedora, Centos, Manjaro
Posts: 317

Original Poster
Rep: Reputation: 70
Quote:
Originally Posted by smeezekitty View Post
why?
why what?
 
Old 10-15-2009, 08:40 PM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
why remove space? you may need it in the future.
 
Old 10-15-2009, 09:19 PM   #5
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Fedora, Centos, Manjaro
Posts: 317

Original Poster
Rep: Reputation: 70
I appreciate your concern for my well being, but do you have anything to contribute about my LVM question?
 
Old 10-15-2009, 09:59 PM   #6
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
i still dont see your logic but this may help
http://ubuntuforums.org/showthread.php?t=451605
 
Old 10-16-2009, 04:34 AM   #7
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
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.

Last edited by GazL; 10-16-2009 at 04:36 AM.
 
Old 10-16-2009, 09:20 PM   #8
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Fedora, Centos, Manjaro
Posts: 317

Original Poster
Rep: Reputation: 70
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.
 
Old 04-12-2010, 01:55 AM   #9
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Fedora, Centos, Manjaro
Posts: 317

Original Poster
Rep: Reputation: 70
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.
 
1 members found this post helpful.
  


Reply

Tags
fedora 11, lvm2



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to reduce lvm in size in RHEL5.0 kbklinux Linux - Software 1 05-14-2009 02:06 AM
How do you safely reduce a LVM partitions size? Igby Linux - Server 4 05-11-2009 11:41 PM
Difference between LVM and LVM2? your_shadow03 Linux - Newbie 2 05-08-2009 02:01 AM
[SOLVED] F10 Boot Problem - No LVM maxkukartsev Fedora 6 04-15-2009 11:07 PM
Reduce LVM Partition size without any data loss viral_Ahire Linux - Software 1 04-11-2008 03:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration