how can I shrink logical volume and create new partition if the logical volume to shrink is present in the middle?

1

I have a HDD of size 120Gb, that has RHEL6 with 2 physical partitions sda1: /boot sda2: LVM managed Logical volumes VolGroup00

VolGroup00 contains following logical volumes /lv_root 36G /lv_opt 45G /lv_home 24G /lv_tmp 3G /lv_audit 3G /lv_log 3G

I had tried shrinking /opt by 4Gb using lvresize, resize2fs and mkfs commands and created new physical partition from the new free space. In this case, /opt was present as last logical volume (as printed by fdisk -l). Freeing space from /opt and creating new partition worked fine. sda3 was created at the end of hdd.

But I want to free space from /home which is present in the middle of logical volume group. When I try to create sda3 by freeing space from /home, all existing logical volumes gets corrupted and OS fails to boot.

Kindly suggest on how this could be achieved. Thanks in advance.

AvinashUpadhyaya

Posted 2015-05-29T07:32:32.707

Reputation: 11

Please clarify your question, because you make very bad mix of physical disks, partitions, physical volumes and logical volumes. At least provide result of mount command – Romeo Ninov – 2015-05-29T08:04:49.447

apologies for my incomplete question. Please check the edited question – AvinashUpadhyaya – 2015-05-29T09:31:55.213

Answers

0

With LVM you do not need to take care about harddisks. So sda? have nothing to do with logical volumes and free space in volume group. If you free diskspace resize2fs and lvreduce you free diskspace in volume group. And you can use this space to create with lvcreate new logical volume. Here is one good manual how to shrink logical volume

Romeo Ninov

Posted 2015-05-29T07:32:32.707

Reputation: 2 062

I think I still didnt clearly put my question. Apologies again for that. I do not want to create logical volume but a physical partition. I want to free space from logical volume /home that is present in sda2 physical partition and create new physical partition sda3. Since /home is present in middle of logical volumes on VolGroup00 that is present on partition sda2, I am not able to create new partition. It is leading to crashing the system. – AvinashUpadhyaya – 2015-05-29T10:20:31.833

Do you have special reason for creating partition instead of logical volume. In all the cases i know you can use LV as normal disk partition. And again: start thinking in sense of LVM or physical hardisks and partitions. Not both of them – Romeo Ninov – 2015-05-29T10:24:10.240

Yes. I wanted a separate partition for rescue and upgrades purpose. And logical volumes will not be available during boot time. Kindly ignore the physical harddisk. I must have misplaced and thats the cause of confusion. The real issue is as I mentioned before, our current version of OS has sda1 as ext3 and sda2 as LVM. I want to create sda3 as ext3 fs by making free space from shrinking /home present on sda2. – AvinashUpadhyaya – 2015-05-29T10:57:46.900