FedoraForum.org - Fedora Support Forums and Community
Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2005
    Posts
    122

    FC4: Installation warning (lvm) and fix: default partitioning shrink logical volume

    (sorry about the long header, I want to make sure other users with this problem can google it relatively easily; what's also why I have reposted it, rather than just append it to my original request for help)

    Firstly, if you are planning on installing FC4, consider very seriously whether you want to use the default ("automatic") partitioning scheme. if you do use it, it will be extremely difficult at a later stage to tailor it. If you think you might later need to restructure the partitioning, you should read the documentation on logical volumes, noting that they are easy to extend but very difficult to shrink. You may wish to consider creating a partitioning scheme with relatively small logical volumes, for later extension.

    If you do get caught in this way, as I was, you may find my experiences useful. But first, let me emphasise just how disastrous this default is. I've been using various unix systems for almost 30 years. I'm not a sysadmin, but I am a reasonably experienced user, and know my way around unix systems. It has taken me a week's solid work to find a solution to the problems created by the FC4 automatic partitioning scheme. That _doesn't_ seem to me a user-friendly default.

    Please note that all I am reporting is that this solution worked for me. If you decide to do something similar, please understand I am _not_ an lvm expert. You should evaluate for yourself whether it might work for you, and make sure that you fully understand the risks. Especially, make sure you have backed up your system fully first. I would not have attempted this before I discovered dar (http://dar.linux.free.fr/), and was certain I had the system fully backed up.

    A. I ran Knoppix
    1. Downloaded Knoppix and burned to CD (http://www.knoppix.net/)
    2. Booted Knoppix on the computer

    B. Got LVM Running on Knoppix (from http://www.knoppix.net/wiki/LVM2)
    1. configured internet connection under Knoppix
    2. modprobe dm-mod
    3. apt-get update
    4. apt-get install lvm-common lvm2
    5. lndir /lib/lvm-200/ /usr/sbin/

    C. Resized the volume (based on http://www.linuxquestions.org/questi...ght=resize+lvm)
    The volume I was resizing was /dev/VolGroup00/LogVol00
    I was resizing to 58G
    It's _crucial_ that the parameters in resize2fs and in lvreduce match
    Otherwise you will probably destroy your filesystem.
    I would strongly recommend not using resize2fs or lvreduce until you have read
    _and understood_ their man pages. If you don't understand what you are doing
    here, and especially the differences between filesystems and partitions, you
    don't know enough to do this safely.
    It's also crucial that you allow enough space for the files already there, as again
    you may well destroy your filesystem if it's too small (My files used only
    about 10G, so I wasn't worried, there was plenty of room. I'm not certain how
    to check the exact size, though I would guess the sizes reported by df are
    probably accurate - I know the sizes reported by du may be too large; anyone
    expert enough to give an accurate opinion? But in any case, you need to allow a
    margin, probably at least 20%, so it doesn't matter too much.)

    1. vgscan
    2. vgchange -a y?3. e2fsck /dev/VolGroup00/LogVol00?4. resize2fs -p /dev/VolGroup00/LogVol00 58G?5. lvreduce -L58G /dev/VolGroup00/LogVol00

    I strongly recommend including the -p parameter in resize2fs. My resize took a couple of hours, and (because I omitted this), I had no way of confirming that it was actually proceeding rather than just hung. Fortunately, I resisted the temptation to reboot... Unlike the post mentioned above, I did not find it necessary to use the -f options. I would strongly recommend _not_ using the -f option in any of these commands until you are certain why the command is failing, and that forcing it will not cause a problem.

    I then exited Knoppix and rebooted Fedora. The filesystem and partition had been shrunk as I had hoped and prayed (believe me, I was sweating as I did the final check). I was able to use the Logical Volume Manager to create additional logical volumes in the freed space. The system appears to be working fine.

  2. #2
    Join Date
    Sep 2005
    Posts
    122
    Sorry about the formatting, that last step should have read

    1. vgscan
    2. vgchange -a y
    3. e2fsck /dev/VolGroup00/LogVol00
    4. resize2fs -p /dev/VolGroup00/LogVol00 58G
    5. lvreduce -L58G /dev/VolGroup00/LogVol00

    (problem with cutting and pasting between OSs)

  3. #3
    Join Date
    Aug 2005
    Posts
    8
    Do you know if there is a way to reclaim the free space out of the LVM partition.

    I mean, you said that you used the space the create new logical volumes, but I wish to allocate that space to another primary partition.

  4. #4
    Join Date
    Sep 2005
    Posts
    122
    To the best of my recollection, that's what the lvreduce does, reduces the LVM partition down to the nominated size. I'm pretty sure that after I had done it, and before adding the new logical volume, the partition map showed the physical disk with around 60G of free space. Why not try it, worst case you end up with free space in the LVM partition and can just expand the logical volume to fill it again? If you do try it, please report the result here, either way, so that future users can build on it (leaving unanswered questions is discourteous to other users, it just clags up the googlespace)

  5. #5
    Join Date
    Aug 2005
    Posts
    8
    I have 2 machines, the older one is a laptop and I'm using it for presentations. I did not want to do the testing on my current machine - if anyone in the future is looking at this thread - PLEASE be sure that you have backup!

    lvreduce changed the size of the LV - /dev/VolGroup00/LogVolume00 in my case - and the "df -h" command showed that I had less space on my / partition (I'm sorry for not quoting but I did more changes afterwards). However, the PV size did not change, and the pvresize is not implemented yet. I read that even after it is implemented, a change in PV would not reduce the size of the VG.

    Some tips for resizing can be found at:
    https://www.redhat.com/archives/linu.../msg00059.html
    http://voidmain.is-a-geek.net/files/...d_root_lv.html

    After having read the avalable literature and tested the ideas, here's the advice I have if you choose LVM: when installing Fedora, manually partition the disk and let the system have 5-10G, hopefully leaving unpartitioned free space. This free space can be distributed among other OS-s at a later point or, alternatively, new LVM partitions can be created and mounted on-the-fly. LVM is a great management system if a new hard drive is to be added - no need to restart!

  6. #6
    Join Date
    Sep 2005
    Posts
    122
    Thanks KC, looks like my understanding of the partition sizing was flawed (since it's not what I was
    trying to do, I have to admit I didn't pay that much attention to it). Thanks for making sure the record is straight.

    On sizing, I'm not sure exactly what you're saying; my thoughts would be something along the lines of: put all the system resources (bin, sbin, sys, dev, mount, .....) in one logical volume, I agree 5 - 10 G would be a good starting point for most purposes (5G for most purposes, but 10G if you were running disk-hungry services). Put /home in a separate logical volume of fairly modest size (ie maybe 50% above what's currently required), and leave as much free space as possible. These are pretty conservative settings, but that's the point - using LVM, it's easy to increase the space later, when it's clear it's needed.

    All the Best
    Bob

  7. #7
    Join Date
    Aug 2005
    Posts
    8
    Yeap, that's precisely what I had in mind! I installed Fedora with the default settings, where the partition is automatic, but what I suggest above is the "smarter" approach. Your first post's comments about the default partitioning is exactly what I think is the case - this default option is not user-friendly.

    Regards, KC

  8. #8
    Join Date
    Sep 2005
    Posts
    122

    Fixed in FC5

    This problem is, pretty much, fixed in FC5: the LVM GUI is able to reduce, as well as
    increase, the size of partitions. Hence you're no longer stuck with the original settings (the only difficulty is, you can't resize a mounted volume; this means that resizing still requires using a separate boot disk if you need to reduce the primary partition).

  9. #9
    Join Date
    Apr 2006
    Posts
    1,092
    Quote Originally Posted by urilabob
    please understand I am _not_ an lvm expert.
    Nor am I - but I'm something of a convert.

    Quote Originally Posted by urilabob
    A. I ran Knoppix
    1. Downloaded Knoppix and burned to CD (http://www.knoppix.net/)
    2. Booted Knoppix on the computer
    Knoppix is a fabulous product, and it's saved my bacon many times - but I always prefer to use the real system to do its own maintenance if I possibly can. That way, I *know* I've got utilities compatible with the filesystems I'm trying to alter. But then I am a worrier... :-)

    Quote Originally Posted by urilabob
    I was resizing to 58G
    It's _crucial_ that the parameters in resize2fs and in lvreduce match
    Otherwise you will probably destroy your filesystem.
    There's a natty trick you can do to overcome this problem.

    - Use resize2fs to shrink the filesystem to *just smaller* than you actually want it (but big enough to contain your data, of course!)
    - Use lvreduce to shrink the partition to the size you actually want it
    - use resize2fs *again*, but without a size parameter to grow the filesystem into the maximum space permitted by the partition

    Vic.

  10. #10
    Join Date
    Sep 2005
    Posts
    122
    Quote Originally Posted by ccrvic
    Nor am I - but I'm something of a convert.
    Me too - my new system is using LVM over RAID, and working wonderfully.

    Quote Originally Posted by ccrvic
    Knoppix is a fabulous product, and it's saved my bacon many times - but I always prefer to use the real system to do its own maintenance if I possibly can. That way, I *know* I've got utilities compatible with the filesystems I'm trying to alter. But then I am a worrier... :-)
    The reason for using Knoppix was that I couldn't find the necessary lvm utilities on the FC4 rescue CD; it was easier to just grab a standard Knoppix CD than to tailor the FC4 rescue CD.

    Quote Originally Posted by ccrvic
    There's a natty trick you can do to overcome this problem.

    - Use resize2fs to shrink the filesystem to *just smaller* than you actually want it (but big enough to contain your data, of course!)
    - Use lvreduce to shrink the partition to the size you actually want it
    - use resize2fs *again*, but without a size parameter to grow the filesystem into the maximum space permitted by the partition

    Vic.
    Thanks, that's well worth knowing
    Bob

Similar Threads

  1. Secure Disk Partitioning, phyical partition or logical volume?
    By yann in forum Installation, Upgrades and Live Media
    Replies: 1
    Last Post: 12th July 2008, 11:24 AM
  2. Kickstart Installation using Existing Logical Volume
    By arifsaha in forum Installation, Upgrades and Live Media
    Replies: 0
    Last Post: 18th January 2008, 08:12 PM
  3. What is the device for /tmp in a default FC5 logical volume setup?
    By Dunhausen in forum EOL (End Of Life) Versions
    Replies: 1
    Last Post: 12th September 2006, 09:16 AM
  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. Replies: 4
    Last Post: 27th February 2005, 05:43 AM

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
  •