# IBM Thinkpad T40, T41, T42 Gentoo Linux install guide by az [AT] ezhikov.net (http://horizon.ath.cx/gentoo)
# "Gentoo: LFS for people who think they don't have time for shit like that" - Lesha
# The Gentoo developers, in their infinite wisdom, have decided not to develop an installer until recently.
# Until the installer is completed, here's a list of things you want to do to install Gentoo and KDE on a T40.
# This is a concise guide. For novel-sized explanations, see http://gentoo.org/doc/en/handbook

# Interactive: configure network (use ifconfig or any other method if you're not booting from a gentoo livecd)
net-setup eth1
# To read this and install side-by-side:
# screen <ctrl-A> <shift-S> links http://horizon.ath.cx/gentoo <ctrl-A> <tab> <ctrl-A> <ctrl-C>
# Interactive: set partitions (one primary bootable partition per drive, and one swap partition)
cfdisk

mke2fs -j -L label -m 0.01 -O dir_index /dev/sda1
mount -o noatime,nodiratime /dev/sda1 /mnt/gentoo
# Disable boot-time filesystem checks
tune2fs -c 0 -i 0 /dev/sda1
tune2fs -L Blackbird /dev/sda1
tune2fs -O has_journal -o journal_data /dev/sda1

# Software suspend (hibernate) doesn't support file swap extents
#dd if=/dev/zero of=/mnt/gentoo/swapfile1 bs=1M count=2048
#mkswap /mnt/gentoo/swapfile1 && chmod 600 /mnt/gentoo/swapfile1
mkswap -L tank /dev/sda2

# Download stage3, portage (change your arch to amd64 if you're on it)
ARCH=x86
cd /
wget http://gentoo.osuosl.org/releases/$ARCH/current/stages -r -l 1 -A 'stage3-*.tar.bz2' --no-directories
wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2
tar -xvjpf stage3-*.tar.bz2 -C /mnt/gentoo
tar -xvjf portage-latest.tar.bz2 -C /mnt/gentoo/usr
mirrorselect -a -s4 -o | grep 'GENTOO_MIRRORS=' >> /mnt/gentoo/etc/make.conf
cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
mount -t proc none /mnt/gentoo/proc
chroot /mnt/gentoo /bin/bash
env-update; source /etc/profile; emerge --sync

mkdir /usr/local/portage
echo 'PORTDIR_OVERLAY="/usr/local/portage"' >> /etc/make.conf
echo 'CLEAN_DELAY="2"' >> /etc/make.conf
echo 'MAKEOPTS="-j2"' >> /etc/make.conf
echo 'FEATURES="${FEATURES} parallel_fetch"' >> /etc/make.conf
echo 'CONFCACHE_DIR="/root/confcache"' >> /etc/make.conf

echo 'VIDEO_CARDS="ati"'>>/etc/make.conf
echo 'INPUT_DEVICES="mouse keyboard evdev"'>>/etc/make.conf
echo 'LANG="en_US.utf8"' >> /etc/env.d/02locale
echo 'LC_ALL="en_US.utf8"' >> /etc/env.d/02locale
echo 'HOSTNAME="blackbird"' >> /etc/conf.d/hostname
echo 'DNSDOMAIN="nodomain"' >> /etc/conf.d/domainname
# Reboot in 5 seconds after a panic
echo 'kernel.panic=5' >> /etc/sysctl.conf
# Choose your timezone...
ln -sf /usr/share/zoneinfo/PST8PDT /etc/localtime
ln -sf /usr/share/zoneinfo/EST5EDT /etc/localtime

# Interactive: edit /etc/make.conf
# To check available USE flags: less /usr/portage/profiles/use.desc
# After setting USE flags, you should "emerge -avtND world"
# e.g., you must recompile ncurses if you set the unicode flag, otherwise packages that use it will fail to emerge
# Here is my make.conf: http://horizon.ath.cx/gentoo/make.conf
nano -w /etc/make.conf
emerge -avtND world

# Interactive: set users/passwords
passwd
for user in "ezhik" "loshadka"; do
	useradd $user -m -G users,wheel,audio -s /bin/bash
	passwd $user
done

# Set partitions in /etc/fstab
# If you don't want boot-time filesystem checks, set fs_passno (the 6th field) to 0.
# You may also wish to set additional mount options (e.g., noatime,nodiratime,commit=10000) (install noflushd to utilize that last option).
sed -i 's/\/dev\/BOOT/\/#dev\/BOOT/' /etc/fstab
sed -i 's/\/dev\/ROOT/LABEL=Blackbird/' /etc/fstab

# Download kernel
emerge tuxonice-sources

# Essential system components
emerge metalog logrotate vixie-cron hotplug dhcpcd grub app-admin/sudo sys-apps/at acpid iptables netplug lvm2 nfs-utils pm-utils
# Other system and T40-specific programs
emerge -n pciutils usbutils pcmciautils hibernate-script reiser4progs ethtool hdparm sdparm
rc-update add hotplug default
rc-update add net.eth0 default
rc-update add autofs default
rc-update add acpid default
rc-update add metalog default
rc-update add vixie-cron default
rc-update add iptables default
rc-update add sshd default
rc-update add samba default
rc-update add portmap default
rc-update add hibernate-cleanup boot

# If you have more than 1 battery and need to control which one is discharging, emerge tp_smapi

sed -i 's/CLOCK="UTC"/CLOCK="local"/' /etc/conf.d/clock
# ln -s /etc/init.d/net.lo /etc/init.d/net.eth1
echo 'dhcp_all="nodns"'>>/etc/conf.d/net
echo '#!/bin/sh
ntpdate -s time.windows.com && hwclock --systohc' > /etc/cron.daily/ntpsync
chmod +x /etc/cron.daily/ntpsync
echo '#!/bin/sh
nice emerge --sync' > /etc/cron.weekly/emerge-sync
chmod +x /etc/cron.weekly/emerge-sync

echo 'echo enable,0xffff8f > /proc/acpi/ibm/hotkey
/usr/sbin/ethtool -s eth0 wol d
/sbin/ifconfig eth1 up; /sbin/ifconfig eth1 down

hdparm -B 255 /dev/sda || /bin/true
hdparm -B 255 /dev/sdb || /bin/true
echo -n 250 > /sys/devices/platform/i8042/serio1/serio2/sensitivity
echo -n 190 > /sys/devices/platform/i8042/serio1/serio2/speed
echo LID > /proc/acpi/wakeup
echo 1 > /sys/module/snd_ac97_codec/parameters/power_save
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done

echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
echo min_power > /sys/class/scsi_host/host1/link_power_management_policy
' >> /etc/conf.d/local.start

# This grub setup can boot Windows from a second hdd in ultrabay.
echo 'timeout 2
default 0
fallback 1
title Linux
#TODO: make this work with labels
kernel (hd0,0)/boot/vmlinuz root=/dev/sda1 resume=swap:/dev/sda2 hpet=force
title Windows
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader +1' > /boot/grub/grub.conf

echo 'root (hd0,0)
setup (hd0)
quit' > /boot/grub/grub.batch
cat /boot/grub/grub.conf /boot/grub/grub.batch | grub --batch

# Interactive: configure kernel
# Critical kernel options:
# acpi, bigmem, Pentium M arch, virtual FSs, radeonfb, e1000, wifi, samba, bluetooth, CPU freq scaling, eventd, ...
# Here's my config: http://horizon.ath.cx/gentoo/.config
cd /usr/src/linux; make menuconfig && make && make install && make modules_install && update-modules

# Optional: reboot

# This will take a few hours. Select the packages you want.
# Add "-avt" to emerge args to see the dependencies and confirm before emerging.
# KDE core
emerge kdebase-startkde
# KDE base packages
emerge -n konqueror konq-plugins kate konsole kdeprint kappfinder kdcop kdesu kfind khotkeys kmenuedit knetattach kpager kscreensaver kstart ksysguard ksystraycmd kxkb klipper kdeartwork-kscreensaver
# Konqueror plugins to display various file metadata
emerge -n kdeaddons-kfile-plugins kdegraphics-kfile-plugins kdemultimedia-kfile-plugins kdenetwork-kfile-plugins kdesdk-kfile-plugins
# Packages currently release-synchronized with KDE
emerge -n kpdf ark klaptopdaemon networkstatus kde-base/kopete kdevelop kdbg quanta korganizer cervisia kooka kompare kaudiocreator kdemultimedia-kioslaves kcharselect kgamma
# Packages on their own release schedules
emerge -n k3b knemo amarok kaffeine showimg kile kio-locate krename wlassistant ksynaptics kdebluetooth yakuake khexedit ktorrent

bonding: Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details.

# "Here's a damn big clue: the reason I find gnome limiting is BECAUSE IT IS."
# - Linus Torvalds

# NB: eclipse is not well-supported in Portage. It's better to just download and use it from your user directory.
emerge -n sun-jdk php ruby gdb emacs vim bluefish tetex latex-unicode doxygen enscript aspell aspell-en ipython strace
emerge -n freetype corefonts freefonts artwiz-fonts sharefonts terminus-font ttf-bitstream-vera intlfonts cronyx-fonts
emerge -n gtk-engines-qt audacity blender inkscape xchat mozilla-firefox mozilla-thunderbird openoffice nspluginwrapper
emerge -n ntp cvs rcs subversion links curl unison keychain dev-util/git
emerge -n wireshark nmap whois netcat socat iftop tcpdump fail2ban traceroute geoip iperf bind-tools iproute2 pptpclient metasploit ftp ncftp rkhunter stunnel rdiff-backup
emerge -n screen potrace tree tcsh bin2iso rar unrar unarj unace unzip p7zip dos2unix byacc sys-process/time bash-completion gentoo-bashcomp wdiff colordiff agrep rpm rpm2targz xfsprogs xfsdump
emerge -n imagemagick dcraw jhead exiftags hugin dvdbackup wmctrl modplugplay vcdimager lame snes9x dosbox mdf2iso xev xbacklight
emerge -n htop lsof lshw cdemu procinfo dosfstools dmidecode dnotify mdadm smartmontools copyfs schedutils
emerge -n hal bluez-utils alsa-utils alsa-oss cups foomatic mlocate wpa_supplicant nopaste
emerge -n radeontool rovclock synaptics
emerge -n gentoolkit gentoolkit-dev portage-utils layman overlay-utils
emerge -n units octave octave-forge koctave PDL maxima raster3d weka bioperl biopython R rkward gnuplot xfig graphviz
emerge -n clustalw hmmer ncbi-tools emboss probcons sim4 seaview t-coffee pymol vienna-rna phylip wise
emerge -n anthy scim-uim skim

# Scanner support
emerge -n iscan sane-backends

# Server only
emerge -n trac setuptools mediawiki apache
emerge --unmerge ssmtp
emerge -n postfix dovecot fetchmail bind dnsmasq

rc-update add hald default
rc-update add bluetooth default
rc-update add alsasound default
rc-update add cupsd default
for user in "ezhik" "loshadka"; do gpasswd -a $user plugdev; done

# Interactive: configure X
Xorg -configure; cp /root/xorg.conf.new /etc/X11/xorg.conf
sed -i 's/\/dev\/mouse/\/dev\/input\/mice/' /etc/X11/xorg.conf
# If X fails to start after this, try xorgcfg -textmode or xorgconfig
# You may want to tweak xorg.conf, in particular set ati driver options, enable synaptics for the touchpad, etc.:
# http://horizon.ath.cx/gentoo/xorg.conf

rc-update add xdm default
echo 'DISPLAYMANAGER="kdm"' >> /etc/conf.d/xdm

# Interactive: Set kdm to launch X without the checker background and with the DPI you like. Find and change this line:
# ServerArgsLocal="-br -dpi 110"
nano -w /usr/kde/3.*/share/config/kdm/kdmrc

# Reboot into your shiny new KDE
reboot -n

# Interactive: associate Bluetooth mouse
# Find the device ID on the mouse or use kbluetoothd configuration->configure services->device discovery->add device to get device ID
# Press the connect button on the mouse
hidd --connect 00:50:F2:7F:3F:3F
echo 'HIDD_ENABLE=true' >> /etc/conf.d/bluetooth

amixer set Master 100% unmute
amixer set PCM 70% unmute

# ACPI scripts: see the following:
# http://bugs.gentoo.org/show_bug.cgi?id=99446
# http://www.gentoo.org/doc/en/power-management-guide.xml
# /usr/src/linux/Documentation/ibm-acpi.txt
emerge -avt acpi-support
rc-update add acpi-support default
/etc/init.d/acpid restart

# Prevent cron from trying to send mail to root
sed -i 's/MAILTO=/#MAILTO=/' /etc/crontab

# Delete the distribution packages
rm /usr/portage/distfiles/*; rm -rf /var/tmp/portage/*

# Update the following files with your favorite versions:
# /etc/hosts - http://someonewhocares.org/hosts/
# ~/.bashrc, ~/.bash_profile - http://horizon.ath.cx/gentoo/.bashrc | http://horizon.ath.cx/gentoo/.bash_profile
# ~/.screenrc - http://michael-prokop.at/computer/config/.screenrc | http://horizon.ath.cx/gentoo/.screenrc
# ~/.emacs
# To enable bash autocompletion: echo "source /etc/bash_completion" >> ~/.bashrc
# To enable colordiff: change /usr/bin/colordiff, line "my $show_banner = 1" to 0; echo "alias diff='colordiff'" >> ~/.bashrc
# You may want to run "cp /etc/skel/.bash_profile /root" if you plan to customize root's .bashrc
touch /var/log/root_mail; ln -s /var/log/root_mail /root/dead.letter

# ALSA configuration [TODO]
# http://horizon.ath.cx/gentoo/asound.conf

# Now spend some time configuring KDE (use the Control Center).
# The Page Back/Forward keys can be enabled by selecting a fancy keyboard model in Regional...->Keyboard Layout.
# Go to Appearance...->GTK Styles... to make GTK apps use the current KDE (Qt) theme.
# You can set up knemo context menu actions to run wlassistant, bring eth0/1 up/down, etc.
# To prevent displaying category headers in K Menu:
sed -i 's/\[menus\]/\[menus\]\nShowMenuTitles=false/' ~/.kde/share/config/kickerrc

# Install a hotswap rule for ultrabay
(cd /etc/hal/fdi/information; wget horizon.ath.cx/gentoo/10-ultrabay.fdi)
# NB: Disk hot-swapping will not work on disks with a password set, since libata doesn't support entering the password!
# Bug fix for xorg losing synaptics touchpad
echo 'KERNEL=="event?", ATTRS{name}=="SynPS/2 Synaptics TouchPad", SYMLINK="input/synaptics"'>>/etc/udev/rules.d/40-personal.rules
# edit xorg.conf touchpad section to point to /dev/input/synaptics and use protocol "event" not "auto-dev" (which is broken)

# To enable binary delta download support: http://gentoo-wiki.com/HOWTO_Install_Deltup
emerge -avt deltup bdelta getdelta

echo 'FETCHCOMMAND="/usr/bin/getdelta.sh \${URI}"' >> /etc/make.conf

# Webmin
emerge webmin
# I like this theme: http://www.stress-free.co.nz/files/theme-stressfree.tar.gz
# (run rm /usr/libexec/webmin/theme-stressfree/message.html after install)
# (Install other modules at the Webmin site)
# Remove the following modules: ADSL, CD Burner, Command Shell, File Manager, Frox FTP Proxy, Jabber IM Server, SSH/Telnet Login, Upload and Download

# Quick Portage guide:
# Good flags to always use when emerging: emerge -avtN
# To unmask a hard-masked Portage package: grep package_name /usr/portage/profiles/package.mask >> /etc/portage/package.unmask
# To accept a certain "~x86" version of a package: echo "~category/package_name-version ~x86" >> /etc/portage/package.keywords
# To force-install a package not available for your arch: echo "category/package_name -*" >> /etc/portage/package.keywords (or you may need "~*")
# To search for installed/available packages by name: emerge search package_name
# To search for a package in all indexed overlays: emerge eix; update-eix; update-eix-remote update; eix -e package
# To examine an installed package: equery (size|files|depends|depgraph) package_name; equery belongs filename
# To inject an ebuild into your tree: put it in an overlay; run "ebuild /path/to/ebuild digest"
# To install a specific older version of a package: emerge -avt =category/package-version
# To avoid putting a package into /var/lib/portage/world: emerge -1 (--oneshot) package_name
# To inject a patch: ebuild x unpack; patch it, ebuild x compile install qmerge (see ebuild file for any other methods that need to be called)
# To forbid Portage from emerging a package: echo "category/package_name-version" >> /etc/make.profile/package.provided
# To resume emerge after a failed ebuild and/or skip that ebuild: emerge --resume --skipfirst
# Always run revdep-rebuild after re-merging binary libraries
# To correct color usage on a light terminal: echo -e 'MERGE_LIST_PROGRESS = "red"' > /etc/portage/color.map

# If you use Java, run java-config --list-available-packages; java-config --append-system-classpath=package1,package2,...
# after emerging extra libraries.
# Run glsa-check regularly to scan for security vulnerabilities:
# emerge -avtn1 `glsa-check -l|grep '\[N\]'|perl -ne'/\((.+)\)/; map { print "$_ " if { glob "/var/db/pkg/$_-*" } } split /\s+/, $1;'`

# General tips:
# To add a user to a group: gpasswd -a user group; to modify users/groups: usermod/groupmod
# To substitute strings in a file: sed -i 's/foo/bar/' file; to drop the first/last 5 lines in a stream: head -n -5, tail -n -5
# To compute math in bash: $((a+b))
# To start all services that are supposed to run in the current runlevel: rc
# In X, ctrl+alt+esc loads xkill
# In amarok, mousewheel over tray icon changes volume, ctrl+mousewheel changes track, shift+mousewheel skips, middle click pauses
# In bash, ctrl+R does command history quicksearch. Pressing ctrl+R again cycles through matches earlier in history
# Bind lst, lss, lsx, lsrt, lsrs, lsrx = ls -t, ls -S, ls -X, ls -r, - sort by timestamp/size/extension/reverse
# Unlike the rest of KDE prefs, K menu customizations are in ~/.local/share, not ~/.kde
# To quickly create a temporary ramdisk: mount -t tmpfs -o size 512m none /mnt/ramdisk
# To convert a VCD image into an avi-contained mpeg: emerge vcdimager; vcdxrip -b image.bin
# To convert an .mdf/.mds image to iso: mdf2iso image.mdf
# To override dvd drive locking: sdparm --command=unlock /dev/cdroms/cdrom0
# To link directories without soft symlinks: mount --bind /path1 /path2
# To allow external clients to connect to X: make sure you're not passing "-nolisten tcp" to X (check ServerArgsLocal in /usr/kde/*/share/config/kdm/kdmrc;
# use "xhost +hostname" to add a host to the list of clients allowed to connect; then use ssh -X or "DISPLAY=hostname /my/program"
# To resolve a hostname into an ip in a shell script: "host hostname"
# Use strace to trace system calls made by a program and their contents

# Bonding multiple network adapters:
# http://gentoo-wiki.com/HOWTO_Setup_Bonded_ethernet_adapters (omit mode=1; want mode=0 - round robin, default)

# Put this into /etc/crontab for reference:
# minute (0-59),
# |     hour (0-23),
# |     |       day of the month (1-31),
# |     |       |       month of the year (1-12),
# |     |       |       |       day of the week (0-6 with 0=Sunday).
# |     |       |       |       |       commands
#*/5    *       *       *       *       echo 'Run me every 5 minutes'

# Firefox extensions to get:
# Tab mix plus | google suggest | downthemall | permit cookies | fasterfox | Live HTTP Headers
# From http://ted.mielczarek.org/code/mozilla/ : nuke anything | fxif | tab preview | flash click to view | plain text links
# From http://imagezoom.yellowgorilla.net/ : imagezoom
# From http://extensionroom.mozdev.org/more-info/keyconfig : keyconfig

# Useful sites:
# http://gentoo-wiki.com
# http://forums.gentoo.org
# http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml
# http://dev.gentoo.org/~plasmaroo/devmanual/ | http://dev.gentoo.org/~g2boojum/portage.html
# More links at http://ref.horizon.ath.cx


# Micro-howto: Creating master and slave nodes for clustering
# See also: http://horizon.ath.cx/cluster
# You need to enable the "Root filesystem on NFS" option on your master's kernel (this won't prevent local booting).
emerge tftp-hpa dhcp syslinux nfs-utils ganglia pvm torque maui copyfs
mkdir /diskless; cd /diskless
# Change your arch to amd64 if you're on it
ARCH=x86
wget http://gentoo.osuosl.org/releases/$ARCH/current/stages -r -l 1 -A 'stage3-*.tar.bz2' --no-directories
tar -xvjpf stage3-*.tar.bz2 /diskless
echo 'touch /fastboot' >> etc/conf.d/local.start
ln -s etc/init.d/sshd etc/runlevels/default
mkdir pxelinux.cfg; cp /boot/vmlinuz boot; cp /usr/lib/syslinux/pxelinux.0 .
echo 'default boot/vmlinuz
append ip=dhcp root=/dev/nfs nfsroot=10.0.0.4:/diskless' >> pxelinux.cfg/default

