将EBS添加到Ubuntu EC2实例。

时间:2023-01-26 12:13:57

I'm having problem connecting EBS volume to my Ubuntu EC2 Instance.

我无法连接EBS卷到我的Ubuntu EC2实例。

Here's what I did:

这是我所做的:

  1. 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)"

    在Amazon AWS控制台,我创建了一个EBS 150GB的卷,并将它附加到一个Ubuntu 11.10 EC2实例上。在EBS卷属性下,“附件”显示:“(我的Ubuntu实例id):/dev/sdf(附加)”

  2. Tried mounting the drive on the Ubuntu box, and it told me "mount: /dev/sdf is not a block device"

    尝试在Ubuntu框上安装驱动器,它告诉我“安装:/dev/sdf不是块设备”

    sudo mount /dev/sdf /vol

    sudo /dev/sdf山/卷

  3. So I checked with fdisk and tried to mount from the new location and it told me it wasn't the right file system.

    所以我用fdisk检查并尝试从新的位置安装,它告诉我这不是正确的文件系统。

    sudo fdisk -l

    sudo fdisk - l

    sudo mount -v -t ext4 /dev/xvdf /vol

    sudo挂载-v -t ext4 /dev/xvdf /vol

    the error:

    错误:

    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

    挂载:错误的fs类型、错误的选项、/dev/xvdf上的错误超块、丢失的代码页或辅助程序,或者在某些情况下在syslog中发现的其他错误——请尝试dmesg | tail之类的

    "dmesg | tail" told me it gave the following error:

    “dmesg | tail”告诉我它给出了以下错误:

    EXT4-fs (sda1): VFS: Can't find ext4 filesystem

    ext4 -fs (sda1): VFS:无法找到ext4文件系统。

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.

我还尝试按照http://www.webmastersessions.com/howto -attach- ebs-volumeto -amazon-ec2实例的指示,将配置放入/etc/fstab文件,但仍然给出了不正确的文件系统错误。

Questions:

问题:

Q1: Based on point 1 (above), why was the volume mapped to 'dev/sdf' when it's really mapped to '/dev/xvdf'?

Q1:基于点1(上面),为什么当它被映射到'/dev/xvdf'时,它被映射到'dev/sdf' ?

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.

问2:我还需要做什么才能装载EBS卷?我想当我把它附加到一个实例时,它会帮我处理所有的事情。

2 个解决方案

#1


322  

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:

由于这是一个新的卷,您需要在步骤1和步骤2之间使用文件系统格式化EBS卷(块设备)。所以你的样本安装点的整个过程是:

  1. Create EBS volume.

    创建EBS卷。

  2. Attach EBS volume to /dev/sdf (EC2's external name for this particular device number).

    将EBS卷附加到/dev/sdf(此特定设备号的EC2外部名称)。

  3. Format file system /dev/xvdf (Ubuntu's internal name for this particular device number):

    格式化文件系统/dev/xvdf (Ubuntu这个特定设备号的内部名称):

    sudo mkfs.ext4 /dev/xvdf
    

    Only format the file system if this is a new volume with no data on it. Formatting will make it difficult or impossible to retrieve any data that was on this volume previously.

    只有当这是一个没有数据的新卷时才格式化文件系统。格式化将使以前检索这个卷上的任何数据变得困难或不可能。

  4. Mount file system (with update to /etc/fstab so it stays mounted on reboot):

    挂载文件系统(更新到/etc/fstab,使其在重新启动时保持挂载):

    sudo mkdir -m 000 /vol
    echo "/dev/xvdf /vol auto noatime 0 0" | sudo tee -a /etc/fstab
    sudo mount /vol
    

#2


-2  

Step 1: create volume
step 2: attach to your instance root volume
step 3: run sudo resize 2fs -p /dev/xvde
step 4: restart apache2 sudo service apache2 restart
step 4: run df -h

步骤1:创建卷步骤2:附加到实例根卷步骤3:运行sudo resize 2fs -p /dev/xvde步骤4:重启apache2 sudo服务apache2重启步骤4:运行df -h

You can see total volume attached to your instance.

您可以看到附加到实例的总容量。

#1


322  

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:

由于这是一个新的卷,您需要在步骤1和步骤2之间使用文件系统格式化EBS卷(块设备)。所以你的样本安装点的整个过程是:

  1. Create EBS volume.

    创建EBS卷。

  2. Attach EBS volume to /dev/sdf (EC2's external name for this particular device number).

    将EBS卷附加到/dev/sdf(此特定设备号的EC2外部名称)。

  3. Format file system /dev/xvdf (Ubuntu's internal name for this particular device number):

    格式化文件系统/dev/xvdf (Ubuntu这个特定设备号的内部名称):

    sudo mkfs.ext4 /dev/xvdf
    

    Only format the file system if this is a new volume with no data on it. Formatting will make it difficult or impossible to retrieve any data that was on this volume previously.

    只有当这是一个没有数据的新卷时才格式化文件系统。格式化将使以前检索这个卷上的任何数据变得困难或不可能。

  4. Mount file system (with update to /etc/fstab so it stays mounted on reboot):

    挂载文件系统(更新到/etc/fstab,使其在重新启动时保持挂载):

    sudo mkdir -m 000 /vol
    echo "/dev/xvdf /vol auto noatime 0 0" | sudo tee -a /etc/fstab
    sudo mount /vol
    

#2


-2  

Step 1: create volume
step 2: attach to your instance root volume
step 3: run sudo resize 2fs -p /dev/xvde
step 4: restart apache2 sudo service apache2 restart
step 4: run df -h

步骤1:创建卷步骤2:附加到实例根卷步骤3:运行sudo resize 2fs -p /dev/xvde步骤4:重启apache2 sudo服务apache2重启步骤4:运行df -h

You can see total volume attached to your instance.

您可以看到附加到实例的总容量。