LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 05-26-2005, 09:11 AM   #1
coreychch
LQ Newbie
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Fedora 16, 17
Posts: 9

Rep: Reputation: 0
LVM and shrinking the root filesystem


Hi all,

I've just recently installed FC3 on my machine containing 2 80Gb drives, and by default, it set up the partitions as follows, using the Logical Volume Manager (which is what I was wanting):

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
155269068 3663744 143718068 3% /
/dev/hde1 101086 12340 83527 13% /boot
none 517764 0 517764 0% /dev/shm

Without really thinking hard about it, I accepted the defaults and proceeded with the install. Now that I look back, I don't really want a stupidly-large '/' partition of around 150GB - so I'm now quite keen to shrink this so I can add another LV for data, etc.

I've read the LVM HOWTO and understand all of the basic concepts. According to it, reducing the size of a LV requires shrinking the size of the filesystem within it before shrinking the LV itself, i.e., the commands I need to run are something like:

# umount /
# resize2fs /dev/mapper/VolGroup00-LogVol00 xxxx
# lvreduce -L-yyyyG /dev/mapper/VolGroup00-LogVol00
# mount /

Of course, being the root partition, things are a bit more complicated than that, as I can't umount the '/' partition while the machine is running.

I did a bit more reading, and I read that you need to boot from the FC3 rescue-cd and *not* mount the partitions - then resizing should be possible. However - once I did this I was unsure how to refer to device '/dev/mapper/VolGroup00-LogVol00' as it was not present.


Is what I am trying to do even possible? Am I on the right track, or do I need to re-install / re-partition everything again?

Help!

Here's some output from running some other LVM commands:

# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 152.53 GB
PE Size 32.00 MB
Total PE 4881
Alloc PE / Size 4876 / 152.38 GB
Free PE / Size 5 / 160.00 MB
VG UUID pVaPp7-V0G2-tk9o-N3hU-aAJ8-4JkJ-a6RqC5


# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID Ph4HyB-YVDU-u3UC-Oppa-YUjp-s2P9-AyU0w0
LV Write Access read/write
LV Status available
# open 1
LV Size 150.44 GB
Current LE 4814
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:0

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID mkZsuo-MEtD-DzDs-P4PV-vIC6-67au-zIDe91
LV Write Access read/write
LV Status available
# open 1
LV Size 1.94 GB
Current LE 62
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:1


# fdisk -l
Disk /dev/hde: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hde1 * 1 13 104391 83 Linux
/dev/hde2 14 9964 79931407+ 8e Linux LVM

Disk /dev/hdg: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdg1 * 1 9964 80035798+ 8e Linux LVM


Regards,
Corey.
 
Old 06-04-2005, 11:50 PM   #2
coreychch
LQ Newbie
 
Registered: Aug 2003
Location: Melbourne, Australia
Distribution: Fedora 16, 17
Posts: 9

Original Poster
Rep: Reputation: 0
Ok, I've figured this out ... so just in case anyone wants to know how to do it:

1. Write the FC rescue disk ISO onto a CD, and reboot the machine from it.
2. Do not mount the file systems.
3. At the prompt, type:

lvm

4. Within LVM, run these commands (comments are after the '#'s):

lvm> vgscan # Will show the name of the Volume Group
lvm> vgchange --available y VolGroup00 # Activates the VG and the LVs in it
lvm> lvscan # Should show the LVs as "ACTIVE"; the devices in /dev it mentions should now exist
lvm> exit # Quit, return to the prompt

5. Now resize the filesystem with this command (e.g., using device /dev/VolGoup00/LogVol00):

e2fsck -f /dev/VolGoup00/LogVol00 # fsck on the filesystem
resize2fs /dev/VolGoup00/LogVol00 nnG # resize the fs to nn GB; nn should be less than the current fs size
e2fsck -f /dev/VolGoup00/LogVol00 # Do another fsck on the filesystem; fix any errors which appear

6. Run lvm again and type:

lvm> lvreduce -LnnG /dev/VolGoup00/LogVol00 # Resize the LV to nn GB; nn should be the same as above
lvm> exit # Quit, return to the prompt

7. Finally, do another filesystem check:

e2fsck -f /dev/VolGoup00/LogVol00 # Do another fsck on the filesystem; fix any errors which appear

8. Remove the CD and reboot.
 
Old 09-08-2010, 08:55 PM   #3
Tom_Wilson
LQ Newbie
 
Registered: Sep 2010
Posts: 3

Rep: Reputation: 2
Thank You!

Here it is, five years after your post. However, it contains just the information that I needed to fix my Fedora 13.

Here's how I got myself in trouble... I decided I wanted to experiment with LVM. I created a logical volume. Then I looked around for a volume group that I could add it to. Gee, the root vg was already set up (saving me some work), why not add my new logical volume to the root volume group?

A few mouse clicks later, and it was done. OK, that was simple enough, now lets try removing it. WHAT DO YOU MEAN THE ROOT VOLUME HAS TO BE UNMOUNTED FIRST ???

That's when the panic set in!!

Your post really bailed me out. Thank you so much.

--Tom
 
Old 11-28-2011, 12:08 PM   #4
mrcleanx
LQ Newbie
 
Registered: Nov 2011
Location: Post Falls, ID
Distribution: Fedora
Posts: 2

Rep: Reputation: Disabled
Thumbs up

Here it is again, 6.5 years after you post. Your steps worked perfectly on Fedora 15.

I'm a bit of n00b with LVM and I had configured my / LV at 500GB. WAY too big for actual needs. Storing the dd image was going to be a problem as well.

Thanks a gigabyte!
 
Old 05-21-2012, 01:47 AM   #5
rootaccess
Member
 
Registered: Mar 2012
Posts: 211

Rep: Reputation: Disabled
Actually, here it is, almost exactly 7 years later.

Just boot off a live CD and if your root is loaded via insmod lvm and you want to shrink it say to 10GB, type

lvresize -L10G /dev/vg0/root --resizefs

vg0=volume group
root=logical volume named root that is mounted to /

Last edited by rootaccess; 05-21-2012 at 11:42 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing a root LVM filesystem eigoteacher Linux - Newbie 7 08-23-2007 09:36 AM
Shrinking Root Partition celticdaddio Suse/Novell 1 10-06-2005 10:00 AM
Shrinking an LVM partition Sabre_X Linux - Software 6 09-30-2005 11:13 PM
Increase EXT3 Filesystem size in a LVM? jadupl2 Red Hat 3 11-14-2004 08:40 PM
bootsector location with lvm filesystem flv7a Linux - General 1 11-07-2003 10:53 AM


All times are GMT -5. The time now is 09:29 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration