个人工具

“UbuntuHelp:LiveCDCustomization”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/LiveCDCustomization}}
 
{{From|https://help.ubuntu.com/community/LiveCDCustomization}}
 
{{Languages|UbuntuHelp:LiveCDCustomization}}
 
{{Languages|UbuntuHelp:LiveCDCustomization}}
 
 
 
 
== How to customize the Ubuntu Desktop CD ==
 
== How to customize the Ubuntu Desktop CD ==
 
 
You may wish to customize the Ubuntu desktop (live) CD, possibly to show off a particular application, or localize to a certain language. Here's how.
 
You may wish to customize the Ubuntu desktop (live) CD, possibly to show off a particular application, or localize to a certain language. Here's how.
 
 
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=warning.png This guide is for the Desktop/Live CD; there is another page referrring to [[UbuntuHelp:InstallCDCustomization| customization of the Alternative Install or Server Install CD]].
 
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=warning.png This guide is for the Desktop/Live CD; there is another page referrring to [[UbuntuHelp:InstallCDCustomization| customization of the Alternative Install or Server Install CD]].
 
 
== System Requirements ==
 
== System Requirements ==
 
 
* About 3-5 gigabytes of free space
 
* About 3-5 gigabytes of free space
 
* Recommended at least 512 MB RAM and 1 GB swap
 
* Recommended at least 512 MB RAM and 1 GB swap
第18行: 第11行:
 
* An Ubuntu kernel with `squashfs` support (the stock kernel in DapperDrake has it)
 
* An Ubuntu kernel with `squashfs` support (the stock kernel in DapperDrake has it)
 
* QEMU, VirtualBox or VMware for testing
 
* QEMU, VirtualBox or VMware for testing
 
 
== The Process ==
 
== The Process ==
 
 
First, make sure that you have installed the needed tools:
 
First, make sure that you have installed the needed tools:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install squashfs-tools mkisofs qemu
 
sudo apt-get install squashfs-tools mkisofs qemu
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Load the squashfs module
 
Load the squashfs module
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo modprobe squashfs
 
sudo modprobe squashfs
 
</nowiki></pre>
 
</nowiki></pre>
 
 
You need to download an official Desktop CD from http://releases.ubuntu.com/.
 
You need to download an official Desktop CD from http://releases.ubuntu.com/.
 
 
Move or copy it into an empty directory:
 
Move or copy it into an empty directory:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
mkdir ~/live
 
mkdir ~/live
第41行: 第27行:
 
cd ~/live
 
cd ~/live
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Extracting the CD contents ===
 
=== Extracting the CD contents ===
 
 
Mount the Desktop .iso
 
Mount the Desktop .iso
 
 
<pre><nowiki>
 
<pre><nowiki>
 
mkdir mnt
 
mkdir mnt
 
sudo mount -o loop ubuntu-6.06.1-desktop-i386.iso mnt
 
sudo mount -o loop ubuntu-6.06.1-desktop-i386.iso mnt
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Extract .iso contents into dir 'extract-cd'
 
Extract .iso contents into dir 'extract-cd'
 
 
<pre><nowiki>
 
<pre><nowiki>
 
mkdir extract-cd
 
mkdir extract-cd
 
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
 
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Extracting the Desktop system ===
 
=== Extracting the Desktop system ===
 
 
Mount the squashfs filesystem
 
Mount the squashfs filesystem
 
 
<pre><nowiki>
 
<pre><nowiki>
 
mkdir squashfs
 
mkdir squashfs
 
sudo mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs
 
sudo mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Extract squashfs contents into dir 'edit'
 
Extract squashfs contents into dir 'edit'
 
<pre><nowiki>
 
<pre><nowiki>
第72行: 第49行:
 
sudo cp -a squashfs/* edit/
 
sudo cp -a squashfs/* edit/
 
</nowiki></pre>
 
</nowiki></pre>
 
 
'''Warning: Do not use `unsquashfs` command from Ubuntu 6.10 (Edgy)''', because it doesn't honour set-id bits (https://launchpad.net/bugs/89417). The version in Ubuntu 7.04 (Feisty) is fine.
 
'''Warning: Do not use `unsquashfs` command from Ubuntu 6.10 (Edgy)''', because it doesn't honour set-id bits (https://launchpad.net/bugs/89417). The version in Ubuntu 7.04 (Feisty) is fine.
 
 
=== Prepare and chroot ===
 
=== Prepare and chroot ===
 
 
If you need the network connection within chroot:
 
If you need the network connection within chroot:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo cp /etc/resolv.conf edit/etc/
 
sudo cp /etc/resolv.conf edit/etc/
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Depending on your configuration, you ''may'' also need to copy the '''hosts''' file:
 
Depending on your configuration, you ''may'' also need to copy the '''hosts''' file:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo cp /etc/hosts edit/etc/
 
sudo cp /etc/hosts edit/etc/
 
</nowiki></pre>
 
</nowiki></pre>
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo chroot edit
 
sudo chroot edit
第93行: 第64行:
 
mount -t sysfs none /sys
 
mount -t sysfs none /sys
 
</nowiki></pre>
 
</nowiki></pre>
 
 
To avoid locale issues and in order to import GPG keys, set:
 
To avoid locale issues and in order to import GPG keys, set:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
export HOME=/root
 
export HOME=/root
 
export LC_ALL=C
 
export LC_ALL=C
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Customizations ===
 
=== Customizations ===
 
 
Few example customizations, and tips  
 
Few example customizations, and tips  
 
 
==== Apt-get ====
 
==== Apt-get ====
 
To view installed packages by size:
 
To view installed packages by size:
第114行: 第80行:
 
apt-get remove --purge package name
 
apt-get remove --purge package name
 
</nowiki></pre>
 
</nowiki></pre>
 
 
==== Custom Background for GNOME ====
 
==== Custom Background for GNOME ====
 
 
Generally background files are located in '''/usr/share/backgrounds'''. Copy your png file there and edit the files:
 
Generally background files are located in '''/usr/share/backgrounds'''. Copy your png file there and edit the files:
* '''/usr/share/gnome-background-properties/ubuntu-wallpapers.xml''' and
+
# '''/usr/share/gnome-background-properties/ubuntu-wallpapers.xml''' and
* '''/etc/gconf/gconf.xml.defaults/%gconf-tree.xml'''
+
2. '''/etc/gconf/gconf.xml.defaults/%gconf-tree.xml'''
 
by changing the string '''/usr/share/backgrounds/warty-final-ubuntu.png''' to point to your file. [http://ubuntuforums.org/showthread.php?t=462810&highlight=warty-final-ubuntu.png More...]
 
by changing the string '''/usr/share/backgrounds/warty-final-ubuntu.png''' to point to your file. [http://ubuntuforums.org/showthread.php?t=462810&highlight=warty-final-ubuntu.png More...]
 
 
==== Change gconf values (fonts, panels etc.) ====
 
==== Change gconf values (fonts, panels etc.) ====
 
 
To make any change on the gconf attributes you must add the value that you want in the file '''/etc/gconf/gconf.xml.defaults/%gconf-tree.xml'''. Adding a value in that file will change the default values of Gnome or other applications, so you can change fonts, backgrounds, themes, cursors etc.
 
To make any change on the gconf attributes you must add the value that you want in the file '''/etc/gconf/gconf.xml.defaults/%gconf-tree.xml'''. Adding a value in that file will change the default values of Gnome or other applications, so you can change fonts, backgrounds, themes, cursors etc.
 
 
Instead of editing the file with '''gedit''' or another text editor, you can use the '''gconftool-2''', under the chroot environment, running the following line:
 
Instead of editing the file with '''gedit''' or another text editor, you can use the '''gconftool-2''', under the chroot environment, running the following line:
 
<pre><nowiki>
 
<pre><nowiki>
 
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set yourkey "yourvalue"
 
gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set yourkey "yourvalue"
 
</nowiki></pre>
 
</nowiki></pre>
 
 
where ''string'', ''yourkey'' and ''yourvalue'' must be the type, key and value that you want to change...
 
where ''string'', ''yourkey'' and ''yourvalue'' must be the type, key and value that you want to change...
 
 
==== Change default language of gfxboot ====
 
==== Change default language of gfxboot ====
 
 
This customization must be done outside the chroot.
 
This customization must be done outside the chroot.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo -s
 
sudo -s
第146行: 第103行:
 
exit
 
exit
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Change "fi" to your preferred locale. Note that this does not change which languages are available in the F2 menu. For more info about gfxboot customization, see [http://uck.sourceforge.net/ Ubuntu Customization Kit].
 
Change "fi" to your preferred locale. Note that this does not change which languages are available in the F2 menu. For more info about gfxboot customization, see [http://uck.sourceforge.net/ Ubuntu Customization Kit].
 
 
* A other way to change the default language of gfxboot without rebuild the packages is to create a file name '''lang''' in the isolinux directory containing your locale's name.
 
* A other way to change the default language of gfxboot without rebuild the packages is to create a file name '''lang''' in the isolinux directory containing your locale's name.
 
 
==== Customization limits ====
 
==== Customization limits ====
 
 
After customization make sure that there are no users with an UID >= 1000. Otherwise your image won't boot because no initial user is available (see /usr/lib/user-setup/functions.sh and /usr/lib/user-setup/user-setup-apply). While in chroot:
 
After customization make sure that there are no users with an UID >= 1000. Otherwise your image won't boot because no initial user is available (see /usr/lib/user-setup/functions.sh and /usr/lib/user-setup/user-setup-apply). While in chroot:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
grep '<sup>[^:]*:[</sup>:]*:[1-9][0-9][0-9][0-9]:' /etc/passwd
 
grep '<sup>[^:]*:[</sup>:]*:[1-9][0-9][0-9][0-9]:' /etc/passwd
 
grep '<sup>[^:]*:[</sup>:]*:[12][0-9][0-9][0-9][0-9]:' /etc/passwd
 
grep '<sup>[^:]*:[</sup>:]*:[12][0-9][0-9][0-9][0-9]:' /etc/passwd
 
</nowiki></pre>
 
</nowiki></pre>
 
 
If you get any hits, try changing the uid:
 
If you get any hits, try changing the uid:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
usermod -u 500 $hit
 
usermod -u 500 $hit
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
=== Advanced Customizations ===
 
=== Advanced Customizations ===
 
 
==== Live CD Kernel ====
 
==== Live CD Kernel ====
 
If you want to customize further the boot process, you can change the livecd kernel, by copying the vmlinuz and initrd you want in place of the ones you find in extract-cd/casper (don't forget to apt-get the right kernel, the one that matches the livecd one, once chrooted into edit).
 
If you want to customize further the boot process, you can change the livecd kernel, by copying the vmlinuz and initrd you want in place of the ones you find in extract-cd/casper (don't forget to apt-get the right kernel, the one that matches the livecd one, once chrooted into edit).
 
 
i.e.
 
i.e.
 
<pre><nowiki>
 
<pre><nowiki>
第177行: 第123行:
 
sudo cp /boot/initrd.img-2.6.15-26-k7 extract-cd/casper/initrd.gz
 
sudo cp /boot/initrd.img-2.6.15-26-k7 extract-cd/casper/initrd.gz
 
</nowiki></pre>
 
</nowiki></pre>
 
 
==== Boot init ====
 
==== Boot init ====
 
 
You have to edit the files in edit/usr/share/initramfs-tools/scripts/casper-bottom/*
 
You have to edit the files in edit/usr/share/initramfs-tools/scripts/casper-bottom/*
 
For example you can change the hostname or the livecd user.
 
For example you can change the hostname or the livecd user.
 
 
i.e.
 
i.e.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo nano edit/usr/share/initramfs-tools/scripts/casper
 
sudo nano edit/usr/share/initramfs-tools/scripts/casper
 
</nowiki></pre>
 
</nowiki></pre>
 
 
and edit the username or hostname
 
and edit the username or hostname
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo nano edit/usr/share/initramfs-tools/scripts/casper-bottom/10adduser
 
sudo nano edit/usr/share/initramfs-tools/scripts/casper-bottom/10adduser
 
</nowiki></pre>
 
</nowiki></pre>
 
 
to edit even the livecd user's password.
 
to edit even the livecd user's password.
 
 
P.S. in order to obtain an encrypted password, you have to use the mkpasswd program that's shipped with whois package!
 
P.S. in order to obtain an encrypted password, you have to use the mkpasswd program that's shipped with whois package!
 
 
==== Rebuilding initrd ====
 
==== Rebuilding initrd ====
 
 
After you've modified the kernel, init scripts or added new kernel modules, you need to rebuild the initrd.gz file and substitute it into the casper directory.
 
After you've modified the kernel, init scripts or added new kernel modules, you need to rebuild the initrd.gz file and substitute it into the casper directory.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo chroot edit
 
sudo chroot edit
第208行: 第143行:
 
</nowiki></pre>
 
</nowiki></pre>
 
(replace the kernel version with the one that the CD will boot with - this can be found in edit/lib/modules)
 
(replace the kernel version with the one that the CD will boot with - this can be found in edit/lib/modules)
 
 
Exit from the chroot jail and move this file to extract-cd/casper:
 
Exit from the chroot jail and move this file to extract-cd/casper:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
exit
 
exit
 
mv edit/initrd.gz extract-cd/casper/
 
mv edit/initrd.gz extract-cd/casper/
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Cleanup ===
 
=== Cleanup ===
 
 
Be sure to remove any temporary files which are no longer needed, as space on a CD is limited. A classic example is downloaded package files, which can be cleaned out using:
 
Be sure to remove any temporary files which are no longer needed, as space on a CD is limited. A classic example is downloaded package files, which can be cleaned out using:
 
<pre><nowiki>
 
<pre><nowiki>
第230行: 第161行:
 
rm /etc/resolv.conf
 
rm /etc/resolv.conf
 
</nowiki></pre>
 
</nowiki></pre>
 
 
now umount (unmount) special filesystems and exit chroot
 
now umount (unmount) special filesystems and exit chroot
 
 
<pre><nowiki>
 
<pre><nowiki>
 
umount /proc
 
umount /proc
第238行: 第167行:
 
exit
 
exit
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Putting the CD together ===
 
=== Putting the CD together ===
 
 
Regenarate manifest
 
Regenarate manifest
 
<pre><nowiki>
 
<pre><nowiki>
第248行: 第175行:
 
sudo sed -ie '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
 
sudo sed -ie '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Compress filesystem
 
Compress filesystem
 
<pre><nowiki>
 
<pre><nowiki>
第254行: 第180行:
 
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs
 
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Set an image name in extract-cd/README.diskdefines
 
Set an image name in extract-cd/README.diskdefines
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo vim extract-cd/README.diskdefines
 
sudo vim extract-cd/README.diskdefines
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Remove old md5sum.txt and calculate new md5 sums
 
Remove old md5sum.txt and calculate new md5 sums
 
<pre><nowiki>
 
<pre><nowiki>
第267行: 第191行:
 
exit
 
exit
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Create Iso
 
Create Iso
 
<pre><nowiki>
 
<pre><nowiki>
第273行: 第196行:
 
sudo mkisofs -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-6.06.1-desktop-i386-custom.iso .
 
sudo mkisofs -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-6.06.1-desktop-i386-custom.iso .
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Testing the CD ===
 
=== Testing the CD ===
 
 
Test using qemu emulator
 
Test using qemu emulator
 
 
<pre><nowiki>
 
<pre><nowiki>
 
qemu -cdrom ubuntu-6.06.1-desktop-i386-custom.iso -boot d
 
qemu -cdrom ubuntu-6.06.1-desktop-i386-custom.iso -boot d
 
</nowiki></pre>
 
</nowiki></pre>
 
 
You can also test with vmplayer (which is free for Linux) which is a little faster than qemu, albeit not free and open source software.
 
You can also test with vmplayer (which is free for Linux) which is a little faster than qemu, albeit not free and open source software.
 
 
=== Burning the image to CD ===
 
=== Burning the image to CD ===
 
 
Simple! Just do:
 
Simple! Just do:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
cdrecord dev=/dev/cdrom ubuntu-6.06.1-desktop-i386-custom.iso
 
cdrecord dev=/dev/cdrom ubuntu-6.06.1-desktop-i386-custom.iso
 
</nowiki></pre>
 
</nowiki></pre>
 
 
== Comments ==
 
== Comments ==
 
 
If you have any comments or questions, please feel free to add them here.
 
If you have any comments or questions, please feel free to add them here.
 
 
I have created an small Customization Example (named Firebird Live CD) by adding an firebird-super-server and flamerobin packages (this apply to ubuntu dapper drake)
 
I have created an small Customization Example (named Firebird Live CD) by adding an firebird-super-server and flamerobin packages (this apply to ubuntu dapper drake)
 
http://flamerobin.blogspot.com/2006/05/creating-flamerobinfirebird-live-cd.html
 
http://flamerobin.blogspot.com/2006/05/creating-flamerobinfirebird-live-cd.html
 
I created an updated guide with Ubuntu Festy Fawn also with an iso download for the Firebird/Flamerobin live cd  
 
I created an updated guide with Ubuntu Festy Fawn also with an iso download for the Firebird/Flamerobin live cd  
 
http://flamerobin.blogspot.com/2007/09/creating-flamerobinfirebird-livecd-with.html
 
http://flamerobin.blogspot.com/2007/09/creating-flamerobinfirebird-livecd-with.html
 
 
----
 
----
 
 
I have created tool for automatic remastering of live CD images. See http://uck.sourceforge.net/ .
 
I have created tool for automatic remastering of live CD images. See http://uck.sourceforge.net/ .
 
 
Features:
 
Features:
** GUI for simple creation of localized CDs (including changing gfxboot and installing language packs)
+
* GUI for simple creation of localized CDs (including changing gfxboot and installing language packs)
** Script for customization of ISO, SquashFS and initrd on live CD.
+
* Script for customization of ISO, SquashFS and initrd on live CD.
 
+
 
----
 
----
 
http://www.atworkonline.it/~bibe/ubuntu/custom-livecd.htm seems to have some nice info. no license that I can see so we would need to ask permission from the author to us its material.
 
http://www.atworkonline.it/~bibe/ubuntu/custom-livecd.htm seems to have some nice info. no license that I can see so we would need to ask permission from the author to us its material.
 
 
----
 
----
 
 
If you want to make the CD boot faster, you might try sorting the files so that they are in the CD in the order that they are accessed: http://lichota.net/%7Ekrzysiek/projects/kubuntu/dapper-livecd-optimization/
 
If you want to make the CD boot faster, you might try sorting the files so that they are in the CD in the order that they are accessed: http://lichota.net/%7Ekrzysiek/projects/kubuntu/dapper-livecd-optimization/
 
 
----
 
----
 
 
Great How To.  I am having one issue however.  I would like to use custom xorg.conf and sources.list files.  Any tips on doing this?  Thanks.
 
Great How To.  I am having one issue however.  I would like to use custom xorg.conf and sources.list files.  Any tips on doing this?  Thanks.
 
* Simply, copy the files to edit/etc/ in the same way (and at the same time) that you copy in the resolv.conf and hosts files.
 
* Simply, copy the files to edit/etc/ in the same way (and at the same time) that you copy in the resolv.conf and hosts files.
 
* I have found that copying xorg.conf doesn't work, as the boot-time scripts overwrite it. Besides, you can't guarantee that a particular xorg.conf will run on all hosts. I'm currently trying to get the binary NVIDIA drivers to work out of the box if an NVIDIA card is present. If I figure out how to fix the xorg.conf, I'll post it here. --JeremyVisser
 
* I have found that copying xorg.conf doesn't work, as the boot-time scripts overwrite it. Besides, you can't guarantee that a particular xorg.conf will run on all hosts. I'm currently trying to get the binary NVIDIA drivers to work out of the box if an NVIDIA card is present. If I figure out how to fix the xorg.conf, I'll post it here. --JeremyVisser
 
 
----
 
----
 
 
I've managed to get Synaptic running from within the chroot environment, but it does hang when I try to apply packages.
 
I've managed to get Synaptic running from within the chroot environment, but it does hang when I try to apply packages.
 
What you do is run "Xnest -ac :1" to get an Xnest server to run on display :1 without access control so anyone can connect to it. Then, in the chroot environment, run "export DISPLAY=:1" to get programs to use the display. Then, type "metacity &" to be able to move windows. Finally, run "synaptic".
 
What you do is run "Xnest -ac :1" to get an Xnest server to run on display :1 without access control so anyone can connect to it. Then, in the chroot environment, run "export DISPLAY=:1" to get programs to use the display. Then, type "metacity &" to be able to move windows. Finally, run "synaptic".
 
 
It works fine until you try to apply packages, where it hangs for me. --JeremyVisser
 
It works fine until you try to apply packages, where it hangs for me. --JeremyVisser
 
 
----
 
----
 
 
Shouldn't the mkinitramfs command use the casper scripts, like "mkinitramfs -o initrd.gz 2.6.15-23-386 -d /usr/share/initramfs-tools"?
 
Shouldn't the mkinitramfs command use the casper scripts, like "mkinitramfs -o initrd.gz 2.6.15-23-386 -d /usr/share/initramfs-tools"?
 
 
----
 
----
 
 
There are tricks on how you can get to feel the GNOME system in your chroot environment.
 
There are tricks on how you can get to feel the GNOME system in your chroot environment.
 
 
1. Copy your xorg.conf in the chrooted "etc/X11/" directory.
 
1. Copy your xorg.conf in the chrooted "etc/X11/" directory.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
cp /etc/X11/xorg.conf edit/etc/X11/
 
cp /etc/X11/xorg.conf edit/etc/X11/
 
</nowiki></pre>
 
</nowiki></pre>
 
 
2. Create generic devices on your chroot system using MAKEDEV
 
2. Create generic devices on your chroot system using MAKEDEV
 
 
<pre><nowiki>
 
<pre><nowiki>
 
cd /dev/
 
cd /dev/
 
MAKEDEV generic
 
MAKEDEV generic
 
</nowiki></pre>
 
</nowiki></pre>
 
 
3. Start X or restart gdm
 
3. Start X or restart gdm
 
 
<pre><nowiki>
 
<pre><nowiki>
 
/etc/init.d/gdm start
 
/etc/init.d/gdm start
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Supposed you want to make modifications on the Desktop, that will be used by all the new users,
 
Supposed you want to make modifications on the Desktop, that will be used by all the new users,
 
just change your $HOME to /etc/skel/ and start gdm or X.
 
just change your $HOME to /etc/skel/ and start gdm or X.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
export HOME=/etc/skel/
 
export HOME=/etc/skel/
 
</nowiki></pre>
 
</nowiki></pre>
 
 
If you want to load all the other stuff GNOME needs (i.e, dbus, avahi, network-manager),
 
If you want to load all the other stuff GNOME needs (i.e, dbus, avahi, network-manager),
 
just boot as (single-user mode), and start dbus in your chrooted environment.
 
just boot as (single-user mode), and start dbus in your chrooted environment.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
/etc/init.d/dbus start
 
/etc/init.d/dbus start
 
</nowiki></pre>
 
</nowiki></pre>
 
 
An example of the whole procedure. (under single-user mode)
 
An example of the whole procedure. (under single-user mode)
 
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo /etc/init.d/networking restart
 
sudo /etc/init.d/networking restart
第385行: 第271行:
 
/etc/init.d/gdm start
 
/etc/init.d/gdm start
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
--- [[UbuntuHelp:joelbryan]]
 
--- [[UbuntuHelp:joelbryan]]
 
 
----
 
----
 
 
Hello,
 
Hello,
 
 
I am about to build a new Livecd and have a question:
 
I am about to build a new Livecd and have a question:
 
When I change the username, hostname and the user's password the user login automatically during booting the livesystem. But this is not desired. Is it correct, that I have to enter a password under a Desktop LiveCD when I delet the encrypted password in /usr/share/initramfs-tools/scripts/casper-bottom/10adduser ?
 
When I change the username, hostname and the user's password the user login automatically during booting the livesystem. But this is not desired. Is it correct, that I have to enter a password under a Desktop LiveCD when I delet the encrypted password in /usr/share/initramfs-tools/scripts/casper-bottom/10adduser ?
 
 
Thanks
 
Thanks
 
 
Changing username and password will not change login behaviour, because this is done in /usr/share/initramfs-tools/scripts/casper-bottom/15autologin
 
Changing username and password will not change login behaviour, because this is done in /usr/share/initramfs-tools/scripts/casper-bottom/15autologin
 
 
--- [[UbuntuHelp:Alexander Hosfeld]]
 
--- [[UbuntuHelp:Alexander Hosfeld]]
 
 
----
 
----
 
 
Having trouble starting a MySQL server from within the chroot jail. Any suggestions?
 
Having trouble starting a MySQL server from within the chroot jail. Any suggestions?
 
 
- Dave
 
- Dave
 
 
 
Hey,
 
Hey,
 
 
I am trying to make a customized live cd of Kubuntu 6.06 that will be completly preconfigured, so that when the user clicks on the install icon on KDE the installer should do everything by itself, meaning that the installer should not ask any questions to the user.
 
I am trying to make a customized live cd of Kubuntu 6.06 that will be completly preconfigured, so that when the user clicks on the install icon on KDE the installer should do everything by itself, meaning that the installer should not ask any questions to the user.
 
 
To do this I am trying to write a preseed file to tell the installer the information that it needs.
 
To do this I am trying to write a preseed file to tell the installer the information that it needs.
 
 
The problem is that even with this preseed file I could only tell the installer what is the username that it should use, the rest of the information is simply ignored by the installer.
 
The problem is that even with this preseed file I could only tell the installer what is the username that it should use, the rest of the information is simply ignored by the installer.
 
 
I must be doing something wrong and would appreciate any and all help given me.
 
I must be doing something wrong and would appreciate any and all help given me.
 
 
Thanks,
 
Thanks,
 
Komyg
 
Komyg
 
 
PS: Should I post my preseed file here?
 
PS: Should I post my preseed file here?
 
 
----
 
----
 
If the livecd is not going to be used for the purposes of installing what files can be removed? Can the "pool" files containing the .debs be removed too?
 
If the livecd is not going to be used for the purposes of installing what files can be removed? Can the "pool" files containing the .debs be removed too?
 
 
- Mike
 
- Mike
 
 
 
----
 
----
 
If I want to put in my LiveCD applications that aren't in the sources.list (like ooffice 2.2 or perl audio converter), what cain I do?
 
If I want to put in my LiveCD applications that aren't in the sources.list (like ooffice 2.2 or perl audio converter), what cain I do?
 
 
 
- Isoldanne
 
- Isoldanne
 
 
----
 
----
 
 
To get desired <code><nowiki>/etc/X11/xorg.conf</nowiki></code> one can modify the <code><nowiki>/usr/bin/dexconf</nowiki></code>.
 
To get desired <code><nowiki>/etc/X11/xorg.conf</nowiki></code> one can modify the <code><nowiki>/usr/bin/dexconf</nowiki></code>.
 
This script generates xorg.conf automatically in liveCD session
 
This script generates xorg.conf automatically in liveCD session
 
according to the booted machine.
 
according to the booted machine.
 
 
For example:
 
For example:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# diff ~/bin/dexconf /usr/bin/dexconf  
 
# diff ~/bin/dexconf /usr/bin/dexconf  
第452行: 第309行:
 
> Option "XkbLayout" "$XKB_LAYOUT"
 
> Option "XkbLayout" "$XKB_LAYOUT"
 
</nowiki></pre>
 
</nowiki></pre>
 
 
-- yotam
 
-- yotam
 
----
 
----
 
 
 
I cant do chroot. When i run it a get this error  
 
I cant do chroot. When i run it a get this error  
 
 
chroot: cannot run command `/bin/bash': No such file or directory
 
chroot: cannot run command `/bin/bash': No such file or directory
 
 
Please help me out
 
Please help me out
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2007年11月30日 (五) 20:05的版本


How to customize the Ubuntu Desktop CD

You may wish to customize the Ubuntu desktop (live) CD, possibly to show off a particular application, or localize to a certain language. Here's how. IconsPage?action=AttachFile&do=get&target=warning.png This guide is for the Desktop/Live CD; there is another page referrring to customization of the Alternative Install or Server Install CD.

System Requirements

  • About 3-5 gigabytes of free space
  • Recommended at least 512 MB RAM and 1 GB swap
  • `squashfs-tools`
  • `mkisofs`
  • An Ubuntu kernel with `squashfs` support (the stock kernel in DapperDrake has it)
  • QEMU, VirtualBox or VMware for testing

The Process

First, make sure that you have installed the needed tools:

sudo apt-get install squashfs-tools mkisofs qemu

Load the squashfs module

sudo modprobe squashfs

You need to download an official Desktop CD from http://releases.ubuntu.com/. Move or copy it into an empty directory:

mkdir ~/live
mv ubuntu-6.06.1-desktop-i386.iso ~/live
cd ~/live

Extracting the CD contents

Mount the Desktop .iso

mkdir mnt
sudo mount -o loop ubuntu-6.06.1-desktop-i386.iso mnt

Extract .iso contents into dir 'extract-cd'

mkdir extract-cd
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd

Extracting the Desktop system

Mount the squashfs filesystem

mkdir squashfs
sudo mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs

Extract squashfs contents into dir 'edit'

mkdir edit
sudo cp -a squashfs/* edit/

Warning: Do not use `unsquashfs` command from Ubuntu 6.10 (Edgy), because it doesn't honour set-id bits (https://launchpad.net/bugs/89417). The version in Ubuntu 7.04 (Feisty) is fine.

Prepare and chroot

If you need the network connection within chroot:

sudo cp /etc/resolv.conf edit/etc/

Depending on your configuration, you may also need to copy the hosts file:

sudo cp /etc/hosts edit/etc/
sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys

To avoid locale issues and in order to import GPG keys, set:

export HOME=/root
export LC_ALL=C

Customizations

Few example customizations, and tips

Apt-get

To view installed packages by size:

dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | less

When you want to remove packages remember to use purge

apt-get remove --purge package name

Custom Background for GNOME

Generally background files are located in /usr/share/backgrounds. Copy your png file there and edit the files:

  1. /usr/share/gnome-background-properties/ubuntu-wallpapers.xml and

2. /etc/gconf/gconf.xml.defaults/%gconf-tree.xml by changing the string /usr/share/backgrounds/warty-final-ubuntu.png to point to your file. More...

Change gconf values (fonts, panels etc.)

To make any change on the gconf attributes you must add the value that you want in the file /etc/gconf/gconf.xml.defaults/%gconf-tree.xml. Adding a value in that file will change the default values of Gnome or other applications, so you can change fonts, backgrounds, themes, cursors etc. Instead of editing the file with gedit or another text editor, you can use the gconftool-2, under the chroot environment, running the following line:

gconftool-2 --direct --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults --type string --set yourkey "yourvalue"

where string, yourkey and yourvalue must be the type, key and value that you want to change...

Change default language of gfxboot

This customization must be done outside the chroot.

sudo -s
apt-get install dpkg-dev
apt-get source gfxboot-theme-ubuntu gfxboot
cd gfxboot-theme-ubuntu*/
make DEFAULT_LANG=fi
sudo cp -af boot/* ../extract-cd/isolinux/
exit

Change "fi" to your preferred locale. Note that this does not change which languages are available in the F2 menu. For more info about gfxboot customization, see Ubuntu Customization Kit.

  • A other way to change the default language of gfxboot without rebuild the packages is to create a file name lang in the isolinux directory containing your locale's name.

Customization limits

After customization make sure that there are no users with an UID >= 1000. Otherwise your image won't boot because no initial user is available (see /usr/lib/user-setup/functions.sh and /usr/lib/user-setup/user-setup-apply). While in chroot:

grep '<sup>[^:]*:[</sup>:]*:[1-9][0-9][0-9][0-9]:' /etc/passwd
grep '<sup>[^:]*:[</sup>:]*:[12][0-9][0-9][0-9][0-9]:' /etc/passwd

If you get any hits, try changing the uid:

usermod -u 500 $hit

Advanced Customizations

Live CD Kernel

If you want to customize further the boot process, you can change the livecd kernel, by copying the vmlinuz and initrd you want in place of the ones you find in extract-cd/casper (don't forget to apt-get the right kernel, the one that matches the livecd one, once chrooted into edit). i.e.

sudo cp /boot/vmlinuz-2.6.15-26-k7 extract-cd/casper/vmlinuz
sudo cp /boot/initrd.img-2.6.15-26-k7 extract-cd/casper/initrd.gz

Boot init

You have to edit the files in edit/usr/share/initramfs-tools/scripts/casper-bottom/* For example you can change the hostname or the livecd user. i.e.

sudo nano edit/usr/share/initramfs-tools/scripts/casper

and edit the username or hostname

sudo nano edit/usr/share/initramfs-tools/scripts/casper-bottom/10adduser

to edit even the livecd user's password. P.S. in order to obtain an encrypted password, you have to use the mkpasswd program that's shipped with whois package!

Rebuilding initrd

After you've modified the kernel, init scripts or added new kernel modules, you need to rebuild the initrd.gz file and substitute it into the casper directory.

sudo chroot edit
mkinitramfs -o /initrd.gz 2.6.15-26-k7

(replace the kernel version with the one that the CD will boot with - this can be found in edit/lib/modules) Exit from the chroot jail and move this file to extract-cd/casper:

exit
mv edit/initrd.gz extract-cd/casper/

Cleanup

Be sure to remove any temporary files which are no longer needed, as space on a CD is limited. A classic example is downloaded package files, which can be cleaned out using:

apt-get clean

Or delete temporary files

rm -rf /tmp/*

Or nameserver settings

rm /etc/resolv.conf

now umount (unmount) special filesystems and exit chroot

umount /proc
umount /sys
exit

Putting the CD together

Regenarate manifest

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 -ie '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop

Compress filesystem

sudo rm extract-cd/casper/filesystem.squashfs
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs

Set an image name in extract-cd/README.diskdefines

sudo vim extract-cd/README.diskdefines

Remove old md5sum.txt and calculate new md5 sums

sudo -s
rm extract-cd/md5sum.txt
(cd extract-cd && find . -type f -print0 | xargs -0 md5sum > md5sum.txt)
exit

Create Iso

cd extract-cd
sudo mkisofs -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-6.06.1-desktop-i386-custom.iso .

Testing the CD

Test using qemu emulator

qemu -cdrom ubuntu-6.06.1-desktop-i386-custom.iso -boot d

You can also test with vmplayer (which is free for Linux) which is a little faster than qemu, albeit not free and open source software.

Burning the image to CD

Simple! Just do:

cdrecord dev=/dev/cdrom ubuntu-6.06.1-desktop-i386-custom.iso

Comments

If you have any comments or questions, please feel free to add them here. I have created an small Customization Example (named Firebird Live CD) by adding an firebird-super-server and flamerobin packages (this apply to ubuntu dapper drake) http://flamerobin.blogspot.com/2006/05/creating-flamerobinfirebird-live-cd.html I created an updated guide with Ubuntu Festy Fawn also with an iso download for the Firebird/Flamerobin live cd http://flamerobin.blogspot.com/2007/09/creating-flamerobinfirebird-livecd-with.html


I have created tool for automatic remastering of live CD images. See http://uck.sourceforge.net/ . Features:

  • GUI for simple creation of localized CDs (including changing gfxboot and installing language packs)
  • Script for customization of ISO, SquashFS and initrd on live CD.

http://www.atworkonline.it/~bibe/ubuntu/custom-livecd.htm seems to have some nice info. no license that I can see so we would need to ask permission from the author to us its material.


If you want to make the CD boot faster, you might try sorting the files so that they are in the CD in the order that they are accessed: http://lichota.net/%7Ekrzysiek/projects/kubuntu/dapper-livecd-optimization/


Great How To. I am having one issue however. I would like to use custom xorg.conf and sources.list files. Any tips on doing this? Thanks.

  • Simply, copy the files to edit/etc/ in the same way (and at the same time) that you copy in the resolv.conf and hosts files.
  • I have found that copying xorg.conf doesn't work, as the boot-time scripts overwrite it. Besides, you can't guarantee that a particular xorg.conf will run on all hosts. I'm currently trying to get the binary NVIDIA drivers to work out of the box if an NVIDIA card is present. If I figure out how to fix the xorg.conf, I'll post it here. --JeremyVisser

I've managed to get Synaptic running from within the chroot environment, but it does hang when I try to apply packages. What you do is run "Xnest -ac :1" to get an Xnest server to run on display :1 without access control so anyone can connect to it. Then, in the chroot environment, run "export DISPLAY=:1" to get programs to use the display. Then, type "metacity &" to be able to move windows. Finally, run "synaptic". It works fine until you try to apply packages, where it hangs for me. --JeremyVisser


Shouldn't the mkinitramfs command use the casper scripts, like "mkinitramfs -o initrd.gz 2.6.15-23-386 -d /usr/share/initramfs-tools"?


There are tricks on how you can get to feel the GNOME system in your chroot environment. 1. Copy your xorg.conf in the chrooted "etc/X11/" directory.

cp /etc/X11/xorg.conf edit/etc/X11/

2. Create generic devices on your chroot system using MAKEDEV

cd /dev/
MAKEDEV generic

3. Start X or restart gdm

/etc/init.d/gdm start

Supposed you want to make modifications on the Desktop, that will be used by all the new users, just change your $HOME to /etc/skel/ and start gdm or X.

export HOME=/etc/skel/

If you want to load all the other stuff GNOME needs (i.e, dbus, avahi, network-manager), just boot as (single-user mode), and start dbus in your chrooted environment.

/etc/init.d/dbus start

An example of the whole procedure. (under single-user mode)

sudo /etc/init.d/networking restart
sudo cp /etc/resolv.conf edit/etc/
sudo cp /etc/X11/xorg.conf edit/etc/X11/
sudo chroot edit
mount -o none /proc
mount -o none /sys
export HOME=/etc/skel/
cd /dev/
MAKEDEV generic
/etc/init.d/dbus start
/etc/init.d/gdm start

--- UbuntuHelp:joelbryan


Hello, I am about to build a new Livecd and have a question: When I change the username, hostname and the user's password the user login automatically during booting the livesystem. But this is not desired. Is it correct, that I have to enter a password under a Desktop LiveCD when I delet the encrypted password in /usr/share/initramfs-tools/scripts/casper-bottom/10adduser ? Thanks Changing username and password will not change login behaviour, because this is done in /usr/share/initramfs-tools/scripts/casper-bottom/15autologin --- UbuntuHelp:Alexander Hosfeld


Having trouble starting a MySQL server from within the chroot jail. Any suggestions? - Dave Hey, I am trying to make a customized live cd of Kubuntu 6.06 that will be completly preconfigured, so that when the user clicks on the install icon on KDE the installer should do everything by itself, meaning that the installer should not ask any questions to the user. To do this I am trying to write a preseed file to tell the installer the information that it needs. The problem is that even with this preseed file I could only tell the installer what is the username that it should use, the rest of the information is simply ignored by the installer. I must be doing something wrong and would appreciate any and all help given me. Thanks, Komyg PS: Should I post my preseed file here?


If the livecd is not going to be used for the purposes of installing what files can be removed? Can the "pool" files containing the .debs be removed too? - Mike


If I want to put in my LiveCD applications that aren't in the sources.list (like ooffice 2.2 or perl audio converter), what cain I do? - Isoldanne


To get desired /etc/X11/xorg.conf one can modify the /usr/bin/dexconf. This script generates xorg.conf automatically in liveCD session according to the booted machine. For example:

# diff ~/bin/dexconf /usr/bin/dexconf 
268,269c268
< 	Option		"XkbLayout"	"us,il"
< 	Option          "XkbOptions" "grp:alt_shift_toggle,grp_led:scroll" 
---
> 	Option		"XkbLayout"	"$XKB_LAYOUT"

-- yotam


I cant do chroot. When i run it a get this error chroot: cannot run command `/bin/bash': No such file or directory Please help me out