将 EBS 添加到 Ubuntu EC2 实例 [英] Add EBS to Ubuntu EC2 Instance
问题描述
我在将 EBS 卷连接到我的 Ubuntu EC2 实例时遇到问题.
I'm having problem connecting EBS volume to my Ubuntu EC2 Instance.
这是我所做的:
我从 Amazon AWS 控制台创建了一个 EBS 150GB 卷并将其附加到 Ubuntu 11.10 EC2 实例.在 EBS 卷属性下,附件"显示:[my Ubuntu instance id]:/dev/sdf (attached)"
From the Amazon AWS Console, I created a EBS 150GB volume and attached it to an Ubuntu 11.10 EC2 instance. Under the EBS volume properties, "Attachment" shows: "[my Ubuntu instance id]:/dev/sdf (attached)"
尝试在 Ubuntu 机器上安装驱动器,它告诉我安装:/dev/sdf 不是块设备"
Tried mounting the drive on the Ubuntu box, and it told me "mount: /dev/sdf is not a block device"
sudo mount/dev/sdf/vol
所以我检查了 fdisk 并尝试从新位置挂载,它告诉我这不是正确的文件系统.
So I checked with fdisk and tried to mount from the new location and it told me it wasn't the right file system.
sudo fdisk -l
sudo mount -v -t ext4/dev/xvdf/vol
错误:
mount:错误的 fs 类型,错误的选项,/dev/xvdf 上的超级块错误,丢失代码页或帮助程序,或其他错误在某些情况下有用的信息在系统日志中找到 - 尝试 dmesg |尾巴左右
mount: wrong fs type, bad option, bad superblock on /dev/xvdf, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so
dmesg | tail"告诉我它给出了以下错误:
"dmesg | tail" told me it gave the following error:
EXT4-fs (sda1):VFS:找不到 ext4 文件系统
EXT4-fs (sda1): VFS: Can't find ext4 filesystem
我还尝试按照 http://www.webmastersessions.com/how-to-attach-ebs-volume-to-amazon-ec2-instance,但仍然给出了同样不正确的文件系统错误.
I also tried putting the configurations into /etc/fstab file as instructed on http://www.webmastersessions.com/how-to-attach-ebs-volume-to-amazon-ec2-instance, but still gave same not the right file system error.
问题:
Q1:基于第 1 点(以上),当卷真正映射到/dev/xvdf"时,为什么会映射到dev/sdf"?
Q1: Based on point 1 (above), why was the volume mapped to 'dev/sdf' when it's really mapped to '/dev/xvdf'?
问题 2:我还需要做什么才能加载 EBS 卷?我以为当我将它附加到实例时它会为我处理一切.
Q2: What else do I need to do to get the EBS volume loaded? I thought it'll just take care of everything for me when I attach it to a instance.
推荐答案
由于这是一个新的卷,所以需要在步骤 1 和步骤 2 之间用文件系统格式化 EBS 卷(块设备).所以整个过程您的示例安装点是:
Since this is a new volume, you need to format the EBS volume (block device) with a file system between step 1 and step 2. So the entire process with your sample mount point is:
创建 EBS 卷.
Create EBS volume.
将 EBS 卷附加到 /dev/sdf
(此特定设备编号的 EC2 外部名称).
Attach EBS volume to /dev/sdf
(EC2's external name for this particular device number).
格式化文件系统 /dev/xvdf
(Ubuntu 的这个特定设备号的内部名称):
Format file system /dev/xvdf
(Ubuntu's internal name for this particular device number):
sudo mkfs.ext4 /dev/xvdf
仅当这是一个没有数据的新卷时才格式化文件系统.格式化将导致难以或不可能检索以前在此卷上的任何数据.
挂载文件系统(更新到/etc/fstab 使其在重启时保持挂载):
Mount file system (with update to /etc/fstab so it stays mounted on reboot):
sudo mkdir -m 000 /vol
echo "/dev/xvdf /vol auto noatime 0 0" | sudo tee -a /etc/fstab
sudo mount /vol
这篇关于将 EBS 添加到 Ubuntu EC2 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!