ENOMEDIUM
Linux / POSIXERRORNotableDeviceHIGH confidence
No Medium Found
Production Risk
Expected when handling removable media; always check for media before operations.
What this means
ENOMEDIUM (errno 123) is returned when a removable media device (CD/DVD drive, tape drive, floppy) has no media inserted.
Why it happens
- 1Opening or reading a CD/DVD drive with no disc inserted
- 2Accessing a tape drive with no tape loaded
- 3Operating on a memory card reader with no card
How to reproduce
open() on a CD-ROM drive with no disc.
trigger — this will error
trigger — this will error
int fd = open("/dev/sr0", O_RDONLY);
// Returns -1, errno = ENOMEDIUM if no disc insertedexpected output
open: No medium found (ENOMEDIUM)
Fix
Insert media before accessing the device
WHEN When accessing removable media devices
Insert media before accessing the device
# Check if media is present using udev udevadm info /dev/sr0 | grep ID_CDROM_MEDIA # Or check with blkid blkid /dev/sr0
Why this works
Use udev or blkid to detect media presence before attempting to open the device.
Sources
Official documentation ↗
Linux Programmer Manual errno(3)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev