Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 29th May 2008, 03:36 PM
pklingem Offline
Registered User
 
Join Date: Nov 2007
Posts: 12
Splitting Logical Volumes

I currently have one LV that contains everything below /, I would like to split it into LV's for /home, /usr, /var, /opt. How would I go about doing this? I have an extra drive that I could use to temporarily store the LVs if necessary. Thanks in advance.
Reply With Quote
  #2  
Old 29th May 2008, 04:55 PM
drunkahol Offline
Registered User
 
Join Date: Jun 2004
Location: Norwich
Posts: 638
If you're happy using the extra drive, then proceed similar (this being an adequate disclaimer!) to the following:

Code:
pvcreate <New_disk>
vgextend <VG_Name> <New_Disk_Path>
lvcreate --name <LV_Name> --size 10G [or whatever size you wish]
mke2fs -j <LV_Path>

Once you have created the LV's, you should mount them in /mnt somewhere, so create a directory in /mnt for them.

Code:
mkdir /mnt/newlv
Then, one by one, mount a new LV at /mnt/newlv and copy all the data from the old mount point to the new LV. /var is going to be tricky as log files are continually used. /home and /opt are the easiest as the are the simplest to "not use" whilst copying the data.

Code:
mount <LV_Path> /mnt/newlv
rsync -av <source_dir> /mnt/newlv
A slightly tricky bit now comes where you're pretty sure the data is on the new LV, but do you want to just delete what was there before testing it?

You can go ahead and

Code:
rm -rf /home/*
if you are happy with the job that rsync does. I run rsync a few times to ensure it does absolutely nothing before deleting old data. If you're paranoid, you can move the data to a new directory (may not be possible with /var and /usr) and reboot the system with the new LV mounted in the appropriate place.

Your /etc/fstab should be edited to include lines similar to:

Code:
/dev/Volume00/usr       /usr          ext3    defaults        1 2
/dev/Volume00/var       /var          ext3    defaults        1 2
/dev/Volume00/home      /home         ext3    defaults        1 2
/dev/Volume00/opt       /opt          ext3    defaults        1 2
Once you've checked the data is OK, delete the old-copy directories to free up space. This is the "simple" part of it as now you want to recover that space and move the new LV's back to the original disk. You may have to use a rescue CD as ext3 partitions need to be unmounted to be reduced - I'm not 100% on this, but I had to do it this way on the RHEL 4 boxes I admin at work.

Once you've reduced the / filesystem, you can lvreduce the / LV. Make sure the LV stays slightly larger than the FS just in case. Once you're happy with the new sizes, run an ext2online to grow the filesystem to fill the LV.

With that done, you're only left needing to move the new LV's from the temporary disk to the original disk. This requires the pvmove command. You can just specify the temporary PV and it will move all physical extents off that PV and onto whatever PV's remain. This sounds like the best option for you, but I tend to move one LV at a time as this also has the benefit of "defragging" your LV's if you've got them spread all over the place. It's a bit manual, but it can be done.

A really handy command when messing with LVM is

Code:
pvdisplay --maps
which shows you all your PV's, but lists the usage of the physical extents (i.e. which part of each LV sits where). It's a bit manual, but you can do a LOT of work online with LVM - and it can be restarted if the system goes down in the middle of anything big.

Sorry this is just a description of what you need to do - I've done it several times at work and it seems to change slightly each time. If you're willing to give it a bash, create some dummy LV's on your new drive and play around with them. That'll give you the confidence to go for it with your live data.

Cheers

Duncan
__________________
Supermicro X5DA8 2x Xeon 2.8GHz 6Gb RAM: Fedora 15
Thinkpad T40p: Fedora 16
HP Pavilion dv9000: Fedora 14
Advent 4211: Fedora 16
Reply With Quote
Reply

Tags
logical, splitting, volumes

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 logical volumes maalamaal Using Fedora 8 25th February 2009 01:04 PM
Missing Logical Volumes ST-ISA Using Fedora 6 28th February 2007 10:11 AM
Resizing Logical Volumes? naz37 Using Fedora 7 20th February 2007 02:15 PM


Current GMT-time: 06:32 (Tuesday, 21-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat