码迷,mamicode.com
首页 > 其他好文 > 详细

Centos Ext4 非LVM扩展分区

时间:2014-10-21 19:56:03      阅读:908      评论:0      收藏:0      [点我收藏+]

标签:centos 扩展分区

---------------声明:分区有风险,操作需谨慎------------------------------------


应用场景:Hyper-V or Esxi,原先空间不够用需要扩展。


第一步(增加硬盘空间)在Esxi或者Hyper-V管理界面 增加硬盘总体空间。

第二步(增加分区空间):

我目前分区是这样的

bubuko.com,布布扣bubuko.com,布布扣

bubuko.com,布布扣


bubuko.com,布布扣

可以看到目前/dev/sda3 已经没有空间了,我们需要对他进行扩展。

扩展需要一下步骤:

  1. 删除/dev/sda3分区

  2. 创建新的sd3分区

  3. 在线扩展硬盘

me@CentOs: fdisk /dev/sda //查看当前磁盘分区数据,记录一下sda3的起始位置。

bubuko.com,布布扣

Command (m for help): p

bubuko.com,布布扣

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.


me@CentOs: reboot //重启应用新的分区表




重启之后:


me@CentOs: resize2fs /dev/sda3 //扩展分区

me@CentOs: 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扩展分区

标签:centos 扩展分区

原文地址:http://billcan.blog.51cto.com/5893906/1566324

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!