sed -i 's/\/dev\/ROOT/\/dev\/nfs/' etc/fstab
echo 'none /home tmpfs size=512m 0 0' >> etc/fstab
#mount -t tmpfs -o size 512m none /mnt/ramdisk
#echo '10.0.0.4:/diskless / nfs sync,hard,intr,rw,nolock 0 0' >> etc/fstab

echo 'INTFTPD_PATH="/diskless"' >> /etc/conf.d/in.tftpd
echo '/diskless 10.0.0.0/24(sync,rw,no_root_squash,no_all_squash)' >> /etc/exports
rc-update add in.tftpd default
rc-update add dhcpd default
rc-update add nfs default

# I haven't found a way to make the host statement generic - looks like you need to mention every node by MAC and IP
echo 'ddns-update-style none;
next-server 10.0.0.4;
subnet 10.0.0.0 netmask 255.255.255.0 {
option range 10.0.0.10 10.0.0.255;
option routers 10.0.0.1;
option domain-name-servers 208.67.222.222, 208.67.220.220;
option subnet-mask 255.255.255.0;
}
host node1 {
hardware ethernet xx:xx:[node 1 mac];
fixed-address 10.0.0.10;
filename "pxelinux.0";
}' > /etc/dhcp/dhcpd.conf

chroot /diskless /bin/bash
passwd
# ... Configure according to your needs ...
# Alternatively, you can mount the server's own bin sbin lib lib32 lib64 usr ... read-only.
# You can also use pxegrub instead of syslinux.


# Micro-howto: Creating and using a svn repository
svnadmin create ~/svn
svn import /path/to/project/dir file:///${HOME}/svn/project
svn co file:///${HOME}/svn/project
svn up file:///${HOME}/svn/project
svn list file:///${HOME}/svn/project
svn commit TODO


# Micro-howto: self-signed HTTPS for the default vhost
cd /etc/apache2/ssl
# For a passphrased key, which starts the server only if a password is supplied: openssl genrsa -des3 -out server.key 1024; otherwise:
openssl genrsa -out server.key 1024
openssl rsa -in server.key -out server.pem
openssl req -new -key server.pem -out server.csr
openssl x509 -req -days 1000 -in server.csr -signkey server.pem -out server.crt
sed -i 's/APACHE2_OPTS="-D DEFAULT_VHOST"/APACHE2_OPTS="-D DEFAULT_VHOST -D SSL -D SSL_DEFAULT_VHOST"/' /etc/conf.d/apache2
sed -i 's/server.key/server.pem/' /etc/apache2/modules.d/41_mod_ssl.default-vhost.conf


# "The user is encouraged to explode and experiment with other functions or settings..."
# - http://www.stanford.edu/group/CIFE/ce222/Reference/labxmove.html

# __END__

# Micro-howto: Bandwidth management and traffic shaping
# All traffic management services on Linux depend on the iproute2 utils, which in turn depend on kernel modules toggled by options CONFIG_NET_SCH*.
emerge iproute2


# Micro-howto: proxying (see privoxy?)

