An EBS volume is attached to EC2 but you cannot mount it
/dev/xvdf: dataShort answer
Attaching only exposes a block device. Find the real device name with lsblk (Nitro instances show NVMe names), check with file -s whether it has a file system, format only an empty volume, then mount it. A volume made from a snapshot already has data, so never run mkfs on it.
Fix it fast
1Find out which cause you have
List the disks and their file systems. The output shows the real device name, whether it has a file system, and whether it is already mounted.
lsblk sudo lsblk -f2Match what you see, then jump to its fix
- 1
mount says the device does not exist, although the console shows it attached as /dev/sdfYou used the device name from the attach dialog, not the real oneFix - 2
sudo file -s <device> prints only: data, and the FSTYPE column of lsblk -f is emptyThe volume is new and has no file system yetFix - 3
file -s shows a file system type (for example XFS), but the volume was empty after mkfsThe volume already holds data, and you formatted it or tried toFix - 4
The volume mounts by hand but is missing after a rebootThe fstab line is wrong, so the mount is lost after reboot or the instance will not bootFix
- 1
What does the error look like?
/dev/xvdf: datamkfs.xfs: command not found
Cause 1 of 4
You used the device name from the attach dialog, not the real one
1Check
The device can have a different name than the one in the block device mapping. On Nitro instances EBS volumes appear as NVMe devices, for example /dev/nvme1n1.
lsblk -o +SERIAL2Fix
Use the name lsblk prints. The NVMe name can change between boots, and NVMe EBS volumes carry the volume ID as their serial number, so list it with lsblk -o +SERIAL to be sure which disk is which.
sudo mount /dev/nvme1n1 /data3Verify
The mount point appears in the lsblk output.
lsblkConfirmed by docs.aws.amazon.com
Cause 2 of 4
The volume is new and has no file system yet
1Check
A new volume is a raw block device. It needs a file system before it can be mounted.
sudo file -s /dev/nvme1n12Fix
Create a file system on the empty volume, make a mount point, and mount it. If mkfs.xfs is not found, install the XFS tools first.
sudo mkfs -t xfs /dev/nvme1n1
sudo mkdir /data
sudo mount /dev/nvme1n1 /data
# only if mkfs.xfs is missing on a yum-based system:
# sudo yum install xfsprogs3Verify
Check the mount and write a test file.
df -h /data
sudo touch /data/test && sudo rm /data/testConfirmed by docs.aws.amazon.com
Cause 3 of 4
The volume already holds data, and you formatted it or tried to
1Check
A volume created from a snapshot likely has a file system on it. Creating a new file system on top of it overwrites the data.
sudo lsblk -f2Fix
Skip mkfs. Mount the existing file system as it is. If you already formatted it, restore it from the snapshot onto a new volume.
sudo mkdir -p /data
sudo mount /dev/nvme1n1 /data3Verify
Your files are listed under the mount point.
ls /dataConfirmed by docs.aws.amazon.com
Cause 4 of 4
The fstab line is wrong, so the mount is lost after reboot or the instance will not boot
1Check
Mount entries are not kept across reboots unless they are in /etc/fstab. AWS recommends the UUID, because device names can change.
sudo blkid2Fix
Back up fstab, add a UUID line with the nofail option, then test it with umount and mount -a before you reboot.
sudo cp /etc/fstab /etc/fstab.orig
# /etc/fstab line (use your own UUID):
# UUID=aebf131c-6957-451e-8d34-ec978d9581ae /data xfs defaults,nofail 0 2
sudo umount /data
sudo mount -a3Verify
mount -a prints no error and /data is mounted.
findmnt /dataConfirmed by docs.aws.amazon.com
How do I stop it coming back?
- Always run lsblk -f first, and format only when the FSTYPE column is empty.
- Use UUIDs and nofail in fstab, and test with mount -a before any reboot.
- Take a snapshot before you change anything on a volume that holds data.
- Check the file permissions on the mount point so your application user can write.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Servers
You enlarged the EBS volume but the instance still shows the old size
NOCHANGE: partition 1 is size 16773087. it cannot be grown
Enlarging an EBS volume only changes the disk.
4 causes, each with a fixServers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix