Today in the installation of Oracle one RAC, look at the operating system DF-LH, found that the/home directory has been divided into more than 500 g,/root directory only 50G, then I burst a foul language, the TM system is how to do.
Filesystem Size used Avail use% mounted on
/dev/mapper/vg_db5-lv_root 50G 6.2G 41G 14%/
Tmpfs 127G 84K 127G 1%/DEV/SHM
/DEV/SDQ1 477M 37M 415M 9%/boot
/dev/mapper/vg_db5-lv_home 496G 70M 471G 1%/Home
#vgdisplay
---Volume Group---
VG Name VG_DB5
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
ACT PV 1
VG Size 557.26 GiB
PE Size 4.00 MiB
Total PE 142658
Alloc pe/size 142658/557.26 GiB
Free Pe/size 0/0
VG UUID Plc2k9-lrvy-bcck-b9qp-3f8k-h6cw-w4vrds
#lvdisplay
---Logical volume---
LV Path/dev/vg_db6/lv_root
LV Name Lv_root
VG Name VG_DB6
LV UUID 6hlvnp-6rgm-korq-eox6-nqqv-8pwb-gg4wne
LV Write Access Read/write
LV Creation Host, Time DB6, 2015-02-02 19:25:11 +0800
LV Status Available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 256
Block Device 253:0
---Logical volume---
LV Path/dev/vg_db6/lv_home
LV Name Lv_home
VG Name VG_DB6
LV UUID yubjai-96d6-jfwx-cmxr-eexe-cuuu-uqrl3l
LV Write Access Read/write
LV Creation Host, Time DB6, 2015-02-02 19:25:17 +0800
LV Status Available
# open 1
LV Size 503.26 GiB
Current LE 128834
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 256
Block Device 253:10
---Logical volume---
LV Path/dev/vg_db6/lv_swap
LV Name Lv_swap
VG Name VG_DB6
LV UUID D5fqb1-tthm-hsrb-b0tm-r1ms-xnvp-dh5ovs
LV Write Access Read/write
LV Creation Host, Time DB6, 2015-02-02 19:27:23 +0800
LV Status Available
# open 1
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead Sectors Auto
-Currently set to 256
Block Device 253:1
There were three LV in a VG, which decided to adjust the size of these three lv. Turn the Lv_home small, then turn the lv_root up. Note that there is a risk of narrowing the space, so I first delete the Oracle,grid user and all the groups inside, and then restart the system.
#userdel Oracle
#userdel Grid
#groudel Oinstall
....................
After rebooting, check the/ETC/GROUP,/ETC/PASSWD, confirm that there are no users and groups, we can start.
1. #umount/home1. #umount/Home
If unsuccessful, an error may occur, the workaround is as follows: Umount:/mnt/cdrom:device is busy.
(In some cases useful info about processes that
Use the device are found by lsof (8) or user (1))
#umount/mnt/cdrom/-f//forced unload also not
Umount2: Device or resource busy
Umount:/mnt:device is busy.
(In some cases useful info about processes
The device is found by lsof (8) or fuser (1)) Umount2: Devices or resources are busy
#fuser-M/home
/home:1338c
# PS aux |grep 1338
Root 1338 0.0 0.2 108292 1912 PTS/2 ss+ 14:27 0:00-bash
Root 1423 0.0 0.1 103236 884 pts/1 s+ 14:49 0:00 grep 1338
#kill-9 1338
#fuser-M/home
#umount/Home
Parsing: But the feeling that this method is only used for those insignificant directories, because the process uses less, if it is/directory, the process will not kill, kill, the system is estimated to collapse.
Reduction of logical volumes, risk, first reducing logical boundaries--reducing physical boundaries
Note: 1, can not be reduced online, you have to uninstall first;
2, to ensure that the size of the reduced space can still store all the original data;
3, before the reduction should be forced to check the file, to ensure that the file system in a consistent state
2. Check
#e2fsck-F/dev/vg_db5/lv_home
E2fsck 1.41.12 (17-may-2010)
First step: Check Inode, block, and size
Step Two: Check the directory structure
3rd Step: Check the directory connectivity
Pass 4:checking Reference counts
5th Step: Check Cluster summary information
/dev/vg_db5/lv_home:29/32989184 files (0.0% non-contiguous), 2121120/131926016 blocks
3. Start shrinking the file system:
#resize2fs/dev/vg_db5/lv_home 1024M
RESIZE2FS 1.41.12 (17-may-2010)
Resize2fs:new size smaller than minimum (307344)
Display 1G is too small, the minimum is 307,344 blocks. Come on, 10 g.
#resize2fs/dev/vg_db5/lv_home 10G
RESIZE2FS 1.41.12 (17-may-2010)
Resizing the filesystem on/dev/vg_db5/lv_home to 2621440 (4k) blocks.
The filesystem on/dev/vg_db5/lv_home is now 2621440 blocks long.
4. Reduce the LV size:
# lvreduce-l 10g/dev/vg_db5/lv_home
Warning:reducing active Logical Volume to 10.00 GiB
This May DESTROY YOUR DATA (filesystem etc)
Does really want to reduce lv_home? [y/n]: Y
Size of logical volume Vg_db5/lv_home changed from 503.26 Gib (128834 extents) to 10.00 GIB (2560 extents).
Logical Volume Lv_home successfully resized
#vgdisplay found out the space has been released.
---Volume Group---
VG Name VG_DB5
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 2
Max PV 0
Cur PV 1
ACT PV 1
VG Size 557.26 GiB
PE Size 4.00 MiB
Total PE 142658
Alloc pe/size 16384/64.00 GiB
Free Pe/size 126274/493.26 GiB
VG UUID JI4TQC-IBHS-O6CB-XH5Q-Q4UK-DIER-DVSMMD
5. Increase the size of the lv:lv_root to 500G
#lvextend-L 500g-f-r/dev/vg_db5/lv_root
Size of logical Volume Vg_db5/lv_root changed from 50.00 Gib (12800 extents) to 500.00 GIB (128000 extents).
Logical Volume Lv_root successfully resized
RESIZE2FS 1.41.12 (17-may-2010)
Filesystem at/dev/mapper/vg_db5-lv_root is mounted on/; On-line resizing required
Old desc_blocks = 4, new_desc_blocks = 32
Performing an on-line resize of/dev/mapper/vg_db5-lv_root to 131072000 (4k) blocks.
The filesystem on/dev/mapper/vg_db5-lv_root is now 131072000 blocks long.
If you want to increase your operating system size again, you don't have to do it.
# Resize2fs/dev/vg_db5/lv_root 500G
RESIZE2FS 1.41.12 (17-may-2010)
The filesystem is already 131072000 blocks long. Nothing to Do!
#resize2fs-P/dev/vg_db5/lv_root
RESIZE2FS 1.41.12 (17-may-2010)
The filesystem is already 131072000 blocks long. Nothing to Do!
After reboot:
#df-LH
Filesystem Size used Avail use% mounted on
/dev/mapper/vg_db5-lv_root 493G 6.2G 461G 2%/
Tmpfs 160G 144K 160G 1%/DEV/SHM
/DEV/SDQ1 477M 37M 415M 9%/boot
/dev/mapper/vg_db5-lv_home 9.8G 37M 9.2G 1%/Home
It's finally done.
For more detailed LVM theory concepts, see the blog:
http://80cto.blog.51cto.com/7503144/1610922
The process and thinking of reducing and increasing LV in Linux