FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 01-24-2010, 04:25 PM
vitaminx
 
Default How to shrink a LVM partition

Hello,

I'd like to shrink a LVM partition on my harddisk. My current setup is
like that:


Name Flags Part Type FS Type [Label]
Size (MB)

------------------------------------------------------------------------------
sda1 Boot Primary Linux ext3 [boot]
246,76
sda5 Logical Linux LVM
159792,52


sda5 is ~160 GB.


I already shrinked the VG:

# vgdisplay | grep Size
VG Size 140,00 GiB
PE Size 4,00 MiB
Alloc PE / Size 4197 / 16,39 GiB
Free PE / Size 31642 / 123,60 GiB


So what I want is to reduce the LVM partition sda5 to 140 GB as well.

Is it possible without any data loss?


Thanks & regards,
vitaminx


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 01-24-2010, 06:27 PM
"Boyd Stephen Smith Jr."
 
Default How to shrink a LVM partition

On Sunday 24 January 2010 11:25:19 vitaminx wrote:
> I'd like to shrink a LVM partition on my harddisk.
>
> Is it possible without any data loss?

Yes, but it is tricky.

Check your file systems. Make sure they are clean before the process starts.

Take backups.

First make sure you have enough free space in your LVs. Then use a
combination of pvmove and pvresize to shrink your PE that corresponds to that
partition. Then shrink the partition in the partition table.

Check your file systems. You may be able to revert any damage done at this
point.

(Optional) Grow the PE to match the new partition size (e.g. if there's lack
at the end you left.) Grow LVs based on newly available space.

Check your file systems. This should be very quick. Growing is a lot less
tricky that shrinking, but it still has to be done in the right order.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
 
Old 01-24-2010, 10:35 PM
Tony Nelson
 
Default How to shrink a LVM partition

On 10-01-24 14:27:21, Boyd Stephen Smith Jr. wrote:
> On Sunday 24 January 2010 11:25:19 vitaminx wrote:
> > I'd like to shrink a LVM partition on my harddisk.
> >
> > Is it possible without any data loss?
>
> Yes, but it is tricky.
>
> Check your file systems. Make sure they are clean before the process
> starts.
>
> Take backups.
>
> First make sure you have enough free space in your LVs.

VGs.

> Then use a
> combination of pvmove and pvresize to shrink your PE that corresponds

PV

> to that partition. Then shrink the partition in the partition table.
>
> Check your file systems. You may be able to revert any damage done
> at this point.
>
> (Optional) Grow the PE to match the new partition size (e.g. if

PV

> there's lack
> at the end you left.) Grow LVs based on newly available space.
>
> Check your file systems. This should be very quick. Growing is a
> lot less tricky that shrinking, but it still has to be done in the
> right order.

--
__________________________________________________ __________________
TonyN.:' <mailto:tonynelson@georgeanelson.com>
' <http://www.georgeanelson.com/>


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 01-25-2010, 09:20 AM
Johannes Wiedersich
 
Default How to shrink a LVM partition

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Boyd Stephen Smith Jr. wrote:
> On Sunday 24 January 2010 11:25:19 vitaminx wrote:
>> I'd like to shrink a LVM partition on my harddisk.
>>
>> Is it possible without any data loss?
>
> Yes, but it is tricky.
>
> Check your file systems. Make sure they are clean before the process starts.
>
> Take backups.
>
> First make sure you have enough free space in your LVs. Then use a
> combination of pvmove and pvresize to shrink your PE that corresponds to that
> partition. Then shrink the partition in the partition table.

Shouldn't vitaminx first resize the underlying file system(s)???

- --
Johannes

Three nations have not officially adopted the International System
of Units as their primary or sole system of measurement: Burma,
Liberia, and the United States.

http://en.wikipedia.org/wiki/Si_units
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAktdcIoACgkQC1NzPRl9qEV5zwCfaLoEHmIwPe f2HNSTMvN4onBk
uboAniI9WFx+UBuaxCjepnq55hGr7XEt
=BK/V
-----END PGP SIGNATURE-----


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 01-25-2010, 03:45 PM
"Boyd Stephen Smith Jr."
 
Default How to shrink a LVM partition

On Monday 25 January 2010 04:20:58 Johannes Wiedersich wrote:
> Boyd Stephen Smith Jr. wrote:
> > On Sunday 24 January 2010 11:25:19 vitaminx wrote:
> >> I'd like to shrink a LVM partition on my harddisk.
> >
> > First make sure you have enough free space in your LVs. Then use a
> > combination of pvmove and pvresize to shrink your PE that corresponds to
> > that partition. Then shrink the partition in the partition table.
>
> Shouldn't vitaminx first resize the underlying file system(s)???

That would be part of making sure there's enough free space on his VGs. (I
said LVs in my message, but Johannes Wiedersich correeccted me.)

I don't allocate all my space to LVs immediately, and grow filesystems as
needed -- if the OP has been doing that, he may already have enough free space
on the VGs.

Also, the filesystems aren't "underlying" LVM. It is vice-versa.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
 
Old 01-25-2010, 04:02 PM
vitaminx
 
Default How to shrink a LVM partition

Am Montag, den 25.01.2010, 10:45 -0600 schrieb Boyd Stephen Smith Jr.:
> LVs in my message, but Johannes Wiedersich correeccted me.)
>
> I don't allocate all my space to LVs immediately, and grow filesystems
> as
> needed -- if the OP has been doing that, he may alr

Hi,

from my understanding resizing the partition itself (FS Type: Linux LVM
as fdisk tells me) should be the last step.

The LV's are all small enough, they barely take 10% of the VG's/PV's
space. In my setup the VG consists of only one PV, so they have the same
size.

I've tried to shrink the PV with pvresize which didn't throw errors -
but fdisk still shows me the same LVM partition size as before.
So I guess the partition table has to be modified somehow?

Greetings,
vitaminx


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 01-25-2010, 04:28 PM
"Boyd Stephen Smith Jr."
 
Default How to shrink a LVM partition

On Monday 25 January 2010 11:02:41 vitaminx wrote:
> I've tried to shrink the PV with pvresize which didn't throw errors -

Good.

> but fdisk still shows me the same LVM partition size as before.

That's normal. pvresize "just" updates the PV header and VG metadata.

> So I guess the partition table has to be modified somehow?

Yes. That was mentioned in my reply: "Then shrink the partition in the
partition table."

You can use fdisk or any other partition table editor for this. Some don't
support resizing a partition. In that case, you can delete and create a
smaller one. If doing the delete/create dance, you *must* create the new
partition on the same cylinder boundary as the current one to preserve the
current data.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
 
Old 01-26-2010, 05:18 AM
Tom H
 
Default How to shrink a LVM partition

>>> I'd like to shrink a LVM partition on my harddisk.

>> Check your file systems. *Make sure they are clean before the process starts.
>> Take backups.
>> First make sure you have enough free space in your LVs. *Then use a
>> combination of pvmove and pvresize to shrink your PE that corresponds to that
>> partition. *Then shrink the partition in the partition table.

> Shouldn't vitaminx first resize the underlying file system(s)?

If vitaminx's LV is > 140gb, yes. The sequence would have to be:
resize2fs ...
lvreduce ...
pvreduce ...
parted ... resize ...


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 10:54 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org