+135 410 16684Mon. - Fri. 10:00-22:00

CentOS下挂载EBS

CentOS下挂载EBS

CentOS下挂载EBS

EBS(Elastic Block Store)是Amazon EC2实例的持久性数据块级存储卷。

在简单介绍一下,购买EBS以后如何挂载到EC2。

环境:CentOS6.5

EBS:300GB

CentOS6.5下挂载EBS

1. 先用fdisk命令查看Device名。

# fdisk -l

Disk /dev/xvdg: 40.3 GB, 40256929792 bytes
255 heads, 63 sectors/track, 4894 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: 0x00000000

Disk /dev/xvde: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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: 0x00000000

Disk /dev/xvdf: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 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: 0x00000000

根据容量判断,/dev/xvdf是购买的EBS。

2. 创建ext4文件系统

# mkfs -t ext4 /dev/xvdf

3. 创建目录及挂载

# mkdir /data
# mount /dev/xvdf /data

4. 确认

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvde       7.9G  650M  6.9G   9% /
tmpfs           7.4G     0  7.4G   0% /dev/shm
/dev/xvdf       296G  191M  281G   1% /data

5. 修改/etc/fstab

在/etc/fstab文件的最后进行添加。

# vi /etc/fstab
/dev/xvdf  /data     ext4    defaults         0 0

6. 重启系统进行确认

# shutdown -r now
# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvde       7.9G  651M  6.9G   9% /
tmpfs           7.4G     0  7.4G   0% /dev/shm
/dev/xvdf       296G  191M  281G   1% /data