Adjust the size of the Linux Logical Volume

After a physical server systems installed Ubuntu 14.04, found the space allocated to the root rolled over, and the roll mounted in the root directory, will affect subsequent use of such logs;

Consider increases without affecting the services running to root space, increasing space to the home volume, record the main process is as follows:

1) reducing the size of large volumes home

1. First unmount the volume

# umount /dev/mapper/ubuntu--vg-home

2. Detection of a file system, the file system size to reset

# e2fsck -f /dev/mapper/ubuntu--vg-home
# Note set here is reduced to the target size
# resize2fs /dev/mapper/ubuntu--vg-home 60G 

3. Reduce the volume size, remount

Here # is mainly to reduce the size of the volume 
# the lvreduce -L 200g / dev / Mapper / Ubuntu - VG- Home # mount -a

 At this time, running  lvs  or  df -hT  command can be seen, volume and file system has been reduced;

2) increase the size of the root volume

Compared reduce the volume and increase the volume more convenient, do not unload volumes, does not affect the normal operation of the service on the file system (it should be so), as follows:

1. Increase the volume size

# lvextend -L +200G /dev/mapper/ubuntu--vg-root

2. Re-set the size of the file system

# resize2fs /dev/mapper/ubuntu--vg-root

 At this time, running  lvs  or  df -hT  command can be seen, volume and file system size has been increased;

3) needs attention

When dismount volumes, there are other services that may be encountered regular use of the corresponding file system, you can find the corresponding PID, after determining that the service can be switched off, as follows:

# lsof /home
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
bash       1429 ubuntu  cwd    DIR    8,1     4096 20316161 /root
...
# kill -9 1429

Reference: https://www.cnblogs.com/linuxprobe/p/5381538.html

Guess you like

Origin www.cnblogs.com/oakyou/p/10988955.html