目的:就是把我所需的软件kvm等跟官方下载的iso整在一张盘上,并在安装系统过程中把这些包都装了,这样就不需要装好系统再行安装所需软件了



步骤:cp deb Packages.gz Release md5sum iso
#为了资源节省,方便测试,文本所有操作均在vmware中实现
1、安装一个debian_6.0_amd64系统
安装所需包,这些就是自己需要定制到安装cd中包含的软件包
# apt-get install gcc
# apt-get install kvm
# apt-get install qemu
# apt-get install libvirt-bin
# apt-get install bridge-utils
如果一些常用软件光盘已自带,则无需用apt-get安装
通过apt-get 安装的包默认存放在/var/cache/apt/archives中
2、新建一个目录用于存放“源iso”
本人以debian-6.0.2.1-amd64-CD-1.iso来做
# mkdir /custom/iso
# mount /dev/cdrom /mnt
# cp -ar /mnt/* /custom/iso <注意查看下iso根目录中的隐藏目录.disk有没拷过来>
3、安装apt-move
# apt-get install apt-move
apt-move是一个专为已下载到/var/cache/apt/archives的软件包生成debian软件包仓库文件结构的工具。为了便于安装,apt会将已安装的软件包下载到本地。 apt-move将默认在/mirrors/debian中生成这个本地仓库。
我将/etc/apt-move.conf中的设置从COPYONLY=no变为COPYONLY=yes以便apt-move不会删除/var/cache/apt/archives/中的软件包。
# apt-move -d squeeze update <此处squeeze名取自iso中dists目录中>
-d参数:只下载不安装
# cp -ar /mirrors/debian/pool/main/* /custom/iso/pool/main/
把apt-get安装的包添加到iso镜像源中,拷贝好了最好进/custom/iso/pool/main/查看下结构有没出错
4、建立更新Packages.gz前提条件
#相关路径一定要与光盘结构相同
# mkdir /custom/scripts
# cd /custom/scripts
# vi apt.conf
APT {
FTPArchive {
Release {
Origin "Debian";
Label "Debian";
Suite "stable";
Codename "squeeze";
Architectures "amd64";
Components "main";
};
};
};
# vi config_binary
Dir {
ArchiveDir "/custom/iso/";
OverrideDir "/custom/scripts/";
CacheDir "/custom";
};
TreeDefault {
Directory "pool/";
};
BinDirectory "pool/main" {
Packages "dists/squeeze/main/binary-amd64/Packages";
BinOverride "override.squeeze.main";
ExtraOverride "override.squeeze.extra.main";
};
Default {
Packages {
Extensions ".deb";
Compress ". gzip";
};
Contents {
Compress "gzip";
};
};
# vi config_installer
Dir {
ArchiveDir "/custom/iso/";
OverrideDir "/custom/scripts/";
CacheDir "/custom";
};
TreeDefault {
Directory "pool/";
};
BinDirectory "pool/main" {
Packages "dists/squeeze/main/debian-installer/binary-amd64/Packages";
BinOverride "override.squeeze.main";
ExtraOverride "override.squeeze.extra.main";
};
Default {
Packages {
Extensions ".udeb";
Compress ". gzip"
};
Contents {
Compress "gzip"
};
};
5、由于ubuntu的仓库结构,apt-move并不是把所有的软件包都插入到Packages.gz文件中。我们必须重新制作Packages.gz。
# cd /custom/iso
# dpkg-scanpackages pool/main /dev/null | gzip > dists/squeeze/main/binary-amd64/Packages.gz
如果没有dpkg-scanpackages,请安装dpkg-dev
貌似还需解压Packages.gz生成dists/squeeze/main/binary-amd64/Packages,操作如下:
# cp dists/squeeze/main/binary-amd64/Packages.gz /tmp
# cd /tmp
# gunzip Packages.gz
# mv Packages /custom/iso/dists/squeeze/main/binary-amd64/
6、生成新的Release
# cd /custom/iso
# apt-ftparchive -c /custom/scripts/apt.conf generate /custom/scripts/config_installer
# apt-ftparchive -c /custom/scripts/apt.conf generate /custom/scripts/config_binary
# rm dists/squeeze/Release
# apt-ftparchive -c /custom/scripts/apt.conf release dists/squeeze > ./dists/squeeze/Release
7、建立preseed.cfg文件,这一步比较关键,我们需要系统自动配置和安装些啥软件就这里了
我的preseed.cfg文件:
# Auto installation
d-i auto-install/enable boolean true
# Always install the server kernel.
d-i base-installer/kernel/override-p_w_picpath string linux-server
# Install the Ubuntu Server seed.
tasksel tasksel/force-tasks string server
# Network configuration.
d-i netcfg/choose_interface select auto
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Do not configure the network at this time
d-i netcfg/get_hostname string ecdata
d-i netcfg/get_domain string ecdata
# Clock and time zone setup
d-i clock-setup/utc boolean false
d-i time/zone string Asia/Shanghai
# Partitioning
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# Account setup
d-i passwd/root-login boolean root
d-i passwd/root-password password 123456
d-i passwd/root-password-again password 123456
d-i user-setup/allow-password-weak boolean true
d-i passwd/make-user boolean true #设为true为了下面的普通用户生效
d-i user-setup/encrypt-home boolean false
# To create a normal user account.
d-i passwd/user-fullname string ecdata
d-i passwd/username string ecdata
# Normal user's password, either in clear text
d-i passwd/user-password password 123456
d-i passwd/user-password-again password 123456
d-i user-setup/allow-password-weak boolean true
# Apt setup
d-i apt-setup/contrib boolean true
d-i apt-setup/use_mirror boolean false
d-i apt-setup/services-select multiselect security
d-i apt-setup/local0/repository string ftp://ftp.cn.debian.org/debian/ stable main #添加进系统的/etc/apt/sources.list
# Scan another CD or DVD?
apt-cdrom-setup apt-setup/cdrom/set-first boolean false #取消安装过程提示扫描其他cd或dvd
# Participate in the package usage survey? #取消安装过程发送package使用报告
d-i popularity-contest/participate boolean false
# Package setup
d-i pkgsel/include string sudo gcc kvm qemu libvirt-bin bridge-utils sudo openssh-server
tasksel tasksel/first multiselect standard
#如果要包含gnome桌面,用下面这段
# Package setup
# d-i pkgsel/include string sudo gcc kvm qemu libvirt-bin bridge-utils sudo openssh-server gdm desktop-base x-window-system-core gnome-core
# tasksel tasksel/first multiselect standard, Desktop environment, gnome-core
# Boot loader installation
d-i grub-installer/only_debian boolean true
# Finishing up the installation
d-i finish-install/reboot_in_progress note
(1)检测新建的preseed.cfg文件时候有语法错误
# debconf-set-selections -c .disk/preseed.cfg
(2)查看系统安装过程中执行的一些操作,对自定义preseed.cfg文件很有帮助,它能提供一些语法的命名
# apt-get install debconf-utils
# debconf-get-selections –installer > /tmp/install
# debconf-get-selections >> /tmp/install
导出debconf数据库和安装程序的cdebconf数据库到文件
(3)把preseed.cfg文件放进光盘根目录.disk中
8、修改引导文件,使能找到preseed文件
注意:语言、国家和键盘无法在预置文件preseed中指定,因为这些要在加载预置文件之前指定,所以要修改isolinux中得txt.cfg和gtk.cfg
我的是这样的:
针对文本模式安装
txt.cfg
append debian-installer/locale=en_US console-keymaps-at/keymap=us preseed/file=/cdrom/.disk/preseed.cfg vga=788 initrd=/install.amd/initrd.gz -- quiet
针对图形安装系统
gtk.cfg
append debian-installer/locale=en_US console-keymaps-at/keymap=us preseed/file=/cdrom/.disk/preseed.cfg video=vesa:ywrap,mtrr vga=788
initrd=/install.amd/gtk/initrd.gz – quiet
9、重做md5,不管做了什么,这一步一定要是建立最终iso前最后一步
# cd /custom/iso
# rm -f md5sum.txt
# find -type f -not -name md5sum -not -name boot.cat -exec md5sum {} \; >> md5sum.txt
10、建立iso <debian6.0已经用genisop_w_picpath代替了mkisofs,用法相同>
# cd /custom/iso
# genisop_w_picpath -o /root/debian-custom.iso -r -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table /custom/iso
over