我这里直接安装的RHEL7的操作系统,使用的是最小化安装,默认很多RPM都没有安装上,友情链接:U盘启动安装Linux系统
我这里演示两种配置YUM本地源,一种是通过U盘,另一种是通过远程Windows共享目录的方式,友情链接:Linux yum源
1. U盘作为本地YUM源
- 插入并且mount U盘
- 制作YUM源文件
Steps:
[root@localhost ~]# fdisk -l #查看U盘信息
Disk /dev/sda: 320.1 GB, 320072933376 bytes, 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x442146ee
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1023999 510976 7 HPFS/NTFS/exFAT
/dev/sda2 1024000 2047999 512000 83 Linux
/dev/sda3 2048000 625141759 311546880 8e Linux LVM
Disk /dev/mapper/rhel-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/rhel-swap: 2164 MB, 2164260864 bytes, 4227072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/rhel-home: 263.2 GB, 263171604480 bytes, 514007040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 8022 MB, 8022982656 bytes, 15669888 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcad4ebea
Device Boot Start End Blocks Id System
/dev/sdb4 * 256 15669887 7834816 b W95 FAT32
[root@localhost ~]# mount /dev/sdb4 /mnt/usb/ #mountU盘到指定目录
[root@localhost ~]# cat /etc/yum.repos.d/rhel-local.repo #新建yum源文件
[rhel_7]
name=local_iso
baseurl=file:///mnt/usb
enabled=1
gpgcheck=1
gpgkey=file:///mnt/usb/RPM-GPG-KEY-redhat-release
2. 用远程Windows共享目录的方式
- 因为我这里使用的是最小化安装,所以首先要用第一种方式把cifs-utils这个rpm包安装上
- 在windows上新建一个directory,共享,并且确保rhel7能够访问
- 把yum源copy到上面新建的共享directory里面
- mount共享directory
- 制作YUM源文件
Steps:
[root@localhost ~]# mount -t cifs //IP/os_share_rhel7 /mnt/rhel7_iso/ -o username=account #mount windows上面的共享directory
Password for username@//IP/os_share_rhel7: *********
[root@localhost ~]# cat /etc/yum.repos.d/rhel-local.repo #新建yum源文件
[rhel_7]
name=local_iso
baseurl=file:///mnt/rhel7_iso
enabled=1
gpgcheck=1
gpgkey=file:///mnt/rhel7_iso/RPM-GPG-KEY-redhat-release
[root@localhost ~]# mount -t cifs IP:share_folder /mnt/linux_share -o user=username #另外一种方式,不同于上面使用的是//,而是使用的冒号(:)