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.

This is my current disk state on a physical CentOS machine:

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_ecomwise-lv_root
                       50G   47G  267M 100% /
tmpfs                 5.8G     0  5.8G   0% /dev/shm
/dev/sda1             485M   63M  397M  14% /boot
/dev/mapper/vg_ecomwise-lv_home
                      406G  158G  227G  41% /home

As you can see my root partition is almost full and I need more space because additional log files cannot be written in the /var directory. This problem grew up after importing a huge database in /var/lib/mysql directory.

I have enough space on my logical volume lv_home but I don't know how can I get piece from lv_home without formatting and losing data from any of the partitions. Is it possible or I need to find another solution?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

This should do it, look at the man pages if you want more details on the specific commands;

umount /home
resize2fs /dev/mapper/vg_ecomwise-lv_home {the size you want}
lvreduce -L-{the size you want} /dev/mapper/vg_ecomwise-lv_home
mount /home

lvextend -L +{the size you want} /dev/mapper/vg_ecomwise-lv_root
resize2fs /dev/mapper/vg_ecomwise-lv_root {the size you want}
share|improve this answer
    
The following error is thrown when I am trying to mount the resized logical volume: mount: wrong fs type, bad option, bad superblock on /dev/mapper/vg_home-lv_home, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so –  bedel7 Apr 24 at 12:22

It is possible to do, using a combination of rezise2fs, lvreduce and lvextend. It's quite dangerous, and I would not recommend doing this on a system with any data you care about. But if you want to try the procedure looks something like this:

#Shrink the filesystem to 200G
resize2fs /dev/mapper/vg_ecomwise-lv_home 200G 
#Use a bit larger to avoid fatal off-by-something errors
lvreduce -L 210G /dev/mapper/vg_ecomwise-lv_home
#Regrow the filesystem to fill the partition
resize2fs /dev/mapper/vg_ecomwise-lv_home 
#Extend the volume by 50G
lvextend -L+50G /dev/mapper/vg_ecomwise-lv_root 
#Grow the filesystem
resize2fs /dev/mapper/vg_ecomwise-lv_root 
share|improve this answer

If you don't want to risk losing data due the partition/file system resizing, why not to stop MySQL, modify the home directory in my.cnf, move the database to /home/mysql/db or so and let MySQL store its data under /home?

share|improve this answer

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.