Archive

Posts Tagged ‘Linux’

Ubuntu 10.04 USB Lock-Ups

July 24th, 2010 Comments off

I recently installed Ubuntu 10.04 LTS on one of my desktop PCs here at home. Love Ubuntu. Easy to use, very compatible with most devices, good plug and play. Don’t get me wrong (for those hardcore Linux folks) I like tinkering with Linux as much as anyone, but I also have work to get done. Fighting for hours getting dual monitors or the right drivers working keeps me from getting that work done. Ok, sorry for the quick rant, back to the subject.

I noticed after installation when I would go to start plugging in some of my external devices via USB the dang thing would lock up on me. That is, desktop completely frozen, unable to remotely ssh into the box, just plain dead.

So, I tried various things and what have you and nothing appeared to help.

My solution was:

apt-get remove modemmanager

Simple as that. I haven’t had any lock-ups, system has been up for several days and I’ve been able to add my alfa wireless and my magic jack to the box without any crashes. Hope this may help you too!

Categories: Linux Tags: , , , , ,

Pure-FTP with Database Authentication

July 24th, 2009 Comments off

LinuxPure-FTP is  a powerful ftp server. If you are like me however, you don’t like to create system accounts for each individual user. Well, this is where we are in luck! Pure-FTP has the ability to tie into both PostgreSQL and MySQL.  In this example I have tied it into a PostgreSQL database. I will also include the MySQL snippet of the configuration but it hasn’t been tested by me. Also note that this is a Gentoo based installation but the general configuration should be the same.

Install Pure-FTP with MySQL and/or PostgreSQL support:

# > vi /etc/make.conf
– add ‘postgres’ and/or ‘mysql’ to the USE flag or:

#> USE=”mysql postgres” emerge -av net-ftp/pure-ftpd

Now that Pure-FTP is installed with the various database support, we can configure Pure-FTP to authenticate off of a database. You may need to tailor the SQL queries to match the schema of your database.

PostgreSQL:

#>  vi /etc/pureftpd-pgsql.conf

# If PostgreSQL listens to a TCP socket
PGSQLServer localhost
PGSQLPort 5432
# *or* if PostgreSQL can only be reached through a local Unix socket
# PGSQLServer /tmp
# PGSQLPort .s.PGSQL.5432
# Mandatory : user to bind the server as.
PGSQLUser [pureftpd]
# Mandatory : user password. You *must* have a password.
PGSQLPassword [pureftpd_password]
# Mandatory : database to open.
PGSQLDatabase [pureftpd_database]
# Mandatory : how passwords are stored
# Valid values are : “cleartext”, “crypt”, “md5″ and “any”
#PGSQLCrypt cleartext
PGSQLCrypt crypt

# In the following directives, parts of the strings are replaced at
# run-time before performing queries :
#
# \L is replaced by the login of the user trying to authenticate.
# \I is replaced by the IP address the user connected to.
# \P is replaced by the port number the user connected to.
# \R is replaced by the IP address the user connected from.
# \D is replaced by the remote IP address, as a long decimal number.
#
# Very complex queries can be performed using these substitution strings,
# especially for virtual hosting.
# Query to execute in order to fetch the password
PGSQLGetPW SELECT password FROM ftp_users WHERE ftp_user=’\L’
# Query to execute in order to fetch the system user name or uid
PGSQLGetUID SELECT uid FROM ftp_users WHERE ftp_user=’\L’
# Optional : default UID – if set this overrides PGSQLGetUID
#PGSQLDefaultUID 1000
# Query to execute in order to fetch the system user group or gid
PGSQLGetGID SELECT gid FROM ftp_users WHERE ftp_user=’\L’
# Optional : default GID – if set this overrides PGSQLGetGID
#PGSQLDefaultGID 1000
# Query to execute in order to fetch the home directory
PGSQLGetDir SELECT dir FROM ftp_users WHERE ftp_user=’\L’
#########OPTIONAL SETTINGS#############
# Optional : query to get the maximal number of files
# Pure-FTPd must have been compiled with virtual quotas support.
# PGSQLGetQTAFS SELECT QuotaFiles FROM users WHERE User=’\L’
# Optional : query to get the maximal disk usage (virtual quotas)
# The number should be in Megabytes.
# Pure-FTPd must have been compiled with virtual quotas support.
# PGSQLGetQTASZ SELECT QuotaSize FROM users WHERE User=’\L’
# Optional : ratios. The server has to be compiled with ratio support.
PGSQLGetRatioUL SELECT ul_ratio FROM ftp_users WHERE ftp_user=’\L’
PGSQLGetRatioDL SELECT dl_ratio FROM ftp_users WHERE ftp_user=’\L’
# Optional : bandwidth throttling.
# The server has to be compiled with throttling support.
# Values are in KB/s .
PGSQLGetBandwidthUL SELECT ul_bandwidth FROM ftp_users WHERE ftp_user=’\L’
PGSQLGetBandwidthDL SELECT dl_bandwidth FROM ftp_users WHERE ftp_user=’\L’

Now we need to modify the pure-ftpd config file (keep in mind this is Gentoo)

#> vi /etc/conf.d/pure-ftpd

Look for the line: AUTH=”-l unix” and change to:

AUTH=”-l pgsql:/etc/pureftpd-pgsql.conf

#> /etc/init.d/pure-ftpd restart

This should conclude your intstallation of Pure-FTP with Postgres database support.

MySQL Config File:

Coming Soon!

A couple of little tweaks that I’ve had to use for some of the configurations.

If you want all users to go to the same directory and don’t have or want to store the directory information in the database you can change this line in the pureftpd-pgsql.conf:

PGSQLGetDir SELECT ‘/home/ftpdir’ FROM ftp_users WHERE ftp_user=’\L’

Simple Interface Bonding (Gentoo)

June 22nd, 2009 Comments off

GentooIts often necessary to add bonding (NIC teaming – in windows world) to a linux config. This gives you 2 things: higher throughput on the interfaces and redundancy (if a card or switch happens to die). I made this post just as a quick reference for how to do such on a Gentoo system.

This article assumes that you have the proper kernel configuration to support bonded interfaces.

Device Driver => Network device support => <M> Bonding driver support

Load the necessary modules for bonding and install the necessary packages.

linux# modprobe bonding
linux# echo “bonding” >> /etc/modules.autoload.d/kernel-2.6
linux# emerge net-misc/ifenslave

Configure the interfaces: vi /etc/conf.d/net

config_eth0=( “null” )
config_eth1=( “null” )
slaves_bond0=”eth0 eth1″
config_bond0=( “10.10.10.69/24″ )
routes_bond0=( “default gw 10.10.10.1″ )

Start the interface and setup to start on boot.

linux# ln -s /etc/init.d/net.lo /etc/init.d/net.bond0
linux# rc-update add net.bond0 default
linux# /etc/init.d/net.bond0 start

If you have eth0 and/or eth1 setup to start on boot already you will need to delete those init scripts.
linux# rc-update del net.eth0; rc-update del net.eth1

Test

Apache mod_log_sql (review)

May 28th, 2009 No comments

LinuxAfter some reading of consolidation options for Apache logs, I ran across mod_log_sql (we are hating spread) which will take Apache logs and log them off to a MySQL database. Sounded great! We could then run scripts to go through and parse the values and run statistics on. Twas perfect for our needs. RIGHT!!!

At my company we run about 12 vhosts over about 5-6 load balanced web servers. All of them were configured to log to our loganalysis server which is a pretty beefy machine. The logging all in all worked well with a few major exceptions listed below.

1) I used the directive:

LogSQLRequestIgnore .gif .jpg .css .ico .png .js

This directive is supposed to be used to ignore any pages ending with that extension. This did not work at all and I had to create a script to actually delete those before analyzing the logs. Bummer but not that big of a deal.

2) While working with the server to optimize the database, there were various times when I would need to restart the MySQL service and a few times I needed to reboot the server. During these periods of time, the web servers were unable to log to the database which brought them to their knees. The inability of the module to handle a database outage gracefully was a major deal breaker for us. I feel this issue is a result of intense disk IO when the database is down. The server is logging to its Apache logs, the the backup SQL logs, and to the Apache error logs for every failed request. This becomes emense with thousands of requests per second. Should this server die or needing maintenance would have ultimately brought our company to a hault.

Long story short, we’re scrapping mod_log_sql and going with an NFS mount out to all the web services which we can then parse and run statistics on using some custom scripts and/or AWStats or Splunk.

Squid Proxy (how-to)

May 26th, 2009 No comments

LinuxWhile I enjoy using the SSH Tunnels to encrypt traffic out of the random local networks that I may be sitting on, sometimes there is a need to establish a more permanent proxy server. For instance, if you don’t have a means to use an SSH client or you have several machines that you would like to service without the need to establish dedicated SSH tunnels/forwards for each machine (administrative nightmare).

I chose Squid for just this function. It was extremely easy to setup and has worked like a charm! Below are some of the basic steps for setting up and using your Squid proxy.

Install Squid:

Gentoo:
#> emerge squid

Red Hat/CentOS:
#> yum install squid

Ubuntu/Debian:
#> apt-get install squid

OpenBSD:
#> export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.4/packages/i386/
#> pkg_add squid

Basic Configuration for Transparent Proxy:

#> vi /etc/squid/squid.conf

Look for the sections listed below and modify accordingly. This is a sample of my ACLs and configurations outside of some of the defaults.

#/etc/squid/squid.conf
acl all src 0.0.0.0/0.0.0.0
acl trusted_hosts 192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0
acl localhost src 127.0.0.1/255.255.255.255
acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 443         # https
acl Safe_ports port 21         # ftp
acl CONNECT method CONNECT

# Deny requests to unknown ports
http_access deny !Safe_ports
# Deny CONNECT to other than SSL ports
http_access deny CONNECT !SSL_ports

http_access allow localhost
http_access allow trusted_hosts
http_access deny all

# Listening port (default 3128)
http_port 3128

# Visible Hostname (may not be needed but doesn’t hurt)
visible_hostname yourserverhostname

This is the basic configuration that should get you going. More advanced configuration options will be coming soon.

Start up Squid:

#> /etc/init.d/squid start

Set Squid to start on-boot (optional)

Gentoo:
#> rc-update add squid default

Red Hat/CentOS:
#> chkconfig squid on

Ubuntu/Debian:
#> update-rc.d squid defaults

OpenBSD:
#> vi /etc/rc.local
Code coming soon…

Configure your Browser:
This is an example Firefox setup. Preferences –> Advanced –> Network –> Connection –> Settings. Select ‘Manual proxy configuration:’ Set the HTTP Proxy: value to your Squid server’s IP (public or private depending on how you are going to use it and based on the ACLs above). Then select ‘Use this proxy server for all protocols’ if you want to go ahead and use this same proxy for all connections.  Setup any exceptions to not proxy (i.e. – locally connected servers). Here’s a screen shot of my configuration.

SSL Configuration:
Coming soon…

Advanced Configurations:
Coming soon…

Categories: Linux, Security Tags: , , ,

SSH Proxy (how-to)

May 23rd, 2009 No comments

TerminalSSH Proxying is one of my every day tools. Sitting at work with a Barracuda firewall looking, snooping, and possibly blocking everything that I do. Hanging at a coffee shop when you see a suspicious person most likely snooping your information out of the air. In the first case I’m primarily just trying to get around a hurdle. In both cases I want my traffic encrypted and hidden from 3rd parties.

What is SSH Proxying?
This is a means of setting up a Secure Shell (SSH) and then piping your various web requests across this pipe or tunnel.

I’ve got 2 different SSH Proxies that I use daily.

Web Traffic – SSH Tunnel/Proxy:

ssh -CqN -D 8080 [username]@[hostname]

For above tunnel I’m using the following:

-D: bind port – in this case 8080 locally
-C: enables compression
-q: quiet mode (suppresses any warnings)
-N: don’t execute any remote commands

The -CqN are just some bells and whistles I use for the connection but not required. Please see below on configuring your browser to use the newly established SSH Tunnel.

Various other traffic (IRC, VNC, Torrent, etc…) – SSH Port Forwarding

ssh -L 6667:irc.[hostname]:6667 [username]@[hostname]

In this example, I’m binding a local port (-L 6667) to a remote boxes port (6667) through the server I have SSH’ed into. You can also add some of the bells and whistles from the web proxy to this one as well. Please see below for using this port forward with and IRC client.

Configuring the Browser:
The general idea (for Firefox) is to go to: Preferences –> Advanced –> Network –> Connection –> Settings. Select ‘Manual proxy configuration’. Set SOCKS Host: localhost Port: 8080. Click OK/Save and you should be good to go.

Here’s a screen shot of my settings:

Firefox SSH Proxy Config

Categories: Linux, Mac, Security, Unix Tags: , , , , , ,

bwm-ng (command line bandwidth monitor)

May 21st, 2009 No comments

bwm-ng is a great little command line bandwidth monitor. HUGE fan. Its available with most all distros so use your favorite package manager to add it. Works on all *nix distributions including the Mac too.

bwm-ng home page: http://www.gropp.org/?id=projects&sub=bwm-ng

On the Mac it works great with a little application called GeekTool (will cover more later) with the following options:

/Users/derek/Applications/bwm-ng/bin/bwm-ng -o plain -c 1

Gentoo XFCE4 Install (issue resolved)

May 21st, 2009 No comments

Per a co-workers recommendation for my old thinkpad I enherited from me mom, I’m installing XFCE4 instead of Gnome on my Gentoo lappy (http://www.gentoo.org/doc/en/xfce-config.xml). I ran into a pretty big issue where I could not get ‘media-libs/netpbm’ installed. Well, after numerous: ‘emerge –depclean’ and ‘emerge –update –newuse world’s I’ve finally got it installed. There seemed to be an issue with ‘getline’ which after some research is part of a C++ library. Well, I wound up seeing that the folowing packages weren’t even installed:

sys-libs/libstdc++-v3
virtual/libstdc++

I’m not sure which exactly did it, but I installed both and was able to get netpbm installed. Whoohoo!

Categories: Linux Tags: , ,

Basic Gentoo Install (with LVM and Raid)

May 20th, 2009 1 comment

Boot the System
When booting make sure the system will boot from CD and insert the Gentoo 2007.0 minimal boot CD, the GUI is good but we have a lot more control for our installation procedures.

To boot the system we need to have 3 options in the boot command:

* docache – This will cache the contents of the CD
* doraid – This will load the RAID kernel modules
* dolvm2 – This loads the logical volume manager kernel modules

gentoo docache doraid dolvm2

When the system is booting accept the default language of US English, this will load the correct keymaps for us to continue.

Network Setup
Most likely our network already loaded correct but to be sure we will run the net-setup command, it is a pretty straightforward dialog based installer.

livecd ~ # net-setup eth0

Setup Remote Access (optional at this point)

For those of you who prefer not to do your work from the an inconvenient location, feel free to start remote access early.

livecd ~ # passwd
livecd ~ # /etc/init.d/sshd start

Setup Filesystems
This will be one of the more complicated parts of the installation procedure, there is a lot of commands that need to be run in the correct sequence.

Load Kernel Modules
The following kernel modules should already be loaded due to our boot options, however, just to be on the safe side we will manually run the commands.

livecd ~ # modprobe raid1
livecd ~ # modprobe dm-mod

Filesystem Scheme
We will be using a fairly standard default scheme for all our systems. The following layout will be mostly suitable for all possible servers, the only exception will be swap which as a general rule of thumb should be twice the size of the available physical memory.

Mount Point Size Partition Type

/boot 100M /dev/sda1 Linux raid autodetect (fd)

swap 1024M /dev/sda2 Linux swap / Solaris (82)

/ 2048M /dev/sda3 Linux raid autodetect (fd)

lvm2 Remaining space /dev/sda4 Linux raid autodetect (fd)

Setup Partitions and RAID
Our next step is to create the disk layout, we will use cfdisk to do this, it is a lot easier to use than fdisk. Once we have the partition layout setup on the primary drive we can go ahead and duplicate it on the second disk, we want to avoid possible mistakes by duplicating it by blocks rather than using cfdisk again.

Next we will create the block devices and setup the raid arrays, the block devices would be setup automatically, however, it is always a good idea to avoid potential problems by doing the task manually just to be certain.

cfdisk /dev/sda (previous scheme)
mkdir /mnt/sda
dd if=/dev/sda of=/mnt/sda/my-sda.mbr count=1 bs=512
sfdisk -d /dev/sda > /mnt/sda/my-sda.sf
dd if=/mnt/sda/my-sda.mbr of=/dev/sdb
sfdisk /dev/sdb < /mnt/sda/my-sda.sf
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2
mknod /dev/md3 b 9 3
mknod /dev/md4 b 9 4
mdadm –create /dev/md1 –level=1 –raid-devices=2 /dev/sda1 /dev/sdb1
mdadm –create /dev/md2 –level=1 –raid-devices=2 /dev/sda2 /dev/sdb2
mdadm –create /dev/md3 –level=1 –raid-devices=2 /dev/sda3 /dev/sdb3
mdadm –create /dev/md4 –level=1 –raid-devices=2 /dev/sda4 /dev/sdb4

The array builds may take quite a long time and we need it to finish before we can proceed to the next step, we can monitor the build process by watching /proc/mdstat, warning, this can take quite a long time to finish so get a coffee, go for a smoke anything.

livecd ~ # cat /proc/mdstat

”Note”: Technically you don’t have to wait before you start using the RAID, once you’ve finished the above commands and the RAID has written its configuration, it is from that point accessible and perfectly safe to work with, but while it’s striping speed will be diminished significantly. Make your own choice for what is suitable.

Create the logical volumes
The logical volume step is pretty straightforward when you know the processes that are happening, initially we scan and check for any existing volume groups, once again there shouldn’t be any, however, best to be certain, next we enable volume group alterations, then we create our physical volume using /dev/md4 this is a mirrored disk. Finally we do a vgcreate to create our volume group.

Now that we have our volume group created we just need to create the logical volumes, we have a predefined format for this:

* /usr – 8G
* /usr/portage – 2G
* /usr/portage/distfiles – 4G
* /home – 10G
* /opt – 4G
* /var – 4G
* /var/tmp – 6G

vgscan
vgchange -a y
pvcreate /dev/md4
vgcreate vg /dev/md4
lvcreate -L8G -nusr vg
lvcreate -L2G -nportage vg
lvcreate -L4G -ndistfiles vg
lvcreate -L10G -nhome vg
lvcreate -L4G -nopt vg
lvcreate -L4G -nvar vg
lvcreate -L6G -nvartmp vg
lvcreate -L2G -ntmp vg
vgs
lvs

Setup Filesystems
Our next step is to create the filesystems themselves, we are using two different filesystem types, firstly for /tmp, /var/tmp and /boot we are using ext2, ext2 is a very quick filesystem, however, it can be risky since it is not journaled therefore we only use it for filesystems we can afford to loose or in the case of /boot a filesystem that is usually not mounted and therefore not at risk in the event of a power outage.

The second filesystem we use is JFS this is IBM’s journaled filesystem, in total across most benchmarks it averages a higher performance than most other filesystem types, it also has a major advantage that you can set your log device to be on a different physical device than your filesystem, which would aid in recovery in the event of a very serious outage.

mke2fs /dev/md1
mkfs.jfs /dev/md3
mkfs.jfs /dev/vg/distfiles
mkfs.jfs /dev/vg/home
mkfs.jfs /dev/vg/opt
mkfs.jfs /dev/vg/portage
mke2fs /dev/vg/tmp
mkfs.jfs /dev/vg/usr
mkfs.jfs /dev/vg/var
mke2fs /dev/vg/vartmp
mkswap /dev/md2
swapon -p 1 /dev/md2
swapon -v -s

Mount Filesystems
Next we mount all our filesystems so we can proceed with the installation process, it is simple, however, don’t make any mistakes accidentally mounting the the wrong filesystem in the wrong place could lead to serious problems.

mount /dev/md3 /mnt/gentoo
cd /mnt/gentoo
mkdir boot home usr opt var tmp
mount /dev/md1 /mnt/gentoo/boot
mount /dev/vg/usr /mnt/gentoo/usr
mount /dev/vg/home /mnt/gentoo/home
mount /dev/vg/opt /mnt/gentoo/opt
mount /dev/vg/tmp /mnt/gentoo/tmp
mount /dev/vg/var /mnt/gentoo/var
mkdir usr/portage var/tmp
mount /dev/vg/vartmp /mnt/gentoo/var/tmp
mount /dev/vg/portage /mnt/gentoo/usr/portage
mkdir usr/portage/distfiles
mount /dev/vg/distfiles /mnt/gentoo/usr/portage/distfiles
chmod 1777 /mnt/gentoo/tmp /mnt/gentoo/var/tmp

Portage and Stages

Set the System Date
Now we need to ensure our date is set correctly, we do this using the date command:

livecd gentoo # date 112615222007

Stages and Snapshot
Our next step is to get the stage file and the portage snapshots.

cd /mnt/gentoo
links gentoo.org
time tar xjpf stage3*
cd /mnt/gentoo/usr
time tar xjf ../portage-lat*

Setup Environment

Chroot
Now we get to the start of the real installation, we do this by chrooting to our new environment, it is pretty easy to do.

Firstly we mount the proc filesystem on the new mountpoints, and copy our /etc/resolv.conf file across, /etc/resolv.conf is what is used to resolve DNS information, then we change our root to the new root filesystem, finally we update all our libraries and paths to the new filesystems.

cd /
mount -t proc proc /mnt/gentoo/proc
(optional for LILO instead of GRUB install) livecd / # mount -o bind /dev /mnt/gentoo/dev
cp -L /etc/resolv.conf /mnt/gentoo/etc/
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile

Zone Information
Next we need to set up our zone information, we just need to copy across our correct zone information file.

ls /usr/share/zoneinfo
cp /usr/share/zoneinfo/US/Eastern /etc/localtime

Hostname
Now we need to set up our correct hostname, please remember to substitute the the example name and IP address to the actual name you will be using.

livecd / # nano -w /etc/hosts

(Update 127.0.0.1 to be 127.0.0.1 localhost.localdomain localhost
add 192.168.1.25 subversion.dmm subversion
note change the ip address to the one you are actually using and the hostname
to be the hostname to the name you are using)

Install the Kernel
Installing the kernel can be a very difficult process if you are not sure what you are doing, however, we will make it as easy as possible, by following these simple steps.

livecd etc # emerge gentoo-sources
livecd etc # cd /usr/src/linux
livecd linux # time make -j2

livecd linux # make modules_install
livecd linux # cp arch/i386/boot/bzImage /boot/bzImage

genkernel:
livecd linux # emerge genkernel
livecd linux # genkernel –lvm2 –dmraid –menuconfig all

Configure the System

Edit /etc/fstab
/etc/fstab is where we define all of our filesystems to be used on our new system.

livecd linux # cd /etc
livecd etc # nano -w fstab
/dev/md1 /boot ext2 noauto,noatime 1 2
/dev/md3 / jfs noatime 0 1
/dev/md2 none swap sw,pri=1 0 0
/dev/vg/usr /usr jfs noatime 1 2
/dev/vg/portage /usr/portage jfs noatime 1 2
/dev/vg/distfiles /usr/portage/distfiles jfs noatime 1 2
/dev/vg/home /home jfs noatime 1 2
/dev/vg/opt /opt jfs noatime 1 2
/dev/vg/tmp /tmp ext2 noatime 1 2
/dev/vg/var /var jfs noatime 1 2
/dev/vg/vartmp /var/tmp ext2 noatime 1 2

Configure Network

livecd etc # cd conf.d
livecd conf.d # echo ‘config_eth0=( “192.168.1.25/24″ )’ >> net
livecd conf.d # echo ‘routes_eth0=( “default via 192.168.1.16″ )’ >> net
livecd conf.d # rc-update add net.eth0 default
livecd conf.d # rc-update add sshd default

Setup Root Password

livecd conf.d # passwd
New UNIX password: type_the_password
Retype new UNIX password: type_the_password_again
passwd: password updated successfully

Setup Clock

livecd conf.d # nano -w /etc/conf.d/clock
CLOCK=”EST”
TIMEZONE=”US/Eastern”
CLOCK_SYSTOHC=”yes”

Edit Additional Configuration Files

livecd conf.d # nano -w /etc/rc.conf
EDITOR=”/usr/bin/vim”

livecd conf.d # nano -w /etc/conf.d/rc
RC_PARALLEL_STARTUP=”yes”
RC_BOOTLOG=”yes”

Install System Tools

At the time of writing there was a bug that meant udev had to be uninstalled before mdadm and lvm2 could be installed so we account for this in the documentation, it may be fixed in the future.

emerge –unmerge udev
emerge udev mdadm lvm2
emerge sysklogd vixie-cron
rc-update add sysklogd default
rc-update add vixie-cron default
emerge jfsutils vim showconsole

Configure Bootloader

Install Grub

livecd conf.d # emerge grub

Configure Grub

livecd conf.d # nano -w /boot/grub/grub.conf

default 0
timeout 10
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Gentoo
root (hd0,0)
kernel /boot/kernel-genkernel-x86-2.6.29-gentoo-r5 root=/dev/ram0 real_root=/dev/md3 domdadm
initrd /boot/initramfs-genkernel-x86-2.6.29-gentoo-r5

Sometimes it may be necessary to point the kernel to the correct root drive. In this case /dev/md3 by passing it ‘md=3,/dev/sda3,/dev/sdb3′

Setup Grub

livecd conf.d # grub –no-floppy
Probing devices to guess BIOS drives. This may take a long time.

grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd0)
Checking if “/boot/grub/stage1″ exists… yes
Checking if “/boot/grub/stage2″ exists… yes
Checking if “/boot/grub/e2fs_stage1_5″ exists… yes
Running “embed /boot/grub/e2fs_stage1_5 (hd0)”… 16 sectors are embedded.
succeeded
Running “install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst”… succeeded
Done.

grub> root (hd1,0)
Filesystem type is ext2fs, partition type 0×83

grub> setup (hd1)

grub> quit

(Optional) Use LILO instead of Grub

LILO in theory has better support for RAID boot devices and is a tried and true workhorse of linux bootloaders. Grub has been standardized across most distributions for many years, on the other hand. The differences for our purposes really come down to what is easier to use configuration wise. Grub has many powerful configuration settings compared to LILO, and also configurations can be changed on the fly without updating the MBR. On the other hand, LILO is small and mostly self-contained. This is being documented here in case there are any formal plans to use LILO as standard. For the time being continue to use Grub.

LILO Configuration

LILO Configuration is simple and easy. First edit the lilo.conf file.

/etc/lilo.conf:

boot=/dev/md1
raid-extra-boot=mbr
prompt
timeout=10
default=gentoo

image=/boot/bzImage
label=gentoo
read-only
root=/dev/md3
append=”ro”

After you’ve edited the configuration file run this command:

livecd / # lilo -v

You should see “Added gentoo *” if it worked correctly.

Reboot

We need to reboot now so we use our newly built system for the rest of the steps

exit
umount /mnt/gentoo/usr/portage/distfiles /mnt/gentoo/usr/portage /mnt/gentoo/usr
umount /mnt/gentoo/var/tmp /mnt/gentoo/tmp /mnt/gentoo/var /mnt/gentoo/opt
umount /mnt/gentoo/proc /mnt/gentoo/home /mnt/gentoo/boot /mnt/gentoo
init 6

