12

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.

I executed the following command: performed: mkdir /space

When I try to execute the following command: sudo mount /dev/sdf1 /space

I get this message: mount: special device /dev/sdf1 does not exist

How can I solve this issue ?

Mohamed Taher Alrefaie
  • 15,698
  • 9
  • 48
  • 66
Jury A
  • 19,192
  • 24
  • 69
  • 93

3 Answers3

22

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.

David Levesque
  • 22,181
  • 8
  • 67
  • 82
  • I tried both solutions, none of them work. In the first one, I get: special device /dev/sdf does not exist. When trying the second one, I get: mount: you must specify the filesystem type. – Jury A Sep 22 '12 at 17:28
  • Also try with "/dev/xvda1" (edited my answer). If it still doesn't work, look for device name starting with "xvd", e.g. using command "ls /dev/xvd*". – David Levesque Sep 22 '12 at 17:43
  • mount is successful now. But, I am still not able to achieve the rest. I am trying to perform a command: ./setup-script But I get: sudo: ./setup-cript: command not found. I am in step 5 in the following tutorial if you can help please. https://www.eff.org/pages/howto-using-ssl-observatory-cloud. I don't know where is the problem? – Jury A Sep 22 '12 at 18:38
  • This looks like a different issue. It may be better to open a new question for it. You can provide a reference to your question here and I will gladly try to help. – David Levesque Sep 22 '12 at 19:14
6

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

medina
  • 8,051
  • 4
  • 25
  • 24
  • 4
    This helped me to discover that my userdata script needed to change "/dev/xvdf" to "/dev/nvme1n1". The newer instance type has a different name for the attached block device (I guess based on the storage device type). – Sam T Aug 06 '19 at 16:33
3

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
ChaitanyaBhatt
  • 1,158
  • 14
  • 11