Linux 永久挂载镜像文件和制作yum源

Linux mount命令是经常会使用到的命令,它用于挂载Linux系统外的文件。

1.镜像挂载到系统指定目录下:
[root@master cdrom]#  mount -t auto  /mnt/cdrom
[root@master cdrom]# mount -t iso9660 /dev/cdrom /mnt/cdrom/
[root@master cdrom]# mount /dev/sr0 /mnt/cdrom/

三种方式均可以挂载到 /mnt/cdrom/

2.永久挂载到指定目录

修改 : /etc/fstab

[root@master cdrom]# more /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sun Aug 12 11:37:00 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=24af8522-d86c-40d4-8383-6b090474431f /boot                   xfs     defaults        0 0
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0
/tmp/swapfree swap swap defaults 0 0
/dev/sdb1     /storehouse   ext2    defaults  0 0
/dev/sr0      /mnt/cdrom/   iso9660   defaults   0 0     #添加这一条记录

3.查看系统文件格式
[root@master cdrom]# df -hT
文件系统              类型      容量  已用  可用 已用% 挂载点
/dev/mapper/rhel-root xfs        27G   19G  8.2G   70% /
devtmpfs              devtmpfs  977M     0  977M    0% /dev
tmpfs                 tmpfs     993M     0  993M    0% /dev/shm
tmpfs                 tmpfs     993M  9.2M  984M    1% /run
tmpfs                 tmpfs     993M     0  993M    0% /sys/fs/cgroup
/dev/sr0              iso9660   3.8G  3.8G     0  100% /mnt/cdrom
/dev/sdb1             ext2      7.8G   19M  7.4G    1% /storehouse
/dev/sda1             xfs      1014M  161M  854M   16% /boot
tmpfs                 tmpfs     199M  8.0K  199M    1% /run/user/42
tmpfs                 tmpfs     199M     0  199M    0% /run/user/1002
tmpfs                 tmpfs     199M     0  199M    0% /run/user/0

 

制作yum源

查看挂载:

[root@master yum.repos.d]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        18G  2.5G   15G  15% /
tmpfs           931M   68K  931M   1% /dev/shm
/dev/sda1       291M   39M  238M  14% /boot
/dev/sr0        3.6G  3.6G     0 100% /media/rhel  --挂载的光盘

安装一些包,到挂载的目录下,进Packages

cd /media/rhel/Packages

安装以下三个包:

[root@master Packages]# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
warning: python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
    deltarpm = 3.5-0.5.20090913git.el6 is needed by python-deltarpm-3.5-0.5.20090913git.el6.x86_64
[root@master Packages]# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
warning: deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:deltarpm               ########################################### [100%]
[root@master Packages]# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
warning: python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:python-deltarpm        ########################################### [100%]
[root@master Packages]# rpm -ivh createrepo-0.9.9-18.el6.noarch.rpm
warning: createrepo-0.9.9-18.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:createrepo             ########################################### [100%]

然后:

cd /etc/yum.repos.d

touch rhel-media.repo

vi rhel-media.repo

[rhel-media]
name=Redhat6.5
baseurl=file:///mnt/cdrom
enabled=1   
gpgcheck=0
gpgkey=file:///media/rhel/RPM-GPG-KEY-redhat-release

直接验证:

[root@master yum.repos.d]# yum install php
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-media                                                                              | 3.9 kB     00:00 ...
rhel-media/primary_db                                                                   | 3.1 MB     00:00 ...
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.3-26.el6 will be installed
--> Processing Dependency: php-common(x86-64) = 5.3.3-26.el6 for package: php-5.3.3-26.el6.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.3.3-26.el6 for package: php-5.3.3-26.el6.x86_64
--> Running transaction check
---> Package php-cli.x86_64 0:5.3.3-26.el6 will be installed
---> Package php-common.x86_64 0:5.3.3-26.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                   Arch                  Version                       Repository                 Size
===============================================================================================================
Installing:
 php                       x86_64                5.3.3-26.el6                  rhel-media                1.1 M
Installing for dependencies:
 php-cli                   x86_64                5.3.3-26.el6                  rhel-media                2.2 M
 php-common                x86_64                5.3.3-26.el6                  rhel-media                525 k

Transaction Summary
===============================================================================================================
Install       3 Package(s)

Total download size: 3.8 M
Installed size: 13 M
Is this ok [y/N]: y
Downloading Packages:
---------------------------------------------------------------------------------------------------------------
Total                                                                          165 MB/s | 3.8 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : php-common-5.3.3-26.el6.x86_64                                                              1/3
  Installing : php-cli-5.3.3-26.el6.x86_64                                                                 2/3
  Installing : php-5.3.3-26.el6.x86_64                                                                     3/3
rhel-media/productid                                                                    | 1.7 kB     00:00 ...
  Verifying  : php-5.3.3-26.el6.x86_64                                                                     1/3
  Verifying  : php-cli-5.3.3-26.el6.x86_64                                                                 2/3
  Verifying  : php-common-5.3.3-26.el6.x86_64                                                              3/3

Installed:
  php.x86_64 0:5.3.3-26.el6                                                                                    

Dependency Installed:
  php-cli.x86_64 0:5.3.3-26.el6                        php-common.x86_64 0:5.3.3-26.el6                       

Complete!

成功!

如果你未能成功,请留言探讨。

posted @ 2018-09-21 10:10  醉城、  阅读(8452)  评论(0编辑  收藏  举报