Post Installation

Configure /etc/make.conf

linux / # vi /etc/make.conf

CFLAGS=”-O2 -mtune=i686 -pipe -fomit-frame-pointer”
CXXFLAGS=”${CFLAGS}”
CHOST=”i486-pc-linux-gnu”

FEATURES=”distcc parallel-fetch userfetch ccache”
MAKEOPTS=”-j2″

USE=”-X acl acpi apache2 bcmath berkdb bzip2 caps cracklib crypt curl emacs
expat ftp gd iconv imap java ldap maildir memlimit mhash mmap mysql nptl
pam pcntl pcre perl posix postgres readline session sharedmem soap sockets
snmp ssl syslog tcpd threads unicode xattr xml”

CCACHE_SIZE=”2G”
CCACHE_DIR=”/var/tmp/ccache”

PORTAGE_ELOG_CLASSES=”warn error log”
PORTAGE_ELOG_SYSTEM=”save”

Update /etc/dispatch.conf

linux / # vi /etc/dispatch.conf

use-rcs=yes

Update System

linux / # emerge distcc ccache
linux / # CCACHE_DIR=”/var/tmp/ccache” ccache -s
linux / # /usr/bin/distcc-config –set-hosts “192.168.1.11 192.168.1.25 localhost”
linux / # emerge –sync
linux / # emerge rcs
linux / # emerge -1 libstdc++-v3
linux / # emerge –newuse -uDav world
linux / # dispatch-conf

