Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shrink logical volume? 1

Status
Not open for further replies.

jet042

MIS
Dec 23, 2002
258
US
I have a laptop running Fedora Core 5, and it works great for me. It's been up for over a year with no problems. Issue is, I sometimes need to use it for work and to do that I need to be running Windows.

Currently, I'm using a full-disk spanning ext3 logical volume (original idea was to get a spiffy new HDD to put in the super bay then extend the logical volume to cover it too). I need to shrink that logical volume to about 15 GB so that I can use the remaining 25 GB for the Windows install.

Previously, I used Partition Magic on a Windows box to do the same thing in reverse, but I can't seem to find a similar tool or a way to do it from the command line. I know that I need to make sure all the data is moved to the front of the drive and then re-set the size of the lvg to the first 15 GB. The question is how? Has anyone done this before or have any ideas how to go about doing it?
 
Use resize2fs to shrink your partition first, followed by a lvreduce to shrink your LV and finally pvmove to move all your PEs from one PV to another.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
I don't typically work with LVM, so I'm not sure of its possible effects to LVM, but parted (command line) and qtparted (graphical) perform the same functionality of Partition Magic. They'll non-destructively resize partitions and move data to accommodate the resize.

I've used this many times with NTFS (under XP), ext2fs, ext3fs and reiserfs without issues. But I would definitely do a thorough backup before I started.


pansophic
 
I'd heard of parted and looked at it some, but not qtparted. I'll give that a shot.

fdisk is unable to see the whole LVM for some reason, so it won't let me shrink it down. I played with it and it's options for a few days without any success.

I'd also seen stuff about using resize2fs and lvreduce, but never the third option. If qtparted won't do what I'm looking for, I'll try that next.

Thanks.
 
I'm probably preaching to the choir, but make sure you have anything important backed up before you start messing around with qparted.
 
jet042 said:
I'd also seen stuff about using resize2fs and lvreduce, but never the third option. If qtparted won't do what I'm looking for, I'll try that next.

LVM Concepts if you are lost:
When you partition a disk as a PV (Physical Volume), LVM divides the partition into chunks of 4MB (default) PEs. When an LV (Logical Volume) is created, LVM takes PEs across all PVs (striping). I think you can change the default from striping to something else but I'm not at liberty to try that now.

When you want to remove a PV or repartition it, you'll need to get all your data off from it. This is where pvmove comes in. You can think of pvmove as "relocating" data from one HDD to another. Once all PEs on a PV is freed, remove the PV from the VG (Volume Group). You now have a stand alone HDD that you can wipe clean and repartition as needed.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Thanks for the info zeland. I'm afraid that parted or qtparted or gparted would destroy the LVM then. I knew that the LVM was more than just spanning partions which was why I qualified my response.


pansophic
 
pansophic:
That is correct. Tampering a PV with any partitioning utilities will kill LVM's PE allocation to a LV.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top