Under LInux how to mount the CD to find rpm package

  • 2021-01-03 21:15:52
  • OfStack

Writing in the front

Linux sometimes requires software to be installed, either online through the yum command or via a downloaded rpm package, but the rpm installation requires you to find the rpm package on which the installation software depends. So let's try that today

System environment CentOS 7.5


[root@localhost /]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core)

1. Find the full path to the CD


[root@localhost /]# ls -l /dev | grep cdrom
lrwxrwxrwx 1 root root      3 3 month   3 09:32 cdrom -> sr0
crw-rw---- 1 root cdrom  21,  1 3 month   3 09:32 sg1
brw-rw---- 1 root cdrom  11,  0 3 month   3 09:32 sr0

This command knows the name of the CD: cdrom, the CD path is /dev/cdrom

2. Mount the CD


[root@localhost /]# mount /dev/cdrom /mnt

mount: /dev/sr0 write protected and will be mounted read-only

This command loads the contents of directory /dev/cdrom into directory /mnt. In other words, the contents of directory /dev/cdrom can be accessed from directory /mnt


[root@localhost /]# cd /mnt/
[root@localhost mnt]# ls
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-77EFI GPL  isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL

3. Copy target rpm package

Go to the directory you just went to Packages and find the target rpm package, using the example "telnet client"


[root@localhost mnt]# cd Packages/
[root@localhost Packages]# ls -l | grep telnet
-rw-rw-r-- 2 root root  65632 8 month  11 2017 telnet-0.17-64.el7.x86_64.rpm
-rw-rw-r-- 2 root root  41804 8 month  11 2017 telnet-server-0.17-64.el7.x86_64.rpm

Here come two, but you can see from the name that the first one is the client and the other one is the server. You can select the first one here, and then copy it to /root. The following results will be successful


[root@localhost Packages]# cp telnet-0.17-64.el7.x86_64.rpm /root/
[root@localhost Packages]# ls -l /root
 The total amount  72
-rw-------. 1 root root 1569 6 month   3 2018 anaconda-ks.cfg
-rw-r--r-- 1 root root 65632 3 month   3 10:08 telnet-0.17-64.el7.x86_64.rpm
-rw-r--r--. 1 root root   0 6 month  30 2018 ????.txt

4. Uninstall the CD

Once you know the target rpm package, remember to uninstall the CD! (Cut out the directory first /mnt)


[root@localhost Packages]# cd /
[root@localhost /]# umount /mnt/
[root@localhost /]# ls -l /mnt/
 The total amount  0

5. Install a copy of rpm


[root@localhost /]# cd root/
[root@localhost ~]# rpm -ivh telnet-0.17-64.el7.x86_64.rpm 
 In the preparation ...             ################################# [100%]
     The software package  telnet-1:0.17-64.el7.x86_64  Is already installed 
[root@localhost ~]# telnet
telnet> 

Is it easy to see that the telnet client has been installed successfully?


Related articles: