[Nottingham] Gentoo fun on an old VIA Epia C3

Martin martin at ml1.co.uk
Mon Apr 20 21:55:45 UTC 2009


Folks,

As mentioned earlier:

 > Meanwhile, as a background task/experiment, I'm chewing through some
 > Gentoo...
 >
 > ... And tripping up on root=/dev/sda1 not being found. Grub is on
 > /dev/hda1, and I've got USB and SCSI compiled into the kernel (and not
 > as modules).
 >
 > "VFS: Cannot open root device "sda1" or unknown-block(0,0)"
 >
 >
 > By the wonders of chroot, I've got it running another recompile from
 > the live (minimal) install cd with a few more tweaks and will next try
 > adding a rootwait to the kernel line.
 >
 > At 533MHz on a "VIA C3 Samuel 2", the compile is going to take a
 > little while...
 >
 >
 > (It can run Ubuntu but hideously slowly!)


Well, well, well, what a whole load o' fun! So...

One thing to note about the "VIA C3 Samuel 2" is that it identifies 
itself as an i686 except that it has no CMOV instruction. Quite a vital 
omission the relegates it to i586 compatibility.

See:
http://radagast.bglug.ca/epia/epia_howto/index.html

That means that the installer for my favoured Mandriva distro cannot be 
booted up. (A syslinx problem? Whereas isolinux works ok...)

An Ubuntu livecd runs ok but is unusably slow, even for a reduced screen 
resolution. The video shares the system PC133 RAM and so steals a 
significant fraction of CPU bandwidth at higher resolutions and higher 
colour depth. Selecting a 80x40 char display speeds things up a bit! 
Anyone got any (two ;-) ) 512MByte PC133 memory modules laying around 
idle, please?... ;-) )

So, all a good excuse to try Gentoo on an 'interesting' test...


Good instructions for what to do are given step-by-step on:

Gentoo Linux x86 Quick Install Guide
http://www.gentoo.org/doc/en/gentoo-x86-quickinstall.xml?style=printable

A few hints from my fun:

Don't try changing the CHOST variable until AFTER you have a working 
installation. More on that later.


My test system is:

   C3 Samuel/Ezra (Via EPIA)

processor  : 0
vendor_id  : CentaurHauls
cpu family : 6
model      : 7
model name : VIA Samuel 2


# cat /proc/cpuinfo
processor       : 0
vendor_id       : CentaurHauls
cpu family      : 6
model           : 7
model name      : VIA Samuel 2
stepping        : 3
cpu MHz         : 533.345
cache size      : 64 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu de tsc msr cx8 mtrr pge mmx 3dnow
bogomips        : 1066.69
clflush size    : 32
power management:


# free -m -t
           total       used       free     shared    buffers     cached
Mem:        494        139        355          0         31         83
-/+ buffers/cache:      24        470
Swap:       488          0        488
Total:      983        139        843

(All in MBytes)



Use:

lspci -v

lsmod | egrep -v '0 $'

to see what hardware there is and what kernel modules are used.




For the step-by-step guide, I used:

/etc/make.conf:

# These settings were set by the catalyst build script that
# automatically built this stage.
# Please consult /etc/make.conf.example for a more detailed example.

#
# Warning: Do not use any stages or packages containing i686
# instructions (such as cmov) with the Samuel 2 and Ezra versions of
# the C3.
#
# The Ezra doesn't have any special instructions that you could optimize
# for, just consider it a K6-3 - basically a Pentium 2 with 3DNow.
# Note: The Mini-ITX EPIA-SP features a VIA C3 Eden processor, even if
# /proc/cpuinfo answers: model name: VIA Nehemiah
#

CFLAGS="-march=c3 -mmmx -m3dnow -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="$CFLAGS"

# WARNING: Changing your CHOST is not something that should be done
# lightly. Please consult http://www.gentoo.org/doc/en/change-chost.xml
# before changing.
CHOST="i586-pc-linux-gnu"

# Set j to be number of CPUs + 1 for best compile performance
MAKEOPTS="-j2"

USE="-cups -ipv6 -isdnlog -pppd -midi -v4l -v4l2 3dnow mmx"

GENTOO_MIRRORS="ftp://gentoo.virginmedia.com/sites/gentoo 
http://mirror.bytemark.co.uk/gentoo 
http://ftp.snt.utwente.nl/pub/os/linux/gentoo 
http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo"



Note: No line breaks in the mirrors list, the sites are space separated. 
Look on:

http://www.gentoo.org/main/en/mirrors2.xml

for the full mirrors list.

You can also use:

emerge mirrorselect
mirrorselect -s3 -b10 -D -o >mirrors_selection

to install a mirrorselect utility to automatically detect, test, and 
output a selection of mirrors that you can then add to the 
/etc/make.conf file. The "-s3" selects the fastest three mirrors.


You can also use:

emerge vim

if you prefer to use the vim editor rather than the default nano editor.


# more /etc/fstab:

# /etc/fstab: static file system information.
#
# noatime turns off atimes for increased performance (atimes normally
# aren't needed; notail increases performance of ReiserFS (at the
# expense of storage efficiency).  It's safe to drop the noatime options
# if you want and to switch between notail / tail freely.
#
# The root filesystem should have a pass number of either 0 or 1.
# All other filesystems should have a pass number 0 or greater than 1.
#
# See the manpage fstab(5) for more information.
#

# <fs>                  <mountpoint>    <type>          <opts> 
<dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
#/dev/BOOT          /boot           ext2    noauto,noatime  1 2
#/dev/ROOT          /               ext3    noatime         0 1
#/dev/SWAP          none            swap    sw              0 0
#
LABEL=boot          /boot           ext2    noatime,noauto  1 2
LABEL=root          /               ext2    noatime         0 1
LABEL=home          /home           ext2    noatime         1 2
LABEL=var           /var            ext2    noatime         1 2
LABEL=misc          /mnt/misc       ext2    noatime         1 2
LABEL=swap-sdb2     none            swap    sw              0 0
#
/dev/cdrom          /mnt/cdrom      auto    noauto,ro       0 0
#/dev/fd0           /mnt/floppy     auto    noauto          0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
#  use almost no memory if not populated with files)
shm                 /dev/shm        tmpfs   nodev,nosuid,noexec     0 0

# procfs (already mounted during init)
#none               /proc           proc    defaults        0 0

# initial consoles?
#none               /dev/pts        devpts  mode=0620       0 0



To format partitions with labels or to add labels, use:

mk2efs -L labelname /dev/sdX

or

tune2fs -L labelname /dev/sdX

to set a label on an existing formatted ext2 partition.


Sooo.... Why use ext2 and noatime for my example? The three drives used, 
hda, sda and sdb are all flash SSDs and the hope is that ext2 and 
noatime will help to minimise the write counts on those devices to 
reduce "wear". Flash devices have a very limited number of writes 
compared to HDDs.



A few hiccups along the way were:

When emerging, I would get:

openpty failed: 'out of pty devices'

The solution is to use, before the chroot-ing:

mount --rbind /dev /mnt/gentoo/dev

The "--rbind" is needed to bind "/dev" and also "/dev/pts".


I just had to go and optimise and so I followed the instructions on what 
to do after changing CHOST from 486 -> 586...

Changing the CHOST variable
http://www.gentoo.org/doc/en/change-chost.xml


You should additionally check what:

perl -V:cc

returns. In my case I incorrectly got:

cc='i486-pc-linux-gnu-gcc';

That was fixed by re-emerging Perl:

emerge perl


If the perl cc is wrong, you can get 'strangeness' with emerges such as 
repeated blocking of packages. The example I blundered into was:


[blocks b     ] <sys-fs/e2fsprogs-1.41 ("<sys-fs/e2fsprogs-1.41" is 
blocking sys-libs/e2fsprogs-libs-1.41.3-r1)
[uninstall    ] sys-libs/com_err-1.40.8
[blocks b     ] sys-libs/com_err ("sys-libs/com_err" is blocking 
sys-libs/e2fsprogs-libs-1.41.3-r1)
[uninstall    ] sys-libs/ss-1.40.8
[blocks b     ] sys-libs/ss ("sys-libs/ss" is blocking 
sys-libs/e2fsprogs-libs-1.41.3-r1)


The re-emerge of perl fixed that on the next attempt.



I installed from:

gentoo-install-x86-minimal-2008.0.iso

burnt to a CD.

eg:

wget 
ftp://gentoo.virginmedia.com/sites/gentoo/releases/x86/2008.0/installcd/install-x86-minimal-2008.0.iso


