- 浏览: 208960 次
- 来自: 北京
文章分类
自定义Ubuntu Live CD
<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!-- [if !mso]> <object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui> </object> <mce:style><!-- st1/:*{behavior:url(#ieooui) } --> <!-- [endif]--><!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:黑体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimHei; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@黑体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} h1 {mso-style-next:正文; margin-top:17.0pt; margin-right:0cm; margin-bottom:16.5pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; line-height:240%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:1; font-size:22.0pt; font-family:"Times New Roman"; mso-font-kerning:22.0pt;} h2 {mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:2; font-size:16.0pt; font-family:Arial; mso-fareast-font-family:黑体; mso-bidi-font-family:"Times New Roman"; mso-font-kerning:1.0pt;} h3 {mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:3; font-size:16.0pt; font-family:"Times New Roman"; mso-font-kerning:1.0pt;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} pre {margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:宋体; mso-bidi-font-family:宋体;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:1117335575; mso-list-type:hybrid; mso-list-template-ids:-957024894 1206141396 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-tab-stop:42.0pt; mso-level-number-position:left; margin-left:42.0pt; text-indent:-18.0pt;} @list l1 {mso-list-id:1328510371; mso-list-type:hybrid; mso-list-template-ids:1673301742 1477195926 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l1:level1 {mso-level-number-format:japanese-counting; mso-level-text:%1、; mso-level-tab-stop:54.0pt; mso-level-number-position:left; margin-left:54.0pt; text-indent:-30.0pt;} @list l2 {mso-list-id:1605110975; mso-list-type:hybrid; mso-list-template-ids:672403016 770892310 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l2:level1 {mso-level-number-format:japanese-counting; mso-level-text:%1、; mso-level-tab-stop:42.0pt; mso-level-number-position:left; margin-left:42.0pt; text-indent:-18.0pt; mso-ascii-font-family:Arial; mso-fareast-font-family:黑体; mso-hansi-font-family:Arial; mso-bidi-font-family:"Times New Roman";} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} --><!-- [if gte mso 10]> <mce:style><!-- /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} --> <!-- [endif]-->
目前,在 Linux 社区, Ubuntu 的系统是最受桌面用户欢迎的,基本上使用 Linux 的初学者都会选择 Ubuntu 系统,这主要是因为 Ubuntu 系统有着强大的 Linux 社区作为后续支持,另外, Ubuntu 系统的易用性比较强,再加上 Ubuntu 系统在设计时,比较注意稳定性和安全性。同时 Ubuntu 系统还有一点就是可玩性比较强,可以让用户根据自己的需要去定制和修改,而且修改方法比较简单。现在我就简单的介绍一下如何根据 Ubuntu 系统,定制一个自己的 Live CD 产品。
前期准备工作
在制作 Live CD 前,先装入一个 Ubuntu 的系统是必须的。另外要根据自己的需要下载一个要改动的 Ubuntu Live CD 原型,你可以登录网站 http://releases.ubuntu.com/ 去下载 。然后,还需要做如下几步:
sudo aptitude install squashfs-tools genisoimage
这一步的目的是要装入 squashfs 文件系统处理工具以及 ISO 制作工具。
接下来执行 sudo modprobe squashfs 。其目的是加载 squashfs 模块,以供后面对 Ubuntu Live CD 光盘中的 squashfs 格式的文件进行处理。
为了介绍方便,接下来我将以 ubuntu 9.04 的 Live CD 产品为例进行介绍。
展开光盘中的内容
<!-- [if !supportLists]-->一、 <!-- [endif]-->创建一个环境。具体的执行步骤入下:
mkdir ~/live
mv ubuntu-9.04-desktop-i386.iso ~/live
cd ~/live
<!-- [if !supportLists]-->二、 <!-- [endif]-->挂载光盘镜像
mkdir mnt
sudo mount -o loop ubuntu-9.04-desktop-i386.iso mnt
<!-- [if !supportLists]-->三、 <!-- [endif]-->展开镜像文件中的内容到 extract-cd 目录下
mkdir extract-cd
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
展开桌面系统
<!-- [if !supportLists]-->一、 <!-- [endif]-->挂载 squashfs 文件系统
mkdir squashfs
sudo mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs
<!-- [if !supportLists]-->二、 <!-- [endif]-->展开 squashfs 文件系统中的内容到 edit 目录下
mkdir edit
sudo cp -a squashfs/* edit/
改变设置,以 root 用户身份来编辑桌面系统
如果你需要网络,则将 resolv.conf 文件复制到展开的 squashfs 文件系统目录 edit 目录下。具体做法是:
sudo cp /etc/resolv.conf edit/etc/
若需要你的计算机配置的话,请复制 hosts 文件到 edit/etc/ 目录下:
sudo cp /etc/hosts edit/etc/
sudo mount --bind /dev/ edit/dev
sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
【注意:这个挂载对后续工作是很有用的。如果你后来决定删除或编辑目录 , 请确保卸载之后再进行 , 否则你的主机系统暂时将成为无用,直到重新启动】
执行下面的操作来解决本地花钱的问题:
export HOME=/root
export LC_ALL=C
进行自定义
Apt-get:
先查看安装的包的情况,具体的执行命令是:
dpkg-query -W --showformat='${Installed-Size} ${Package}/n' | sort -nr | less
这条命令的执行结果是,根据包的尺寸大小来排列安装的具体包。
当要删除不用的包时,执行命令:
aptitude purge package-name
自定义启动后的背景:
一般背景图片都放在了 /usr/share/backgrounds 目录下。所以先将要设置的背景图片放置在 /usr/share/backgrounds 目录下。然后修改默认的“注册表”的值。具体的 gconf 值是 /usr/share/gnome-background-properties/ubuntu-wallpapers.xml 和 /usr/share/gconf/defaults/16_ubuntu-wallpapers 文件中的 /usr/share/backgrounds/warty-final-ubuntu.png 。将值 /usr/share/backgrounds/warty-final-ubuntu.png 改成你要设置的图片的绝对路径即可。详细设置,你可以参照 Desktop background bug 。
修改默认 gconf 设置【字体, panel 等】:
要想修改默认的 gconf 值,你必须先添加你想改的值到 /etc/gconf/gconf.xml.defaults/%gconf-tree.xml 文件中。在该文件中添加 gconf 值将改变 gnome 或者应用程序的默认值。因此你可以根据自己的需求,去修改字体,背景图等等。
与以前修改不同的是,在这里你需要执行 gconftool-2 来修改。具体的做法是,你先进入 chroot 的环境,然后运行下面的命令即可:
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set yourkey "yourvalue"
这里的字符串 yourkey 和 yourvalue 指的是你要改动的类型,键名称和键值。所以一定要注意。
几个默认值一次性修改的方法:
一个个值去设置 gconf 的值比较麻烦,下面介绍一个比较好的方法来一次性设置多个键值。要想设置,最好的办法是先使用一个测试用户,根据自己的需要将相应的值都设置好,然后执行下面的命令将值导入到一个 xml 文件中:
gconftool-2 --dump /the/settings/branch/you/need > ~/live/your-new-settings.xml
sudo chown root:root ~/live/your-new-settings.xml # 修改生成的文件为 root 用户权限文件
sudo mv ~/live/your-new-settings.xml ~/live/edit/your-new-settings.xml # 复制该文件到你要执行的目录下。
此时再以 chroot 进入到该环境,再执行
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --load /your-new-settings.xml
rm /your-new-settings.xml # 删除该文件,以节省空间。
这种做法在目前的修改中是最常用的。一般你可以根据自己的个人习惯,或者是兴趣爱好,先将自己的系统设置好,然后再将自己的 gconf 值导出去,到了 live CD 系统中,再执行这样的操作安装进去即可。
为安装的开始设置默认的语言
这个操作跟刚才的 chroot 操作不一样,这个操作是要对一个 gfxboot 的工具包进行实质性的修改和编译操作。具体的操作如下:
sudo –s # 切换用户到 root 用户下
aptitude install dpkg-dev # 网络安装 dpkg-dev 包。这个包是编译时必须的。
apt-get source gfxboot-theme-ubuntu gfxboot # 获取 gfxboot 的源码。
cd gfxboot-theme-ubuntu*/ # 进入到 gfxboot 的目录
make DEFAULT_LANG=fi # 根据指定的语言进行编译
sudo cp -af boot/* ../extract-cd/isolinux/ # 复制编译好的文件到指定的目录下去。
Exit # 退出操作。
在这里 DEFAULT_LANG=fi 指的是设置一个默认的语言。如果是要设置简体中文,则将 fi 改成 zh_CN 即可!但是这个设置不改变 F2 中的语言列表清单。
另外一种做法,就是不去重编译 gfxboot ,直接在 isolinux 目录下创建一个名为 lang 的文件,在里面写上你要指定的默认语言名称即可。例如要制定简体中文,则在里面写上 zh_CN 即可。
自定义限制:
为了保障安装能够顺利的启动,你必须在自定义修改完成后,确认没有任何用户使用 UID >=999 。否则将无法完成安装初始化和启动。具体的做法是:
grep '^[^:]*:[^:]*:[1-9][0-9][0-9][0-9]:' /etc/passwd
grep '^[^:]*:[^:]*:[12][0-9][0-9][0-9][0-9]:' /etc/passwd
查询是否有任何值在这个范围内。如果有任何输出,请执行usermod -u 500 $hit
命令来修改。
其他定制:
你可能希望编辑文件 /etc/default 来改变系统启动时的动作。你可能也想编辑 /etc/profile 文件, /etc/bash.bashrc, 和 /etc/bash_completion 来改变系统中的所有用户的登录设置。有不可能直接编辑默认的 Live CD 用户(例如 casper , ubuntu , 或 user )。但你可以直接编辑 root 用户的默认文件( /root 是在 chroot 环境下。)
如果你想改变 Live CD 的默认时钟设置,你可以运行下面的命令:
dpkg-reconfigure tzdata
如果你添加了一个本地化的设置,并且你想将其设置成默认设置,你可以修改 /etc/default/locale 文件。命令是:
locale-gen new_locale
update-locale LANG=new_locale LANGUAGE=new_locale LC_ALL=new_locale
这个设置必须要以 root 用户的身份在 chroot 的环境下进行。
高级自定义设置
定制 Live CD 的内核
你可以根据自己的需要来升级 Live CD 默认的启动内核,也可以利用一个自己定制过的内核来改变 Live CD 的启动。具体的做法是复制你想去替换的 vmlinuz 和 initrd 到 extract-cd/casper 目录下,覆盖同名文件即可。当然 vmlinuz 和 initrd 文件的命名规则一定要遵守这个规则。当然,如果你的 vmlinuz 和 initrd 的名称不是这个,可以改变名称,但是要保证 extract-cd/casper 目录下的名称一定是这两个。例如:
sudo cp edit/boot/vmlinuz-2.6.15-26-k7 extract-cd/casper/vmlinuz
sudo cp edit/boot/initrd.img-2.6.15-26-k7 extract-cd/casper/initrd.gz
改变初始化脚本
你可以编辑文件 edit/usr/share/initramfs-tools/scripts/casper-bottom/* 来修改初始化启动脚本。例如修改主机名称等。例如:
sudo nano edit/usr/share/initramfs-tools/scripts/casper
来编辑用户名和主机名。
sudo nano edit/usr/share/initramfs-tools/scripts/casper-bottom/10adduser
来修改 LiveCD 用户的密码。
重编译 initrd
当你修改完内核,编辑过初始化脚本,并且添加了新的内核模块后,你需要重新编译一下 initrd.gz 文件来代替 casper 目录下的同名文件。以保证能够顺利的正常的启动。具体做法是:
sudo chroot edit
mkinitramfs -o /initrd.gz 2.6.15-26-k7
(记得使用你当前要修改的内核版本来代替这里跟的内核版本。)
当你重编译完成后,记得退出 chroot 环境,并将编译出来的文件放置到 extract-cd/casper/ 目录下。
exit
mv edit/initrd.gz extract-cd/casper/
清楚 Live CD 环境中的垃圾文件
因为 CD 空间有限,一定要在最后,记得删除那些不再用的临时文件以便节省空间。一个典型的例子就是在最后,清楚那些下载下来的包文件。具体的做法是 aptitude clean 。或者删除临时文件 rm -rf /tmp/* ~/.bash_history 。再或者是删除 nameserver 文件。做法是 rm /etc/resolv.conf
在完成清理工作后,记得卸载刚才加入的挂载,并推出 chroot 环境。做法是:
umount /proc
umount /sys
exit
sudo umount edit/dev
注意: 在卸载 /proc 目录时,如果无法卸载,可以使用 umount -lf /proc 命令来强行卸载。
生成最终的 ISO 镜像文件
1. 重新生成要安装的文件列表。具体的做法是:
chmod +w extract-cd/casper/filesystem.manifest
sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}/n' > extract-cd/casper/filesystem.manifest
sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/casper/d' extract-cd/casper/filesystem.manifest-desktop
2. 接下来重新制作 squashfs 文件:
sudo rm extract-cd/casper/filesystem.squashfs
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs -nolzma
注意: -nolzma 操作仅限于 9.04 版本。
3. 在 extract-cd/README.diskdefines 文件中 设置一个镜像文件名。具体做法是:
sudo vim extract-cd/README.diskdefines
4. 生成新的 MD5 校验码到 md5sum.txt 文件中:
sudo -s
rm extract-cd/md5sum.txt
(cd extract-cd && find . -type f -print0 | xargs -0 md5sum > md5sum.draft)
cat extract-cd/md5sum.draft | grep -v md5sum.draft | grep -v isolinux/boot.cat > extract-cd/md5sum.txt
rm extract-cd/md5sum.draft
exit
5. 创建最终的 ISO 文件,做法是:
cd extract-cd
sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-9.04.1-desktop-i386-custom.iso .
测试光盘镜像
如果你的机器不支持 VT 虚拟化技术,你可以使用 qemu 虚拟机来测试
qemu -cdrom ubuntu-9.04.1-desktop-i386-custom.iso -boot d -m 512
如果你的机器支持 VT 虚拟化技术,你可以使用
kvm -cdrom ubuntu-9.04-desktop-i386-custom.iso -boot d -m 512
来测试。当然你也可以使用 virtualbox-ose 来测试一下。这个工具是免费的,而且 Ubuntu 系统中就自带了。
制作光盘
制作光盘很简单,具体的命令是:
cdrecord dev=/dev/cdrom ubuntu-9.04-desktop-i386-custom.iso
总结:
总体来说,自定义 Ubuntu 的 Live CD 光盘,实际很简单,具体的制作有如下几个步骤:
<!-- [if !supportLists]-->1. <!-- [endif]-->寻找好自己要定制的母版;
<!-- [if !supportLists]-->2. <!-- [endif]-->展开 ISO 光盘;
<!-- [if !supportLists]-->3. <!-- [endif]-->根据自己的需求修改 squashfs 文件;
<!-- [if !supportLists]-->4. <!-- [endif]-->清理垃圾文件;
<!-- [if !supportLists]-->5. <!-- [endif]-->整合生成光盘镜像;
<!-- [if !supportLists]-->6. <!-- [endif]-->测试新的光盘镜像;
<!-- [if !supportLists]-->7. <!-- [endif]-->刻录新光盘。
参考文献:
https://help.ubuntu.com/community/LiveCDCustomization
相关推荐
ubuntu livecd自动安装,ubuntu光盘自动安装的isolinux.cfg文件
Ubuntu是从光盘引导进入Live版,如果安装则需要开启安装向导从光盘安装。这么做的主要目的是让用户体验完Ubuntu的魅力之后,自愿来安装。但是,一些开始就决定安装的用户就会觉得有一些不便。文庄就是从这个角度考虑...
使用Ubuntu LiveCD安装grub 因为安装windows,或者不小心删除/改变了mbr,都有可能导致启动时看不到grub的引导菜单或者提示出错,下面是恢复的办法 (写于Ubuntu下,但应该可适用于其它系统)
本文介绍了如何自定义ubuntu更新源,并且给出了一些源的地址,需要的下了
ubuntu引导修复——使用LiveCD更新UbuntuGrub引导 。
通过liveCD进行ubuntu启动修复.doc
详细描述了如何使用UltraISO制作u盘启动的ubuntu步骤
How To 用 ubuntu Desktop LiveCD测试新电脑
tux2live可将常用LINUX定制成LIVECD版,比如UBUNTU等
这是一个轻量级的 Ubuntu 发行版.. 由你决定你需要什么,只需 apt 获取你的软件包。 安装程序没有安装,只是创建一个 tar ball 或 unsquashfs 到新驱动器并调整 initrd(删除 casper 和 live-tools 等); 一旦启动...
ubuntu自定义登录session和桌面环境
thinclient:用于构建自定义Ubuntu映像的工具,该映像可通过网络引导并完全在RAM中工作
ubuntu-20.04.3-live-server-amd64的光盘镜像文件,是ubuntu官方的原版ISO镜像
Ubuntu下自定义和使用库 博客,http://blog.csdn.net/shunqiziranhao007/article/details/8298175
有种非常有趣的Linux版本被叫做 “Live CD”。...有用于Linux桌面系统版本的Live CD(比如Ubuntu),有用于模拟游戏、并行计算以及集群和网格、科学/数学计算、生物信息学的……当然,也有用于系统安全测试与审核的。
ubuntu-22.04-live-server-arm64.iso https://releases.ubuntu.com/jammy/
ubuntu-22.04-live-server-riscv64.img.gz http://cdimages.ubuntu.com/ubuntu/releases/22.04/release/