# See also:
# http://lartc.org/howto/
# http://www.docum.org/docum.org/faq/cache/

# TODO: To rescind httpd authentication for a subnet:

# transkode staden

# Micro-howto: Creating an encrypted loopback volume, home directory, or root filesystem
emerge cryptsetup-luks

# Loopback volume
touch /path/to/volume
shred -n1 -s5G /path/to/volume
losetup /dev/loop0 /path/to/volume
cryptsetup -y create mycrypt /dev/loop0
mke2fs -j -O dir_index /dev/mapper/mycrypt

echo '#!/bin/bash
blah blah
losetup /dev/loop0 /path/to/volume
cryptsetup create mycrypt /dev/loop0
mount /dev/mapper/mycrypt /mnt/volume' >> mount-script
echo '#!/bin/bash
umount /mnt/volume
cryptsetup remove mycrypt
losetup -d /dev/loop0' >> umount-script

# Micro-howto: Using unison/rsync and unionfs for transparent workgroup versioning
mount -t unionfs -o dirs=dir1:dir2:dir3 none uniondir
mount -t unionfs -o dirs=/usr/src/linux-mod:/usr/src/linux=ro none /usr/src/linux-work
See also: copyfs

# Micro-howto: Using start-stop-daemon and writing an init.d script

pam_mount-- BROKEN --
echo 'auth optional /lib/security/pam_mount.so use_first_pass'>>/etc/pam.d/login
echo 'session optional /lib/security/pam_mount.so'>>/etc/pam.d/login


# TODO: emerge leafnode and nntp client daemon micro-howto
# http://ozlabs.org/~jk/docs/mergefb/
# TODO: zip contents of /etc/portage/*
# http://gentoo-wiki.com/HOWTO_Anonymity_with_Tor_and_Privoxy
# http://gentoo-wiki.com/HOWTO_Port_Knocking (for e.g. samba)
#http://theorie.physik.uni-wuerzburg.de/~arwagner/computer/T41p/
#airsnort kiconeditor systemconfigurator usbview cdrecord-prodvd mp3burn pinfo dev-embedded/avr-gcc dev-embedded/avr-libc dev-embedded/uisp cdmp3 dcd mp3_check oxine net-analyzer/cacti netperf portmap sys-cluster/mpich sys-devel/gettext autofs
#usb.hotplug: onadd: copy /etc/twocards /etc/alsa.conf onremove: copy /etc/onecard /etc/alsaconf
# fubar'd things:
# dvi-lcd, alsa config, xkb/kxkb/skim, acpi scripts
# unified filepicker for qt/gnome/gtk/ooo
	17 - Configuring ALSA - Correctly
	[code]# emerge alsa-utils[/code]
	Since alsa 0.9 (i believe) there has been an excellent configurator script included for ALSA
	[code]# alsaconf[/code]
	17.3 - the asoundrc/asound.conf file
	www.phaeronix.net has made an excellent asound.conf file, here is the url to it, copy it and past it in either ~/user/.asoundrc, or /etc/asound.conf
	Go to the "Alsa Config" Section[/code]
	17.4 - Editing Additional Files
	[code]# nano /etc/modules.d/alsa
	<Find near the botton snd-***, and sound-***>
	change *** to your sound card name, for example...
	snd-intel8x0 sound-intel8x0
	snd-emu10k1 sound-emu10k1[/code]
	[code]# rc-update add alsasound default[/code]
	Now alsa should be successfully configured, and configured right - Additional tools you may use could be, alsamixer, amixer, etc

set ulimits before running apps in debug to prevent runaways/swap death

portage wishlist:
- background/parallel fetch
- automatic revdep rebuild
- automatic blocker resolution
- delta fetching+server
- binary package infrastructure
- tinderboxes
- integrated registered overlay package search
- registered overlay and cross-overlay dependency syntax
- integrated full-tree revdep search
- integrated full-tree file ownership search
- bring back the real packages.gentoo.org

bash wishlist:
- below-the-line autocompletion choices
- fish features: ?
- auto-suggest xargs on args overflow
linux wishlist:
- swap death prevention
# Colored with sh2html.pl