-
10th May 2007, 02:52 PM
#1
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)
-
10th May 2007, 03:06 PM
#2
Very cool, I didn't know this could be done in rescue mode.
Bookmarked
-
10th May 2007, 04:04 PM
#3
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.
-
10th May 2007, 04:16 PM
#4
I used VMware Server to run a copy of FC6 for creating the screenshots in the article.
-
10th May 2007, 04:18 PM
#5
Oh, that sounds interesting. Thanks :-) Have a nice day then!
-
4th June 2007, 03:24 PM
#6
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.
-
4th June 2007, 08:27 PM
#7
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.
-
7th June 2007, 01:41 AM
#8
Ok, so it worked as expected then. Thanks for clarifying that for me.
-
15th July 2007, 11:55 PM
#9
Super, it worked for me too. Thanks.
edit: I am using KDE, how can I acces that GUI graphic to see the free space?
-
11th December 2007, 03:01 PM
#10
lvm command not found
linux says that the lvm command is not found, nor system-configuration-lvm
what do i have to do now?
thx
-
11th December 2007, 04:29 PM
#11
Originally Posted by
theosofica
linux says that the lvm command is not found, nor system-configuration-lvm
what do i have to do now?
thx
Would you tell me with more detailed info? Could you boot the OS? Are hard disks found? Have you used a bootable CD to investigate the disks before?
-
11th December 2007, 04:37 PM
#12
yes the os boots ok, i resized the filesystem to 25gb:
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
25G 6.9G 17G 30% /
/dev/sda1 99M 19M 76M 20% /boot
tmpfs 252M 0 252M 0% /dev/shm
[xxxxxxxx@localhost ~]$
i did everything with the fc rescue cd, till the last step.. i can not go into the lvm shell
thx
-
11th December 2007, 04:53 PM
#13
Oh... In fact, I was so afraid of risk in resizing disk this way so I chose the safer way: using a Live CD (Ubuntu) to move all data to another place and then formatted, resized freely. I'm sorry that I don't have enough experience to give you an advice. In the mean time of waiting for experts' guide, I think you just leave what you're doing, and try my way above to save your data first if needed.
G'luck!
-
11th December 2007, 05:03 PM
#14
hello
i used the fc8 dvd (instead of fc7)in rescue mode and he was able to do lvresize
so far so good
thx
-
4th February 2008, 07:12 PM
#15
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..
Similar Threads
-
By khskinsfan in forum Installation, Upgrades and Live Media
Replies: 0
Last Post: 20th June 2009, 07:22 PM
-
By SRT in forum Using Fedora
Replies: 5
Last Post: 6th August 2006, 07:23 PM
-
By urilabob in forum EOL (End Of Life) Versions
Replies: 9
Last Post: 30th April 2006, 01:21 PM
-
By ajwynn in forum Using Fedora
Replies: 2
Last Post: 7th May 2005, 03:11 AM
-
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
-
Forum Rules
[[template footer(Guest)]]