xenserver中linux vps 如何调整硬盘大小 2015-03-19 @ TECH /dev/xvdadiskfadiskresizeresize2fsxenserver
首先这里说的调整指的是增加,目前还没有遇到需要单独减小硬盘的情况,分区用默认的ext2/3/4
一、关机, xencenter中调整硬盘大小
二、开机,fadisk相关操作
df -l -BG 然后 fdisk -l 查看映射、硬盘大小是否已经调整成功,vps中默认的一般是 /dev/xvda,如下所示
Disk /dev/xvda: 32.2 GB, 32212254720 bytes 255 heads, 63 sectors/track, 3916 cylinders, total 62914560 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 identifier: 0x000c9e45 Device Boot Start End Blocks Id System /dev/xvda1 2048 15988735 7993344 83 Linux /dev/xvda2 15990782 16775167 392193 5 Extended /dev/xvda5 15990784 16775167 392192 82 Linux swap / Solaris
硬盘大小已成功调整为32.2GB,那么接下来就是重建分区表来使用这32.2GB
执行 fdisk /dev/xvda 按提示操作,p 显示分区表,d 删除分区, n 新建分区,w保存分区表
把上面3个分区全删除后新建为一整个分区,执行完成后应如下所示
Disk /dev/xvda: 32.2 GB, 32212254720 bytes 64 heads, 51 sectors/track, 19275 cylinders, total 62914560 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 identifier: 0x0008292e Device Boot Start End Blocks Id System /dev/xvda1 2048 62914559 31456256 83 Linux
重启生效。
三、resize2fs 调整映射大小
执行 resize2fs -p /dev/xvda1 和 df -l -BG 查看映射是否调整成功
—EOF–
番外篇:xencenter中自带模版建vps硬盘最小8G,而实际上linux vps硬盘1G即可,登录xenserver命令行可调整
#查找模版uuid,比如debian 7 wheezy 64-bit [root@xen ~]# xe template-list|grep -b1 64-bit|grep -b1 Wheezy 819-2091-uuid ( RO) : c6f1c77e-09eb-b3c4-bf5c-3ac6113c085a ... #读取配置 [root@xen ~]# xe template-param-get uuid=c6f1c77e-09eb-b3c4-bf5c-3ac6113c085a param-name=other-config disks: <provision><disk device="0" size="8589934592" sr="" bootable="false" type="system"/></provision>; mac_seed: ... #修改配置:8589934592=8G,2147483648=2G,1073741824=1G [root@xen ~]# xe template-param-set uuid=c6f1c77e-09eb-b3c4-bf5c-3ac6113c085a other-config:disks='<provision><disk device="0" size="2147483648" sr="" bootable="false" type="system"/></provision>' #检查配置 [root@xen ~]# xe template-param-get uuid=c6f1c77e-09eb-b3c4-bf5c-3ac6113c085a param-name=other-config disks: <provision><disk device="0" size="2147483648" sr="" bootable="false" type="system"/></provision>; mac_seed: ...
参考资料:
https://www.schirmacher.de/display/INFO/How+to+increase+XenServer+virtual+machine+root+or+swap+partition
https://maanasroyy.wordpress.com/2012/06/03/resize-a-linux-vm-lvm-disk-in-xenserver/
暂无评论