Ubuntu-server版(字符安装界面)系统镜像的分析和制作方法

Ubuntu-server版(字符安装界面)系统镜像的分析和制作方法

V0.3

瓶子

一、概述
Ubuntu-server版系统镜像的大体构成及制作方法如下图所示:

二、从零开始构建Ubuntu-Server系统安装镜像
2.1 Debian-installer

–initrd.gzvmlinuzisolinux/的制作

Debian-installer是Debian的系统安装程序,ubuntu的server和alternate版都是使用Debian-installer作为系统安装程序。Debian-installer是一种字符界面的安装程序,可以对系统安装的软件包进行定制。

1、使用Debian-installer的ubuntu分支的源码

2、安装构建Debian-installer的依赖包:sudoapt-get build-dep debian-installer

3、创建debian-installer所需的源列表sources.list.udeb.local,构建debian-installer时会根据本机的sources.list生成所需的sources.list.udeb,可根据需要创建合适的sources.list.udeb.local来代替sources.list.udeb。

    例,在debian-installer源码/build/下建立sources.list.udeb.local,其内容如下:

debcopy:/home/xin/work/version/debian-installer/build/ localudebs/

debhttp://archive.ubuntu.com/ubuntu raring main/debian-installer

debhttp://archive.ubuntu.com/ubuntu raring-securitymain/debian-installer

debhttp://archive.ubuntu.com/ubuntu raring-updates main/debian-installer

debhttp://archive.ubuntu.com/ubuntu raring-proposedmain/debian-installer

4、根据需要(光盘启动、硬盘启动和网络启动等)构建带有debian-installer的内核文件,例如:makebuild_cdrom_isolinux

结果将在dest/目录下生成如下文件:

├── cdrom

 ├──debian-cd_info.tar.gz

 ├── initrd.gz

 └── vmlinuz

其中debian-cd_info.tar.gz内容为光盘启动所需的syslinux相关文件,也可供debian-cd使用自动生成光盘镜像。

定制:

config目录下修改给之文件可具体对内核等功能进行配置,具体有待根据实际需求进行分析。

2.2 debootstrap&mksquashfs

–filesystem.{manifest,size,squashfs}的制作

filesystem.squashfs是由debootstrap生成的ubuntu基础系统经过mksquashfs打包而成。

1、生成标准ubuntu基础系统:sudodebootstrap raring ./testfs

2、为安装系统时增加自定义的包集合菜单,方法有二种:

    方法一)在上面生成的testfs/usr/share/下建立tasksel/name.desc文件,内容例如:

Task:1234-server

Section:server

Description:mymy server

Selectsthe BIND DNS server and its documentation.

Packages:list

acl

tree

    方法二)修改tasksel-data包,修改其中的ubuntu-tasks.desc文件或增加一个.desc文件。

3、将已制作好的基础文件系统打包:

生成filesystem.squashfs文件:sudomksquashfs testfs ./filesystem.squashfs

生成filesystem.size文件:printf$(sudo du -sx --block-size=1 fs | cut -f1) > ./filesystem.size

生成filesystem.manifest文件:sudochroot fs dpkg-query -W --showformat=‘{Package} {Version}\n’ | sudotee ./filesystem.manifest

2.3 光盘引导

–isolinux/的制作

isolinux/下为光盘引导的相关文件,可使用debian-installer生成的debian-cd_info.tar.gz提供的文件,也可使用自定义引导程序。其引导参数例:

kernel/install/vmlinuz

    appendfile=/cdrom/preseed/ubuntu-server.seed vga=788initrd=/install/initrd.gz -- quiet

2.4 自动化安装系统

–preseed/的制作

preseed/下放置的是各种自动化安装系统的seed文件,可根据需要按照相关规则编写seed文件,ubuntuserver所使用的为ubuntu-server.seed。在引导参数中需指定seed文件。

2.5 光盘中源的软件包

–pool/的制作

pool/下是光盘中本地源的所有软件包,软件包按照源的标准文件结构放置。使用apt-move工具可将指定文件夹下的所有软件包按照源的标准文件结构放置,即可生成所需的pool目录。Apt-move是一个专为已下载到/var/cache/apt/archives的软件包生成debian软件包仓库文件结构的工具。

光盘中所携带的所有软件包之间必须没有冲突并有完整的依赖关系,同时不能和debootstrap生成的基础系统中已安装的软件包有冲突。

2.6 光盘中源的包列表

–dists/的制作

dists/下是光盘中本地源的包列表,其中至少应包含两个包列表:1)光盘中所有供系统安装的.deb包的包列表(Packages),2)Debian-installer所需的.udeb包的包列表。

其中.deb包的Packages制作方法:

1、由于Packages中包的相关信息需要包含Task字段,所以需要从http://archive.ubuntu.com/ubuntu/indices下载override.raring.extra.main和override.raring.main文件

2、创建/opt/apt-ftparchive/apt-ftparchive-deb.conf文件,内容可例如:
Dir {
ArchiveDir"/opt/cd-image/";

};

TreeDefault {

Directory"pool/";

};

BinDirectory"pool/main" {

Packages"dists/raring/main/binary-i386/Packages";

BinOverride"/opt/indices/override.raring.main";

ExtraOverride"/opt/indices/override.raring.extra.main";

};

BinDirectory"pool/restricted" {

Packages"dists/raring/restricted/binary-i386/Packages";

BinOverride"/opt/indices/override.raring.restricted";

};

Default {

Packages {

Extensions".deb";

Compress". gzip";

};

};

Contents {

Compress"gzip";

};

3、生成Packages(Packages.gz):

apt-ftparchivegenerate /opt/apt-ftparchive/apt-ftparchive-deb.conf

包含各类文件校验和签名的Release文件并不是必须的,其制作方法和.udeb包列表的制作方法可详见https://help.ubuntu.com/community/InstallCDCustomization。这部分若没特别修改可直接用ubuntu官方提供的和相应Debian-installer版本配套的.udeb包列表。

2.7 光盘信息

.disk/目录

.disk/目录下为记录一些光盘属性的文件,此目录是制作镜像所必须的。debian-installer会读取其中信息以判断是否为ubuntu的系统安装盘。

2.8 创建iso

sudo mkisofs-r -V “$IMAGE_NAME” -cache-inodes -J -l -bisolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot-boot-load-size 4 -boot-info-table -o …/ubuntu-server.iso .

2.9 simple-cdd

自动化构建ubuntu-server系统安装镜像

simple-cdd可以根据配置文件,利用Debian-installer和Debian-cd等工具自动构建ubuntu-server系统安装镜像。(由于这些软件默认配置都是针对Debian的,具体配置和使用还有待分析)

三、在已有ubuntu-server的iso中增加新包
如何在已有ubuntu-server的iso中增加新包,并在系统安装过程中增加对应选项的方法可参考上文,也可详见相关文档。

四、参考
https://help.ubuntu.com/community/InstallCDCustomization

http://schlutech.com/2011/07/the-debian-install-process/

http://wiki.debian.org/DebianInstaller

http://wiki.debian.org/DebianCustomCD

http://wiki.debian.org/Simple-CDD

http://wiki.debian.org/Simple-CDD/Howto

http://wiki.debian.org/DebianInstaller/Modify/CD

https://help.ubuntu.com/12.04/serverguide/installing-from-cd.html

https://help.ubuntu.com/12.04/installation-guide/i386/index.html

:(:(:(:(:frowning:

Apt-move在12.04的版本上是不是没用呢,生成的/mirrors/debian 下的pool dists 目录都是空的:o

应该可以的 所有工作都是在12.04上做的
刚在12.04上试了下 “sudo apt-move move”是生效的

非常好的帖子,学习了。