首先登錄宿主機(jī),查看
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
442G 155G 265G 37% /
/dev/sda1 99M 15M 80M 15% /boot
tmpfs 3.7G 0 3.7G 0% /dev/shm
none 3.7G 112K 3.7G 1% /var/lib/xenstored
生成一塊100G硬盤(pán)(過(guò)程比較慢 可以再開(kāi)一個(gè)宿主機(jī)終端 去指定目錄下 ll查看進(jìn)度)
#dd if=/dev/mapper/VolGroup00-LogVol00 of=/extenda/backup/backup/14_server_ext.img bs=1M
count=102400
修改配置文件,添加新生廠的磁盤(pán)給14_server虛擬機(jī)
# vim /etc/xen/14_server
disk = [ "tap:aio:/extenda/backup/backup/14_server.img,xvda,w","tap:aio:/extenda/backup/backup/14_server_ext.img,xvdb,w"]
重啟14_server虛擬機(jī)
# xm list
Name ID Mem(MiB) VCPUs State Time(s)
13_server 1 1024 1 -b---- 6390.2
14_server 10 4000 3 -b---- 1413.1
15_server 6 256 1 -b---- 8191.4
16_server 7 256 1 -b---- 227598.7
Domain-0 0 2389 8 r----- 24219.3
# xm destroy 14_server
# xm create 14_server
進(jìn)入14_server虛擬機(jī)進(jìn)行下一步的操作
# xm console 14_server
查看是否添加磁盤(pán)給14_server
# ll /dev/xvdb
brw-r----- 1 root disk 202, 16 May 11 11:46 /dev/xvdb
查看擴(kuò)容前磁盤(pán)情況
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
29G 19G 9.1G 67% /
/dev/xvda1 99M 22M 72M 24% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm
192.168.1.15:/home/www/dms/test/resources/upload
6.7G 3.4G 2.9G 54% /home/www/dms/resources/upload
192.168.1.15:/home/www/dms/test/resources/download
6.7G 3.4G 2.9G 54% /home/www/dms/resources/download
# fdisk -l
Disk /dev/xvda: 22.2 GB, 22221422592 bytes
255 heads, 63 sectors/track, 2701 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 2701 21591360 8e Linux LVM
Disk /dev/xvdb: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdb doesn't contain a valid partition table
創(chuàng)建物理卷
#pvcreate /dev/xvdb
查看物理卷
# pvdisplay
--- Physical volume ---
PV Name /dev/xvda2
VG Name VolGroup00
PV Size 20.59 GB / not usable 29.12 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 658
Free PE 0
Allocated PE 658
PV UUID DOzt7l-flYL-vpo2-25eh-xooh-5wgS-BFAi38
--- Physical volume ---
PV Name /dev/xvdb
VG Name VolGroup00
PV Size 100.00 GB / not usable 32.00 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 3199
Free PE 2879
Allocated PE 320
PV UUID IP8Vcl-DEG0-mGyn-UGiv-J1gH-B1EG-aJrPrN
查看原vg的情況
# vgdisplay
--- Volume group ---
VG Name VolGroup00 //注意這個(gè)名字 這是我們要給新pv添加的vg名
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 120.53 GB
PE Size 32.00 MB
Total PE 3857
Alloc PE / Size 978 / 30.56 GB
Free PE / Size 2879 / 89.97 GB
VG UUID zhDUVP-A8hK-hIXH-moR3-qqNC-2HS4-NGFK4m
擴(kuò)展卷組 將/dev/xvdb物理卷添加到VolGroup00 卷組中
# vgextend VolGroup00 /dev/xvdb
添加磁盤(pán)空間
# lvextend -L +10G /dev/mapper/VolGroup00-LogVol00
也可以使用命令
# lvextend -l +10%FREE /dev/mapper/VolGroup00-LogVol00
此時(shí),如果有df命令查看的話,會(huì)發(fā)現(xiàn)root空間并沒(méi)有增加的.還需要執(zhí)行以下兩步操作才可以.
檢查邏輯卷
#e2fsck -f /dev/mapper/VolGroup00-LogVol00
重新定義分區(qū)大小
#resize2fs /dev/mapper/VolGroup00-LogVol00
大功告成 快用df -h命令看看吧,希望您也能成功喲!