歡迎您光臨本站 註冊首頁

lvm下縮小根分區

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

一/先查看當前的 根分區 大小為21G
[root@test-disk ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 21G 960M 19G 5% /
/dev/mapper/VolGroup00-LogVol02 7.6G 151M 7.3G 2% /home
/dev/hda1 99M 12M 82M 13% /boot
tmpfs 189M 0 189M 0% /dev/shm

二/插入系統光碟,啟動后輸入linux rescue進去救援模式,不要配置網路,不要讓系統根掛載到/mnt/sysimage上,所以的界面選擇“skip”

分別為:查看物理卷 查看卷組 查看邏輯卷 激活邏輯卷

三/開始減小根文件系統大小


四/減小根lv大小


此時得出LogVol00的LE數量為682,總的PE數量為956,大小32M,所以可以減少的大小為
(956-682)*32M=8768M


五/重啟進去系統,再次查看根分區情況
[root@test-disk ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 13G 956M 12G 8% /
/dev/mapper/VolGroup00-LogVol02 7.6G 151M 7.3G 2% /home
/dev/hda1 99M 12M 82M 13% /boot
tmpfs 189M 0 189M 0% /dev/shm

[root@test-disk ~]# vgdisplay 查看卷組情況
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 10
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 29.88 GB
PE Size 32.00 MB
Total PE 956
Alloc PE / Size 682 / 21.31 GB
Free PE / Size 274 / 8.56 GB
VG UUID l6vUxv-U8KC-gVdH-RQH5-QuUC-jsdl-HjpVqN

[root@test-disk ~]# lvdisplay /dev/VolGroup00/LogVol00
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID Nbcfw3-7jG7-URyG-fRdl-5k6j-x0BC-EFpt0J
LV Write Access read/write
LV Status available
# open 1
LV Size 12.75 GB
Current LE 408
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

六/把從根分區減出的添加到/home
[root@test-disk ~]# umount /home/
[root@test-disk ~]# e2fsck -f /dev/VolGroup00/LogVol02
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup00/LogVol02: 11/2064384 files (9.1% non-contiguous), 103072/2048000 blocks

[root@test-disk ~]# lvextend -l 274 /dev/VolGroup00/LogVol02
/dev/cdrom: open failed: Read-only file system
Extending logical volume LogVol02 to 16.38 GB
Logical volume LogVol02 successfully resized

[root@test-disk ~]# e2fsck -f /dev/VolGroup00/LogVol02
e2fsck 1.39 (29-May-2006)


Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup00/LogVol02: 11/2064384 files (9.1% non-contiguous), 103072/2048000 blocks

[root@test-disk ~]# resize2fs /dev/VolGroup00/LogVol02
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/VolGroup00/LogVol02 to 4292608 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol02 is now 4292608 blocks long.

[root@test-disk ~]# mount -a

[root@test-disk ~]# df -h 再次查看,成功
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 13G 956M 12G 8% /
/dev/hda1 99M 12M 82M 13% /boot
tmpfs 189M 0 189M 0% /dev/shm
/dev/mapper/VolGroup00-LogVol02 16G 155M 16G 1% /home

本文出自 「linux」 博客,請務必保留此出處http://tonychiu.blog.51cto.com/656605/491794


[火星人 ] lvm下縮小根分區已經有1060次圍觀

http://coctec.com/docs/linux/show-post-49379.html