Centos7使用U盘引导安装时卡在Starting dracut initqueue hook,以及Centos停止更新后软件源的设置

HTML  2026-02-02 01:30  8  

之前都是在虚拟平台安装Centos,第一次使用U盘在实体机上安装,使用的镜像是CentOS-7-x86_64-Minimal-2009.iso进不了安装页面,卡在Starting dracut initqueue hook,网上搜索得知是由于安装程序无法确定安装文件的位置,解决方法是修改U盘的驱动器名称,Centos默认会寻找Label名为"CentOS 7 x86_64"驱动器加载安装程序,不知道是不是由于U盘是使用Windows烧录的原因,磁盘名称有长度限制变成了“CentOS 7 x8”,导致无法正确启动安装程序,包括直接复制iso文件中的内容到U盘根目录下时,不正确设置驱动器名称时也会出现此情况,解决方法如下:

在选择U盘引导后的引导启动界面选择第一项"Install CentOS 7",按键盘E键修改,

修改前:

linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet

修改后:
linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20x8 quiet
改为U盘实际的名称,按CTRL+X,即可顺利完成安装。
---------结束----------------------------------------

下面说我踩过的坑,我参照网上的使用安装U盘实际挂载路径代替LABEL方式进行指定也不能正常安装,因为我最开是直接解压复制iso文件到U盘的,LABEL值为空,所以第一时间没有考虑修改Label,这里说一下使用实际挂载路径的修改方式
1.先查看挂载的磁盘,在引导时按E修改

linuxefi /images/pxeboot/vmlinuz linux dd nomodeset quiet

CTRL+X后可以查看到所有的磁盘挂载路径,我的是sda1

2.记录磁盘路径后(一般为sda/sdb/scd等字样,我的U盘是sda1),重启继续修改引导项

将linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet

修改为linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:/dev/sda1 quiet
替换其中路径为实际的安装U盘路径,CTRL+X后可以正常加载安装程序了,因为我偷懒使用直接指定路径的方式,导致在最后一步开始安装时出现“设置基础软件仓库时出错”的错误,安装程序又无法找到软件包了,这时候我还没意识到是因为我通过linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:/dev/sda1 quiet指定导致的,一直在网上找在线的软件包网址,每次尝试又会花费近十分钟,也尝试过添加inst.repo参数,都以失败告终,最后决定通过修改实际LABEL方式,成功了,我以为LABEL跟直接写挂载路径一样,结果并不一样。最后修改linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=CentOS\x207\x20x8 quiet,也就是磁盘名称为“CentOS 7 x8”的情况,完成安装。

下面说一下Centos停止更新后软件源的设置,我先贴一下默认的仓库配置文件,位于/etc/yum.repos.d/CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

可以看到centos通过设置mirrorlist在更新源时获取多个镜像源,根据实际下载速度会进行切换,现在基本所有的镜像源都关掉了,就算有能用的估计过不了多久也会关闭,但是CentOS留了一个Vault存档源:vault.centos.org,可以设置软件包从这里面下载,虽然慢点,但一定会比其他非官方的活的更久。只需要注释掉配置文件中每个片段的mirrorlist行,添加baseurl为vault.centos.org的域名的路径即可,例如[base]中,添加baseurl=http://vault.centos.org/7.9.2009/os/$basearch/,其他类似,完整配置文件如下(注意我的写法是固定为7.9.2009版本,如果你的版本不一致,或者后续需要升级系统,可以尝试用他示例的$releasever变量方式)

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

最后执行以下命令后,就可以正常安装软件了

sudo yum clean all
sudo yum makecache

参考:

https://blog.csdn.net/xiaoma19961101/article/details/130391436

https://blog.csdn.net/weixin_70065088/article/details/144565986


发布于 2026-02-02 01:30, 最后修改于2026-02-03 10:35