我用虛擬機(jī)裝的RHEL5.0,虛擬了8G的磁盤(pán),用的自動(dòng)分區(qū),現(xiàn)在想調(diào)整分區(qū)大小用df -lh查看了一下,出現(xiàn):Filesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol00 6.7G 3.4G 3.0G 54% /再用fdisk -l查看,出現(xiàn)Device boot Start End Blocks Id System/dev/sda2 14 1044 8281507+ 8e Linux LVM請(qǐng)看截圖有4問(wèn)題,請(qǐng)教大家一下:1)/dev/mapper/VolGroup00-LogVol00,這里的掛載點(diǎn)是什么意思,我不太明白???2)我總共只虛擬了8G的磁盤(pán),怎么在/dev/sda2下又出現(xiàn)了8281507 ???3)我沒(méi)有創(chuàng)建LVM,怎么/dev/sda2的掛載點(diǎn)是linux LVM ???4)如果我想擴(kuò)充根分區(qū)的大小,該怎么創(chuàng)建LVM ???
你用的自動(dòng)分區(qū)方式,系統(tǒng)默認(rèn)安裝的時(shí)候選擇的是用lvm安裝的!
還有你是想調(diào)大還是調(diào)小,調(diào)大的話(huà)需要新增加硬盤(pán),調(diào)小的話(huà)可能數(shù)據(jù)會(huì)造成丟失!
具體怎么調(diào)整需要先學(xué)習(xí)了 lvm后才可以 !
樓上的,請(qǐng)參見(jiàn)此帖的問(wèn)題4.-我想擴(kuò)充根分區(qū)的大小.
我的問(wèn)題你還是沒(méi)有回答清楚,我想問(wèn)
1)/dev/mapper/VolGroup00-LogVol00掛載在/分區(qū)下,
"mapper/VolGroup00-LogVol00"這些目錄指的是什么?為什么我用fdisk -l不能看到它?
2)我剛用vgscan和lvscan查看如下,
這里的LogVol00和LogVol01是不是/分區(qū)和swap分區(qū)的大小?它們就是LVM的大小?3)我想擴(kuò)充根分區(qū)的大小,該怎么辦?
1,/dev/mapper/VoLGroup00-LogVol00,是一個(gè)邏輯卷設(shè)備 !這個(gè)設(shè)備是邏輯設(shè)備,不是物理設(shè)備,所以不能用fdisk -l來(lái)查看,你可以通過(guò) lvdisplay 查看 !
2,在安裝的時(shí)候,你先建立了一個(gè) swap空間,剩余的空間系統(tǒng)首先建立一個(gè)physical volumes,這個(gè)物理卷的大小就應(yīng)該是你分完swap分區(qū)后剩余的大小,然后在physical volumes上創(chuàng)建 volume groups ,最后在volume groups上面創(chuàng)建 logical volumes.這個(gè) /dev/mapper/VoLGroup00-LogVol00就是 logical volumes的名字!
3的意思就是上面我說(shuō)的 把/dev/sda2分區(qū)全部分配給了這個(gè)邏輯卷 !分區(qū)的大小你不用太關(guān)心,畢竟虛擬機(jī)上面分配的大小不是太準(zhǔn)確 !
具體怎么調(diào)整邏輯卷的大小可以等晚上回去我發(fā)一篇文章,這個(gè)一下子不好說(shuō) !
三,Logical Volume Manager(LVM)
creating logical volumes
1,create physical volumes
pvcreate /dev/sda3
2,assign physical volumes to volume groups
vgcreate vg0 /dev/sda3
3,create logical volumes from volume groups
lvcreate -L 256M -n data vg0
mke2fs -j /dev/vg0 data
resizing logical volumes
growing volumes
lvextend: can grow logical volumes
resize2fs: can grow EXT3 filesystems online
vgextend:adds new physical volumes to an existing volume group
shrinking volumes
filesystem must be reduced first
requires a filesystem check and cannot be performed online
lvreduce can then reduce the volume
volume groups can be reduced with:
pvmove /dev/sda4
vgreduce vg0 /dev/sda4
using LVM Snapshosts
1,create snapshot of existing logical volume
#lvcreate -l 64 -s -n databackup /dev/vg0/data
-l: 大小,(PE數(shù)量)
-s: 創(chuàng)建快照
-n: 快照名稱(chēng)
2,mount snapshot
#mkdir -p /mnt/databackup
#mount -o ro /dev/vg0/databackup /mnt/databackup
3,remove snapshot
#umount /mnt/databackup
#lvremove /dev/vg0/databackup
例子1:
創(chuàng)建lvm
分區(qū)情況:
/dev/sda5 1864 2113 2008093+ 83 Linux
/dev/sda6 2114 2363 2008093+ 83 Linux
/dev/sda7 2364 2613 2008093+ 83 Linux
1,準(zhǔn)備物理分區(qū)
[root@tonykorn97 ~]# pvcreate /dev/sda5 /dev/sda6
Physical volume "/dev/sda5" successfully created
Physical volume "/dev/sda6" successfully created
2,創(chuàng)建卷組(vg)
[root@tonykorn97 ~]# vgcreate vg0 /dev/sda5 /dev/sda6
Volume group "vg0" successfully created
3,創(chuàng)建邏輯卷(lv)
[root@tonykorn97 ~]# lvcreate -L 256M -n data vg0
Logical volume "data" created
[root@tonykorn97 ~]# mke2fs -j /dev/vg0/data
4,查看邏輯卷狀態(tài)(pvdisplay,vgdisplay,lvdisplay):
[root@tonykorn97 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name vg0
PV Size 1.92 GB / not usable 1.03 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 490
Free PE 426
Allocated PE 64
PV UUID IGrsYz-U1Cd-d2zc-qMZU-mN2F-6lhN-SnurgQ
--- Physical volume ---
PV Name /dev/sda6
VG Name vg0
PV Size 1.92 GB / not usable 1.03 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 490
Free PE 490
Allocated PE 0
PV UUID 42JR9t-eVBb-b10D-J3YB-DwIe-30Tn-A4f1qq
--- Physical volume ---
PV Name /dev/sda2
VG Name vol0
PV Size 13.67 GB / not usable 17.96 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 437
Free PE 165
Allocated PE 272
PV UUID zQcqMn-cl8j-vDJX-q1RK-qZu7-tOOd-U4bhsd
[root@tonykorn97 ~]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 3.83 GB
PE Size 4.00 MB
Total PE 980
Alloc PE / Size 64 / 256.00 MB
Free PE / Size 916 / 3.58 GB
VG UUID pVpA1x-0zHs-a2K4-f43m-lgs2-LmHt-wFIylW
--- Volume group ---
VG Name vol0
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 13.66 GB
PE Size 32.00 MB
Total PE 437
Alloc PE / Size 272 / 8.50 GB
Free PE / Size 165 / 5.16 GB
VG UUID mvOUOL-nHtO-aqUo-vM82-27hf-gUw0-iqUAhK
[root@tonykorn97 ~]# lvdisplay
--- Logical volume ---
LV Name /dev/vg0/data
VG Name vg0
LV UUID zJWu4F-3AkP-nGlZ-vivg-g0EM-DrjQ-z80oaa
LV Write Access read/write
LV Status available
# open 0
LV Size 256.00 MB
Current LE 64
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:2
--- Logical volume ---
LV Name /dev/vol0/root
VG Name vol0
LV UUID 2YFBhR-WfBk-JFjy-uRB7-Z1lt-2hVi-62GTED
LV Write Access read/write
LV Status available
# open 1
LV Size 8.00 GB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:0
--- Logical volume ---
LV Name /dev/vol0/home
VG Name vol0
LV UUID 7RcMbr-BAXi-kJ3t-5A1P-vqNh-3OuC-bY2qlk
LV Write Access read/write
LV Status available
# open 1
LV Size 512.00 MB
Current LE 16
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:1
[root@tonykorn97 ~]#
例子2:增大邏輯卷的步驟
簡(jiǎn)單的步驟如下(文件系統(tǒng)沒(méi)有加載):
[root@tonykorn97 ~]# lvextend -L +500M /dev/vg0/data
Extending logical volume data to 756.00 MB
Logical volume data successfully resized
[root@tonykorn97 ~]# resize2fs /dev/vg0/data
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg0/data to 774144 (1k) blocks.
The filesystem on /dev/vg0/data is now 774144 blocks long.
[root@tonykorn97 ~]# lvdisplay
--- Logical volume ---
LV Name /dev/vg0/data
VG Name vg0
LV UUID zJWu4F-3AkP-nGlZ-vivg-g0EM-DrjQ-z80oaa
LV Write Access read/write
LV Status available
# open 0
LV Size 756.00 MB
Current LE 189
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:2
詳細(xì)步驟:
1,lvextend -L +500M /dev/vg0/data
2,umount /data
3,e2fsck -f /dev/vg0/data
4,resize2fs /dev/vg0/data
5,lvdisplay
例子3,縮小vg的容量大?。ㄒ话闱闆r下不要用)
1,umont /data
2,e2fack -f /dev/vg0/data
3,[root@tonykorn97 ~]# resize2fs /dev/vg0/data 100M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg0/data to 102400 (1k) blocks.
The filesystem on /dev/vg0/data is now 102400 blocks long.
[root@tonykorn97 ~]#
4,[root@tonykorn97 ~]# lvreduce -L 100M /dev/vg0/data
WARNING: Reducing active logical volume to 100.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce data? [y/n]: y
Reducing logical volume data to 100.00 MB
Logical volume data successfully resized
[root@tonykorn97 ~]#
5,lvdisplay
[root@tonykorn97 ~]# lvdisplay
--- Logical volume ---
LV Name /dev/vg0/data
VG Name vg0
LV UUID zJWu4F-3AkP-nGlZ-vivg-g0EM-DrjQ-z80oaa
LV Write Access read/write
LV Status available
# open 0
LV Size 100.00 MB
Current LE 25
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:2
例子4,增大物理卷組的步驟
1,pvcreate /dev/sda7
2,vgextend vg0 /dev/sda7
3,vgdisplay
原來(lái)的狀態(tài):
[root@tonykorn97 ~]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 3.83 GB
PE Size 4.00 MB
Total PE 980
Alloc PE / Size 25 / 100.00 MB
Free PE / Size 955 / 3.73 GB
創(chuàng)建pv
[root@tonykorn97 ~]# pvcreate /dev/sda7
Physical volume "/dev/sda7" successfully created
擴(kuò)展vg
[root@tonykorn97 ~]# vgextend vg0 /dev/sda7
Volume group "vg0" successfully extended
查看現(xiàn)在的狀態(tài):
[root@tonykorn97 ~]# vgdisplay
--- Volume group ---
VG Name vg0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 5.74 GB
PE Size 4.00 MB
Total PE 1470
Alloc PE / Size 25 / 100.00 MB
Free PE / Size 1445 / 5.64 GB
VG UUID pVpA1x-0zHs-a2K4-f43m-lgs2-LmHt-wFIylW
例子5,刪除邏輯卷
[root@tonykorn97 ~]# lvremove /dev/vg0/data
Do you really want to remove active logical volume "data"? [y/n]: y
Logical volume "data" successfully removed
[root@tonykorn97 ~]#
例子6,刪除pv,此時(shí)這個(gè)分區(qū)正在使用,需要先刪除vg,然后才可以再刪除pv
[root@tonykorn97 ~]# pvremove /dev/sda7
Can't pvremove physical volume "/dev/sda7" of volume group "vg0" without -ff
[root@tonykorn97 ~]# vgremove /dev/vg0
Volume group "vg0" successfully removed
[root@tonykorn97 ~]# pvremove /dev/sda7
Labels on physical volume "/dev/sda7" successfully wiped
[root@tonykorn97 ~]#
不要使用pvremove的-ff參數(shù),使用的話(huà)會(huì)把vg信息破壞掉。
上面的命令需要?jiǎng)h除vg,如果vg中存在內(nèi)容的話(huà)就不能使用,正確的做法是:
[root@tonykorn97 ~]# vgreduce vg0 /dev/sda7
Removed "/dev/sda7" from volume group "vg0"
[root@tonykorn97 ~]# pvremove /dev/sda7
Labels on physical volume "/dev/sda7" successfully wiped