<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[静怡家园]]></title> 
<link>http://www.zhanghaijun.com/index.php</link> 
<description><![CDATA[书山有路勤为径，学海无涯苦作舟！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[静怡家园]]></copyright>
<item>
<link>http://www.zhanghaijun.com/post//</link>
<title><![CDATA[ESXI虚拟机磁盘根分区无损扩容]]></title> 
<author>碟舞飞扬 &lt;webmaster@zhanghaijun.com&gt;</author>
<category><![CDATA[技术文章]]></category>
<pubDate>Tue, 02 Aug 2016 02:32:51 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//</guid> 
<description>
<![CDATA[ 
	ESXI虚拟机磁盘扩容总体上比较简单，为了数据的安全，动手前做好数据备份，或者克隆虚拟机备份，通过VMware vSphere Client客户端连接ESXI，编辑要扩容磁盘的虚拟机设置，选择磁盘可以直接修改为想要扩容的大小，注意该大小确定之后不能往小的修改，重启虚拟机之后你会发现磁盘的容量并没有发生改变，用fdisk -l查看硬盘的容量确实是已修改后的容量了，要想正常使用新增的容量我们还要做以下几步：<br/><br/>一、关闭要扩容的虚拟机，然后把磁盘添加到其他的虚拟机，或者使用LiveCD引导，我们这里直接把磁盘添加到另一台虚拟机，使用VMware vSphere Client客户端连接ESXI，选择要添加磁盘的那台虚拟机，编辑虚拟机设置-添加-硬盘-使用现有虚拟磁盘-浏览选择我们要扩容的那块磁盘之后确定保存，然后重启这台虚拟机。<br/><br/>二、登录虚拟机操作系统,执行以下操作：<br/><br/>[root@localhost ~]# fdisk -l /dev/sdb<br/><br/>Disk /dev/sdb: 268.4 GB, 268435456000 bytes<br/>255 heads, 63 sectors/track, 32635 cylinders<br/>Units = cylinders of 16065 * 512 = 8225280 bytes<br/>Sector size (logical/physical): 512 bytes / 512 bytes<br/>I/O size (minimum/optimal): 512 bytes / 512 bytes<br/>Disk identifier: 0xd0b1bc7f<br/><br/>&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Blocks&nbsp;&nbsp; Id&nbsp;&nbsp;System<br/>/dev/sdb1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1033&nbsp;&nbsp;&nbsp;&nbsp; 8297541&nbsp;&nbsp; 82&nbsp;&nbsp;Linux swap / Solaris<br/>/dev/sdb2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1034&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20887&nbsp;&nbsp; 159477255&nbsp;&nbsp; 83&nbsp;&nbsp;Linux<br/><br/>这是我们内部的测试机，磁盘空间有限，为了充分的利用磁盘空间，分区比较简单，就一个交换分区和根分区，下面我们使用fdisk删除根分区，并重新建根分区：<br/><br/>[root@localhost ~]# fdisk /dev/sdb<br/><br/>WARNING: DOS-compatible mode is deprecated. It&#039;s strongly recommended to<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch off the mode (command &#039;c&#039;) and change display units to<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sectors (command &#039;u&#039;).<br/><br/>Command (m for help): d<br/>Partition number (1-4): 2<br/><br/>Command (m for help): p<br/><br/>Disk /dev/sdb: 268.4 GB, 268435456000 bytes<br/>255 heads, 63 sectors/track, 32635 cylinders<br/>Units = cylinders of 16065 * 512 = 8225280 bytes<br/>Sector size (logical/physical): 512 bytes / 512 bytes<br/>I/O size (minimum/optimal): 512 bytes / 512 bytes<br/>Disk identifier: 0xd0b1bc7f<br/><br/>&nbsp;&nbsp; Device Boot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Blocks&nbsp;&nbsp; Id&nbsp;&nbsp;System<br/>/dev/sdb1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1033&nbsp;&nbsp;&nbsp;&nbsp; 8297541&nbsp;&nbsp; 82&nbsp;&nbsp;Linux swap / Solaris<br/><br/>Command (m for help): n<br/>Command action<br/>&nbsp;&nbsp; e&nbsp;&nbsp; extended<br/>&nbsp;&nbsp; p&nbsp;&nbsp; primary partition (1-4)<br/>p<br/>Partition number (1-4): 2<br/>First cylinder (1034-32635, default 1034): <br/>Using default value 1034<br/>Last cylinder, +cylinders or +size{K,M,G} (1034-32635, default 32635): <br/>Using default value 32635<br/><br/>Command (m for help): wq<br/>The partition table has been altered!<br/><br/>Calling ioctl() to re-read partition table.<br/>Syncing disks.<br/><br/>三、格式化磁盘<br/>使用 resize2fs 扩大文件系统大小，磁盘原有的数据不会丢失。<br/>e2fsck -f /dev/sdb2<br/>resize2fs /dev/sdb2<br/><br/>四、关闭该虚拟机，移除这块磁盘，启动那台要扩容的虚拟机，登录系统之后我们发现磁盘已经是扩容后的大小了，最重要的是数据无损。<br/>[root@localhost ~]# df -h<br/>Filesystem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Size&nbsp;&nbsp;Used Avail Use% Mounted on<br/>/dev/sda2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 239G&nbsp;&nbsp;101G&nbsp;&nbsp;126G&nbsp;&nbsp;45% /<br/>tmpfs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.9G&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;3.9G&nbsp;&nbsp; 0% /dev/shm<br/>[root@localhost ~]# <br/><br/>如果像阿里云那样，数据盘在单独的一块磁盘，就更好操作了。<br/>Tags - <a href="http://www.zhanghaijun.com/tags/esxi/" rel="tag">esxi</a> , <a href="http://www.zhanghaijun.com/tags/%25E7%25A3%2581%25E7%259B%2598%25E6%2589%25A9%25E5%25AE%25B9/" rel="tag">磁盘扩容</a>
]]>
</description>
</item><item>
<link>http://www.zhanghaijun.com/post//#blogcomment</link>
<title><![CDATA[[评论] ESXI虚拟机磁盘根分区无损扩容]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhanghaijun.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>