任务1、插⼊优盘,读取优盘数据
fdisk -l 查看优盘设备号
创建一个挂载点目录
mkdir /mnt/usb
挂载优盘到创建的目录
mount /dev/sdb1 /mnt/usb
使用 ls /mnt/usb 命令查看优盘内容。
任务2、在vmware配置光盘iso⽂件,在linux系统中读取光盘⽂件
![](https://i-blog.csdnimg.cn/direct/df4a35e7f07b40aca75926a8a4c47422.png)
[root@2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 18G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
sr0 11:0 1 8.8G 0 rom
[root@2 ~]# ls /mnt
[root@2 ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@2 ~]# ls /mnt
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL
[root@2 ~]# vim /etc/yum.repos.d/hh.repo
[a]
name=a
baseurl=file:///mnt
gpgcheck=0
[root@2 ~]# yum repolist
任务3、配置阿⾥云yum仓库
https://developer.aliyun.com/mirror/centos //查找帮助文档
[root@2 ~]# ls /etc/yum.repos.d
hh.repo
[root@2 ~]# mv /etc/yum.repos.d/hh.repo /etc/yum.repos.d/hh.repo.backup
[root@2 ~]# ls /etc/yum.repos.d/
hh.repo.backup
[root@2 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
![](https://i-blog.csdnimg.cn/direct/f2691394fc984e1f902019686c723f60.png)
[root@2 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo hh.repo.backup
[root@2 ~]# yum clean all
![](https://i-blog.csdnimg.cn/direct/3ebb9b9ec47d4f7cb1e7e53588a0d2a7.png)
[root@2 ~]# yum makecache
![](https://i-blog.csdnimg.cn/direct/ed5ecf600b3f4c99975bde8b783c2bff.png)
[root@2 ~]# yum repolist
![](https://i-blog.csdnimg.cn/direct/a28f4682810a4c8084a768b70ee066cd.png)
任务4、配置清华镜像仓库
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ //查找帮助文档
[root@2 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@2 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo.backup hh.repo.backup
[root@2 ~]# vim /etc/yum.repos.d/centos-base.repo
[base]
name=centos-$releasever-base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-7
[root@2 ~]# yum clean all
[root@2 ~]# yum makecache
[root@2 ~]# yum repolist
任务5、配置腾讯镜像仓库
https://mirrors.tencent.com/
[root@2 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@2 ~]# ls /etc/yum.repos.d/
CentOS-Base.repo.backup hh.repo.backup
[root@2 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
![](https://i-blog.csdnimg.cn/direct/cb3d7792351e492fa95c6d2e45635d50.png)
[root@2 ~]# yum clean all
[root@2 ~]# yum makecache
[root@2 ~]# yum repolist
![](https://i-blog.csdnimg.cn/direct/41d10a3bdee846868139fde07c87ee7f.png)
任务6、⾃建仓库 包含 tree net-tools bash-completion nginx 等包
vim /etc/yum.conf //将keepcache后改为1
![](https://i-blog.csdnimg.cn/direct/b6bc7627961340d4aad38d746baa9a8e.png)
1029 yum install --downloadonly --downloaddir=./soft net-tools
1030 yum install --downloadonly --downloaddir=./soft bash-completion
1031 yum install --downloadonly --downloaddir=./soft nginx
1032 yum install --downloadonly --downloaddir=./soft tree
![](https://i-blog.csdnimg.cn/direct/5cb1d77c777e42bda70c6f56d007c32c.png)
[root@2 ~]# ls soft/
bash-completion-2.1-8.el7.noarch.rpm net-tools-2.0-0.25.20131004git.el7.x86_64.rpm
[root@2 ~]# yum -y install createrepo
[root@2 ~]# createrepo ./soft/
[root@2 ~]# ls soft/
bash-completion-2.1-8.el7.noarch.rpm net-tools-2.0-0.25.20131004git.el7.x86_64.rpm repodata nginx-1.26.1-2.el7.ngx.x86_64.rpm tree-1.6.0-10.el7.x86_64.rpm
[root@2 ~]# mv /etc/yum.repos.d/CentOS-Base.repo.repo /etc/yum.repos.d/CentOS-Base.repo.txt
[root@2 ~]# mv /etc/yum.repos.d/nginx.repo /etc/yum.repos.d/nginx.repo.txt
[root@2 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.txt
[root@2 ~]# yum clean all
[root@2 ~]# yum makecache
[root@2 ~]# yum -y install bash-completion.noarch
[root@2 ~]# yum -y install net-tools.x86_64
[root@2 ~]# yum -y install nginx
[root@2 ~]# yum -y install tree