Gentoo Live-CD: Difference between revisions
No edit summary |
No edit summary |
||
| Line 98: | Line 98: | ||
{{Root|emerge -uD world}} | {{Root|emerge -uD world}} | ||
{{Root|emerge -e world}} | {{Root|emerge -e world}} | ||
{{Root|emerge glibc --oneshot}} (optional; nicht nötig wenn zuvor {{ | {{Root|emerge glibc --oneshot}} (optional; nicht nötig wenn zuvor {{Root|emerge -e world}} ausgeführt wurde) | ||
Nun wird die Systemzeit gesetzt und die Mountpunkte bzw. Optionen in der {{ | Nun wird die Systemzeit gesetzt und die Mountpunkte bzw. Optionen in der {{Path|/etc/fstab}} angepasst. Optional werden dmraid und slocate installiert. | ||
{{Root|cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime}} | {{Root|cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime}} | ||
Latest revision as of 15:08, 27 July 2011
Voraussetzungen auf dem Host
Bevor man mit der ganzen Prozedur beginnt müssen auf dem Host folgende Vorrausetzungen erfüllt sein.
Software:
- app-cdr/cdrkit
- sys-fs/squashfs-tools
Kernel Konfiguration:
| Linux Kernel Configuration: Hostkonfiguration |
Device Drivers ---> Block devices ---> <*> Loopback device support Filesystems ---> Miscellaneous filesystems ---> <*> SquashFS 3.3 - Squashed file system support |
Arbeitsverzeichnis vorbereiten
Da nun alle Vorrausetzungen erfüllt sind beginnen wir damit ein Verzeichnis anzulegen mit dem wir arbeiten. In meinem Tutorial habe ich dafür /root/livecd/source gewählt.
Jetzt laden wir ein aktuelles stage3 Archiv herunter. In meinem Beispiel ein i686 Archiv, da meine LiveCD auf möglichst vielen Architekturen laufen soll. Denkbar wäre natürlich auch eine x86_64 CD oder gar PPC (nicht getestet!).
Jetzt muss das ganze natürlich noch an die richtige Stelle entpackt werden.
Anschließend wechseln wir in das Arbeitsverzeichnis und mounten die benötigten Resourcen.
Resourcen mounten
Chrooten
Nun chrooten wir in unsere Entwicklungsumgebung und beginnen mit der Gentoo Installation, die im Grunde genauso wie eine ganz normale Stage2 Installation abläuft. Im folgenden trotzdem nochmal Schritt für Schritt erläutert.
Grundinstallation
Jetzt passen wir die /etc/make.conf an unser Zielsystem an auf dem die LiveCD dann laufen soll. Wie oben schon erwähnt wähle ich hier i686 um die CD möglichst generisch zu halten.
CFLAGS="-O2 -march=i686 -pipe" CXXFLAGS="-O2 -march=i686 -pipe" CHOST="i686-pc-linux-gnu" USE="nptl nptlonly livecd -gtk -gnome qt kde dvd alsa cdr" MAKEOPTS="-j2" AUTOCLEAN="yes" ACCEPT_KEYWORDS="~x86"
Damit wir einen optimalen Code erhalten aktualisieren wir auch den GCC und setzen den neuen GCC dann natürlich auch aktiv.
Damit wir den Overhead möglichst gering halten, entfernen wir auch sämtliche nicht benötigte Sprachen der glibc.
de_DE.UTF-8 UTF-8
Jetzt können wir das ganze System auf den aktuellen Stand bringen und es anschließend neu kompilieren lassen. Falls man kein
bzw
machen möchte sollte man zumindest die glibc neu emergen.
(optional; nicht nötig wenn zuvor
ausgeführt wurde)
Nun wird die Systemzeit gesetzt und die Mountpunkte bzw. Optionen in der /etc/fstab angepasst. Optional werden dmraid und slocate installiert.
(optional)
/dev/loop0 / squashfs ro,defaults 0 0 proc /proc proc defaults 0 0 shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
Im folgenden wird erklärt wie der Kernel zu konfigurieren ist und was sonst noch notwendig ist um einen Kernel für den LiveCD-Betrieb zu erhalten, außerdem konfigurieren wir hier den grub Bootloader und installieren gensplash für ein bisschen Eye-Candy.
| Linux Kernel Configuration: Hostkonfiguration Live-CD |
# squashfs filesystem # Filesystems ---> # Layered filesystems ---> # <*> Union file system (EXPERIMENTAL) # iso9660 cdrom filesystem # initrd support, set size to 8MB # loopback block device support # IDE/ATAPI cdrom device support # ext2 filesystem support (which we use for our initrd image), (it is a good idea if it is an rescue cd of some sort to include support for most systems, may come in handy). # tmpfs filesystem support |
default 0
timeout 30
splashimage=(cd)/boot/grub/splash.xpm.gz
title=Gentoo-LiveCD NO-FB
root (cd)
kernel (cd)/boot/kernel-genkernel-x86-2.6.26-gentoo-r1 root=/dev/ram0 real_root=/dev/loop0 looptype=squashfs loop=/livecd.squashfs udev nodevfs cdroot
initrd (cd)/boot/initramfs-genkernel-x86-2.6.26-gentoo-r1
Kernel konfigurieren.
bzw:
Wenn das Kernel Konfigurationsmenü erscheint sollte man noch überprüfen ob denn auch wirklich alle oben genannten Kerneloptionen aktiviert bzw. fest in den Kernel kompiliert sind. Anschließend Menuconfig beenden, die Konfiguration speichern lassen und warten bis der Kernel installiert ist.
Damit die init-Skripte beim Booten nicht meckern müssen wir die livecd-tools installieren, welchen wir beim Boot den Kernelparameter mit Hilfe der Grub Zeile 'cdboot' übergeben.
app-misc/livecd-tools
Anschließend konfigurieren wir noch unser System
us -> de (optional)
modules_eth0=( "dhcpcd" )
eth0 zum Defaul-Runlevel hinzufügen
Hostnamen eintragen
127.0.0.1 localhost livecd ::1 localhost livecd
Hostnamen setzen
HOSTNAME="livecd"
Syslogger installieren
zum Default-Runlevel hinzufügen
DHCP-Client installieren
XFS-Dateisystemtools installieren
ReiserFS-Dateisystemtools installieren
JFS-Dateisystemtools installieren
Jetzt verlassen wir die Chroot-Umgebung, erstellen unsere Build-Skripte und starten den Vorgang um eine LiveCD zu erzeugen.
Backup der Basisinstallation
Optional können wir nun natürlich noch ein Backup des ganzen anlegen damit, falls doch einmal etwas schief gehen sollte man nicht nocheinmal die ganze Installation durchkauen muss.
Build-Skripte erstellen und LiveCD erzeugen
#!/bin/bash
LIVECD=~/livecd
TARGET=${LIVECD}/target
TARGET_SOURCE=${TARGET}/files/source/
SOURCE=${LIVECD}/source
rm -rf ${TARGET}
mkdir ${TARGET}
cp -a ${SOURCE}/boot ${TARGET}/
mkdir -p ${TARGET}/files/source
rsync -a --delete --progress --exclude "var/tmp/*" --exclude "var/cache/*" --exclude "*.h" --exclude "usr/portage" --exclude "etc/portage" --exclude "usr/share/doc" --exclude "usr/src" ${SOURCE}/ ${TARGET_SOURCE}
cd ${TARGET}/files
mount -o bind /sys ${TARGET_SOURCE}/sys
mount -o bind /dev ${TARGET_SOURCE}/dev
mount -o bind /proc ${TARGET_SOURCE}/proc
mkdir -p ${TARGET_SOURCE}/usr/portage
mount -o bind /usr/portage ${TARGET_SOURCE}/usr/portage
echo "Execute ./before-build now, but first MAKE SURE it has correctly chrooted to the livecd ${TARGET_SOURCE} directory"
chroot ${TARGET_SOURCE}/ /bin/bash --login
umount ${TARGET_SOURCE}/sys
umount ${TARGET_SOURCE}/dev
umount ${TARGET_SOURCE}/proc
umount ${TARGET_SOURCE}/usr/portage
env-update
source /etc/profile
cd ${TARGET_SOURCE}
rm -rf var/tmp/*
rm -rf var/run/*
rm -rf var/lock/*
rm -rf var/cache/*
rm -rf var/db
rm -rf tmp/*
rm -f etc/mtab
touch etc/mtab
rm -rf usr/portage
rm -rf etc/portage
rm -rf usr/share/doc
rm root/.bash_history
rm root/.zcompdump
rm -rf var/log
mkdir var/log
rm etc/make.profile
rm before-build
rm -rf usr/src/
rm -rf boot
rm info
cd ${TARGET}/files
mksquashfs source/ ${TARGET}/livecd.squashfs
cd ${TARGET}
touch livecd
rm -rf ${TARGET}/files/
cd ${LIVECD}
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -iso-level 4 -hide-rr-moved -c boot.catalog -o ${LIVECD}/livecd.iso ${TARGET}/
env-update
update-modules
localepurge
emerge sys-fs/fuse dmraid
emerge unmerge localepurge genkernel
slocate -u
slocate .keep > info
for x in $(cat info);
do
rm ${x}
done
Build Prozess starten
Anschließend ein
ausführen um zu prüfen ob man auch wirklich in der Chroot-Umgebung ist
Wenn man wieder den Commandprompt hat
eingeben und warten bis das Build-Skript fertig ist. Mit einem weiteren
kann man die Build-Umgebung verlassen und das ISO letztendlich brennen.
Nachträgliche Modifikationen & erneutes Build
Da wir ja ein komplettes System haben ist es sehr einfach jederzeit neue Pakete hinzuzufügen und das System aktuell zu halten. Dafür gibt es auch ein praktisches Skript.
#!/bin/bash mount -o bind /proc source/proc mount -o bind /sys source/sys mount -o bind /dev source/dev mount -o bind /dev/pts source/dev/pts mount -o bind /usr/portage source/usr/portage chroot source/ /bin/bash --login umount source/proc umount source/sys umount source/dev/pts umount source/dev umount source/usr/portage
Dann noch
ausführen um die Umgebungsvariablen zu übernehmen und schon kann man weiter basteln. Wenn man fertig ist reicht ein einfaches
Anschließend wie in Punkt 8 "Build Prozess starten" verfahren.
Addons
- UnionFS:
I use genkernel and unionfs together, and so I have the unionfs overlay over the whole livecd (what I want). Use genkernel with "--unionfs-dev"; change the build script to produce a "livecd.unionfs" instead of "livecd.squashfs" and give grub (in menu.list) the "unionfs" option
Temp
- Qemu
[ebuild N ] app-text/texi2html-1.76 372 kB
[ebuild N ] app-emulation/qemu-softmmu-0.7.2 (-kqemu) +sdl 1,310 kB
[ebuild N ] app-emulation/qemu-user-0.7.2 0 kB
[ebuild N ] app-emulation/qemu-0.7.2 0 kB
qemu -m 128 -cdrom /temp/knoppix-custom.iso -boot d -user-net
- Mountskript
#!/sbin/runscript
# Copyright 2005 Michiel Hazelhof
# Distributed under the terms of the GNU General Public License v2
depend () {
# Just to make it look better
after autoconfig
}
start() {
# Set ${NTFS} to a value, not sure if this is needed
NTFS=$"0"
# Get al excisting partitions usinf fdisk, and loop those to determine what to do with each
for x in $(fdisk -l | awk {'print $1'} | grep dev | cut -c6-99);
do
# Just to make sure the type2 is empty and not used if not needed
TYPE2=$"(0)"
# Grep partition type, so we have the /dev/* and the type, now we can determine what to do with it.
# Get $6 to for none bootable partitions
TYPE="$(fdisk -l | grep ${x} | awk {'print $7'})"
TYPE2="$(fdisk -l | grep ${x} | awk {'print $6'})"
# If TYPE returns nothing we start using TYPE2 because it (probably) is a non-bootable partition
if [[ ${TYPE} == "" ]] ; then
# Do not mount if TYPE2 returns extended
if [[ ${TYPE2} == "Extended" ]] ; then
SHIT=$"1"
# Mount "none" bootable NTFS partition using captive-ntfs, and start captive-ntfs only if it is the first time
elif [[ ${TYPE2} == "HPFS/NTFS" ]] ; then
if [[ ${NTFS} = "0" ]] ; then
ebegin "Starting captive-ntfs!"
chmod 755 /
screen -d -m -S captive_ntfs captive-sandbox-server
NTFS=$"1"
fi
ebegin "Trying to mount /dev/${x} as ntfs, using captive-ntfs"
mkdir /mnt/${x}
mount -t captive-ntfs /dev/${x} /mnt/${x} 2>/dev/null >/dev/null >/dev/null
# Use partition as swap if it is swap
elif [[ ${TYPE2} == "swap" ]] ; then
ebegin "Trying to use /dev/${x} as swap"
swapon /dev/${x} 2>/dev/null >/dev/null >/dev/null
# If none of the above exceptions is true, just try to mount it
else
ebegin "Trying to mount /dev/${x}"
mkdir /mnt/${x}
mount /dev/${x} /mnt/${x} 2>/dev/null >/dev/null >/dev/null
fi
# If it is a bootable partition we run this part of the loop
else
# Don't mount if extended
if [[ ${TYPE} == "Ext'd" ]] ; then
SHIT=$"1"
# If it TYPE returns W95, check for hidden
elif [[ ${TYPE} == "W95" ]] ; then
TYPE2="$(fdisk -l | grep ${x} | awk {'print $6'})"
# If W95 returns hidden mount it but mention it is hidden
elif [[ ${TYPE2} == "Hidden" ]] ; then
ebegin "Trying to mount /dev/${x}, but is is a hidden partition this might fail"
mkdir /mnt/${x}
mount /dev/${x} /mnt/${x} 2>/dev/null >/dev/null >/dev/null
# Mount bootable NTFS partition using captive-ntfs, and start captive-ntfs only if it is the first time
elif [[ ${TYPE} == "HPFS/NTFS" ]] ; then
if [[ ${NTFS} = "0" ]] ; then
ebegin "Starting captive-ntfs!"
chmod 755 /
screen -d -m -S captive_ntfs captive-sandbox-server
NTFS=$"1"
fi
ebegin "Trying to mount /dev/${x} as ntfs, using captive-ntfs"
mkdir /mnt/${x}
mount -t captive-ntfs /dev/${x} /mnt/${x} 2>/dev/null >/dev/null >/dev/null
# Use partition as swap if it is swap, this should not occur as swap normaly is not a bootable partition
elif [[ ${TYPE} == "swap" ]] ; then
ebegin "Trying to use /dev/${x} as swap"
swapon /dev/${x} 2>/dev/null >/dev/null >/dev/null
fi
fi
done
}
Mit Bootsplash
default 0
timeout 30
splashimage=(cd)/boot/grub/splash.xpm.gz
title=Gentoo-LiveCD Test1
root (cd)
kernel (cd)/boot/kernel-genkernel-x86-2.6.13-gentoo-r4 vga=791 splash=silent,theme:livecd-2005.1 CONSOLE=/dev/tty1 quiet root=/dev/ram0 init=/linuxrc looptype=squashfs loop=/livecd.squashfs udev nodevfs cdroot dodmraid
initrd (cd)/boot/initramfs-genkernel-x86-2.6.13-gentoo-r4
title=Gentoo-LiveCD Test2
root (cd)
kernel (cd)/boot/kernel-genkernel-x86-2.6.13-gentoo-r4 vga=791 splash=silent,theme:livecd-2005.1 CONSOLE=/dev/tty1 quiet root=/dev/ram0 init=/linuxrc looptype=squashfs loop=/livecd.squashfs udev nodevfs cdroot dodmraid
initrd (cd)/boot/initramfs-genkernel-x86-2.6.13-gentoo-r4
title=Gentoo-LiveCD NO-FB
root (cd)
kernel (cd)/boot/kernel-genkernel-x86-2.6.13-gentoo-r4 root=/dev/ram0 init=/linuxrc looptype=squashfs loop=/livecd.squashfs udev nodevfs cdroot dodmraid
initrd (cd)/boot/kernel-genkernel-x86-2.6.13-gentoo-r4
title=Memtest86
root (cd)
kernel (cd)/boot/memtest86/memtest.bin
title=Memtest86+
root (cd)
kernel (cd)/boot/memtest86plus/memtest.bin
Zur Erklärung:
- 'kernel-genkernel-x86-2.6.13-gentoo-r4' trägt den Namen des installierten Kernels
- 'initramfs-genkernel-x86-2.6.13-gentoo-r4' trägt den Namen des installierten Kernelinitramfs
- 'vga=791 splash=silent,theme:livecd-2005.1 CONSOLE=/dev/tty1 quiet' übergibt dem Kernel die nötigen Informationen um das Bootsplash richtig anzuzeigen
Es folgt die Konfiguration des Genkernels mit Bootsplash Unterstützung.
Splash-Themes Paket
Ausführen und mit Strg+C abbrechen um einen Standard Genkernel zu erhalten.
Theme und Kernel konfigurieren.
Eine Übersicht über die verfügbaren Bootsplash Themes erhält man mit
Zur Zeit noch nicht möglich, genkernel mit UnionFS:
Offene Fragen
(eventuell bei jedem Kernelupdate nötig?) Teil des Bootsplash Pakets
Probleme
- livecd-tools lassen sich nicht emergen
- UnionFS Genkernel Support kaputt, wird auch nicht mehr maintained (eventuell Kernel patchen?)
Quellen
http://forums.gentoo.org/viewtopic.php?t=244837 http://gentoo-wiki.com/HOWTO_build_a_LiveCD_from_scratch http://www.knoppix.net/wiki/Knoppix_Remastering_Howto#Test_CD_Image_Without_Burning_a_CD http://forums.gentoo.org/viewtopic-t-244837-postdays-0-postorder-asc-start-150.html http://www.linux-user.de/ausgabe/2005/10/093-zubefehl/ http://www.gentoo.org/doc/en/genkernel.xml