aws linux切换root,centos调整在AWS上的Linux实例的root EBS卷大小

我创建了一个新的CentOS Linux实例。我实例的创建后,但是当系统上线时只显示盘8GB是可用的过程中选择了根卷的50GB。我试着用resize2fs中调整大小根磁盘,我得到以下信息

root@howtoing.com [~]# resize2fs /dev/xvda1

The filesystem is already 16775167 blocks long. Nothing to do!所以,我按照下面的实例创建过程中选择的步骤,并能够成功地调整空间的大小

第1步:进行备份我们强烈建议把你的实例的完整备份(AMI)做任何更改。同时创建根磁盘的快照。

第2步:检查当前分区现在使用以下命令检查磁盘分区。你可以看到,/dev/xvda是53GB的大小,但

root@howtoing.com [~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/xvda1 8G 3.7G 4.2G 45% /

tmpfs 1.8G 0 1.8G 0% /dev/shm

/usr/tmpDSK 485M 111M 349M 25% /tmp

root@howtoing.com [~]# fdisk -l

Disk /dev/xvda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 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: 0x00098461

Device Boot Start End Blocks Id System

/dev/xvda1 * 1 1045 8387584 83 Linux

第3步:增大空间的大小现在使用以下命令设置磁盘分区重新启动。执行如下命令。

root@tecadmin[~]# fdisk /dev/xvda

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').现在,使用u选项改变显示单元扇区。

Command (m for help): u

Changing display/entry units to sectors现在打印分区表来检查磁盘详细信息

Command (m for help): p

Disk /dev/xvda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders, total 104857600 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: 0x00098461

Device Boot Start End Blocks Id System

/dev/xvda1 * 2048 16777215 8387584 83 Linux现在,使用以下命令删除第一个分区。

Command (m for help): d

Selected partition 1现在,创建一个使用下面的命令一个新的分区。对于第一个扇区输入2048(如上面的命令的输出显示)和最后一秒只需按Enter键选择所有分区。

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First sector (63-104857599, default 63): 2048

Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): [PRESS ENTER]

Using default value 104857599再次打印分区表。你会看到新的分区已经占据了所有的磁盘空间。

Command (m for help): p

Disk /dev/xvda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders, total 104857600 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: 0x00098461

Device Boot Start End Blocks Id System

/dev/xvda1 2048 104857599 52427776 83 Linux现在设置分区 1 启动标志。

Command (m for help): a

Partition number (1-4): 1永久写入磁盘分区,然后退出。

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.让我们使所有上述更改后重新启动系统。

root@howtoing.com [~]# reboot让我们用resize2fs中命令调整文件系统。记住,你的文件系统调整不格式化。

root@howtoing.com [~]# resize2fs /dev/xvda1

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/xvda1 is mounted on /; on-line resizing required

old desc_blocks = 1, new_desc_blocks = 4

Performing an on-line resize of /dev/xvda1 to 13106944 (4k) blocks.

The filesystem on /dev/xvda1 is now 13106944 blocks long.

第4步:验证升级磁盘此时,您的根卷已成功调整。只是验证磁盘已正确地调整大小

root@howtoing.com[~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/xvda1 50G 6.7G 40G 15% /

tmpfs 1.8G 0 1.8G 0% /dev/shm

/usr/tmpDSK 485M 111M 349M 25% /tmp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值