Error when mounting drive

后端 未结 3 2066
难免孤独
难免孤独 2021-02-20 14:48

I created an EC2 amazon instance (ubuntu) and created a volume from an available snapshot. The volume has been successfully attached to my instance as /dev/sdf.

相关标签:
3条回答
  • 2021-02-20 15:29

    Complementing David Levesque answer.

    You can check which volumes have been mounted with. The following will list them all:

    $ sudo lsblk --output NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,LABEL
    

    You will get something like that

    NAME    TYPE SIZE FSTYPE MOUNTPOINT LABEL
    xvda    disk   8G                   
    └─xvda1 part   8G ext4   /          cloudimg-rootfs
    xvdf    disk  30G                   
    └─xvdf1 part  30G ext4              cloudimg-rootfs
    

    Then you can mount it with

    $ sudo mount /dev/xvdf1 /space -t ext4
    

    I hope it helps

    0 讨论(0)
  • 2021-02-20 15:39

    Try mounting the device "/dev/sdf" instead of "/dev/sdf1".

    If that still doesn't work, try mounting it as "/dev/xvdf" or "/dev/xvda1", e.g.:

    sudo mount /dev/xvda1 /space
    

    The explanation for this name mismatch can be found in the "Attach Volume" dialog of the EC2 management screen:

    Note: Newer linux kernels may rename your devices to /dev/xvdf through /dev/xvdp internally, even when the device name entered here (and shown in the details) is /dev/sdf through /dev/sdp.

    0 讨论(0)
  • 2021-02-20 15:51

    In my CloudFormation UserData section I had the attach-volume command and mount command execute sequentially without a delay. I introduced a 5 second delay between the attach-volume command and mount command and it solved the problem.

    aws ec2 attach-volume --volume-id $volumeId --instance-id $instanceId --device /dev/xvdf
    sleep 5
    mount /dev/xvdf /db -t ext4
    
    0 讨论(0)
提交回复
热议问题