From Fedora Project Wiki


本页阐述了如何制作一张基于 Fedora 系统(包括派生发行版,例如 RHEL , CentOS )的定制版 Live CD 或 DVD .

如果您只是想把一个预制 ISO 写入光盘, 请查看 http://fedoraproject.org/en/get-fedora 下载一个 LiveCD 或 LiveDVD, 然后在 install guideburning how-to 查看进一步的说明.

project wiki 查看更多的详情. 该项目的讨论在 http://admin.fedoraproject.org/mailman/listinfo/livecd.


该项目和它的源文件支持 GPLv2 许可证. 查看该文件的拷贝获取详情.

创建一个 Live 镜像

要创建一个 Live 镜像, 要用到 livecd-creator 工具. 需要超级用户权限. 这个工具多少有点自己的记录, 用 --help 查看它的选项.

livecd-creatorlivecd-tools 包的一部分. 如果您的系统没有安装, 用下面的命令安装:

su -c 'yum install livecd-tools spin-kickstarts'

如果您对本地化 Live CD 文件感兴趣, 还要安装 l10n-kickstarts.

livecd-creator 是怎样工作的

简而言之, livecd-creator 程序

  • ext3 文件系统新建一个文件,文件系统中包含了构成 Live CD 的所有数据
  • Loopback 将这个文件挂载到根文件系统
  • 将必要的核心文件系统 (/dev, /dev/pts, /proc, /sys, /selinux) 挂载到根目录
  • 用一个配置文件定义所需的包和默认的配置选项.文件的格式与用 kickstart 安装系统是所用的一样.
  • yum 和 kickstart 文件中给出的库安装所需的包
  • 可选的,由 live CD 配置文件指定的运行脚本.
  • 重新标识整个根文件系统(为 SELinux)
  • 创建一个 live CD 特定的,匹配已安装的内核的 initramfs
  • 卸载已经挂载到根目录的核心文件系统
  • 卸载根文件系统
  • 创建一个只包含 ext3/4 文件(压缩)的 squashfs 文件系统
  • 配置 bootloader
  • 创建一个 iso9660 可引导 CD/DVD

Live 镜像配置文件

Live 镜像的配置是在一个文件中定义的,文件的格式与用 kickstart 安装系统是的一样. 它们包含了一些基本的系统配置条目, 包清单和一个在构建过程的最后阶段运行的脚本.

对于 Fedora 项目, 两个最重要的 live 镜像配置文件是

  • fedora-live-minimization.ks : 基本 live 镜像系统 (包含在 'livecd-tools' 包)
  • fedora-live-desktop.ks : 完整的桌面,带有应用程序和对于 Fedora 所支持所有语言环境的输出输出支持 (这是 'spin-kickstarts' 包的一部分)

其他定制版的 kickstart 文件(例如 Fedora Electronics Lab) 可以在安装 'spin-kickstarts'包后在 /usr/share/spin-kickstarts/ 中找到。

Set SELinux to permissive mode

SELinux should be in permissive mode for livecd-creator to work. Run the following as root user first before attempting to create a live cd or dvd.

setenforce 0

Making a 32-bit spin ISO on a 64-bit machine

If you have an x86_64 machine you're building on but you want a 32-bit happy iso image, add the following before your livecd-creator command:

setarch i686 livecd-creator [...]

Example: Spinning the Fedora Desktop Live CD

Note that because of the way livecd-creator works, it is not possible to choose a different set of packages or a different filesystem during installation. Assuming that you use the fedora-live-desktop.ks configuration file, then the following command:

livecd-creator \
--config=/usr/share/doc/livecd-tools-<version>/livecd-fedora-desktop.ks \
--fslabel=Fedora-LiveCD --cache=/var/cache/live

or

livecd-creator \
--config=/usr/share/spin-kickstarts/fedora-livecd-desktop.ks \
--fslabel=Fedora-LiveCD --cache=/var/cache/live

will create a live CD called "Fedora-LiveCD".

The name given by --fs-label is used:

  • as a file system label on the ext3 and iso9660 file systems (As such, it's visible on the desktop as the CD name)
  • in the isolinux boot loader.

If you have the repositories available locally and don't want to wait for the download of packages, just substitute the URLs listed in the configuration file to point to your local repositories.

You can use setarch command to create a x86 live cd/dvd on a x86_64 system. Ex: setarch i386 livecd-creator <..> .

Example: A Barebones Live CD

The command

livecd-creator \
--config=/usr/share/doc/livecd-tools-<version>/livecd-fedora-minimal.ks --cache=/var/cache/live 

will create a live CD that will boot to a login prompt.

Barebones Live CD does not support login capability.
Since no configuration is done, the user will not be able to login to the system as the root password is not set/cleared.


Testing your Live CD using KVM or qemu

As root:

qemu-kvm -m 512 -cdrom filename.iso

If you do not have KVM support, you can use qemu instead

qemu -m 512 --cdrom filename.iso

Replace filename.iso with the name of your created Live CD image.

Be sure to "yum install kvm qemu" as root for releases before Fedora 11. Fedora 11 has merged kvm and qemu into a single package. Just installing qemu package is enough.

Live image Installs

As of Fedora 7, anaconda has support for doing an installation from a live image. To use this, double click on the Install to Hard Drive item on the desktop or run

/usr/bin/liveinst

if you don't have such an icon.

Live Image Media Verification

The live image can incorporate functionality to verify itself. To do so, you need to have isomd5sum installed both on the system used for creating the image and installed into the image. This is so that the implantisomd5 and checkisomd5 utilities can be used. These utilities take advantage of embedding an md5sum into the application area of the iso9660 image. This then gets verified before mounting the real root filesystem.

Using Live Images from USB Media

USB sticks are becoming increasingly prevalent and are a nice way to use live images. You can take a live CD or DVD iso image and transform it so that it can be used on a USB stick. To do so, use the livecd-iso-to-disk script:

/usr/bin/livecd-iso-to-disk /path/to/live.iso /dev/sdb1

Replace /dev/sdb1 with the (unmounted) partition where you wish to put the live image. This is not a destructive process; any data you currently have on your USB stick will be preserved.

Additional information available at How to create and use Live USB.

Other Resources