Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Faketoo



I just finished setting up a "fake" Gentoo installation inside a chroot jail.
Seems to work pretty well for development, I can experiment with no fear of
sodding up my actual workstation. In case anyone is interested, I have
attached a "Captain's Log" (think commented shell script) detailing the
commands that I ran to build my "Faketoo" instance.

Cheers,
Josh

-- 
Josh Glover

GPG keyID 0xDE8A3103 (C3E4 FA9E 1E07 BBDB 6D8B  07AB 2BF1 67A1 DE8A 3103)
gpg --keyserver pgp.mit.edu --recv-keys DE8A3103
# Faketoo: Building a development Gentoo install inside a chroot jail
# ---------------------------------------------------------------------------

# Insert Gentoo i686 LiveCD (Disc 1)
mount /mnt/cdrom

# Create chroot jail
sudo mkdir ~/faketoo
sudo chown root:root ~/faketoo
sudo chmod 755 ~/faketoo

# Install Gentoo in jail
cd ~/faketoo
sudo tar xvjpf /mnt/cdrom/stages/stage3-pentium4-20040218.tar.bz2
sudo tar xvjf /mnt/cdrom/snapshots/portage-20040223.tar.bz2 -C usr/
sudo mkdir usr/portage/distfiles/
sudo cp /mnt/cdrom/distfiles/* usr/portage/distfiles/
sudo cp -ar /lib/modules ~/faketoo/lib/modules
sudo rm -rf ~/faketoo/dev
sudo mkdir ~/faketoo/dev
sudo chown root:root ~/faketoo/dev
sudo chmod 755 ~/faketoo/dev

# Swap Gentoo Pentium4 Package CD into CDROM drive
umount /mnt/cdrom

# Enter jail
sudo mount -o bind -t devfs /dev ~/faketoo/dev
sudo mount -t proc none ~/faketoo/proc
sudo cp /etc/resolv.conf ~/faketoo/etc/
sudo chroot ~/faketoo /bin/bash
env-update
source /etc/profile
export PS1=': \u@example.com; '

# Create "boot" script, which will turn on all necessary services
echo '#!/bin/bash' >/boot.sh
chmod +x /boot.sh

# Set localtime
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime

# Create /etc/fstab
cat >/etc/fstab <<EOF
/dev/cdroms/cdrom0      /mnt/cdrom      iso9660         noauto,ro,user  0 0
EOF

# Setup networking
echo faketoo >/etc/hostname
echo domain.tld >/etc/dnsdomainname
echo '/etc/init.d/domainname start' >>/boot.sh

# Configure rc.conf
sed -i -e 's/^EDITOR/#EDITOR/' -e 's/^#\(EDITOR=.\+vim"\)$/\1/' /etc/rc.conf 

# Fix USE flags
sed -i -e 's/^USE="\(.\+\)"$/USE="\1 -gpm"/' /etc/make.conf

# Setup Portage to use binary packages when available
mount /mnt/cdrom
export PKGDIR=/mnt/cdrom

# Install system logger and cron daemon
emerge -k syslog-ng
echo '/etc/init.d/syslog-ng start' >>/boot.sh
emerge -k vixie-cron
echo '/etc/init.d/vixie-cron start' >>/boot.sh

# Setup root's environment
passwd
cat >~/.bashrc <<EOF
export PS1=': \u@example.com; '
export PS2=': ; '
EOF

# Accounts management
groupadd juser
useradd juser -m -g juser -G users,wheel,audio,games -s /bin/bash
passwd juser
cat >~juser/.bashrc <<EOF
export PS1=': \u@example.com; '
export PS2=': ; '
EOF

# Install a decent editor
emerge vim

# Setup sudo
emerge -k sudo
sed -i -e 's/^# \(%wheel\tALL=(ALL)\tALL\)$/\1/' /etc/sudoers
cat >>/etc/sudoers <<EOF
Defaults        !lecture,timestamp_timeout=60
EOF

# Leave jail
umount /mnt/cdrom
exit

# Create virgin image
umount /mnt/cdrom
cd
sudo tar cvjf ~/faketoo.tbz2 faketoo

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links