Difference between pages "Grub-install" and "User:Apple/projects/Transplant"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
(I corrected a typo.)
 
(Created page with "''a.k.a. I like my Linux how I like my women... <s>easy to set up</s>flexible.'' This is a script to backup and/or transfer a working Funtoo installation onto a fresh install (o...")
 
Line 1: Line 1:
This is an annotation about what grub-install does. This is based on the <code>=sys-boot/grub-1.98-r1</code> version.
''a.k.a. I like my Linux how I like my women... <s>easy to set up</s>flexible.''


<syntaxhighlight lang="bash">
This is a script to backup and/or transfer a working Funtoo installation onto a fresh install (on the same or a different host).
#! /bin/sh
</syntaxhighlight>
This tells the Linux kernel that this script will be executed with <code>/bin/sh</code>.
<syntaxhighlight lang="bash">


# Install GRUB on your drive.
It won't speed up an install and it doesn't make it easier, but with it you can do a single reboot
# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009  Free Software Foundation, Inc.
and have a complete working system without tedious config file editing.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
</syntaxhighlight>
This section tells that this script falls under the GNU General Public License.
<syntaxhighlight lang="bash">


# Initialize some variables.
==The Script==
transform="s,x,x,"


prefix=/usr
{| width="100%" cellpadding=0 cellspacing=0 style="margin: .5em 0; background-color: #f2fff2; border: solid 1px #bfffbf;"
exec_prefix=${prefix}
| style="background-color: #c1ffc1; border: solid 1px #a0ffa0; border-bottom: 1px solid #888; font-size: 0.9em" | '''Code:''' /usr/local/bin/transplant
sbindir=/sbin
|-
bindir=/bin
| style="padding: 0 0.5em; font-family=monospace, fixed; white-space: pre;"|  
libdir=/lib64
<tt><nowiki>
PACKAGE_NAME=GRUB
#!/bin/bash
PACKAGE_TARNAME=grub
# I use heavy amounts of bashisms
PACKAGE_VERSION=1.98
# ...see if you can find them all!
target_cpu=i386
platform=pc
host_os=linux-gnu
font=/usr/share/grub/ascii.pf2
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
</syntaxhighlight>
These are some variables set when Grub was configured for the system.
<syntaxhighlight lang="bash">


grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
# Copyright 2010 Daniel Cordero
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] || [ "${target_cpu}-${platform}" = "mips-yeeloong" ] ; then
# Licensed under the GPLv2
    grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
else
    grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}`
fi
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
rootdir=
grub_prefix=`echo /boot/grub | sed ${transform}`
modules=


install_device=
test "$PWD" = "$HOME" && cd /tmp # I don't clean up after myself
no_floppy=
force_lba=
recheck=no
debug=no


if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
# When I say "list", I mean space-separated (ahem... $IFS) list.
    disk_module=biosdisk
NETIF_LIST="" # List of interface initscripts
elif [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
SERVICES="" # List of services to be placed into default runlevel
    disk_module=
HOST_FILES="" # List of host-specific /etc files
else
ETC_FILES="" # List of generic/shared /etc files
    disk_module=ata
HOME_FILES="" # List of files in $HOME
fi
HOME_FOLDERS="" # List of folders in $HOME
</syntaxhighlight>
Further variables were initialized some of which were done so in a platform-dependent manner such as <code>disk_module</code> being set to <code>biosdisk</code> on i386-pc systems.
<syntaxhighlight lang="bash">


# Usage: usage
mkdir -p etc/{portage/{package.use,savedconfig,profile},runlevels/default}
# Print the usage.
mkdir -p etc/init.d
usage () {
mkdir -p home/$USER
    cat <<EOF
mkdir -p usr/lib/X11/xdm
Usage: grub-install [OPTION] install_device
mkdir -p var/lib/portage
Install GRUB on your drive.
mkdir -p host


  -h, --help              print this message and exit
rsync -ar --exclude .keep {/usr/,}local/
  -v, --version          print the version information and exit
rsync -r /etc/portage/{package.use,savedconfig,profile} etc/portage
  --modules=MODULES      pre-load specified modules MODULES
  --root-directory=DIR    install GRUB images under the directory DIR
                          instead of the root directory
  --grub-setup=FILE      use FILE as grub-setup
  --grub-mkimage=FILE    use FILE as grub-mkimage
  --grub-mkdevicemap=FILE use FILE as grub-mkdevicemap
  --grub-probe=FILE      use FILE as grub-probe
  --no-floppy            do not probe any floppy drive
  --recheck              probe a device map even if it already exists
  --force                install even if problems are detected
EOF
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
    cat <<EOF
  --disk-module=MODULE    disk module to use
EOF
fi
if [ "${target_cpu}-${platform}" = "mips-yeeloong" ] ; then
    cat <<EOF
  --font=FILE            font file to use
EOF
fi
    cat <<EOF


INSTALL_DEVICE can be a GRUB device name or a system device filename.
for service in $SERVICES; do
ln -sf /etc/init.d/$service etc/runlevels/default/$service
done


grub-install copies GRUB images into /boot/grub (or /grub on NetBSD and
for netif in $NETIF_LIST; do
OpenBSD), and uses grub-setup to install grub into the boot sector.
ln -sf /etc/init.d/netif.tmpl etc/init.d/netif.$netif
done


If the --root-directory option is used, then grub-install will copy
for home_folder in $HOME_FOLDERS; do
images into the operating system installation rooted at that directory.
rsync -ra $HOME/$home_folder/ home/$USER/$home_folder
done


Report bugs to <bug-grub@gnu.org>.
for home_file in $HOME_FILES; do
EOF
cp -a $HOME/$home_file home/$USER/$home_file
}
test x"$home_file" = "x.xinitrc" && ln -sf .xinitrc home/$USER/.xsession
</syntaxhighlight>
This sets up the usage message that <code>grub-install</code> prints if it doesn't understand what arguments it was given.
<syntaxhighlight lang="bash">
# Check the arguments.
for option in "$@"; do
    case "$option" in
    -h | --help)
usage
exit 0 ;;
    -v | --version)
echo "grub-install (GNU GRUB ${PACKAGE_VERSION})"
exit 0 ;;
    --modules=*)
modules=`echo "$option" | sed 's/--modules=//'` ;;
    --font=*)
font=`echo "$option" | sed 's/--font=//'` ;;
    --root-directory=*)
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
    --grub-setup=*)
grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;;
    --grub-mkimage=*)
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
    --grub-mkdevicemap=*)
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
    --grub-probe=*)
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
    --no-floppy)
no_floppy="--no-floppy" ;;
    --recheck)
recheck=yes ;;
    --disk-module=*)
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
          disk_module=`echo "$option" | sed 's/--disk-module=//'`
        fi ;;
    # This is an undocumented feature...
    --debug)
debug=yes ;;
    -f | --force)
        setup_force="--force" ;;
    -*)
echo "Unrecognized option \`$option'" 1>&2
usage
exit 1
;;
    *)
if test "x$install_device" != x; then
    echo "More than one install_devices?" 1>&2
    usage
    exit 1
fi
install_device="${option}" ;;
    esac
done
done
</syntaxhighlight>
This section parses the command line arguments and sets variables appropriately.
<syntaxhighlight lang="bash">


# for make_system_path_relative_to_its_root()
. ${libdir}/grub/grub-mkconfig_lib


if test "x$install_device" = x && test "${target_cpu}-${platform}" != "mips-yeeloong"; then
for etc_file in $ETC_FILES; do
    echo "install_device not specified." 1>&2
(test "x$(dirname $etc_file)" != "x." && \
    usage
test ! -d "$(dirname $etc_file)") && \
    exit 1
mkdir -p etc/$(dirname $etc_file)
fi
cp -a /etc/$etc_file etc/$(dirname $etc_file)/$(basename $etc_file)
</syntaxhighlight>
done


This block ensures that a destination device was specified to <code>grub-install</code> as an argument.
for host_file in ${HOST_FILES}; do
 
(test "x$(dirname $host_file)" != "x." && \
<syntaxhighlight lang="bash">
test ! -d "$(dirname $host_file)") && \
 
mkdir -p host/$(dirname $host_file)
# If the debugging feature is enabled, print commands.
cp -a /etc/$host_file host/$(dirname $host_file)/$(basename $host_file)
setup_verbose=
done
if test $debug = yes; then
    set -x
    setup_verbose="--verbose"
fi
</syntaxhighlight>
 
This block makes <code>grub-install</code> more verbose if grub was built with debugging enabled.
 
<syntaxhighlight lang="bash">
 
# Initialize these directories here, since ROOTDIR was initialized.
case "$host_os" in
netbsd* | openbsd*)
    # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
    # instead of /boot/grub.
    grub_prefix=`echo /grub | sed ${transform}`
    bootdir=${rootdir}
    ;;
*)
    # Use /boot/grub by default.
    bootdir=${rootdir}/boot
    ;;
esac
</syntaxhighlight>
Set up the location where Grub will be installed.
<syntaxhighlight lang="bash">
 
grubdir=${bootdir}/`echo grub | sed ${transform}`
device_map=${grubdir}/device.map
 
grub_probe="${grub_probe} --device-map=${device_map}"
 
# Check if GRUB is installed.
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
    set $grub_setup dummy
    if test -f "$1"; then
        :
    else
        echo "$1: Not found." 1>&2
        exit 1
    fi
fi
 
set $grub_mkimage dummy
if test -f "$1"; then
    :
else
    echo "$1: Not found." 1>&2
    exit 1
fi
 
set $grub_mkdevicemap dummy
if test -f "$1"; then
    :
else
    echo "$1: Not found." 1>&2
    exit 1
fi
</syntaxhighlight>
These blocks ensure that grub components are installed.
<syntaxhighlight lang="bash">
# Create the GRUB directory if it is not present.
test -d "$bootdir" || mkdir "$bootdir" || exit 1
test -d "$grubdir" || mkdir "$grubdir" || exit 1


# If --recheck is specified, remove the device map, if present.
cp -a {/,}usr/lib/X11/xdm/Xsetup_0
if test $recheck = yes; then
cp -a {/,}var/lib/portage/world
    rm -f $device_map
fi


# Create the device map file if it is not present.
tar cf $(hostname)-overlay.tar host/
if test -f "$device_map"; then
tar cf usrlocal-overlay.tar local/
    :
tar cf home-overlay.tar home/
else
tar cf funtoo-overlay.tar etc/ usr/ var/ \
    # Create a safe temporary file.
home-overlay.tar usrlocal-overlay.tar $(hostname)-overlay.tar
    test -n "$mklog" && log_file=`$mklog`
# DESTRUCTIVE
 
xz funtoo-overlay.tar # non-destructive
    $grub_mkdevicemap --device-map=$device_map $no_floppy || exit 1
</nowiki>
fi
</tt>
</syntaxhighlight>
|}
This creates the device map by calling <code>grub-mkdevicemap</code>. That program will create a mapping from the Grub device names to the Linux device nodes.
<syntaxhighlight lang="bash">
 
# Make sure that there is no duplicated entry.
tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \
    | sort | uniq -d | sed -n 1p`
if test -n "$tmp"; then
    echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2
    exit 1
fi
</syntaxhighlight>
This does some sanity checks on the device map file in case it has been manually corrected in an erroneous way.
<syntaxhighlight lang="bash">
 
# Copy the GRUB images to the GRUB directory.
for file in ${grubdir}/*.mod ${grubdir}/*.lst ${grubdir}/*.img ${grubdir}/efiemu??.o; do
    if test -f $file && [ "`basename $file`" != menu.lst ]; then
rm -f $file || exit 1
    fi
done
for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
    cp -f $file ${grubdir} || exit 1
done
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
    for file in ${pkglibdir}/*.img ${pkglibdir}/efiemu??.o; do
if test -f $file; then
    cp -f $file ${grubdir} || exit 1
fi
    done
fi
 
# Copy gettext files
mkdir -p ${grubdir}/locale/
for file in ${grubdir}/locale/*.mo ${pkglibdir}/locale/*.mo; do
    if test -f "$file"; then
        cp -f "$file" ${grubdir}/locale/
    fi
done
</syntaxhighlight>
This copies grub components and its localization files to the [[The_Root_Filesystem#.2Fboot_:_Static_files_of_the_boot_loader|boot]] directory.
<syntaxhighlight lang="bash">


# Write device to a variable so we don't have to traverse /dev every time.
==Usage==
grub_device=`$grub_probe --target=device ${grubdir}`


if ! test -f ${grubdir}/grubenv; then
Fill in the 6 variables at the top of the script. You'll constantly be adding more files as the original system gets more customised.
    $grub_editenv ${grubdir}/grubenv create
fi


# Create the core image. First, auto-detect the filesystem module.
When you're ready (or as a cron job), run the script and save the resulting tarball somewhere.
fs_module=`$grub_probe --target=fs --device ${grub_device}`
if test "x$fs_module" = x -a "x$modules" = x; then
    echo "Auto-detection of a filesystem module failed." 1>&2
    echo "Please specify the module with the option \`--modules' explicitly." 1>&2
    exit 1
fi


# Then the partition map module. In order to support partition-less media,
Boot your install environment. Partition, format and unpack (or work up to) a stage3. Grab a portage tree.
# this command is allowed to fail (--target=fs already grants us that the
# filesystem will be accessible).
partmap_module=`$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`


# Device abstraction module, if any (lvm, raid).
Unpack the main tarball (you probably don't want to unpack the other tarballs yet):
devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}`


# The order in this list is critical. Be careful when modifying it.
{{Root|<nowiki># tar xvJf --exclude "*.tar" funtoo-overlay.tar.xz -C /mnt/gentoo
modules="$modules $disk_module"
</nowiki>}}
modules="$modules $fs_module $partmap_module $devabstraction_module"
</syntaxhighlight>
Since Grub is modular, it needs the modules that allow it to recognize the boot directory. Consequently, it uses the <code>grub-probe</code> command to determine the modules necessary and adds them to the modules list in an appropriate order. Once it can recognize the boot directory, Grub can dynamically load modules as necessary and read its configuration file.
<syntaxhighlight lang="bash">


relative_grubdir=`make_system_path_relative_to_its_root ${grubdir}` || exit 1
Take a peek at the list of files in $HOST_FILES and edit them to the host's specification.
if [ "x${relative_grubdir}" = "x" ] ; then
    relative_grubdir=/
fi


prefix_drive=
{{Info|You cannot expect every host to have the exact geometry or architecture as the original host. If, by some miracle, the two are exactly alike, go ahead and unpack the host tarball (probably into <tt>/tmp</tt>).}}
config_opt=


if [ "x${devabstraction_module}" = "x" ] ; then
{{Info|The host tarball uses the prefix <tt>host/</tt> instead of the regular <tt>etc/</tt>. This is for your protection (and a limitation of the script... but mostly protection).}}
    if [ x"${install_device}" != x ]; then
      if echo "${install_device}" | grep -qx "(.*)" ; then
        install_drive="${install_device}"
      else
        install_drive="`$grub_probe --target=drive --device ${install_device}`"
      fi
      install_drive="`echo ${install_drive} | sed -e s/,[0-9]*[a-z]*//g`"
    fi
    grub_drive="`$grub_probe --target=drive --device ${grub_device}`"


    # Strip partition number
Chroot in and run (I suggest in a screen, nohup or another VT):
    grub_drive="`echo ${grub_drive} | sed -e s/,[0-9]*[a-z]*//g`"
{{Root|<nowiki># env-update; source /etc/profile
    if [ "$disk_module" = ata ] ; then
# emerge -uDN world</nowiki>}}
        # generic method (used on coreboot and ata mod)
        uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
        if [ "x${uuid}" = "x" ] ; then
          echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
          exit 1
        fi
        echo "search.fs_uuid ${uuid} root " > ${grubdir}/load.cfg
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
config_opt="-c ${grubdir}/load.cfg "
        modules="$modules search_fs_uuid"
    elif [ "x${grub_drive}" != "x${install_drive}" ] ; then
        uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
        if [ "x${uuid}" = "x" ] ; then
          echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
          exit 1
        fi
        echo "search.fs_uuid ${uuid} root " > ${grubdir}/load.cfg
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
config_opt="-c ${grubdir}/load.cfg "
        modules="$modules search_fs_uuid"
    fi
else
    prefix_drive=`$grub_probe --target=drive --device ${grub_device}`
fi
</syntaxhighlight>
Partitions can be moved around or initialized in a different order, so Grub wants to identify filesystems by their UUIDs. It also can load from a drive different from where it is installed. It does further probing to determine if the UUID module will be needed and includes it with the other modules.
<syntaxhighlight lang="bash">


if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
Wait (or finish configuration). Remember to make a kernel and <tt># boot-update</tt> (and installing the bootloader to MBR if necessary).
    $grub_mkimage ${config_opt} --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1


    # Now perform the installation.
Add an identical user (it's not in the script, but you might want to save the output of <tt>$ groups</tt>) and unpack <tt>home-overlay.tar</tt>. If you have anything in <tt>usrlocal-overlay.tar</tt> you can unpack that too.
    $grub_setup ${setup_verbose} ${setup_force} --directory=${grubdir} --device-map=${device_map} \
        ${install_device} || exit 1
elif [ "${target_cpu}-${platform}" = "mips-yeeloong" ] ; then
    $grub_mkimage ${config_opt} -f ${font} -d ${pkglibdir} -O elf --output=/boot/grub.elf --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
else
    $grub_mkimage ${config_opt} -d ${pkglibdir} --output=/boot/multiboot.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
fi


echo "Installation finished. No error reported."
{{Info|If you're installing on a different architecture, the contents of <tt>/usr/local</tt> may be useless for your CPU.
If you're lucky, it may be all architecture-independent/interpreted scripts, or nothing at all.}}


# Bye.
If all goes well, reboot (and remove the install environment)!
exit 0
</syntaxhighlight>
Grub finally uses the information about needed modules to create an image using <code>grub-mkimage</code>. The initial <code>boot.img</code> file is then modified to point to the <code>core.img</code> file that was just generated. That image is then installed to the desired installation device with <code>grub-setup</code>.
[[Category:Grub]]

Latest revision as of 14:19, November 17, 2010

a.k.a. I like my Linux how I like my women... easy to set upflexible.

This is a script to backup and/or transfer a working Funtoo installation onto a fresh install (on the same or a different host).

It won't speed up an install and it doesn't make it easier, but with it you can do a single reboot and have a complete working system without tedious config file editing.

The Script

Code: /usr/local/bin/transplant

#!/bin/bash # I use heavy amounts of bashisms # ...see if you can find them all! # Copyright 2010 Daniel Cordero # Licensed under the GPLv2 test "$PWD" = "$HOME" && cd /tmp # I don't clean up after myself # When I say "list", I mean space-separated (ahem... $IFS) list. NETIF_LIST="" # List of interface initscripts SERVICES="" # List of services to be placed into default runlevel HOST_FILES="" # List of host-specific /etc files ETC_FILES="" # List of generic/shared /etc files HOME_FILES="" # List of files in $HOME HOME_FOLDERS="" # List of folders in $HOME mkdir -p etc/{portage/{package.use,savedconfig,profile},runlevels/default} mkdir -p etc/init.d mkdir -p home/$USER mkdir -p usr/lib/X11/xdm mkdir -p var/lib/portage mkdir -p host rsync -ar --exclude .keep {/usr/,}local/ rsync -r /etc/portage/{package.use,savedconfig,profile} etc/portage for service in $SERVICES; do ln -sf /etc/init.d/$service etc/runlevels/default/$service done for netif in $NETIF_LIST; do ln -sf /etc/init.d/netif.tmpl etc/init.d/netif.$netif done for home_folder in $HOME_FOLDERS; do rsync -ra $HOME/$home_folder/ home/$USER/$home_folder done for home_file in $HOME_FILES; do cp -a $HOME/$home_file home/$USER/$home_file test x"$home_file" = "x.xinitrc" && ln -sf .xinitrc home/$USER/.xsession done for etc_file in $ETC_FILES; do (test "x$(dirname $etc_file)" != "x." && \ test ! -d "$(dirname $etc_file)") && \ mkdir -p etc/$(dirname $etc_file) cp -a /etc/$etc_file etc/$(dirname $etc_file)/$(basename $etc_file) done for host_file in ${HOST_FILES}; do (test "x$(dirname $host_file)" != "x." && \ test ! -d "$(dirname $host_file)") && \ mkdir -p host/$(dirname $host_file) cp -a /etc/$host_file host/$(dirname $host_file)/$(basename $host_file) done cp -a {/,}usr/lib/X11/xdm/Xsetup_0 cp -a {/,}var/lib/portage/world tar cf $(hostname)-overlay.tar host/ tar cf usrlocal-overlay.tar local/ tar cf home-overlay.tar home/ tar cf funtoo-overlay.tar etc/ usr/ var/ \ home-overlay.tar usrlocal-overlay.tar $(hostname)-overlay.tar # DESTRUCTIVE xz funtoo-overlay.tar # non-destructive

Usage

Fill in the 6 variables at the top of the script. You'll constantly be adding more files as the original system gets more customised.

When you're ready (or as a cron job), run the script and save the resulting tarball somewhere.

Boot your install environment. Partition, format and unpack (or work up to) a stage3. Grab a portage tree.

Unpack the main tarball (you probably don't want to unpack the other tarballs yet):

Template:Root

Take a peek at the list of files in $HOST_FILES and edit them to the host's specification.

Template:Info

Template:Info

Chroot in and run (I suggest in a screen, nohup or another VT): Template:Root

Wait (or finish configuration). Remember to make a kernel and # boot-update (and installing the bootloader to MBR if necessary).

Add an identical user (it's not in the script, but you might want to save the output of $ groups) and unpack home-overlay.tar. If you have anything in usrlocal-overlay.tar you can unpack that too.

Template:Info

If all goes well, reboot (and remove the install environment)!