Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to the world of logical volumes. I have installed a Linux (CentOS), and the installer created an 50 GB root logical volume (mounted at /), and a 475 GB home logical volume (mounted under /home). There is also 32 GB swap. The hard disk is a hardware-raid-virtual-disk (I don't know if this is relevant)

Now it turned out that I need a large space under /opt, but most of my free space is under /home. I guess the solution must be to create a new opt volume (the space, 200GB should be taken away from the home volume), and mount it under /opt.

It should be easy, but all the tutorials/questions I found deal with setting up LVM from the ground up (which I don't need)... So what is the command to take away a given space from an existing volume, and give it to a new volume? Thank you in advance.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

First unmount /home

umount /home

Then do a fsck

e2fsck -f /dev/mapper/vg-lvhome

Now shrink it to 275G

resize2fs /dev/mapper/vg-lvhome 275G

Resize LV

lvreduce -L 275G /dev/mapper/vg-lvhome

Mount /home

mount /home

NOTE: Of course you need to have 275G free space on /home

Now you can extend your lv as you like

lvextend -L +200G /dev/mapper/vg-lvopt
resize2fs /dev/mapper/vg-lvopt
share|improve this answer
    
This worked file until the last step, then lvextend gave me the message Logical volume lv_opt not found –  WannaKnow Mar 7 '13 at 20:30
    
OK, I solved, with lvcreate instead of lvextend and mkfs.ext4 instead of resize2fs. Thank you very nuch! –  WannaKnow Mar 7 '13 at 20:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.