Friday, December 10, 2021

Mount DVD/CDROM with command on Linux CentOS / Red Hat / Oracle Linux / Ubuntu

 Minimal install is an important security for deploying Linux. It means only essential packages are installed. Therefore, GUI is usually not available. It becomes helpful to know how to mount CDROM/DVD when you need to install packages/software from DVD.

Basically, different Linux distributions and different versions may have different commands to do that. Here, I am trying to demonstrate a way which can be used on most of the Linux distributions/versions. It includes three steps,

* Identify DVD/CDROM device name (drive name)
* Create mount point (directory)
* Mount the DVD/CDROM on created mount point

Step 1. Identify DVD/CDROM device name (drive name)

This is most important step, and the only chanllege to mount the drive. Many commands/utilities can display DVD/CDROM device name, such as blkid, lsscsi, dmesg. But they are not always available. Most time, I use following command

  cat /proc/sys/dev/cdrom/info

It lists the information of the DVD/CDROM drive, and includes drive name. It proves to be working, at least, on CentOS, Red Hat Enterprise Linux, Oracle Linux, Ubuntu.

Sample output,
[root@RHEL4]# cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.20 2003/12/17

drive name:             sr1     sr0
drive speed:            1       32
drive # of slots:       1       1
Can close tray:         1       1
Can open tray:          1       1
Can lock tray:          1       1
Can change speed:       0       1
Can select disk:        0       0
Can read multisession:  1       1
Can read MCN:           1       1
Reports media changed:  1       1
Can play audio:         1       1
Can write CD-R:         0       0
Can write CD-RW:        0       0
Can read DVD:           0       1
Can write DVD-R:        0       0
Can write DVD-RAM:      0       0
Can read MRW:           0       1
Can write MRW:          0       1
Can write RAM:          0       1
The the example, the server has two DVD/CDROM drives sr1 and sr0. The full path of their device names are respectively /dev/sr1 and /dev/sr0.

Step 2. Create mount point

Mount point is a directory where you are going to mount DVD/CDROM. You can create your preferred directory with command

mkdir -p <directory>

For example
[root@RHEL4]# mkdir -p /media/cdrom
Step 3. Mount DVD/CDROM on the mount point with command,

  mount <device name> <mount point>

For example,
[root@RHEL4]# mount /dev/sr0 /media/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only

No comments: