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

AWS EC2 调整云主机根卷大小

时间:2015-07-29 14:11:12      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:amazon ec2   云主机   

对于Redhat/Amazon Linux操作系统,请参考:
调整amazon EC2云主机的EBS启动磁盘大小(http://blog.sina.com.cn/s/blog_704836f40101anhf.html

对于centos 操作系统,需要做些额外的操作步骤,才能是根卷的大小调整生效,操作如下:

[root@ip-10-0-8-58 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 802M 6.7G 11% /
tmpfs 7.3G 0 7.3G 0% /dev/shm
/dev/xvdb 493G 198M 467G 1% /mnt
[root@ip-10-0-8-58 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdb 202:16 0 500G 0 disk /mnt
[root@ip-10-0-8-58 ~]# fdisk -u /dev/xvda

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’).

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-41943039, default 63): 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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 41943039 20970496 83 Linux

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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 41943039 20970496 83 Linux

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@ip-10-0-8-58 ~]# reboot

Broadcast message from root@ip-10-0-8-58
(/dev/pts/0) at 3:58 …

The system is going down for reboot NOW!
[root@ip-10-0-8-58 ~]# Connection to 54.223.220.111 closed by remote host.
Connection to 54.223.220.111 closed.

d@D-PC /d/work/key
$ ssh -i aws-ssh-key.pem root@54.223.220.111

d@D-PC /d/work/key
$ ssh -i aws-ssh-key.pem root@54.223.220.111
Last login: Wed Jul 29 03:07:54 2015 from 223.71.247.139
[root@ip-10-0-8-58 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 802M 6.7G 11% /
tmpfs 7.3G 0 7.3G 0% /dev/shm
/dev/xvdb 493G 198M 467G 1% /mnt
[root@ip-10-0-8-58 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 20G 0 part /
xvdb 202:16 0 500G 0 disk /mnt
[root@ip-10-0-8-58 ~]# fdisk -u /dev/xvda

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’).

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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 41943039 20970496 83 Linux

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-41943039, default 63): p
First sector (63-41943039, default 63): 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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 41943039 20970496 83 Linux

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/xvda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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 41943039 20970496 83 Linux

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@ip-10-0-8-58 ~]# reboot

Broadcast message from root@ip-10-0-8-58
(/dev/pts/0) at 4:03 …

The system is going down for reboot NOW!
[root@ip-10-0-8-58 ~]# Connection to 54.223.220.111 closed by remote host.
Connection to 54.223.220.111 closed.

$ ssh -i aws-ssh-key.pem root@54.223.220.111
Last login: Wed Jul 29 03:59:36 2015 from 223.71.247.139
[root@ip-10-0-8-58 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 802M 6.7G 11% /
tmpfs 7.3G 0 7.3G 0% /dev/shm
/dev/xvdb 493G 198M 467G 1% /mnt
[root@ip-10-0-8-58 ~]#
[root@ip-10-0-8-58 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 802M 6.7G 11% /
tmpfs 7.3G 0 7.3G 0% /dev/shm
/dev/xvdb 493G 198M 467G 1% /mnt
[root@ip-10-0-8-58 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 20G 0 part /
xvdb 202:16 0 500G 0 disk /mnt
[root@ip-10-0-8-58 ~]# 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 = 2
Performing an on-line resize of /dev/xvda1 to 5242624 (4k) blocks.
The filesystem on /dev/xvda1 is now 5242624 blocks long.

[root@ip-10-0-8-58 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 806M 18G 5% /
tmpfs 7.3G 0 7.3G 0% /dev/shm
/dev/xvdb 493G 198M 467G 1% /mnt

版权声明:本文为博主原创文章,未经博主允许不得转载。

AWS EC2 调整云主机根卷大小

标签:amazon ec2   云主机   

原文地址:http://blog.csdn.net/knight_zhen/article/details/47125413

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