向 Amazon EC2 实例添加磁盘

向 Amazon EC2 实例添加磁盘

我正在使用 Amazon EC2 实例,但磁盘空间不足

[root@ip-10-59-143-73 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde1            5.7G  3.3G  2.3G  60% /
none                  1.9G     0  1.9G   0% /dev/shm

我添加了“弹性块”>卷>5GB卷并附加到实例ID。

我重新启动了实例并在 /dev/ 中获得了一个新的磁盘设备

[root@ip-10-59-143-73 ~]# ll /dev/xvd*
brw-rw---- 1 root disk 202,  65 Jun 12 12:16 /dev/xvde1
brw-rw---- 1 root disk 202, 144 Jun 12 12:16 /dev/xvdj
brw-rw---- 1 root disk 202, 146 Jun 12 12:28 /dev/xvdj2 <<<< new one

[root@ip-10-59-143-73 ~]# cat /proc/partitions
major minor  #blocks  name

 202       65    6291456 xvde1  <<<< Old 6GB volume
 202      144  419395584 xvdj
 202      146    5242880 xvdj2  <<<< new one

[root@ip-10-59-143-73 ~]# mount
/dev/xvde1 on / type ext4 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

[root@ip-10-59-143-73 ~]# cat /etc/fstab
LABEL=_/   /         ext4    defaults        1 1
none       /proc     proc    defaults        0 0
none       /sys      sysfs   defaults        0 0
none       /dev/pts  devpts  gid=5,mode=620  0 0
none       /dev/shm  tmpfs   defaults        0 0

xvde1 是旧的,xvdj2 可能是新的。

如何将新磁盘添加到可用磁盘空间?

跟进:

1)消除混淆: - Amazon EC2 可以自动完成所有操作,但添加磁盘空间不是自动的,必须手动进行(不像 Elastic IP 或 VPC 那样)。

2)饲料

$ ll /dev/xvd*
brw-rw---- 1 root disk 202,  65 Jun 12 12:37 /dev/xvde1
brw-rw---- 1 root disk 202, 144 Jun 12 12:37 /dev/xvdj
brw-rw---- 1 root disk 202, 146 Jun 12 12:37 /dev/xvdj2

$ mkfs.ext4 /dev/xvdj
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
26214400 inodes, 104848896 blocks
5242444 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
3200 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: <<< hit enter
done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

$ cat /etc/fstab # Before
LABEL=_/   /         ext4    defaults        1 1
none       /proc     proc    defaults        0 0
none       /sys      sysfs   defaults        0 0
none       /dev/pts  devpts  gid=5,mode=620  0 0
none       /dev/shm  tmpfs   defaults        0 0

$ cat /etc/fstab # After
LABEL=_/   /         ext4    defaults        1 1
none       /proc     proc    defaults        0 0
none       /sys      sysfs   defaults        0 0
none       /dev/pts  devpts  gid=5,mode=620  0 0
none       /dev/shm  tmpfs   defaults        0 0
/dev/xvdj   /volume_one  ext4  noatime  0 0

$ mkdir /volume_one
$ mount /volume_one
$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde1            5.7G  3.3G  2.3G  60% /
none                  1.9G     0  1.9G   0% /dev/shm
/dev/xvdj             394G  199M  374G   1% /volume_one

答案1

您始终可以增加当前卷大小,而不必附加新磁盘。您只需对当前磁盘进行快照,创建一个具有更多空间的新卷,然后使用之前使用的相同挂载点重新附加到您的实例即可。

无论如何:要么扩展磁盘,要么分配新磁盘。亚马逊有一个非常清晰的文档,其中包含有关如何在 Linux 系统上处理它的分步说明。

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html

相关内容