HOWTO_AutoLiveCD
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Warning - This page and project is a work in progress... See the Todo/Requests for Help section, and feel free to answer my requests (in fact, I encourage you to do so! Every little helps). Comments and criticisms on the Talk page, please - I want to make this a useful tool for everyone, and for that I need input and knowledge from other people.
Update (2008-04-25): People still occasionally download the scripts, and I've heard that sometimes the official installer can be a bit buggy. Also, I don't know how well the official one would do multiple installations. Once I finish my final exams in a month or two, I might start working on this again...
Update (24/10/2005): The scripts have been updated, and they should now work with universal LiveCDs and LiveCDs of any version (from 2005.0). They will also attempt to download a stage tarball from a random server from a list of 11. If this fails, the install will drop the user into a shell, and they can fix the problem. The scripts now also deal with the 2005.1 initrd (although not as well as they could).
Update (20/10/2005): I've created some scripts that will generate an AutoLiveCD from the minimal 2005.0 ISO, but they should also work on other ISOs. Needs more testing, but if anyone would like to volunteer to test the AutoLiveCD, I'd be very grateful! The scripts can be obtained from http://www.doc.ic.ac.uk/~dmi04/gentoo/. I'd like people to enter some details, but if they would prefer not to, then let me know, and I'll see. I would like to know how many people are interested in the AutoLiveCD, and get some feedback from the testers.
To install the scripts, extract the tarball, and edit the livecdgen script. It's fairly self-explanatory, and you only need to modify the variables at the top. You'll need a minimal or universal LiveCD to build it from. Then run it, and it should build you an AutoLiveCD.
Update (13/10/2005): The AutoLiveCD has worked for a machine from a Stage1 install, almost completely automated. It's still far from finished, as I know nothing about LILO, and it could use a few tweaks here and there. I will shortly be putting up a link to a page where you can download details about how to create your very own AutoLiveCD.
Contents |
Background
I'm in the middle of creating an automated installation LiveCD for Gentoo. It was originally based heavily on the Advanced Install HOWTO article, but has become its own creation after much reference to the Gentoo Handbook and much trial and error. The AutoLiveCD does try to automate things as much as possible, and the end plan is to have a completely automatic install. By that, I mean that you provide the LiveCD with a set of configuration files and it will then go off and install Gentoo to your exact specifications - without you having to sit there and watch! I suppose this is mainly intended for system administrators or for other people who have to install a large number of similar machines, but this should silence complaints about the length of time that Gentoo takes to install!
I have personally tested the AutoLiveCD on a machine of my own (Athlon 1200, 256MB RAM, 1x20GB HDD, 1x60GB HDD), and it took just under 8 hours to do a Stage1 installation. All I had to do was watch all of the pretty, geeky text scroll by. (Yes, the comma was intended.)
It's based on the 2005.0 Minimal LiveCD, but the scripts should integrate just as well with any other version.
This page will contain some documentation about the project, made up as I go along, when I have time to do so. Hopefully (eventually) it will become a reference guide, possibly with links to the new ISO or a script to modify an existing LiveCD image.
The Beginning
The project essentially relies on a set of scripts added to the normal LiveCD. To achieve this aim, I 'unpacked' the ISO by mounting it and copying the files from it to my hard drive. I then extracted the files from the the livecd.squashfs loopback filesystem that was in the ISO. This makes up the bulk of the LiveCD root. The initrd is stored in isolinux/gentoo.igz, which is a gzipped ext2 loopback filesystem. I made a few small modifications to that, but I won't document them until they're finished, as they're not very big, but may change.
My filesystem (in relation to the AutoLiveCD) looks like this (courtesy of tree):
/livecd/
|-- e2fs
|-- iso
| |-- docs
| |-- stages
| `-- isolinux
`-- squashfs
|-- bin
|-- boot
|-- dev
|-- etc
|-- home
|-- install_helper
|-- lib
|-- mnt
|-- opt
|-- proc
|-- root
|-- sbin
|-- sys
|-- tmp
|-- usr
`-- var
A quick overview of some of the items in the tree:
- e2fs is the mountpoint for the initrd, when I need to mount it.
- iso is the root of the ISO image.
- iso/stages contains x86 and i686 stages 1-3 and Pentium3 and Pentium4 stages 2-3.
- squashfs is the uncompressed version of the squashfs filesystem that will appear on the livecd
- squashfs/install_helper contains my installation helper scripts
Changes to a normal LiveCD
- MOTD
- Some stages included on cd
- Should load fine from a USB stick as well [TODO: Insert link to relevant HOWTO or TIP here]
- Installation scripts
- bc and hexdump are included on the LiveCD, as they're used by some scripts
Todo/Requests for Help
Pending tasks for HOWTO AutoLiveCD | edit -history - watch - purge | |
|---|---|---|
| ||
Please answer these requests - I'd like to be able to include these features, or fix these problems, or know what I'm missing or doing wrong...
- RFH: Does anyone know how I can use screen to have a split-screen effect? It might be nice to have 2-4 lines at the top of the screen explaining what's happening, and all of the compilation happening below... but is this possible? (Answered: see the Talk page )
- RFH: 10_checknet should also check for connectivity, but I need a good way to do this. Any suggestions? The way in the script, redundant though it is, still sometimes fails, and I'm not sure why...
- RFH: Information about LILO configuration?
- RFH: USE flags? See below
- RFH: More information on the 2005.1 initrd. 2005.0 (and possibly earlier) used a gzipped ext2 filesystem. 2005.1 uses a set of concatenated cpio archives, although it's anyone's guess why. I need a better way to rip out the trailer from these cpio archives, so that it extracts properly. At the moment, I just rip out the "TRAILER!!!" text that signifies the end of the archive. There must be a (slightly) better way...
- RFH: this is on an 2006.1 livecd livecdgen was edited
soundig autogen # dmesg | tail APIC error on CPU0: 40(40) APIC error on CPU0: 40(40) APIC error on CPU0: 40(40) APIC error on CPU0: 40(40) APIC error on CPU0: 40(40) ISO 9660 Extensions: Microsoft Joliet Level 3 ISO 9660 Extensions: RRIP_1991A APIC error on CPU0: 40(40) VFS: Can't find an ext2 filesystem on dev loop0. APIC error on CPU0: 40(40)
Scripts
NOTE: This section is a very brief overview of the scripts. It is (and will be) possible to add custom scripts, based on the same system. So, for example, if you wanted to add a script between the filesystem script and the chroot script, then you would name it "23_customscript". The autoinstall script simply executes all of the scripts in numerical order, as long as they match the regular expression "[0-9][0-9]_.+", essentially two digits, an underscore, and then any text.
autoinstall
This is the main script - it calls all the other installation scripts in order.
05_hdparm
Applies generic hdparm settings to each IDE drive (separate settings for hard drives and CD drives), based on settings from configuration file.
10_checknet
Checks that network interfaces are up. Should also check for connectivity, but I need a good way to do this. Any suggestions?
| File: Current 10_checknet script |
#!/bin/sh
#
# Gentoo installation helper scripts, written by David Ingram
#
# They should help with a more automated installation of Gentoo Linux,
# and eventually with a fully automated install (with config file)
#
# Some parts of the installation based upon the Advanced Install guide on
# the Gentoo wiki at: [[HOWTO_Advanced_Install]]
#
HELPERDIR=`dirname $0`
. ${HELPERDIR}/functions.sh
ebegin "Checking interface status"
eindent
IF_UP=`ifconfig | grep Link | cut -f1 -d' '`
IF_ALL=`ifconfig -a | grep Link | cut -f1 -d' '`
if [[ "$IF_UP" == "$IF_ALL" ]]; then
einfo "All interfaces (`echo "$IF_UP" | tr '\n' ' ' | sed -e 's/ /, /g;' | sed -e 's/, $//'`) are up"
eend 0
else
for i in $IF_ALL; do
[[ `echo "$IF_UP" | grep $i` ]] || ewarn "Interface $i is down"
done;
ewend 1 "Some interfaces are down - networking may not function"
fi
eoutdent
exit 0
echo
ebegin "Checking internet connection (might take a while, please wait)"
eindent
ping -c4 -w1 www.google.com #>/dev/null 2>&1
if [[ "$?" == "0" ]]; then
einfo "Internet seems to be working"
eend 0
else
ping -c4 -w1 www.bbc.co.uk #>/dev/null 2>&1
if [[ "$?" == "0" ]]; then
einfo "Internet seems to be working"
eend 0
else
eend 1 "Cannot ping some sites - is the Internet working?"
fi
fi
eoutdent
|
15_partitions
Sets up the partitions on each drive, as specified in the configuration file. If the configuration file does not exist or is empty, then it will ask the user to partition each drive manually.
20_filesystems
Automatically detects swap partitions, and asks user if they want it to be formatted as swap. Also does swapon for them too. Can handle multiple swap partitions, but I don't know how likely this is to happen. This script then proceeds to create and mount the filesystems that have been listed in the configuration file.
25_chroot
This is by far the largest script, and probably needs a great deal of explanation (which I unfortunately don't have the time to write at the moment). I'll try to explain what the script does, but I haven't got it to hand at the moment, and so can't give any exact details.
- Copies and extracts the stage tarball (stage configurable by user)
- Selects mirrors (if the user wants this to happen)
- Adds some defaults to make.conf as below, or copies the user's predefined make.conf file
- Options for using ccache and distcc
- USE flags as follows (please give advice on most generic and/or best!):
- Workstation: "oss -kde -qt cups gnome gtk aac aalib acpi alsa audiofile avi bash-completion bzlib cdparanoia cdr dedicated divx4linux dv dvd dvdread encode exif fbcon ffmpeg flac ftp gd ieee1394 imagemagick imap java javascript jpeg libcaca live mad maildir mikmod mime mng mono mp3 mpeg msn network nptl nptlonly ogg opengl pdflib perl png real samba sndfile ssl theora unicode xvid tiff truetype usb userlocales vcd win32codecs wmf zlib"
- Server: "oss -kde -qt cups gnome gtk acpi apache2 bash-completion bzlib dedicated doc dvd dvdread encode ethereal exif fbcon ftp gd ieee1394 imagemagick imap java javascript jpeg maildir mime mng mono mysql network nptl nptlonly pdflib perl php png -postgres samba ssl unicode tiff truetype usb userlocales wmf zlib"
- Allows user to edit make.conf if the defaults were entered
- Mounts /proc
- Prepares the chroot environment (by outputting a script to it and copying /etc/resolv.conf)
- Enters the chroot (execs the script)
- Updates environment
- Asks user for date/time
- Syncs Portage tree
- Checks make.conf for ccache and distcc and sets up appropriately (doesn't do distcc yet)
The next things that happen depend on what stage the user decided to start from. Start at the appropriate stage, and keep reading until the end.
Stage1
- Bootstraps (emerge --oneshot --nodeps gcc-config && emerge linux-headers && /usr/portage/scripts/bootstrap.sh)
Stage2
- Installs libperl
- emerge system
Stage3
- emerges (NOTE: This list is no longer correct, but I can't fix it at the moment):
- syslog-ng
- grub
- hotplug
- coldplug
- vixie-cron
- slocate
- reiserfsprogs
- dosfstools
- e2fsprogs
- udev
- dhcpcd
- vim
- pciutils
- screen
- app-admin/sudo
- superadduser
- emerge --nodeps
- acpid
- ntp
- Sets up default runlevel (Adds syslog-ng, net.eth0, vixie-cron, sshd, hotplug, coldplug, acpid, ntpd)
- Updates time via ntp
- Sets timezone (Assumes GB)
- emerge gentoo-sources
- Copies a kernel configuration if the user so desires
- Gets user to configure kernel (make menuconfig) if it's set in the config
- Checks they're happy with it, then makes it (make && make modules_install) and installs the images
- Checks sanity in /etc/conf.d/rc
- Sets default hostname/domainname
- Skips:
- /etc/hosts modification
- Setting up autoload modules
- Multiple ethernet device configuration
- Sets up a default grub.conf and then lets user edit it
- Installs GRUB
- Edits /etc/fstab
- Asks user to set root password
- Adds a new user (via superadduser)
- Leaves chroot
99_cleanup
Cleans up after the chroot, unmounts everything and reboots. You should now have a fully-working Gentoo system! Don't forget to remove the LiveCD first...
detectfs
BASH script to identify filesystems. Ripped most of the detection code from the source of mount (except for NTFS and FAT32 - found those out myself). Might have been useful with the original direction of the script (i.e. full automation, no configuration file), but I now doubt it. Just for anyone who's interested and might find it useful though:
| File: detectfs |
#!/bin/bash
#
# Gentoo installation helper scripts, written by David Ingram
#
# They should help with a more automated installation of Gentoo Linux,
# and eventually with a fully automated install (with config file)
#
# Some parts of the installation based upon the Advanced Install guide on
# the Gentoo wiki at: [[HOWTO_Advanced_Install]]
#
#
# Attempts to detect filesystem type by checking the superblocks.
# Requires root privileges
# TODO: Add detection of XFS, JFS and others that people might use
LINUXONLY="yes" # Only think about Linux partition types
[[ `id -ur` -ne 0 ]] && echo "You must be root to check filesystems" && exit 1
for dev in $*; do
[[ $# -gt 1 ]] && out="${dev}: "
id=0
if [[ "$LINUXONLY" == "yes" ]]; then
sb=`head -c16 ${dev} | hex | sed -e's/ //g' | cut -d. -f3`
[[ "${sb}" == "NTFS" ]] && id=1 && echo "${out}NTFS"
sb=`head -c96 ${dev} | hex | egrep "^0050 " | sed -e's/ //g' | cut -d. -f3`
[[ "${sb}" == "FAT32" ]] && id=1 && echo "${out}FAT32"
fi
sb=`head -c1088 ${dev} | hex | egrep "^0430 " | cut -c32,33,35,36`
[[ "${sb}" == "53ef" || "${sb}" == "51ef" ]] && id=1 && echo "${out}ext2/3"
sb=`head -c4096 ${dev} | hex | egrep "^0ff0 " | sed -e 's/ //g' | cut -d. -f7`
[[ "${sb}" == "SWAPSPACE2" || "${sb}" == "SWAP-SPACE" ]] && id=1 && echo "${out}swap space"
sb=`head -c65600 ${dev} | hex | egrep "^10030 " | sed -e's/ //g' | cut -d. -f5`
[[ "${sb}" == "ReIsEr2Fs" || "${sb}" == "ReIsErFs" ]] && id=1 && echo "${out}reiserfs"
[[ $id -eq 0 ]] && echo "${out}Unknown"
done
|
functions.sh
Modified (heavily cut-down) version of the Gentoo /sbin/functions.sh file. I liked the pretty output, so I borrowed it.
Configuration files
This is preliminary documentation and subject to change.
Main configuration
This file contains the options for the overall installation, as well as the locations of the other config files.
| File: ./cfg_main |
# Location of partitioning info
partitionfile=./cfg_parts
# Location of filesystem info
fsfile=./cfg_fs
# Automatically detect and format swap partitions?
autoswap=yes
# Automatically search for best mirrors?
automirrors=no
# make.conf location
makeconf=./cfg_make
# Replace existing make.conf? (Done BEFORE mirrorselect otherwise appended afterwards)
makereplace=yes
# Location of list of packages to emerge after main installation complete
pkglist=./cfg_packages
# hdparm settings
hdparm_hdd=-d1c1u1
hdparm_cdd=-d1c1u1
# Initial stage tarball
stage=1
arch=x86
livecd="2005.0"
# Silent portage sync?
silent_sync=yes
# DistCC hosts
distcc_hosts="localhost"
# Various system package choices
logger=syslog-ng
bootmgr=grub
crond=vixie-cron
# filesystem programs are done automatically from reading fsfile above. If you want others,
# then add them to the pkglist.
# editor can be a space-separated list, first item is preferred editor
pref_editor=vim
# Set up runlevels
rl_default="${logger} net.eth0 ${crond} sshd hotplug coldplug acpid ntpd"
#rl_boot=
# I18n
# Timezone to link to
timezone=GB
# Keyboard map
kbdmap=uk
# Kernel sources and .config
#ksource=gentoo-sources
kconfig=./cfg_kernel
# Hostname/domainname
host=AutoLiveCD
domain=autoinstalled.gentoo.org
# /etc/hosts, autoload modules and multiple Ethernet devices
hostsfile=./cfg_hosts
hoststype=append # or replace
#autoload= # space-separated list of modules, or filename containing module on each line
#autoloadtype=list # or file
ethcards=1 # number of ethernet cards. creates links net.eth{n} to net.eth0, does nothing more
# GRUB config (note: I use GRUB, so I don't know about LILO config)
# Initial config file
grubconf=./cfg_grub
# Root drive, used in root and setup commands
grubroot=hd0,0
grubsetup=hd0
# Add users/groups after install (not implemented)
groupsconf=./cfg_groups
usersconf=./cfg_users
passwdconf=./cfg_passwd
|
Partition configuration
| File: ./cfg_parts |
# Number of drives drives=1 # First drive device drive1=/dev/hda # Number of partitions on this drive drive1parts=3 # Commands to send to fdisk for each partition. Note that comma will be replaced by newline drive1part1=p,1,,+64M,a,1 drive1part2=p,2,,+512M,t,2,82 drive1part3=p,3,, |
Filesystem configuration
The autoswap option in the main configuration file will cause the scripts to automatically detect and format any swap-format (type 82) partitions.
| File: ./cfg_fs (without autoswap) |
# Number of partitions to format parts=3 # Partition device part1=/dev/hda1 # Partition filesystem part1fs=ext2 # Partition mountpoint part1point=/boot # Partition 2 part2=/dev/hda2 part2fs=swap part2point=none # Partition 3 part3=/dev/hda3 part3fs=reiserfs part3point=/ |
| File: ./cfg_fs (with autoswap) |
# Number of partitions to format parts=2 # Partition 1 part1=/dev/hda1 part1fs=ext2 part1point=/boot # Partition 2 part2=/dev/hda3 part2fs=reiserfs part2point=/ |
Package configuration
Note: Not implemented yet
The package configuration is just a list of the full names of packages to emerge after installation. Just for a short example:
| File: ./cfg_pkg |
app-cdr/cdrtools games-fps/quake1 |
Users configuration
No format defined yet
Groups configuration
No format defined yet
Password configuration
No format defined yet
... work in progress [24 Oct 2005]
Concerns or Compliments? Please use the Discussion section.
Browse categories > Gentoo Linux Wiki > Subpages
Browse categories > Gentoo Linux Wiki > Wiki maintenance > To do
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and real estate agent tools.
