LLI Wiki — My Digital Knowledge Base

Mount a CD, USB key or disk on Linux (fstab and UUID)

Detect an optical drive, mount a media, identify a disk by UUID and configure fstab.

This page gathers the commands to detect an optical drive, mount a CD, a USB key or a disk on Linux, and make a mount permanent through /etc/fstab using the disk UUID.

Detect the optical drive

dmesg | egrep -i --color 'cdrom|dvd|cd/rw|writer'
lsblk
less /proc/sys/dev/cdrom/info

Mount a CD or DVD

sudo mkdir -p /media/cdrom
sudo mount /dev/sr0 /media/cdrom

Unmount afterwards with sudo umount /media/cdrom.

Mount a remote directory with sshfs

sudo sshfs -o allow_other,default_permissions user@fileserver:/remote/path /mnt/fileserver/

List mounts and disk space

findmnt
cat /proc/mounts
mount -l
df -h

Identify a disk by its UUID

sudo blkid

Example output (dummy UUIDs):

/dev/sdb1: UUID="00000000-0000-0000-0000-000000000000" BLOCK_SIZE="4096" TYPE="ext4"
/dev/sda1: UUID="00000000-0000-0000-0000-000000000000" BLOCK_SIZE="4096" TYPE="ext4"

To make the mount permanent:

  1. Note the UUID with sudo blkid.
  2. Back up /etc/fstab.
  3. Replace /dev/sdX with UUID=xxxx in /etc/fstab.
  4. Test with sudo mount -a.
  5. Check with df -h.

Automatic mount of a removable disk

With udisks (without fstab):

udisksctl mount -b /dev/sdb1
udisksctl unmount -b /dev/sdb1

Notes

Mastodon LLIMastodon SocialFosstodon