標籤:centos 擴充分區
---------------聲明:分區有風險,操作需謹慎------------------------------------
應用情境:Hyper-V or Esxi,原先空間不夠用需要擴充。
第一步(增加硬碟空間)在Esxi或者Hyper-V管理介面 增加硬碟總體空間。
第二步(增加分區空間):
我目前分區是這樣的
650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/4C/D5/wKiom1RGCxOzKtKcAACdqtGn6_s551.jpg" title="T1.png" alt="wKiom1RGCxOzKtKcAACdqtGn6_s551.jpg" />
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/4C/D6/wKioL1RGC86R3RqvAAB2QUsFigg303.jpg" title="T3.png" alt="wKioL1RGC86R3RqvAAB2QUsFigg303.jpg" />
可以看到目前/dev/sda3 已經沒有空間了,我們需要對他進行擴充。
擴充需要一下步驟:
刪除/dev/sda3分區
建立新的sd3分區
線上擴充硬碟
[email protected]: fdisk /dev/sda //查看當前磁碟分割資料,記錄一下sda3的起始位置。
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/4C/D5/wKiom1RGC02B0JvKAACeCTDxQhY642.jpg" title="T2.png" alt="wKiom1RGC02B0JvKAACeCTDxQhY642.jpg" />
Command (m for help): p
650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />
Command (m for help): d
Partition number (1-4): 3 //刪除掉 sda3, 刪除後可以再用 P 命令查看一下時候被刪除
Command (m for help):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):3 //因為我sd3 之前是Primary ,重新建立sd3 主要磁碟分割
First sector (334-624287999, default 3334): //這裡會讓你選擇sda3開始的位置,預設情況下應該和我們之前記錄的 3334 是同一個值
Using default value 3334
Last sector, +sectors or +size{K,M,G} (3334-624287999, default 524287) //結尾數會比以前大,因為系統已經自動把我們的unlocation Space空間添加進去了
Command (m for help): w //寫入分區表,如果你發現之前的配置有問題,千萬不要儲存(即輸入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.
[email protected]: reboot //重啟應用新的分區表
重啟之後:
[email protected]: resize2fs /dev/sda3 //擴充分區
[email protected]: df -h //查看擴充結果
本文只為sda3 進行了擴充,並未對sda2進行擴充,如果對sda2進行擴充可能會覆蓋sda3的資料(推測)。。。所以筆者推薦大家在最初分區的時候還是首選LVM吧。
--------------參考文獻--------------------------
http://codesilence.wordpress.com/2013/03/14/live-resizing-of-an-ext4-filesytem-on-linux/
Centos Ext4 非LVM擴充分區