Gentoo

Installation
http://en.gentoo-wiki.com/wiki/Safe_Cflags

http://www.gentoo.org/doc/en/gentoo-x86-quickinstall.xml

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml

http://en.gentoo-wiki.com/wiki/RAID/Software

http://en.gentoo-wiki.com/wiki/Software_RAID_Install

http://en.gentoo-wiki.com/wiki/Custom_Stage4

/dev/* /home/* /mnt/* /proc/* /sys/* /tmp/* /usr/portage/distfiles/* /var/tmp/*
 * 1) cat /root/misc/stage4.excl

$ cat /boot/grub/grub.conf default 0 timeout 3 title Gentoo Linux 2.6.37-r4 root (hd0,0) kernel /boot/kernel-2.6.37-gentoo-r4 root=/dev/md3

/dev/md1		/boot		ext3		noauto,noatime	1 2 /dev/md2		none		swap		sw		0 0 /dev/md3		/		ext3		noatime		0 1 /dev/md4		/home		ext3		noatime		0 1
 * 1) /etc/fstab: static file system information.
 * 2) 			 	 		 		

$ cat /etc/portage/package.use sys-libs/glibc userlocales sys-power/nut -usb sys-apps/iproute2 -minimal net-nds/openldap -minimal ssl dev-lang/php apache2 ctype curl gd hash ldap mysql nls pcre pdo session simplexml unicode xml net-misc/dhcp -minimal media-libs/gd jpeg png dev-perl/GD jpeg png net-dialup/mgetty -fax mail-mta/sendmail sasl mail-client/mutt -crypt imap dev-db/mysql -minimal net-analyzer/rrdtool -python perl sys-apps/smartmontools -minimal mail-filter/MailScanner f-prot spamassassin net-nds/openldap -ssl app-editors/nano -minimal x11-libs/cairo svg

$ cat /etc/portage/package.keywords sys-libs/pam ~amd64 net-nds/phpldapadmin ~amd64 sci-misc/boinc ~amd64 net-proxy/squid ~amd64 net-analyzer/squidsites ~amd64 net-firewall/fwanalog ~* * net-misc/hylafax ~amd64 net-dialup/mgetty ~amd64 net-analyzer/calamaris ~amd64 mail-filter/spamassassin ~amd64 mail-filter/MailScanner ~amd64 net-mail/tnef ~amd64 dev-perl/Filesys-Df ~amd64 app-admin/webmin ~amd64 net-firewall/shorewall-common ~amd64 net-firewall/shorewall-perl ~amd64

Kernel Config Files
config-server-x86_64-2.6.37-gentoo-r4

config-desktop-i686-2.6.38-gentoo-r6

http://kernel.xc.net/

http://how-to.wikia.com/wiki/How_to_configure_the_Linux_kernel

Favourite Kernel Config Options (Just For Fun)

B.A.T.M.A.N. Advanced Meshing Protocol (BATMAN_ADV)

Logging In
ssh username@ipaddress (type in your ssh passphrase) su - root (type in the root password) screen -r

Logging Out
Ctrl+A D Ctrl+D Ctrl+D

Rebooting The Server
reboot

Power Off The Server
poweroff

How Do I Check Something Has Started On Boot?
rc-status --all

How Do I Test Something Before I Make It Start On Boot?
/etc/init.d/ start

How Do I Make Something Start On Boot?
ls -lah /etc/init.d/   (to find out scriptname) rc-update add  default

How Do I Stop Something Starting On Boot?
ls -lah /etc/init.d/   (to find out scriptname) rc-update del  default

Links
http://www.littlefield.info/linux/gentoo_linux_faqs.txt

Turn Off Hardware Beep Sound For Terminal
http://www.cyberciti.biz/faq/how-to-linux-disable-or-turn-off-beep-sound-for-terminal/

Error - lpstat: Unable to connect to server
Edit the file /etc/cups/client.conf and change the ServerName line to your full hostname...

echo "ServerName `hostname -f`" > /etc/cups/client.conf

Fixing Various RAID Devices Error
If you see this error when starting up:-

* Starting up RAID devices ...                     [ !! ]

And you see this error when shutting down:-

mdadm: fail to stop array /dev/md0: Device or resource busy

...then remove the word raid from the RC_VOLUME_ORDER variable in /etc/conf.d/rc

RC_VOLUME_ORDER="evms lvm dm"

Change Preferred Minor MD Superblock On Software RAID Hard Disk
A hard disk drive failure on one of my servers prompted a manual software RAID 1 check and resync. Using good old SystemRescueCD, this was done but in doing so it inadvertently changed the preferred minor md superblock number on the array's hard disk drives from 3 to 124.

mdadm --misc --examine /dev/sda3 |grep 'Preferred Minor' Preferred Minor : 124

To fix this, stop the array and reassemble it again but update the superblock as it runs. Make sure you declare which hard disk drive partitions you are using as you assemble:-

mdadm --verbose --misc --stop /dev/md124 mdadm --verbose --assemble --update=super-minor --run /dev/md3 /dev/sda3 /dev/sdb3

To check it has worked, run the following 2 commands:-

mdadm --misc --examine /dev/sda3 |grep 'Preferred Minor' Preferred Minor : 3

cat /proc/mdstat md3 : active raid1 sdb3[0] sda3[1] 10490368 blocks [2/2] [UU]

How to Quickly Find and Replace Text Across Multiple Files with One Command
perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt

[RFC/RFT PATCH v3] sched: automated per tty task groups
This patch gives you the much talked about peformance boost... and yes, wow. :-)

You have to install the very latest kernel sources, then follow the instructions at http://forums.gentoo.org/viewtopic-t-852922.html

Here are my notes...

vaio-sabayon ~ # emerge =sys-kernel/vanilla-sources-2.6.37_rc2 vaio-sabayon ~ # eselect kernel list Available kernel symlink targets: [1]  linux-2.6.34-gentoo-r1 * [2]  linux-2.6.35-gentoo-r10 [3]  linux-2.6.36-gentoo [4]  linux-2.6.37-rc2 vaio-sabayon ~ # eselect kernel set 4 vaio-sabayon ~ # cd /usr/src/ vaio-sabayon /usr/src # ll total 88K drwxr-xr-x 7 root root 4.0K 2010-11-17 23:08. drwxr-xr-x 18 root root 4.0K 2010-06-17 04:35 .. -rw-r--r-- 1 root root  59K 2006-01-03 22:33 .config -rw-r--r-- 1 root root    0 2005-11-15 18:26 .keep lrwxrwxrwx 1 root root   16 2010-11-17 23:08 linux -> linux-2.6.37-rc2 drwxr-xr-x 24 root root 4.0K 2010-06-25 12:55 linux-2.6.34-gentoo-r1 drwxr-xr-x 24 root root 4.0K 2010-10-19 10:51 linux-2.6.35-gentoo-r10 drwxr-xr-x 23 root root 4.0K 2010-10-22 20:47 linux-2.6.36-gentoo drwxr-xr-x 23 root root 4.0K 2010-11-17 23:05 linux-2.6.37-rc2 drwxr-xr-x 7 root root 4.0K 2009-10-07 16:24 rpm vaio-sabayon /usr/src # cd linux vaio-sabayon /usr/src/linux # ll total 484K drwxr-xr-x 23 root root 4.0K 2010-11-17 23:05. drwxr-xr-x 7 root root 4.0K 2010-11-17 23:08 .. drwxr-xr-x 26 root root 4.0K 2010-11-17 23:05 arch drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 block -rw-r--r-- 1 root root  19K 2010-10-20 21:30 COPYING -rw-r--r-- 1 root root  92K 2010-10-20 21:30 CREDITS drwxr-xr-x 3 root root 4.0K 2010-11-17 23:05 crypto drwxr-xr-x 87 root root 12K 2010-11-17 23:05 Documentation drwxr-xr-x 89 root root 4.0K 2010-11-17 23:05 drivers drwxr-xr-x 37 root root 4.0K 2010-11-17 23:05 firmware drwxr-xr-x 70 root root 4.0K 2010-11-17 23:05 fs -rw-r--r-- 1 root root  936 2010-10-20 21:30 .gitignore drwxr-xr-x 20 root root 4.0K 2010-11-17 23:05 include drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 init drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 ipc -rw-r--r-- 1 root root 2.5K 2010-11-17 23:04 Kbuild -rw-r--r-- 1 root root  252 2010-11-17 23:04 Kconfig drwxr-xr-x 8 root root 4.0K 2010-11-17 23:05 kernel drwxr-xr-x 7 root root 4.0K 2010-11-17 23:05 lib -rw-r--r-- 1 root root 4.0K 2010-10-20 21:30 .mailmap -rw-r--r-- 1 root root 179K 2010-11-17 23:04 MAINTAINERS -rw-r--r-- 1 root root  51K 2010-11-17 23:04 Makefile drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 mm drwxr-xr-x 52 root root 4.0K 2010-11-17 23:05 net -rw-r--r-- 1 root root  18K 2010-11-17 23:04 README -rw-r--r-- 1 root root 3.3K 2010-10-20 21:30 REPORTING-BUGS drwxr-xr-x 9 root root 4.0K 2010-11-17 23:05 samples drwxr-xr-x 13 root root 4.0K 2010-11-17 23:05 scripts drwxr-xr-x 8 root root 4.0K 2010-11-17 23:05 security drwxr-xr-x 21 root root 4.0K 2010-11-17 23:05 sound drwxr-xr-x 5 root root 4.0K 2010-11-17 23:05 tools drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 usr drwxr-xr-x 3 root root 4.0K 2010-11-17 23:05 virt vaio-sabayon /usr/src/linux # cp /home/paully/Desktop/sched.patch. `/home/paully/Desktop/sched.patch' -> `./sched.patch' vaio-sabayon /usr/src/linux # ll total 496K drwxr-xr-x 23 root root 4.0K 2010-11-17 23:08. drwxr-xr-x 7 root root 4.0K 2010-11-17 23:08 .. drwxr-xr-x 26 root root 4.0K 2010-11-17 23:05 arch drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 block -rw-r--r-- 1 root root  19K 2010-10-20 21:30 COPYING -rw-r--r-- 1 root root  92K 2010-10-20 21:30 CREDITS drwxr-xr-x 3 root root 4.0K 2010-11-17 23:05 crypto drwxr-xr-x 87 root root 12K 2010-11-17 23:05 Documentation drwxr-xr-x 89 root root 4.0K 2010-11-17 23:05 drivers drwxr-xr-x 37 root root 4.0K 2010-11-17 23:05 firmware drwxr-xr-x 70 root root 4.0K 2010-11-17 23:05 fs -rw-r--r-- 1 root root  936 2010-10-20 21:30 .gitignore drwxr-xr-x 20 root root 4.0K 2010-11-17 23:05 include drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 init drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 ipc -rw-r--r-- 1 root root 2.5K 2010-11-17 23:04 Kbuild -rw-r--r-- 1 root root  252 2010-11-17 23:04 Kconfig drwxr-xr-x 8 root root 4.0K 2010-11-17 23:05 kernel drwxr-xr-x 7 root root 4.0K 2010-11-17 23:05 lib -rw-r--r-- 1 root root 4.0K 2010-10-20 21:30 .mailmap -rw-r--r-- 1 root root 179K 2010-11-17 23:04 MAINTAINERS -rw-r--r-- 1 root root  51K 2010-11-17 23:04 Makefile drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 mm drwxr-xr-x 52 root root 4.0K 2010-11-17 23:05 net -rw-r--r-- 1 root root  18K 2010-11-17 23:04 README -rw-r--r-- 1 root root 3.3K 2010-10-20 21:30 REPORTING-BUGS drwxr-xr-x 9 root root 4.0K 2010-11-17 23:05 samples -rw-r--r-- 1 root root  11K 2010-11-17 23:08 sched.patch drwxr-xr-x 13 root root 4.0K 2010-11-17 23:05 scripts drwxr-xr-x 8 root root 4.0K 2010-11-17 23:05 security drwxr-xr-x 21 root root 4.0K 2010-11-17 23:05 sound drwxr-xr-x 5 root root 4.0K 2010-11-17 23:05 tools drwxr-xr-x 2 root root 4.0K 2010-11-17 23:05 usr drwxr-xr-x 3 root root 4.0K 2010-11-17 23:05 virt vaio-sabayon /usr/src/linux # cat sched.patch | patch -p1 patching file include/linux/sched.h Hunk #3 succeeded at 1935 (offset -1 lines). patching file kernel/sched.c Hunk #2 succeeded at 616 (offset 10 lines). Hunk #3 succeeded at 2020 (offset 10 lines). Hunk #4 succeeded at 7967 (offset -17 lines). Hunk #5 succeeded at 8497 (offset -17 lines). Hunk #6 succeeded at 8522 (offset -17 lines). patching file kernel/fork.c patching file drivers/tty/tty_io.c patching file kernel/sched_autogroup.h patching file kernel/sched_autogroup.c patching file kernel/sysctl.c patching file init/Kconfig patching file Documentation/kernel-parameters.txt vaio-sabayon /usr/src/linux # make && make modules_install vaio-sabayon ~ # cp arch/x86/boot/bzImage /boot/kernel-2.6.37-rc2 vaio-sabayon ~ # cp System.map /boot/System.map-2.6.37-rc2 vaio-sabayon ~ # cp .config /boot/config-2.6.37-rc2 vaio-sabayon ~ # reboot vaio-sabayon ~ # cat /proc/sys/kernel/sched_autogroup_enabled 1 vaio-sabayon ~ # uname -r 2.6.37-rc2

Oh yeah... very nice - much faster and smoother - seriously :-)

Bluetooth Headset With Skype
echo "net-wireless/bluez test-programs" >> /etc/portage/package.use emerge -pv net-wireless/bluez emerge -q net-wireless/gnome-bluetooth

http://en.gentoo-wiki.com/wiki/Bluetooth_headset

ERROR: Gnome: DBus error org.gtk.Private
Open gconf-editor, go to apps>nautilus>preferences and uncheck media_automount and media_automount_open

Manually Fixing Broken Portage
http://www.gentoo.org/proj/en/portage/doc/manually-fixing-portage.xml

Tinderbox Precompiled Packages
http://tinderbox.dev.gentoo.org/default-linux/amd64/sys-apps/

Getting Beautiful Fonts
http://www.kev009.com/wp/2009/12/getting-beautiful-fonts-in-gentoo-linux/

Verbose Check A Disk Drive
fsck.ext3 -f -v -C0 -p /dev/sdc1

Installing Ubuntu One
Switch to root user.

su - root

Install layman.

emerge layman

Fetch the latest Gentoo Ubuntu One overlay.

layman --fetch --overlays git://github.com/michael-manley/Gentoo-Ubuntu-One-Overlay.git --add gentoo-ubuntu-one

Check that it is installed locally.

layman -l

Update your list of packages.

eix-update

Search for ubuntu.

eix ubuntu

Install package ubuntuone-client.

emerge -q ubuntuone-client

Shoreline Firewall (Shorewall) Tips
To list the connections from an IP address.

conntrack -L -s 192.168.0.103

To drop all the connections from an IP address.

conntrack -D -s 192.168.1.102

It can take up to 1 minute to drop all of them, so be patient. You can then restart shorewall and be certain any NEW connections (not ESTABLISHED ones) will be accounted for.

Rsync Over SSH
Copy from remote to local

/usr/bin/rsync -a -e ssh username@192.168.0.x:~/path/to/folder/ ~/my/local/folder/

Copy from local to remote

/usr/bin/rsync -a -e ssh ~/my/local/folder/ username@192.168.0.x:~/path/to/folder/

Spaces In File Or Folder Name
If you want to rsync a file or folder with spaces in the file name, you have to escape and put double-quotes around both the local and remote shell parts of the command.

e.g.

/usr/bin/rsync -a -e ssh "username@192.168.0.x:\"~/path/to/folder/with spaces\"" ~/my/local/folder/