Read the comments and instructions and links above first!

Format your partitions as appropriate and mount:

mount -o noatime LABEL=root /mnt/gentoo
mount -o noatime LABEL=home /mnt/gentoo/home
mount -o noatime LABEL=var /mnt/gentoo/var
mount -o noatime LABEL=misc /mnt/gentoo/mnt/misc
mount -o noatime LABEL=boot /mnt/gentoo/boot
swapon LABEL=swap-sdb2
cd /
mount -t proc proc /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
cp -f -L /etc/resolv.conf /mnt/gentoo/etc/
chroot /mnt/gentoo /bin/bash
env-update && source /etc/profile

# Setup the various config files and do whatever emerges

cd /usr/src/linux
make menuconfig

# In menuconfig, ensure that support for usb, usb mass storage,
# scsi devices and all filesystems are built in to the kernel '*'.
# That is, NOT as modules 'M'. Also, for any specific hardware needed.
# Get a working kernel and then afterwards experiment in excluding
# extraneous bits. Likely won't speed up the kernel but it may speed
# up future compiling

time make -j2
make modules_install
cp -v arch/i386/boot/bzImage /boot/kernel

# Edit grub menu.lst

exit

sync
umount /mnt/gentoo/boot
umount /mnt/gentoo/mnt/misc
umount /mnt/gentoo/var
umount /mnt/gentoo/home
umount /mnt/gentoo/dev/pts
umount /mnt/gentoo/dev
umount /mnt/gentoo/proc
umount /mnt/gentoo/


reboot

# Upon reboot, remove CD and see your new gentoo kernel start up

# THEN is the time for optimising and updates and installs!


EXCEPT... The USB memory sticks weren't found! That was fixed by adding 
a rootwait on the kernel line.

Next, I got:

Warning: unable to open an initial console

Followed by a kernel panic.

The actual problem was that sda and sdb were transposed between the 
livecd kernel and the compiled kernel. Also, eth0 and eth1 were transposed.

Fixed by just replacing root=sda1 with instead root=sdb1


So, the grub lines are:

title kernel rootwait sdb1 (Gentoo compiled)
root (hd0,0)
kernel /boot/kernel root=/dev/sdb1 rootwait


There's various other (out of date?) comments in forums about needing 
initrd, or "mknod /dev/console c 5 1" or add into /etc/fstab "none 
/dev/pts devpts mode=0620 0 0" to populate /dev before udev gets to set 
things up. Note also that DEVFS is 'obsolete' and initrd is preferred if 
you need to go that route. None of those were needed for this example.


Curiously, the kernel line "root=LABEL=root" didn't work :-( ...




To do a full update, a wise sequence is:

emerge --update portage
emerge --sync
emerge --pretend --update system
emerge --update system
emerge --pretend --update world
emerge --update world


Special note for config files:

From:

man emerge

When Portage installs a file into a protected directory tree like /etc, 
any existing files will not be overwritten. If a file of the same name 
already exists, Portage will change the name of the to-be-installed file 
from 'foo' to '._cfg0000_foo'. If '._cfg0000_foo' already exists, this 
name becomes '._cfg0001_foo', etc. In this way, existing files are not 
overwritten, allowing the administrator to manually merge the new config 
files and avoid any unexpected changes.

In addition to protecting overwritten files, Portage will not delete any 
files from a protected directory when a package is unmerged. While this 
may be a little bit untidy, it does prevent potentially valuable config 
files from being deleted, which is of paramount importance.

Protected directories are set using the CONFIG_PROTECT variable, 
normally defined in /etc/make.globals. Directory exceptions to the 
CONFIG_PROTECTed directories can be specified using the 
CONFIG_PROTECT_MASK variable. To find files that need to be updated in 
/etc, type

find /etc -iname '._cfg????_*'.



Next to try is to see whether the compiler option "Os" is better or not 
than "O2"... Anyone tried a comparison on a C3?


Phew!

First impressions are that "emerge" and the very fine grained control is 
tremendous. Rather neat! It also seems to make the C3 a bit more 
responsive, even if compiles might take all night! All for further 
experimenting.

Hope that's of interest to anyone dabbling into Gentoo for the first time.


Have fun!
Martin

-- 
----------------
Martin Lomas
martin at ml1.co.uk
----------------



More information about the Nottingham mailing list