linux mount/umount 挂载/卸载ISO镜像

虚拟机加载ISO镜像

VMWare中的Linux虚拟机设置ISO镜像文件的路径,先完成设置,接着连接

vmware_set_iso.png

mount挂载

先在/media目录下创建cdrom文件夹,用于统一的挂载ISO镜像文件,这样便于日常操作

1
2
[root@linux1 /]# cd /media
[root@linux1 media]# mkdir cdrom

linux光驱加载的文件路径默认是在/dev/cdrom目录下,但不能操作也不能像文件夹那样直接操作,所以用mount命令挂载到物理路径

1
2
3
4
5
6
[root@linux1 cdrom]# mount /dev/cdrom /media/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@linux1 media]# ll cdrom/ #接下来就可以像普通文件夹一样操作ISO镜像中的文件夹了,但这只是只读的喔
l^H^H^H^H^H^H^H^H^H^Htotal 863
dr-xr-xr-x. 3 root root 2048 Sep 26 2014 EFI
-r--r--r--. 1 root root 8724 Nov 7 2012 EULA

配置简单的本地YUM源

baseurl:文件的路径;enabled:启用当前yum源;gpgcheck:gpg检查不启用

1
2
3
4
5
6
7
[root@linux1 ~]# cd /etc/yum.repos.d/
[root@linux1 yum.repos.d]# cat rhel6-iso.repo
[rhel-source]
name=Red Hat Enterprise Linux 6 ISO
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0

测试本地YUM源是否配置好了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@linux1 yum.repos.d]# yum clean all #清空缓存
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: rhel-source
Cleaning up Everything
[root@linux1 yum.repos.d]# yum list vsftp* #查找软件
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel-source | 4.1 kB 00:00 ...
rhel-source/primary_db | 3.1 MB 00:00 ...
Available Packages
vsftpd.x86_64 2.2.2-12.el6_5.1 rhel-source
[root@linux1 yum.repos.d]# yum install vsftpd.x86_64 #安装软件
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.2.2-12.el6_5.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================================================================
Installing:
vsftpd x86_64 2.2.2-12.el6_5.1 rhel-source 151 k
Transaction Summary
=======================================================================================================================================================================
Install 1 Package(s)
Total download size: 151 k
Installed size: 331 k
Is this ok [y/N]: n #输入“n”取消安装
Exiting on user Command
[root@linux1 yum.repos.d]#

卸载ISO镜像【重要】

使用完了,记得一定要卸载掉喔~~~

1
2
3
[root@linux1 media]# umount /media/cdrom
[root@linux1 media]# ll cdrom/
total 0

如果要退出光驱,可以使用以下命令

1
[root@linux1 media]# eject /dev/cdrom
您的赞赏将鼓励我继续分享!
Fork me on GitHub