虚拟机磁盘扩容
1. 将需要扩容的虚拟机关机,点击虚拟机——编辑配置——硬盘,调整所需大小:
2. 调整完成后开启虚拟机。
3. 查看磁盘设备
命令:# fdisk -l
结果:
Disk /dev/sda: 697.9 GB, 697932185600 bytes
255 heads, 63 sectors/track, 84852 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00054716
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 39163 314059776 8e Linux LVM
找到需要扩展的磁盘设备
4. 使用fdisk /dev/sda 对磁盘进行分区
命令:# fdisk /dev/sda
结果:
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partit
p
Partition number (1-4): 3
First cylinder (39163-84852, default 39163):
Using default value 39163
Last cylinder, +cylinders or +size{K,M,G} (39163-84852, default 84852):
Using default value 84852
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 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)
Syncing disks.
依次输入n,p, 3(分区号,根据实际情况配置),enter,enter ,最后按w保存
之前最大的分区号是2,所以将本分区号设置为3
5. 使用fdisk -l查看分区是否创建成功
命令: fdisk -l
结果: Physical volume "/dev/sda3" successfully created
本结果应该是有3个分区才正确,这里不给出结果内容
6.重启机器
命令:# reboot
因为只有重启后,才能正式生效。
7.使用pvcreate创建物理卷
命令:# pvcreate /dev/sda3
结果: Physical volume "/dev/sda3" successfully created
8.查看原VG的情况
命令: vgdisplay
结果:
--- Volume group ---
VG Name VolGroup //注意记录此名字,扩容时将新的pv加入指定的名字
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 7.51 GiB
PE Size 4.00 MiB
Total PE 1922
AllocPE / Size 1922 / 7.51 GiB
Free PE / Size 0 / 0
VG UUID FnUsmX-s284-GeRK-hJNJ-BbIG-Vpe7-OuFZE1
9. 扩展卷组,将/dev/sdb物理卷添加到VolGroup卷组中
命令:# vgextend VolGroup /dev/sda3
结果:
Volume group "VolGroup" successfully extended
其中,VolGroup就是步骤6中查看得到的VG Name。
再查看VG情况,可以看到VG大小变化,空余空间。
10. 查看更改后VG的情况
命令:# vgdisplay
结果:
--- Volume group ---
VG Name VolGroup
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 22.50 GiB
PE Size 4.00 MiB
Total PE 5761
AllocPE / Size 1922 / 7.51 GiB
Free PE / Size 3839 / 15.00 GiB
VG UUID FnUsmX-s284-GeRK-hJNJ-BbIG-Vpe7-OuFZE1
11. 将新的VG空间划入LV(扩容lv_root)
命令:# lvextend -L +340G /dev/mapper/vgGW-lvRoot (空间以实际增加空间为准)
结果: 暂无内容
12. 检查/root逻辑卷
命令:# e2fsck -f /dev/mapper/vgGW-lvRoot
结果: 暂无内容
13. 重新定义分区大小
命令:# resize2fs /dev/mapper/vgGW-lvRoot (如需要xfs格式执行xfs_growfs /dev/mapper/vgGW-lvRoot)
结果: 暂无内容
14. 查看扩充后的磁盘状态
命令:# df -h
扩盘工作完成。
附录:
如使用直接添加新硬盘:
第一, 打开VMware vSphere Client并登陆,选择需要修改的虚拟主机
第二, 打开“资源分配”栏目,选择编辑
第三,点击“编辑”后出现
此处选择“添加”按钮,
【注意:此处如果要“移除”的话,我们可以选择要删除的磁盘,点击“移除”按钮,并选择“从虚拟机中移除并从磁盘删除文件”的选项~】
选择“硬盘”,下一步,选择“创建新的虚拟磁盘”
点击下一步,选择磁盘大小,此处,我们输入为“80G”
最后点击完成。会显示
此处,显示“正在添加”,当添加完毕后,会显示如下:
此时,代表已经添加完毕!
附录:
Windows Server扩展磁盘
登入到Windows Server虚拟机中,通过磁盘管理器进行初始化操作。步骤如下:
第一,打开计算机管理,点击“存储”中的“磁盘管理”;
第二,我们可看出新增的磁盘空间如下:
其中,红色标志的“磁盘2”是刚刚加入的空间;
第三,点击“磁盘2”,右击,选择“初始化磁盘”,
第四,点击“确定”;选中右边的“未指派”,右击,选择“新建磁盘分区”,点击“下一步”,选择“主磁盘分区”,选择分区大小,并指派驱动器号,最后选择“完成”即可。
|
文章
|
23535
|
创建日期
|
8-23-2018
|
作者
|
wangjianb
|
评分
|
(None)
|
|