LiveCD镜像文件的定制化

本文详细描述了如何从头开始制作CentOS7的LiveCD镜像,包括制作ks应答文件、下载和上传ISO、挂载与解压、修改系统文件、打包和重新打包LiveCD的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  最近想要定制化一款属于自己的LiveCD镜像文件,并且里边封装好所需要的软件程序,本文将会记录具体的操作步骤,供有需要的人参考借鉴。

环境说明:

环境配置说明配置参数
编码环境Centos7.9
LiveCD文件CentOS-7-livecd-x86_64.iso

附LiveCD下载链接:

Centos7:https://buildlogs.centos.org/centos/7/isos/x86_64/
Centos6:https://mirrors.bfsu.edu.cn/centos-vault/6.10/isos/x86_64/

操作步骤:

1、制作ks应答文件,可拷贝已安装系统生成的文件。

  默认情况下,已经安装好的系统在root用户的家目录下会默认有ks文件(centos7.9默认为anaconda-ks.cfg),直接拷贝就可以使用。也可以使用其它工具来自动生成。
  这里不做重点阐述,感兴趣的小伙伴可以查阅资料。

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8

# Network information
network  --bootproto=dhcp --device=enp4s0f0 --onboot=off --ipv6=auto --no-activate
network  --bootproto=dhcp --device=enp4s0f1 --onboot=off --ipv6=auto
network  --bootproto=dhcp --device=enp4s0f2 --onboot=off --ipv6=auto
network  --bootproto=dhcp --device=enp4s0f3 --onboot=off --ipv6=auto
network  --hostname=localhost.localdomain

# Root password
rootpw --iscrypted $6$gaK5808gYkpuiQPa$7Dd6l95oDjOvy.NlSPtwZVVGddwePE0e/N5ou8g8Rqassl4JJvMe5kVLcBKSrFCr7Zqf6mTEayiX62wQzOaot1
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# X Window System configuration information
xconfig  --startxonboot
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=sda

%packages
@^graphical-server-environment
@backup-server
@base
@compat-libraries
@core
@desktop-debugging
@development
@dial-up
@dns-server
@file-server
@gnome-desktop
@guest-agents
@guest-desktop-agents
@ha
@hardware-monitoring
@identity-management-server
@infiniband
@input-methods
@internet-browser
@java-platform
@kde-desktop
@large-systems
@load-balancer
@mail-server
@mainframe-access
@mariadb
@multimedia
@network-file-system-client
@performance
@postgresql
@print-client
@print-server
@remote-system-management
@resilient-storage
@security-tools
@smart-card
@system-admin-tools
@virtualization-client
@virtualization-hypervisor
@virtualization-tools
@x11
kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

2、从镜像网站下载对应的LiveCD版本的iso文件,然后上传到服务器上。

在这里插入图片描述这里推荐下载 CentOS-7-livecd-x86_64.iso ,该iso镜像文件相对较小,且桌面版本为通用的,比较好用。

3、挂载iso镜像文件,拷贝系统文件。

myFile: 存放镜像所有文件内容。
mySquashfs:存放 squashfs 临时系统打包文件内容。

mount -o loop CentOS-7-livecd-x86_64.iso /mnt/

mkdir /myFile
cp -rf /mnt/* /myFile/

mkdir /mySquashfs
cp -rf  /myFile/LiveOS/squashfs.img /mySquashfs/

4、解压squashfs.img文件。

#安装squashfs-tools工具
yum install -y squashfs-tools
cd /mySquashfs/
unsquashfs squashfs.img

解压成功后会在当前目录下产生一个squashfs-root目录。

5、挂载squashfs-root里的文件系统,根据需求修改系统文件。

mount -o loop squash-root/LiveOS/ext3fs.img /media/
#修改系统文件,可chroot切入系统中,也可在外边直接修改文件。
chroot /media/

6、修改完毕后重新打包squashfs.img文件。

cd /mySquashfs/
mksquashfs squashfs-root/ squashfs.img -comp xz

7、拷贝新的squashfs.img文件到LiveCD镜像文件目录下。

rm -rf /myFile/LiveOS/squashfs.img
cp /mySquashfs/squashfs.img /myFile/LiveOS/squashfs.img

8、重新打包LiveCD镜像文件。

mkisofs -R -b isolinux/isolinux.bin -c isolinux/boot.cat -o /home/MyLiveCDv7.0.iso -V "CentOS-7-livecd-x86_64" -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -bisolinux/efiboot.img -no-emul-boot -allow-limited-size .

注意: 这里的 -V 后的名字要与与 EFI/BOOT/grub.cfg 文件里的label一致,否则系统启动时找不到硬盘

9、如果想要手动创建LiveCD镜像文件的话,可以执行下列命令:

#安装livecd-tools
yum -y install livecd-tools
#制作livecd ISO镜像文件
livecd-creator --verbose -c centos7-livecd.ks --cache=cache -f centos7-livecd
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一条代码鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值