Virtual machine centos7 mount CD


foreword

在Linux系统中,新加的硬盘需要先挂载后才能读写使用,本文为大家介绍如何在Centos 7中如何挂载和永久性的挂载。

提示:以下是本篇文章正文内容,下面案例可供参考

1. Mount the disc?

Copy the following command to confirm which CDROM file is under the /dev folder in the machine:

[root@localhost  /]# ls -l /dev/ | grep -Fi cdrom

You can see that
insert image description here
/dev/cdrom is just a symbolic link to /dev/sr0; here sr0, sg0;

The Linux system can recognize most optical storage devices as SCSI devices, such as /dev/sr0, /dev/sr1, etc. However, if the optical drive uses an old interface, it may be recognized as a PATA device. The /dev/sr* devices are read-only, they are only used to read data from the disc. Readable and writable optical disk drives are represented by device files like /dev/sg0, and g stands for "generic".

Create a new file, we will mount it later, usually created in /mnt

[root@localhost ~]# mkdir /mnt/centos7
[root@localhost mnt]# mount /dev/cdrom /mnt/centos7
mount: /dev/sr0 is write-protected, mounting read-only     #提示已挂载
[root@localhost mnt]# df /mnt/centos7				#这里可以看到centos7挂载了/dev/sr0
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sr0         4600876 4600876         0 100% /mnt/centos7

Here you can see if there are any files in the centos7 file

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

This method will no longer be mounted after the computer is restarted. You need to manually mount it again to /mnt/centos7 and you will find that the folder is empty.

2. Permanent mount

用/etc/fstab文件配置的方式让系统在开机加载文件系统的时候去挂载光盘。

insert image description here
Backup first.

cp /etc/fstab /etc/fstab_backup		

blkid view file system
insert image description here
We remember behind sr0.
insert image description here
Reboot to see if it is mounted.
insert image description here

succeeded


Summarize

提示:这里对文章进行总结:

Simple mounting method, I hope it can help everyone

Guess you like

Origin blog.csdn.net/LShuo666/article/details/129023534