首先将优盘或光盘插入服务器中,然后使用lsblk查看块设备信息(块设备有硬盘、软盘驱动器、CD-ROM驱动器和闪存等)。

优盘和光盘可以从/dev中看到,这时候是无法查看sdb4和sr1内的文件的

创建挂载位置,一般挂载到/mnt内(光盘也可挂载到/media下,随意);使用mkdir命令创建文件夹

开始挂载优盘和光盘,挂载后可以查看光盘和优盘里的文件。
挂载命令
mount /dev/sr1 /mnt/centos/
mount /dev/sdb4 /mnt/Udisk/

挂载完成后再次查看块设备,出现挂载位置

编辑源文件vi /etc/yum.repos.d/CentOS-Media.repo 在baseurl格式下面添加一行file:///mnt/centos/ 务必把enabled置为1
name=CentOS-$releasever - Media #描述
baseurl=file:///mnt/centos/ #设置资源库的地址,可以写阿里云也可以是自己的yum源 如ftp://、http://、file:///等
enabled={1|0} #1表示开启本地更新,0不开启;
gpgcheck={1|0} #1表示检查,0不检查;

然后将CentOS-*.repo移动到其他地方 mv CentOS-*.repo /
yum clean all #清除缓存
yum makecache #生成缓存
yum install gcc -y #安装gcc
使用完成后记得卸除挂载
umount /dev/sr1 /mnt/centos、umount /dev/sdb4 /mnt/Udisk

网友评论