Archive for September, 2008

When APT complains about

September 16, 2008

Shortly after responding to Jonathan Groll on the CLUG’s mailing list about BADSIG errors. I’ve had the pleasure of experiencing it again.

pants:~$ sudo aptitude update 
W: GPG error: lenny/updates Release: The following signatures were invalid: BADSIG A70DAF536070D3A1 Debian Archive Automatic Signing Key (4.0/etch)
W: You may want to run apt-get update to correct these problems

I often have to remind myself to use Acquire::http::No-Cache=True when my machines are behind a SAIX proxy.

pants:~$ sudo aptitude -o Acquire::http::No-Cache=True update
it lenny/updates/non-free Sources
Fetched 14B in 12s (1B/s)
Reading package lists... Done

I should probably just put the below code in my apt.conf or in a file in apt.conf.d to safe me from future occurrences.

    No-Cache "true";

Installing Gentoo from a LiveCD or Desktop using LVM

September 14, 2008

Its been a while since I have manually had to install Gentoo on a host, as we use our own custom Gentoo build called “fatboy”. Since I had no cd at the time. I figured I’d give the manual route a go which I haven’t since gentoo’s 2005 release. So I give you a brief description of how to get lvm under a live cd working whilst building gentoo.

If you’re using a live environment you’d probably want to install lvm2, Well if your gonna use it anyway. Once installed run the command “modprobe dm-mod” to load the appropriate kernel module.

modprobe dm-mod

We’ll execute a vgscan to scan all disks for volume groups, rebuild caches and will return to any volume groups found. We then activate any existing volgroups (if any) with vgchange.

vgchange -a y

vgchange activates and makes available “-a” the volume groups. The vgchange tool is commonly used to activate and de-activate volume groups but also yields a plethora of other capabilities. I didn’t have any volume groups since this was a fresh install.

My partition layout looks as follows:

boot	100Mb
root 	900Mb
swap	512Mb
usr	10Gb
tmp	1Gb
var	5Gb
home	5Gb

Use fdisk and create a partition based on what you want, but if you’re gonna use lvm make sure you leave an appropriate segment for your volume group depending on what you’ve chosen.

I created three partitions using fdisk. One for boot, swap and the last to be used for lvm.
So I ended up with the following:

/dev/hda1	boot
/dev/hda2	swap
/dev/hda3	for use by lvm,

To initialize the 3rd partition of this drive for lvm we use the command pvcreate.

pvcreate /dev/hda3

If you intend using more that one partition or drive and you want to extend it over different partitions, you can seperate the arguments with a space and initialize it like so:

pvcreate /dev/firstdevice /dev/seconddevice
vgcreate volgrp /dev/sda3

The vgcreate command will create us a volume group with the name volgrp on our partition we chosen to use for lvm.

So now we create our logical volumes using a tool called lvcreate and name them accordingly.

lvcreate -L900M -nroot volgrp
lvcreate -L10G -nusr volgrp
lvcreate -L1G -ntmp volgrp
lvcreate -L5G -nvar volgrp
lvcreate -L5G -nhome volgrp

As you may notice the -L option takes the size as an argument, the -n option for the name and the last argument being the volume group on which you would like create your logical volume.

If we do a lvscan it’ll now show us the active logical volumes we’ve just created, alternative you could run lvdisplay as it displays the atrributes and various other information about our logical volumes.

Now we’ll have to create our directories to which we’ll build our gentoo environment, The gentoo hand uses /mnt/gentoo, so we’ll use it too. So we create a directory called gentoo in /mnt. Before we continue creating mount points for our logical volumes we’ll need to create filesystems on for our logical volumes and partitions and mount the root partition first. We do this by using the e2fsprogs utilities and since I am going to use ext3 for all my partitions aside from boot I can do the following.

for i in /dev/volgrp/* ; do mke2fs -j $i ; done

This will create ext3 filesystems for all my logical volumes. The only outstanding partitions are swap and boot for which I do the following.

mke2fs /dev/hda1
mkswap /dev/hda2

Now we’re ready to create our mount points and mount our filesytems.
We mount root first then create our mount points of course.

mount /dev/volgrp/root /mnt/gentoo
for i in boot usr tmp var home ; do mkdir /mnt/gentoo/${i} ; done

We mount boot.

mount /dev/hda1 /mnt/gentoo/boot

We mount the rest of our filesytems and activate our swap partition.

for i in usr tmp var home ; do mount /dev/volgrp/${i} /mnt/gentoo/${i}

From here on out its safe to follow the gentoo handbook at chapter 5 and just do the regular download and unpack of stage3 tarballs and the latest portage snapshot which you can find on your local gentoo mirror.

When you mount your /proc filesystem you should rather use the bind option.

mount -o bind /proc /mnt/gentoo/proc

Also, before you reboot you might wana de-activate your volume groups with vgchange.

vgachange -a -n

Make sure that when you compile your kernel you compile it with device mapper support, and edit your fstab correctly.

I forgot to mention that you’ll probably need to create an initrd image if your root partition is an logical volume.
A useful script to do this can be found here.
The syntax for the script is as follows.

sh lvm2create_initrd -M gentoo

or tell it to look for a specific kernel

sh lvm2create_initrd -M gentoo 2.6.25-gentoo-r7