FedoraForum.org - Fedora Support Forums and Community
Results 1 to 15 of 20

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2005
    Location
    Finland
    Posts
    5,072

    How to shrink your LVM root volume using rescue mode

    The initial situation: Fedora Core 6 basic desktop installation with default partitioning
    • A /boot partition of about 100 MiB
    • The rest of disk space set up as a LVM physical volume containing
      • 2xRAM size of swap space
      • the rest filled by the / logical volume

    (click for a full-size image)

    The goal: shrink / to allow creation of separate logical volumes for e.g. /home, /tmp or other uses.

    Step 1: Starting the rescue mode Because mounted ext3 filesystems can't be reduced, we must boot the machine in rescue mode. You can use either the first install CD, the install DVD or the separate rescue CD, and boot with the "linux rescue" command.

    First the rescue environment asks you to pick your language and keyboard layout. Choose the ones matching your Fedora system. You can skip the networking setup, it's not needed in this process.

    Let the rescue system mount your Fedora installation, this ensures that the LVM system is correctly initialized, all necessary modules are loaded and the /dev entries for LVM volumes are created.


    If everything is OK, you will see this screen, and pressing Enter will start the rescue mode Bash shell.


    Step 2: Preparations Start with checking the disk information, the command "mount" shows you the name of the / logical volume, now mounted as /mnt/sysimage. "df -h" shows the disk usage. Write down the device name of the volume you are going to resize and the amount of used space on that volume, in the example it's /dev/VolGroup00/LogVol00 with 2.0 GiB in use.


    Unmount everything under /mnt/sysimage and finally /mnt/sysimage itself. Use the "-l" option for umount if you get complaints about busy devices.


    Step 3: Shrinking the filesystem Before you can resize the filesystem you must run "e2fsck -f" on it. Resize2fs will complain and refuse to work if you forget to run e2fsck.
    There are two things you must remember when choosing the new size of your filesystem:
    • LVM allocates space in 32MiB chunks by default, the new size must be a multiple of the LVM extent size.
    • The filesystem mustn't be too full after resizing or you may have problems when restarting the system. Try to leave at least 20% free space on the volume.

    The resize2fs program will take a while to run. You can add "-p" option to its command line to see a progress bar.


    Step 4: Shrinking the logical volume The rescue disc has only the "lvm" command shell instead of separate commands for each LVM operation. While in the lvm shell, you can use the "help" command to display information such as a list of commands and options available for each command. Shrink the volume to the same size you specified in the previous step for the filesystem. Use "exit" or "quit" to leave the lvm shell.


    Step 5: Reboot The command "exit" will leave the rescue mode and reboot the machine. Remove the rescue disc from the drive and the system should boot normally to the GUI mode.


    Checking the result Compare the graphical LVM status to the initial version and you see the unused space available for creating new logical volumes.
    (click for a full-size image)

  2. #2
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    4,999
    Very cool, I didn't know this could be done in rescue mode.

    Bookmarked

  3. #3
    Join Date
    May 2007
    Posts
    48
    I agree with sideaways, your How-To is very excellent! It'll help many people using LVM a lot.

    Very useful! Thank you very much, markkuk!

    P/S: an off question, just a curiousness, how can you capture the boot screen so? Sometimes I want to capture some screens like that in my topic, but don't know how to do. Could you tell me, please? Thanks.

  4. #4
    Join Date
    Apr 2005
    Location
    Finland
    Posts
    5,072
    I used VMware Server to run a copy of FC6 for creating the screenshots in the article.

  5. #5
    Join Date
    May 2007
    Posts
    48
    Oh, that sounds interesting. Thanks :-) Have a nice day then!

  6. #6
    Join Date
    Apr 2007
    Posts
    43
    so, how is this different from using a fedora livecd and using the lvm-gnome-gui to resize a logical volume?

    reason I ask: I (at least thought I) did something similiar using the gparted system cd, "relieved" around 10gb on my hd, to find out that it apparently isn't good enough for the fedora 7 installer. I get a message saying that there isn't enough disc drive space. If I looked at the lvm-gnome-gui, it will show that on the physical lvm partition, there's 10gb of free space, but the "free space" is still red, as though it is still part of the overall physical lvm partition scheme. Did I just not do something right?

    I'm going to try to use resize2fs again and see if that does the trick.

  7. #7
    Join Date
    Apr 2005
    Location
    Finland
    Posts
    5,072
    Quote Originally Posted by SGSeries2
    If I looked at the lvm-gnome-gui, it will show that on the physical lvm partition, there's 10gb of free space, but the "free space" is still red, as though it is still part of the overall physical lvm partition scheme. Did I just not do something right?
    You didn't do anything wrong, the free space is right where it should be.

  8. #8
    Join Date
    Apr 2007
    Posts
    43
    Ok, so it worked as expected then. Thanks for clarifying that for me.

  9. #9
    Join Date
    Jul 2007
    Posts
    21

    Thumbs up

    Super, it worked for me too. Thanks.

    edit: I am using KDE, how can I acces that GUI graphic to see the free space?

  10. #10
    Join Date
    Jun 2007
    Posts
    36
    nothing came as output while entering last lvm command
    the shrinking didn't occur and can we use the newly created volume as Fat32 and access from Windows..

  11. #11
    Join Date
    Apr 2008
    Posts
    1

    LVM doesn't work

    I had the same problem using the Fedora 8 DVD

    When the lvm command doesn't react, you should use both lvm and lvresize commands in one line...

    example:
    sh-3.1# lvm lvresize --size 3G /dev/VolGroup00/LogVol00

    Hope this works for you!

  12. #12
    Join Date
    Apr 2009
    Posts
    1
    You will find there are different versions of lvm on different rescue disks.
    If you get nothing back when typing just 'lvm' then try sending the lvm command you need as a pram. As in:

    lvm lvresize --size 3G /dev/VolGroup00/LogVol00

    Hope this helps....

  13. #13
    Join Date
    Apr 2009
    Posts
    121
    I followed Markkuk's instructions several times to both extend/reduce logical volumes. It works great! But now I would like to install Windows MCE/XP in my unused space of my Volume Group. In order to do this, though, I must first reduce the entire Volume Group. I have never tried lvresize with an entire volume group but only for logical volumes within a volume group. I would simply try running lvresize on the Volume Group as a whole, but noticed in the Logical Volume Management program that my logical volume extents are separated, in my physical volume, by unused space (after recently reducing my /home volume). See my attached image. I wonder what will happen if I simply try running lvresize to reduce the entire Volume Group. Would it be necessary to first move volume extents?
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Physical_volume.jpg 
Views:	100 
Size:	33.3 KB 
ID:	18146  
    Fedora 20 64-bit
    CPU AMD|PH II X2 545 3.0G AM3
    nVidia GeForce GT220 video card
    4GB DDR2 Memory

  14. #14
    Join Date
    Dec 2005
    Posts
    54
    For FC5, I found the procedure needs one small change ...

    I had no problem unmounting /mnt/sysimage/*, but as the procedure notes, the rescue disk won't let you umount /mnt/sysimage (in my case, /dev/VolGroup00/LogVol00), and you have to add the "-l" ("lazy") argument.

    However the rescue disk's version of umount has a different meaning for the "-l" argument (something related to "loop"), and it wouldn't unmount. I worked around this by redefining my PATH variable, moving all of the /mnt/sysimage directories to the front of the list, before /sbin and /usr/sbin (etc), then I executed "umount -l /mnt/sysimage". After this, everything worked fine. You may want to play it safe, and copy /mnt/sysimage/bin/umount to somewhere like /. I bet that it would fully read /mnt/sysimage/bin/umount before umounting the file system that contained it; it did, but I may have just been lucky.

    I'd also suggest add all the commands you intend to use to a file saved to a thumb drive; also print out the file. Then when you're in the rescue shell, there's a lot less chance of error.

    For those nervous about whether a command has hung ("have I lost my file system?"), I saw these times on a logical volume which I resized from 271G to 240, then resized from 240 to 250:
    * "e2fsck -f /dev/VolGroup00/LogVol00": 5 minutes
    * "resize2fs /dev/VolGroup00/LogVol00 240G": 7 minutes
    * "lvm resize --size 250G VolGroup00/LogVol00: instant
    * "resize2fs /dev/VolGroup00/LogVol00": 1 minute

  15. #15
    Join Date
    Mar 2009
    Posts
    1
    well i fallowed the steps, and it seemed like it worked i used fedora unity feb release 64bit, and after reboot it seemed like everything was working, it was going and booting, and kernel panic happened, half way... i then tried again (reboot) same thing... i went into the rescue disk, to only find at the process to find my linux install that it said it could not find any...

    other commands showed that i had no more LVM at all, there wre no physical or anything left

    i dont know if software raid matters, but i had boot on raid 1, and then swap and then about a 60G raid 5, and lvm on top of that were everything else was installed.

    This was a test install, but still a pain to have lost it, and the biggest problem is i dont know why.

    only error i got, and i do not think its related because im using the drives as regular IDE's not fake raiding them... was when it is supposed to detect the linux install i get an error sil: raid type 253 not supported

    but it pauses and continues just fine, i could do the steps above, just after reboot it went poof

    the raid is there but no sign of lvm

Similar Threads

  1. LiveCD Volume to Shrink Error
    By khskinsfan in forum Installation, Upgrades and Live Media
    Replies: 0
    Last Post: 20th June 2009, 07:22 PM
  2. Rescue mode-how to get root
    By SRT in forum Using Fedora
    Replies: 5
    Last Post: 6th August 2006, 07:23 PM
  3. Replies: 9
    Last Post: 30th April 2006, 01:21 PM
  4. Is it possible to shrink a Logical Volume?
    By ajwynn in forum Using Fedora
    Replies: 2
    Last Post: 7th May 2005, 03:11 AM
  5. Shrink volume group?
    By veritas in forum Using Fedora
    Replies: 2
    Last Post: 12th April 2005, 01:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •