个人工具

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

来自Ubuntu中文

跳转至: 导航, 搜索
 
第22行: 第22行:
 
mkdir work
 
mkdir work
 
cd work
 
cd work
 +
 
mkdir chroot
 
mkdir chroot
 +
 
sudo debootstrap --arch i386 gutsy chroot  http://archive.ubuntu.com/ubuntu
 
sudo debootstrap --arch i386 gutsy chroot  http://archive.ubuntu.com/ubuntu
 
</nowiki></pre>
 
</nowiki></pre>
第29行: 第31行:
 
sudo cp /etc/resolv.conf chroot/etc/resolv.conf
 
sudo cp /etc/resolv.conf chroot/etc/resolv.conf
 
sudo cp /etc/apt/sources.list chroot/etc/apt/sources.list
 
sudo cp /etc/apt/sources.list chroot/etc/apt/sources.list
 +
 
sudo chroot chroot
 
sudo chroot chroot
 +
 
mount /proc
 
mount /proc
 
mount /sys
 
mount /sys
 
apt-get update
 
apt-get update
 
locale-gen en_CA.UTF-8
 
locale-gen en_CA.UTF-8
 +
 
apt-get install ubuntu-standard casper (and whatever other packages you want)
 
apt-get install ubuntu-standard casper (and whatever other packages you want)
 
apt-get install discover1 laptop-detect os-prober
 
apt-get install discover1 laptop-detect os-prober
 +
 
apt-get install linux-generic  
 
apt-get install linux-generic  
 +
 
apt-get clean
 
apt-get clean
 +
 
rm -rf /tmp/*
 
rm -rf /tmp/*
 +
 
rm /etc/resolv.conf
 
rm /etc/resolv.conf
 +
 
umount -l -f /proc
 
umount -l -f /proc
 
umount -l -f /sys
 
umount -l -f /sys
第54行: 第64行:
 
You will need a kernel and an initrd that was build with the casper scripts.  Grab them from your chroot.   
 
You will need a kernel and an initrd that was build with the casper scripts.  Grab them from your chroot.   
 
<pre><nowiki>
 
<pre><nowiki>
 +
 
cp chroot/boot/vmlinuz-2.6.22-14-generic image/casper/vmlinuz
 
cp chroot/boot/vmlinuz-2.6.22-14-generic image/casper/vmlinuz
 +
 
cp chroot/boot/initrd.img-2.6.22-14-generic image/casper/initrd.gz
 
cp chroot/boot/initrd.img-2.6.22-14-generic image/casper/initrd.gz
 +
 
</nowiki></pre>
 
</nowiki></pre>
 
You need the isolinux binary and the sbm binary.
 
You need the isolinux binary and the sbm binary.
 
<pre><nowiki>
 
<pre><nowiki>
 
cp /usr/lib/syslinux/isolinux.bin image/isolinux/
 
cp /usr/lib/syslinux/isolinux.bin image/isolinux/
 +
 
cp /boot/memtest86+.bin image/install/memtest
 
cp /boot/memtest86+.bin image/install/memtest
 
cp /boot/sbm.img image/install/
 
cp /boot/sbm.img image/install/
第67行: 第81行:
 
<pre><nowiki>
 
<pre><nowiki>
 
This is an Ubuntu Remix Live CD.
 
This is an Ubuntu Remix Live CD.
 +
 
For the default live system, enter "live".  To verify the CD for errors, enter "check".  To run memtest86+, enter "memtest"
 
For the default live system, enter "live".  To verify the CD for errors, enter "check".  To run memtest86+, enter "memtest"
 
</nowiki></pre>
 
</nowiki></pre>
第74行: 第89行:
 
DEFAULT live
 
DEFAULT live
 
LABEL live
 
LABEL live
menu label ^Start or install Ubuntu
+
  menu label ^Start or install Ubuntu
kernel /casper/vmlinuz
+
  kernel /casper/vmlinuz
append  file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.gz quiet splash --
+
  append  file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.gz quiet splash --
 
LABEL check
 
LABEL check
menu label ^Check CD for defects
+
  menu label ^Check CD for defects
kernel /casper/vmlinuz
+
  kernel /casper/vmlinuz
append  boot=casper integrity-check initrd=/casper/initrd.gz quiet splash --
+
  append  boot=casper integrity-check initrd=/casper/initrd.gz quiet splash --
 
LABEL memtest
 
LABEL memtest
menu label ^Memory test
+
  menu label ^Memory test
kernel /install/memtest
+
  kernel /install/memtest
append -
+
  append -
 
LABEL hd
 
LABEL hd
menu label ^Boot from first hard disk
+
  menu label ^Boot from first hard disk
localboot 0x80
+
  localboot 0x80
append -
+
  append -
 
DISPLAY isolinux.txt
 
DISPLAY isolinux.txt
 
TIMEOUT 300
 
TIMEOUT 300
第96行: 第111行:
 
Create manifest:
 
Create manifest:
 
<pre><nowiki>
 
<pre><nowiki>
 +
 
sudo chroot chroot dpkg-query -W --showformat='${Package} ${Version}\n' > image/casper/filesystem.manifest
 
sudo chroot chroot dpkg-query -W --showformat='${Package} ${Version}\n' > image/casper/filesystem.manifest
 
sudo cp image/casper/filesystem.manifest image/casper/filesystem.manifest-desktop
 
sudo cp image/casper/filesystem.manifest image/casper/filesystem.manifest-desktop
第131行: 第147行:
 
cd image
 
cd image
 
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-remix.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-remix.iso .
 +
 
</nowiki></pre>
 
</nowiki></pre>
 
The boot.cat file will be automatically created.
 
The boot.cat file will be automatically created.

2007年12月6日 (四) 10:41的最新版本

This procedure works and can create an ugly, but bootable Ubuntu live cd (along with the hardware autodetection and configuration) from scratch. You do not need to start from an already-made live cd. You may wish to create an Ubuntu remix and distribute it as a live cd. Here is a way to do that without having to start from an existing Ubuntu Desktop cd.

Overview

There are three different areas to think about: The host system, the disk image and the chroot. 1- The host system. This is your current Ubuntu install. You will need to install syslinux squashfs-tools and mkisofs to be able to build the live cd with your current system. 2- The disk image. The disk image is a directory that we will burn to a cd. You will copy the isolinux bootloader (from the syslinux package) onto the disk image (into the folder, for now). You will include an isolinux configuration file which will allow you to show a menu at boot time. You will also copy the kernel from the chroot onto the disk image (folder). The disk image will be created in the host environment (outside of the chroot) 3- The chroot environment. This is the system that will run from the disk. It does not need a kernel, nor a bootloader unless you are planning on installing it back onto a hard disk (using Ubiquity). It is useful to install Casper into the chroot and then install a kernel which you will copy out into the disk image. The initrd that is then created when the kernel is installed will contain the casper boot scripts. Otherwise, you will need to create an initrd (with the casper scripts) for your disk image in the host system. The chroot will end up inside the disk image in the form of a squashed (compressed) file. For right now, it will be just another folder on your host system. The basic steps are to 1- Create a chroot and install your packages there. 2- Compress the chroot system into a file. 3- Create and configure the disk image which will have the bootloader (isolinux), the kernel and the compressed filesystem image. And other stuff. 4- Burn the cd and test it out.

Make the chroot environment

install debootstrap. (Note, the latest version of debootstrap is available here. Run

mkdir work
cd work

mkdir chroot

sudo debootstrap --arch i386 gutsy chroot  http://archive.ubuntu.com/ubuntu

That will create a directory with a chroot directory within it. It will then install a bare ubuntu system there.

sudo cp /etc/resolv.conf chroot/etc/resolv.conf
sudo cp /etc/apt/sources.list chroot/etc/apt/sources.list

sudo chroot chroot

mount /proc
mount /sys
apt-get update
locale-gen en_CA.UTF-8

apt-get install ubuntu-standard casper (and whatever other packages you want)
apt-get install discover1 laptop-detect os-prober

apt-get install linux-generic 

apt-get clean

rm -rf /tmp/*

rm /etc/resolv.conf

umount -l -f /proc
umount -l -f /sys
exit

That will allow you to enter that chroot and install packages, then clean up and leave. This is where you build your custom system using packages from the Ubuntu archives.

Create the cd image directory and populate it

Install syslinux squashfs-tools mkisofs sbm You need these packages to work on the cd image (syslinux contains isolinux which is what makes the cd bootable. Squashfs-tools will compress the image. SBM is a tool which is useful to have on the cd if you cannot get it to boot. Make the image directory and the needed subdirectories.

mkdir image image/casper image/isolinux image/install

You will need a kernel and an initrd that was build with the casper scripts. Grab them from your chroot.


cp chroot/boot/vmlinuz-2.6.22-14-generic image/casper/vmlinuz

cp chroot/boot/initrd.img-2.6.22-14-generic image/casper/initrd.gz

You need the isolinux binary and the sbm binary.

cp /usr/lib/syslinux/isolinux.bin image/isolinux/

cp /boot/memtest86+.bin image/install/memtest
cp /boot/sbm.img image/install/

Create an isolinux.txt file in image/isolinux to display at boot time: Example:

This is an Ubuntu Remix Live CD.

For the default live system, enter "live".  To verify the CD for errors, enter "check".  To run memtest86+, enter "memtest"

Create an isolinux.cfg file in image/isolinux/ Read usr/share/doc/syslinux/syslinux.doc on configuration options. Here is an example of what could be in the file:

DEFAULT live
LABEL live
  menu label ^Start or install Ubuntu
  kernel /casper/vmlinuz
  append  file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.gz quiet splash --
LABEL check
  menu label ^Check CD for defects
  kernel /casper/vmlinuz
  append  boot=casper integrity-check initrd=/casper/initrd.gz quiet splash --
LABEL memtest
  menu label ^Memory test
  kernel /install/memtest
  append -
LABEL hd
  menu label ^Boot from first hard disk
  localboot 0x80
  append -
DISPLAY isolinux.txt
TIMEOUT 300
PROMPT 1

Now your disk image can boot. Create manifest:


sudo chroot chroot dpkg-query -W --showformat='${Package} ${Version}\n' > image/casper/filesystem.manifest
sudo cp image/casper/filesystem.manifest image/casper/filesystem.manifest-desktop
sudo sed -ie '/ubiquity/d' image/casper/filesystem.manifest-desktop

Compress the chroot:

sudo mksquashfs chroot image/casper/filesystem.squashfs

Create a diskdefines:

nano image/README.diskdefines

example:

#define DISKNAME  Ubuntu 7.04 "Feisty Fawn" - Release i386 **Remix**
#define TYPE  binary
#define TYPEbinary  1
#define ARCH  i386
#define ARCHi386  1
#define DISKNUM  1
#define DISKNUM1  1
#define TOTALNUM  0
#define TOTALNUM0  1

Calculate MD5

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

Turn the image directory into an iso image

Create iso

cd image
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-remix.iso .

The boot.cat file will be automatically created.

To Do

-Graphical boot -Can you install the system back onto a hard drive with ubiquity?