Centos文本模式安装

1 准备工作

1.1 创建系统盘

1
2
3
4
# Download a Ubuntu server ISO file
sudo apt-get install qemu-system-x86
# Create a QCOW2 disk image
qemu-img create -f qcow2 femu.qcow2 80G

1.2 下载镜像

1
2
mkdir images && cd images
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso

1.3 挂载镜像

1
2
3
4
5
mkdir centos
sudo mount CentOS-7-x86_64-Minimal-2009.iso ./centos -o loop
# find the full path of vmlinuz and initrd
find ./centos -name "vmlinuz"
find ./centos -name "initrd"

2 安装

在文本模式安装时,由于缺少图形化界面,需要通过实现提取内核并在Qemu启动时进行指定才可以看到文本显示界面。完整的启动命令如下:

1
2
3
sudo qemu-system-x86_64 -m 1024 -smp 4 -boot d -cpu host -enable-kvm \
-hda femu.qcow2 -cdrom CentOS-7-x86_64-Minimal-2009.iso -nographic \
-kernel ./centos/images/pxeboot/vmlinuz -initrd ./centos/images/pxeboot/initrd.img -append console=ttyS0

进入安装过程后按照提示完成各部分设置即可。

3 启动&配置

3.1 启动

安装完成后,使用以下命令启动:

1
sudo qemu-system-x86_64 -hda femu.qcow2 -net nic -net user -m 4096 -localtime -smp 4 -cpu host -enable-kvm

3.2 配置

第一次进入系统后,系统没有网络,需要进行相应配置:

1
sudo dhclient

Centos文本模式安装
https://zdawng.github.io/posts/7d530f04/
作者
ZDawnG
发布于
2023年10月19日
许可协议