AWS EC2 調整雲主機根卷大小

來源:互聯網
上載者:User

標籤:amazon ec2   雲主機   

對於Redhat/Amazon Linux作業系統,請參考:
調整amazon EC2雲主機的EBS啟動磁碟大小(http://blog.sina.com.cn/s/blog_704836f40101anhf.html)

對於centos 作業系統,需要做些額外的操作步驟,才能是根卷的大小調整生效,操作如下:

[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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.
[[email protected] ~]# reboot

Broadcast message from [email protected]
(/dev/pts/0) at 3:58 …

The system is going down for reboot NOW!
[[email protected] ~]# Connection to 54.223.220.111 closed by remote host.
Connection to 54.223.220.111 closed.

[email protected] /d/work/key
$ ssh -i aws-ssh-key.pem [email protected]

[email protected] /d/work/key
$ ssh -i aws-ssh-key.pem [email protected]
Last login: Wed Jul 29 03:07:54 2015 from 223.71.247.139
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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.
[[email protected] ~]# reboot

Broadcast message from [email protected]-0-8-58
(/dev/pts/0) at 4:03 …

The system is going down for reboot NOW!
[[email protected] ~]# Connection to 54.223.220.111 closed by remote host.
Connection to 54.223.220.111 closed.

$ ssh -i aws-ssh-key.pem [email protected]
Last login: Wed Jul 29 03:59:36 2015 from 223.71.247.139
[[email protected] ~]# 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
[[email protected] ~]#
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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.

[[email protected] ~]# 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 調整雲主機根卷大小

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.