Install NTP

linux / # emerge ntp

linux / # vi /etc/ntp.conf

# NOTES:
# – you should only have to update the server line below
# – if you start getting lines like ‘restrict’ and ‘fudge’
# and you didnt add them, AND you run dhcpcd on your
# network interfaces, be sure to add ‘-Y -N’ to the
# dhcpcd_ethX variables in /etc/conf.d/net

# Name of the servers ntpd should sync with
# Please respect the access policy as stated by the responsible person.
#server ntp.example.tld iburst

server
server
server

# you should not need to modify the following paths
driftfile /var/lib/ntp/ntp.drift

#server ntplocal.example.com prefer
#server timeserver.example.org

# Warning: Using default NTP settings will leave your NTP
# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)
# from accessing the NTP server, uncomment:
#restrict default ignore

# To deny other machines from changing the
# configuration but allow localhost:
restrict default nomodify nopeer
restrict 127.0.0.1

# To allow machines within your network to synchronize
# their clocks with your server, but ensure they are
# not allowed to configure the server or used as peers
# to synchronize against, uncomment this line.
#
#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap

linux / # vi /etc/conf.d/ntp-client
NTPCLIENT_OPTS=”-b -u ”

linux / # /etc/init.d/ntp-client start
linux / # rc-update add ntp-client default
linux / # /etc/init.d/ntpd start
linux / # rc-update add ntpd default

Categories: Linux Tags: , ,