QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3326|回复: 5

中标普华桌面Live CD1.0制作过程简介

[复制链接]
发表于 2006-12-15 09:00:17 | 显示全部楼层 |阅读模式
中标普华桌面Live CD1.0制作过程简介
                                                    [email protected]

1,目前两种livecd制作方法(或者说是制作程序)

(1)Linux-live
Intro:
Linux Live is a set of shell scripts which allows you to create own LiveCD from every Linux distribution. Just install your favourite distro, remove all unnecessary files (for example man pages and all other files which are not important for you) and then download and run these scripts to build your custom Live Linux.
Current version of Linux Live scripts 5 is Linux Live 5.5.0 (released 22nd of August 2006). It doesn't work with old 2.4 kernels, only with 2.6 ones. Unpack the archive to /tmp, login as root and run ./runme.sh. You need unionfs and squashfs support for your Linux Kernel.

How does it work:
It boots by using initrd, then it creates union in /union and adds /changes to it as a read-write branch. After then, it mounts the whole packed filesystem from the CD and inserts it to union, and finally /union is chrooted.

(2)Kadischi
What is Kadischi:
Kadischi is an application for Fedora-based Live CD generation. It takes a Fedora Core RPM repository as an input and outputs a live ISO9660 CD image. Kadischi is still in the early stage of development, but has basic functionality and can be run successfully.
How does Kadischi work:
Basically, Kadischi uses Anaconda to install the system in a temporary directory (specified in the configuration file) on user's hard drive. It then executes the collection of scripts in order to modify the system to run successfully in read-only environment (CD). After all modifications are done, Kadischi creates an initrd image, then compresses the system tree (actually, it creates a compressed copy, and then removes the original one), and finally creates an ISO9660 CD image of the system. You need  squashfs support for your Linux Kernel.

2,我的制作方法(不同于以上方法)

(1)先安装好一个中标普华桌面3.0。命名为第一操作系统
(2)再安装一个中标普华桌面3.0在另外分区,命名第二操作系统。装好以后不要引导第二操作系统,直接进入第一操作系统。
(3)进入第一操作系统然后开始对另外分区上的第二操作系统进行裁减。如删除第二操作系统的rpm数据库,doc文件,info文件,手册文件,删除除了英文和中外以外的语言包,删除boot目录 等。最好第二操作系统大约体积为1600M左右。
(4)在第二操作系统中建立/livecd文件夹。
将 etc  home  opt  root  tmp  var  xkb这些目录大成neoshine.tar.gz包 放入/livecd目录中,然后再建立/livecd/tmpfs /livecd/ramfs,原因后述。然后将第二操作系统中etc  home opt  root  tmp  var  xkb删除。重建/etc目录,内容如下:fstab  init.d inittab mtab  rc  rc.local rc.sysinit  udev group  initlog.conf  makedev.d  passwd rc.d rc.neoshine  shadow。在第二操作系统中建立/usr/lib/X11/xkb到/xkb的链接,原因后述。
(5)修改第二操作系统中的 rc.sysinit,去掉有关check root filesystem等操作。如何不用的启动项目等。
(6)在第一操作系统中利用mksquashfs工具将第二操作系统打包成NeoShine.sqsh文件。前提系统模块中有squashfs。
(7)制作光盘系统启动的initrd.img。initrd的原理网路上颇多,这里不再累述。把关键脚本列出。几处上面提到的问题缘由通过代码解释既会明晰。
initrd.gz中的linuxrc

代码:
#!/bin/bash
打开内核中initrd调试模式,有助调试系统
if [ "${INITRD_DBG}" = "x" ]; then set -x; fi

挂载proc文件系统
echo "Mounted proc filesystem"
mount -t proc /proc /proc

挂载sysfs tmpfs文件系统
echo "Mounting sysfs filesystem"
mount -t sysfs none /sys
mount -t tmpfs none /tmp

在创建/dev目录
echo "Creating /dev"
mount -o mode=0755 -t tmpfs none /dev

建立pts shm目录,用于系统
mkdir /dev/pts
mkdir /dev/shm

加载loop squashfs模块
modprobe loop
modprobe squashfs

启动udev,在/dev/下建立设备文件
echo "udev starting"
udevstart

挂载光驱
mount /dev/cdrom /cdrom

不要挂载rootfs文件系统
# Make kernel don't mount root fs
echo 0x100 > /proc/sys/kernel/real-root-dev

echo "Mounting root filesystem"
再来一次udev,以防缺少/dev/下设备
udevstart
挂载光盘中NeoShine.sqsh文件到/sysroot
mount -t squashfs -oloop,ro /cdrom/NeoShine.sqsh /sysroot
echo "Doing the pivot_root"
进入sysroot,利用系统调用将根文件系统转移
cd /sysroot
pivot_root /sysroot /sysroot/initrd
cd /

在新根文件系统中建立/dev/
# Mount a (writeable) ramfs at dev and populate it with nodes:
mount -n -t ramfs initrd_dev /dev

在新根文件系统中建立设备文件
cd /dev
for node in mem kmem null port zero core full ram ptmx tty pty shm cpu input agpgart dri cdrom console; do
/initrd/sbin/MAKEDEV $node
done

同上上过程
mkdir /dev/shm

创建pts目录给pseudo-terminal用
mkdir /dev/pts
mount -n -t devpts initrd_devpts /dev/pts

执行rc.neoshine文件
echo "Setting up readonly-root"
/etc/rc.neoshine

NeoShine.sqsh中的/etc/rc.neoshine
代码:
#!/bin/bash

一函数
mount_file() {
if [ -e ${1} ] && [ -e /livecd/tmpfs${1} ]; then
mount -n --bind /livecd/tmpfs${1} ${1}
fi
}

挂载各个相关文件系统
echo "Mounting tmpfs on /livecd/tmpfs"
mount -t tmpfs none /livecd/tmpfs

echo "Mounting ramfs on /livecd/ramfs"
mount -t ramfs none /livecd/ramfs

将neoshine.tar.gz解压缩
echo "Extracting files to /livecd/tmpfs"
tar --directory /livecd/tmpfs -zxf /livecd/neoshine.tar.gz >/dev/null 2>&1

将/livecd/中的目录绑定到实际目录中
echo "Binding files from /livecd/tmpfs to their original locations"
mount_file /tmp
chmod a+rwxt /livecd/tmpfs/tmp

mount_file /var

chmod a+rwxt /livecd/tmpfs/var/tmp

mount_file /root
mount_file /home
mount_file /opt
mount_file /mnt
mount_file /media
mount_file /etc

mount_file /xkb

准备启动rc.sysinit
echo "Moving /etc/rc.d to /livecd/ramfs"
mv /etc/rc.d /livecd/ramfs/ >/dev/null 2>&1
ln -s /livecd/ramfs/rc.d /etc/rc.d

接下来就是该主操作系统的事情了

(将initrd添加bootsplash。
Splash.bin -s -f /etc/.......conf >> initrd.gz
(9)组织iso文件结构
|-- NeoShine.sqsh
|-- boot
|   |-- initrd.gz
|   |-- initrdrescue.gz
|   |-- isolinux.bin
|   |-- memtest
|   |-- splash.cfg
|   |-- splash.txt
|   |-- vmlinuz
|   `-- vmlinuzrescue
`-- isolinux.cfg
1 directory, 10 files
(10)编写isolinux.cfg
display boot/splash.cfg
default desktop
prompt 1
timeout 40
F1 boot/splash.txt
F2 boot/splash.cfg
label desktop
kernel boot/vmlinuz
append initrd=boot/initrd.gz init=linuxrc quiet vga=791 splash=silent showopts
label rescue
kernel boot/vmlinuzrescue
append initrd=boot/initrdrescue.gz ro root=/dev/ramdisk
label memtest
kernel boot/memtest
(11)刻盘
mkisofs -V  " Neoshine Livecd" -b boot/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -T  -l -o  Neoshine_livecd_1.0.iso  iso

附录:
1,Linux-live 和 Kadischi 源码大家可以下载看看,实现过程也很简单。
2,What is Squashfs :Squashfs is a compressed read-only filesystem for Linux. Squashfs is intended for general read-only filesystem use, for archival use (i.e. in cases where a .tar.gz file may be used), and in constrained block device/memory systems (e.g. embedded systems) where low overhead is needed. The filesystem is currently stable, and has been tested on PowerPC, i586, Sparc and ARM architectures.

3,What is Unionfs :Unionfs is useful for unified source tree management, merged contents of split CD-ROM, merged separate software package directories, data grids, and more. Unionfs allows any mix of read-only and read-write branches, as well as insertion and deletion of branches anywhere in the fan-out. To maintain unix semantics, Unionfs handles elimination of duplicates, partial-error conditions, and more.
 楼主| 发表于 2006-12-15 09:00:50 | 显示全部楼层
gugong 我终于抽空发文档了
回复

使用道具 举报

发表于 2006-12-15 10:07:27 | 显示全部楼层
  

Thks
回复

使用道具 举报

发表于 2006-12-23 03:16:30 | 显示全部楼层
    
回复

使用道具 举报

 楼主| 发表于 2006-12-23 10:18:53 | 显示全部楼层
以上文档可以扔到垃圾箱中了。

我换成aufs了  嘻嘻
回复

使用道具 举报

发表于 2007-12-30 23:37:27 | 显示全部楼层
那就重写这篇文章嘛,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-4-20 01:57 , Processed in 0.121285 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表