LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   shrink an lvm partition (https://www.linuxquestions.org/questions/linux-hardware-18/shrink-an-lvm-partition-948596/)

Pedroski 06-05-2012 05:21 AM

shrink an lvm partition
 
I have Fed 17 and Windows installed.
/dev/sda1 ntfs, /dev/sda ntfs, /dev/sda3 ext4 500mb /boot, /dev/sda4 extended 267GB with /dev/sda5 lvm2 pv vg_pedro-bedro


I don't like this. I want to shrink sda5 to half its size and install another Linux there.

Can I do this, or must I reformat the whole hd??

gparted says it can shrink sda4, but I haven't tried it yet, for fear of losing data.

syg00 06-05-2012 07:24 AM

You must do (in order):
- shrink the filesystem
- shrink the lv
- (maybe) shrink the vg
- (maybe) shrink the pv.

Then allocate a new partition for the new system.
The maybe's are because it might be possible to re-use the vg and pv for the new system if LVM. Personally I wouldn't risk it - free up all the space you need and allocate new (logical) partition(s) for the new system.

tldp.org has a LVM how-to.

MensaWater 06-05-2012 07:32 AM

Actually sda5 is almost certainly used as the Physical Volume (PV) for a Volume Group (VG) so you'll definitely need to shrink the VG and the PV. Prior to doing that you'd have to be sure none of the Logical Volumes (LVs) are using the space. Shrinking the filesystems/LVs should only be necessary if the VG doesn't have free space in it already. Shrinking filesystems is done before shrinking LVs and also should be done only after running an fsck on the filesystem.

You'd really need to read and understand man pages for
lvm
vgdisplay
lvdisplay
pvdisplay
pvresize
lvresize
resize2fs (assuming you're using ext2/ext3 filesystems)

syg00 06-05-2012 07:50 AM

Definitely ???.

A new system doing a pvscan will find it.
Must test if two systems can use the same pv/vg (presuming some free space in at least the vg) one day ...

MensaWater 06-05-2012 09:13 AM

Quote:

Originally Posted by syg00 (Post 4695945)
Definitely ???.

A new system doing a pvscan will find it.
Must test if two systems can use the same pv/vg (presuming some free space in at least the vg) one day ...

What are you responding to? I don't see how it relates to the OP's question at all.


All times are GMT -5. The time now is 10:16 PM.