一、登陸到EVElinux
輸入df -h查看一下/dev/mapper/eve--ng--vg-root這個文件目錄,這裏就是存放鏡像的。app
二、EVE關機編輯EVE虛擬機ide
以下圖擴展目前的容量:ui
而後點擊擴展,擴展完畢以後,會提示:磁盤已成功擴展,您必須從客戶及操做系統內部對磁盤從新進行分區和擴展文件系統。spa
注意:你沒法擴展具備快照的虛機中的磁盤,必須刪除快照。操作系統
三、EVE系統層面增長對磁盤出從新配置orm
我這裏分配的是200Gblog
root@eve-ng:~# fdisk -l
Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytesci
.......rem
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3e3ca055
Device Boot Start End Sectors Size Id Type //磁盤分區狀況
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 83884031 82882562 39.5G 5 Extended
/dev/sda5 1001472 83884031 82882560 39.5G 8e Linux LVM
Disk /dev/mapper/eve--ng--vg-root: 38.6 GiB, 41406169088 bytes, 80871424 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/eve--ng--vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
給硬盤sda分區:
root@eve-ng:~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (999424-419430399, default 999424): 83884032 //sda3的start sector值是sda2的end sector + 1 ,由於sda1和sda2中間有一些sector沒使用,因此First sector提示的默認值爲999424
Last sector, +sectors or +size{K,M,G,T,P} (83884032-419430399, default 419430399): (直接回車)
Created a new partition 3 of type 'Linux' and of size 160 GiB.
Command (m for help): p
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3e3ca055
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 83884031 82882562 39.5G 5 Extended
/dev/sda3 83884032 419430399 335546368 160G 83 Linux
/dev/sda5 1001472 83884031 82882560 39.5G 8e Linux LVM
Partition table entries are not in disk order.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
root@eve-ng:~# reboot //重啓,使得分區生效
將sda3加入到Volume group(VG)中:
查看VG名字:
root@eve-ng:~# vgdisplay
--- Volume group ---
VG Name eve-ng-vg
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 39.52 GiB
PE Size 4.00 MiB
Total PE 10117
Alloc PE / Size 10117 / 39.52 GiB
Free PE / Size 0 / 0
VG UUID EvwUbc-nfsg-dHqA-znxB-U3gv-V782-Q8ZxkI
將sda3加入到eve-ng-vg這個VG中
root@eve-ng:~# vgextend eve-ng-vg /dev/sda3
Physical volume "/dev/sda3" successfully created
Volume group "eve-ng-vg" successfully extended
再次查看:
root@eve-ng:~# vgdisplay
--- Volume group ---
VG Name eve-ng-vg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
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 199.52 GiB
PE Size 4.00 MiB
Total PE 51077
Alloc PE / Size 10117 / 39.52 GiB
Free PE / Size 40960 / 160.00 GiB
VG UUID EvwUbc-nfsg-dHqA-znxB-U3gv-V782-Q8ZxkI
四、擴容Logical Volume(LV)
首先查看LV的路徑和大小
root@eve-ng:~# lvdisplay
--- Logical volume ---
LV Path /dev/eve-ng-vg/root
LV Name root
VG Name eve-ng-vg
LV UUID ktUpR0-VpqS-rJJv-a1FC-u6Gd-U8yN-2WYQ53
LV Write Access read/write
LV Creation host, time eve-ng, 2018-03-21 02:25:21 +0200
LV Status available
# open 1
LV Size 38.56 GiB
Current LE 9872
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/eve-ng-vg/swap_1
LV Name swap_1
VG Name eve-ng-vg
LV UUID oFbeHd-xHkl-cpe1-22Nx-xX73-xLJF-fJKrXK
LV Write Access read/write
LV Creation host, time eve-ng, 2018-03-21 02:25:21 +0200
LV Status available
# open 2
LV Size 980.00 MiB
Current LE 245
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
將剩下的容量擴容到/dev/eve-ng-vg/root路徑下:
root@eve-ng:~# lvextend -l +100%FREE /dev/eve-ng-vg/root
Size of logical volume eve-ng-vg/root changed from 38.56 GiB (9872 extents) to 198.56 GiB (50832 extents).
Logical volume root successfully resized.
再次查看:
root@eve-ng:~# lvdisplay
--- Logical volume ---
LV Path /dev/eve-ng-vg/root
LV Name root
VG Name eve-ng-vg
LV UUID ktUpR0-VpqS-rJJv-a1FC-u6Gd-U8yN-2WYQ53
LV Write Access read/write
LV Creation host, time eve-ng, 2018-03-21 02:25:21 +0200
LV Status available
# open 1
LV Size 198.56 GiB
Current LE 50832
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/eve-ng-vg/swap_1
LV Name swap_1
VG Name eve-ng-vg
LV UUID oFbeHd-xHkl-cpe1-22Nx-xX73-xLJF-fJKrXK
LV Write Access read/write
LV Creation host, time eve-ng, 2018-03-21 02:25:21 +0200
LV Status available
# open 2
LV Size 980.00 MiB
Current LE 245
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
從新計算文件系統大小
root@eve-ng:~# resize2fs /dev/eve-ng-vg/root
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/eve-ng-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 13
The filesystem on /dev/eve-ng-vg/root is now 52051968 (4k) blocks long.
五、查看磁盤使用狀況
root@eve-ng:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.9G 0 7.9G 0% /dev
tmpfs 1.6G 18M 1.6G 2% /run
/dev/mapper/eve--ng--vg-root 196G 8.1G 179G 5% /
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/sda1 472M 83M 365M 19% /boot
擴容完成!