终于搞懂Livecd的制作了,从此可以任意定制livecd工具了

制作Livecd步骤:

1、写ks文件;

例如:

lang en_GB.UTF-8
keyboard us
timezone Asia/Shanghai --isUtc

#selinux --enforcing
selinux --disabled

#firewall --enabled --service=cockpit
firewall --disabled

#xconfig --startxonboot
services --enabled=sshd

# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --size 8192 --fstype ext4
part /boot/efi --fstype="ext4" --size=200
part /boot --fstype="ext4" --size=1024
part swap --fstype="swap" --size=2048
part /run/initramfs/live --fstype="ext4" --grow --size=1


# Root password
auth --useshadow --enablemd5
rootpw --plaintext ROOTPassWorD
repo --name=base --baseurl=http://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/
repo --name=updates --baseurl=http://mirrors.ustc.edu.cn/centos/7/updates/x86_64/
repo --name=extras --baseurl=http://mirrors.ustc.edu.cn/centos/7/extras/x86_64/
repo --name=epel --baseurl=http://mirrors.aliyun.com/epel/7/x86_64

%packages
@core
kernel
bash
openssh-server
shim                         #支持uefi启动,必须的包
grub2                        #支持uefi启动,必须的包
grub2-efi                    #支持uefi启动,必须的包
grub2-tools                  #支持uefi启动,必须的包
grub2-efi-x64-cdboot         #支持uefi启动,必须的包
efibootmgr                   #支持uefi启动,必须的包
unzip
vim
net-tools

%end

%post

%end

2、使用livecd-creator创建livecd镜像:
 

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

命令执行成功后,会在当前目录下生成一个iso文件;

安装定制工具,或修改一些文件:
3、挂载iso镜像,将iso文件下的所有文件拷贝到一个其他位置;

#mount -o loop centos-livecd.iso /mnt
#cp -rp /mnt/* /newiso/

4、将/LiveCD/squashfs.img文件拷贝至一个新位置;

#cp /newiso/LiveOS/squashfs.img /workpath/

4、解压squashfs.imge文件:

#安装squashfs-tools
#yum -y install squashfs-tools
#cd /workpath
#unsquashfs squashfs.img

解压成功后当前目录下会产生一个目录squashfs-root
5、挂载squashfs-root/LiveCD/ext3fs到一个目录下;

#mount -o loop squash-root/LiveOS/ext3fs.img /media/


6、chroot到挂载的目录下,进行安装软件;

#chroot /media/

chroot到/media/之后,安装定制工具,或修改这里的文件;

注意:安装板卡驱动或打内核模块时,一定保证制作livecd的系统内核版本与livecdISO里工具要求的内核版本一致,否则安装的内核模块或板卡驱动肯能不能正常使用。

PS:设置Livecd系统自动使用root用户登录,避免手动登录,也可以添加开机自运行脚本

修改文件/usr/lib/systemd/system/getty@.service

[Service]
# the VT is cleared by TTYVTDisallocate
# ExecStart=-/sbin/agetty --noclear %I $TERM
# 将上面内容修改为如下内容
ExecStart=-/sbin/agetty --autologin root --noclear %I

7、安装后,删除没必要的文件,重新打包squashfs.img

#cd /workpath
#mksquashfs squashfs-root/ squashfs.img -comp xz


8、将新的squashfs.img拷贝到livcd镜像文件的LiveCD目录下;

#rm -fr /newiso/LiveOS/squashfs.img
#cp /workpath/squashfs.img /newiso/LiveOS/squashfs.img

9、到LivCD文件所在的目录下使用genisoimagem或mkisofs重新打包iso镜像;

#genisoimage -v -cache-inodes -joliet-long -R -J -T -V MyLiveCD -o /databackup/MyLiveCD_v1.0.iso -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul -boot-load-size 4 -boot-info-table -eltorito-alt-boot -bisolinux/efiboot.img -no-emul-boot -allow-limited-size .
或
#mkisofs -R -b isolinux/isolinux.bin -c isolinux/boot.cat -o /tmp/MyLiveCD_v6.0.iso -V "LiveCD" -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -bisolinux/efiboot.img -no-emul-boot -allow-limited-size .

-V后跟的label要与EFI/BOOT/grub.cfg文件里的label一致,否则系统启动时找不到硬盘;

参考文章:

CentOS 7 Live-CD 的制作 - 八戒的技术博客

定制化LiveCD_weixin_34255055的博客-CSDN博客

CentOS7实现开机自动登录_centos7 自动登录_@码小白的博客-CSDN博客

  • 2
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
Live CD 是一种可以在计算机上启动的操作系统,它不需要安装在硬盘上,而是从 CD、DVD 或 USB 设备等可移动设备中启动。如果您忘记了您的操作系统的密码,您可以使用 Live CD 来重置密码。 以下是使用 Live CD 重置密码的步骤: 1. 下载并烧录 Live CD:您可以从网上下载 Ubuntu、Fedora、Kali LinuxLinux 发行版的 Live CD。然后,您需要将其烧录到 CD、DVD 或 USB 设备中。 2. 启动计算机:将 Live CD 插入计算机,并重新启动计算机。在启动过程中,您需要进入计算机的 BIOS 设置,并将 CD/DVD 或 USB 设备设置为启动设备。 3. 进入 Live CD:启动计算机后,您会进入 Live CD 的桌面环境。这个环境与您平常使用的操作系统不同,但可以使用类似的界面和应用程序。 4. 打开终端:在 Live CD 中,打开终端并输入以下命令: ``` sudo fdisk -l ``` 该命令将显示您计算机上的硬盘分区情况。请记住您的 Linux 系统分区的名称,例如 `/dev/sda1`。 5. 挂载 Linux 系统分区:输入以下命令以挂载 Linux 系统分区: ``` sudo mount /dev/sda1 /mnt ``` 请将 `/dev/sda1` 替换为您的 Linux 系统分区名称。 6. 修改密码:输入以下命令以修改密码: ``` sudo chroot /mnt passwd username ``` 请将 `username` 替换为您要重置密码的用户名。然后,您会被要求输入新密码。 7. 重启计算机:完成密码重置后,断开 Live CD,并重新启动计算机。您现在可以使用新密码登录您的系统了。 请注意,这些步骤仅适用于 Linux 操作系统。如果您使用的是 Windows 操作系统,您可以使用类似的方法重置密码,但具体步骤可能有所不同。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值