View Full Version : Shrinking a partition

15th June 2006, 05:45 AM
I need to shrink the partition on my laptop to create an additional partition of about 15 GB.
I know how to expand an existing partition if there is free unallocated space after it, but I'm not sure how to shrink my partitoin. My HD is as follows:
/dev/sda1 boot start: 1 end: 13 blocks: 104391 ID: 83 System: Linux
/dev/sda2 start: 14 end: 4864 blocks 38965657+ ID: 8e System Linux LVM

I thought I remembered setting it up with a swap partition but I guess not. Maybe that was my desktop.
sda2 is nowhere near full (28 GB free). I have a kanotix live CD with QT parted on it, but when I boot with it, it detects this, but resize is greyed out.
Anyway I can go about resizing this?

15th June 2006, 06:38 AM
You may want to read up on LVM=> http://www.tldp.org/HOWTO/LVM-HOWTO/

Your swap and your / partition are most likely logical volumes within the LVM partition. You can't resize an LVM partition using QTparted. Everything you need should be available through LVM. However, it could get a little tricky because you are most likely going to need to reduce the size of the / partition logical volume and I'm not sure if you can do that while it is mounted because you will need to reduce the size of the file system underneath it. That means you will probably need to boot from the Fedora Recover CD to perform the filesystem resize and LVM work from a command line.

As always--backup your data before playing with paritions or logical volumes:)

15th June 2006, 06:48 AM
wow thats a huge howto.
I was expecting I'd have to use Kanotix or some other LiveCD to do the work from. No worries there. I'll start digging through this. If I get confused I'll be back :)

15th June 2006, 06:34 PM
This is an output from my lvmdiskscan The big 35 GB partition I'm assuming is my main HD, the 1.9 GB piece is that possibly my swap?

[root@crossmr ~]# lvmdiskscan
/dev/ramdisk [ 16.00 MB]
/dev/dm-0 [ 35.19 GB]
/dev/ram [ 16.00 MB]
/dev/sda1 [ 101.94 MB]
/dev/dm-1 [ 1.94 GB]
/dev/ram2 [ 16.00 MB]
/dev/sda2 [ 37.16 GB] LVM physical volume
/dev/ram3 [ 16.00 MB]
/dev/ram4 [ 16.00 MB]
/dev/ram5 [ 16.00 MB]
/dev/ram6 [ 16.00 MB]
/dev/ram7 [ 16.00 MB]
/dev/ram8 [ 16.00 MB]
/dev/ram9 [ 16.00 MB]
/dev/ram10 [ 16.00 MB]
/dev/ram11 [ 16.00 MB]
/dev/ram12 [ 16.00 MB]
/dev/ram13 [ 16.00 MB]
/dev/ram14 [ 16.00 MB]
/dev/ram15 [ 16.00 MB]
2 disks
17 partitions
0 LVM physical volume whole disks
1 LVM physical volume

So it seems if I use resize2fs /dev/dm-0 15G
this will reduce the file system by 15GB.
Then if I run
lvreduce -L-15G /dev/dm-0

it should free up 15 GB. What is done with the 15 GB at that point? Is it still being kept within the LVM, do I need to further tell it somehow to release that space so its considered "unpartitioned" or does it do that automagically?

[edit] So when I'm in Kanotix and lvmdiskscan I get a completely different output and it just shows /dev/sda2 and not the /dev/dm-0 partition.

15th June 2006, 09:42 PM
lvmdiskscan List devices that could be used as physical volumes. Your / and your swap are most likely logical volumes within the existing LVM partition.

Boot into your system normally. su to root. Go into the lvm shell by typing in lvm at the command prompt. Issue an lvscan at the lvm> prompt to see your logical volumes. You can also issue a help command at the lvm> prompt to see all the available commands.

Depending on what you need the 15 GB partition for you could do it one of a couple different ways. If you need the 15 GB partition while running under Linux then you could simply create another logical volume within the existing LVM partition once you get the / partition resized. If you need the new 15 GB outside of Linux then you will still need to reduce the size of the LVM physical volume so there will be enough room to create a regular disk partition.

Since this is your first time I recommend setting up another LVM on a test machine or an external USB drive and playing with it that way.

15th June 2006, 11:08 PM
well I need the 15 gb as a separate partition to install Vista Beta 2 on. I'm going to an MS event in a week and a half (yeah yeah I know). Part of the event is them giving everyone copies and installing it there at the event on a machine you bring. I realize it will be full of propoganda and such, but there may be free food.

Unfortunately I don't have any machines I can mess around with lvm on, so I think I'm going to have to go for it and hope for the best :) My laptop isn't critical right now, so if I waste a day putting FC5 back on it because I mess it up, its not the end of the world. If you can think of any threads or sites that give an example walkthrough of the procedure I'd greatly appreciate it.