Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 17th January 2009, 19:13
anw anw is offline
Member
 
Join Date: Feb 2007
Posts: 53
Thanks: 0
Thanked 6 Times in 6 Posts
Default Resizing partitions with & w/o lvm

Normally, I would just try stuff to see what worked, but in this case there's real data that I don't want to lose, so thought I'd ask for advice here first.

I have three partitions on this disk, laid out thusly:

|--root--|--swap--|-------------- hda3 (lvm) --------------|

hda3 is the only one using lvm. What I want to do is shrink hda3 from the front, to give a couple of more (contiguous) gigabytes to swap. There's plenty of room. Here's the output of lvdisplay:
Quote:
# lvdisplay
--- Logical volume ---
LV Name /dev/dynamic/usr
VG Name dynamic
LV UUID CDMnar-5290-7F1t-e4wf-Mvw6-ghv9-ombuVG
LV Write Access read/write
LV Status available
# open 1
LV Size 120.00 GB
Current LE 30720
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:0

--- Logical volume ---
LV Name /dev/dynamic/var
VG Name dynamic
LV UUID jdJHED-8bMO-qZ1P-IM9J-unzL-ScqQ-uyBcJU
LV Write Access read/write
LV Status available
# open 1
LV Size 120.00 GB
Current LE 30720
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:1

--- Logical volume ---
LV Name /dev/dynamic/home
VG Name dynamic
LV UUID xjGtYV-04XE-7ihk-tlkR-RrMB-Vljd-d7kun2
LV Write Access read/write
LV Status available
# open 1
LV Size 17.98 GB
Current LE 4602
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:2
and here's the output of pvdisplay:
Quote:
# lvm pvs
PV VG Fmt Attr PSize PFree
/dev/hda3 dynamic lvm2 a- 435.96G 177.98G
So, there's plenty of room; but what I don't understand is there doesn't seem to be any way to tell lvresize or pvresize how to move the lv's or pv's around. In other words, I want to tell pvresize (and probably fdisk, too, right?) to scoot everything over to the right by a couple of gig, then tell fdisk to increase the swap partition by said amount.

I've found several examples on the net, but none demonstrate how to exercise this fine a control over the starting and ending locations, and, as I say, I'd be much more open to just experimenting if these weren't currently in use with (a lot) of real, live data.

TIA!
Reply With Quote
Sponsored Links
  #2  
Old 18th January 2009, 01:27
grandpagenocide grandpagenocide is offline
Senior Member
 
Join Date: Jun 2007
Location: Brooklyn, NY
Posts: 308
Thanks: 13
Thanked 43 Times in 29 Posts
Send a message via AIM to grandpagenocide Send a message via MSN to grandpagenocide
Default

While online enlarging is no problem, you have to umount for shrinking!
Code:

# umount /dev/vg_blah/lv_blah

Perform a check of the filesystem...
Code:

# e2fsck -f /dev/vg_blah/lv_blah

Resize the filesystem first.
Code:

# resize2fs /dev/vg_blah/lv_blah 9G

Then reduce the size of the logical volume.
Code:

# lvreduce -L -1G /dev/vg_blah/lv_blah

After that you can shrink down the volume group if desired.
Code:

# vgreduce vg_blah /dev/sdxy

Warning: It is crucial that you use the exact amount of space. If you reduce volume more than the filesytem you truncate the logical volume and you risk data loss!

!!! I WOULD NEVER SHRINK A FILESYSTEM WITHOUT A BACKUP !!!

copied from linuxquestions.org, worked for me, boot off linux rescuse disk or live distro, i do advise play around on a spare box if u got one, i completly screwed up like 10 times before i found this tut and got it right
__________________
Hosting for the Masses
http://rhwebhosting.com
Reply With Quote
  #3  
Old 18th January 2009, 03:32
anw anw is offline
Member
 
Join Date: Feb 2007
Posts: 53
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Thanks for the help!

Don't I have to reduce the VG size if I'm going to reduce the partition? I have three lv's in this VG, but an extra 177 gig or so of space in the volume group, which is the full size of the partition. So, do I need to shrink any of the LVs? And, when I do shrink the VG, how do I tell it to shrink it from the front, and not from the back (i. e., add space between swap and hda3 so I can contiguously expand swap)?
Reply With Quote
  #4  
Old 18th January 2009, 12:17
falko falko is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,743 Times in 2,577 Posts
Default

I think this tutorial has everything you need: http://www.howtoforge.com/linux_lvm
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 18th January 2009, 17:25
anw anw is offline
Member
 
Join Date: Feb 2007
Posts: 53
Thanks: 0
Thanked 6 Times in 6 Posts
 
Default

Hey, Falko!

Thanks. I had actually read that article, but there were still a couple of questions I had. Right now, as you can see in a minute by what I'm fixing to post, this may have been OBE- I think I'm just going to get a new drive if it's pretty easy.

If not, I'll return to this and figure out exactly what question I had on that article.

Thanks for the help! New question coming...
Reply With Quote
Reply

Bookmarks

Thread Tools
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
Resizing partitions 22hosting Installation/Configuration 2 18th October 2010 05:23
Unable to repair/re-install ubunt svr ubuntu 8.04/8.10 on RAID 5 LVM lucy_t Installation/Configuration 5 19th December 2008 20:59
debian, lvm, raid, grub, custom kernel koi Installation/Configuration 4 3rd November 2007 10:39
On: Recover Data From RAID1 LVM Partitions With Knoppix Linux LiveCD saracen HOWTO-Related Questions 1 11th May 2007 09:57
Xen: Smp & Lvm zokahn HOWTO-Related Questions 5 27th January 2006 10:28


All times are GMT +2. The time now is 18:10.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.