Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

[HowTo] gentoo linux on a compact flash card (chroot-build!)

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
42 posts
  • 1
  • 2
  • Next
Author
Message
pi-cubic
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 143
Joined: Sun May 25, 2003 5:06 pm

[HowTo] gentoo linux on a compact flash card (chroot-build!)

  • Quote

Post by pi-cubic » Thu Apr 21, 2005 7:48 pm

Introduction
This HowTo describes how to create a system booting from a Compact Flash (CF) card, but operating (almost only) in the RAM. Because of the limited program-/erase-cycles of a CF card, it is important to reduce these cycles to a minimum. Though, your system should be able to save some configuration-changes in /etc. That's why I decided to put /etc on an extra r/w-partition on the cf-card. Everything else in / is in RAM an lost when the system reboots (!).

The flexibility of my approach ist the gentoo-chroot behind the scenes. the system is built from a chroot which gives you full control over all packages with portage, easy updating and customization possibilities.

This HowTo also implies that you have an IDE-CF-controller which is accessable via /hdX. Of course, if your card-reader has a different controller, replace /hdX with your card-reader device.

Here's a brief overview about the system-architecture:
1) the CF-card has two partitions: hdc1 (for /boot and root.tgz) and hdc2 (for /etc)
2) the system boots with grub and uses the initrd from /boot
3) in the "pre-boot-enviroment" (initrd), hdc1 (ro) and hdc2 (rw) are mounted to /cf
4) then the root.tgz tarball is extracted to /new and hdc2 mounted to /new/etc (still in the initrd)
5) pivot_root makes /new to our new root enviroment
6) control is passed to init booting the system

Requirements
You need to have enough space on your system. Depending on what packages you need to include in your CF-system, this will vary. I'd say in average a 4GB free space is fair enough.

You must be familiar with installing Gentoo using a stage1/2 tarball because that's what we're going to use in this mini-HowTo. If you're in doubt, consult the Gentoo Handbook (http://www.gentoo.org/doc/en/handbook/).

Setting up the build environment
Our build environment is a directory we will 'chroot' into and install gentoo. Its contents will make the CF-system later on. I will use the name 'source' for it, and will create it under a directory in my home called 'base'.

Code: Select all

cd ~
mkdir -p base/source
Download a stage1 or stage2 tarball from one of the gentoo mirrors to your home directory. I'm using an x86 stage2. Once downloaded untar it to 'source'. Then create necessary 'oldroot' directory which will be used during initial boot.

Code: Select all

cd base/source
tar xvjpf ~/stage1-x86-2005.0.tar.bz2 
# or
tar xvjpf ~/stage2-x86-2005.0.tar.bz2 
mkdir oldroot
Now, download the latest portage snapshot to your home directory and untar it to your new build directory

Code: Select all

cd base/source/usr/
tar xvjf ~/portage-whatever.tar.bz2
If you need to download packages during the installation, then setup whatever files in 'base/source/etc' required to reach the internet. For example 'resolv.conf'.

Your source directory is now ready to start installating gentoo.

Installing gentoo
Setup necessary mount points before you 'chroot' to your build directory and start installation. On my system I keep 'distfiles' under the default '/usr/portage' directory. I'm going to use it instead of downloading distfiles again during the installation.

Code: Select all

cd base/source
mount -o bind /proc proc
mkdir usr/portage/distfiles
mount -o bind /usr/portage/distfiles usr/portage/distfiles
Now 'chroot' to source and start the installation. Be careful with the modification of your /etc/make.conf, the more USE-flags you put in it, the bigger the system will be. I use a minimalistic set us USE-flags. Here is my example 'make.conf' for a VIA Samuel CPU:

Code: Select all

######################################
#   /etc/make.conf
######################################

USE="alsa -arts -avi -bitmap-fonts -cdr -cups -dvd -emacs -esd -foomaticdb -gif -gtk -gtk2 -jpeg -gnome -kde -nls -motif -mp3 -mpeg -oggvorbis -opengl -oss perl -pdflib -png -ppds -qt -quicktime samba -spell -truetype -truetype-fonts -type1-fonts -X -xmms"

#from http://radagast.bglug.ca/epia/epia_howto/index.html
# notice the -Os optimization for small binaries!
CFLAGS="-march=i586 -m3dnow -mmmx -Os -pipe -fomit-frame-pointer"
CHOST="i586-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"

GENTOO_MIRRORS="http://ftp.uni-erlangen.de/pub/mirrors/gentoo http://ftp.tu-clausthal.de/pub/linux/gentoo http://gentoo.oregonstate.edu http://www.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
Let's do the installation!

Code: Select all

cd base/source
chroot . /bin/bash --login
env-update && source /etc/profile
cd /usr/portage; scripts/bootstrap.sh (stage1 only: bootstrap system)
emerge --newuse system                (stage1, stage2 only: install base system)
ln -sf /usr/share/zoneinfo/<path to time zone file> /etc/localtime
emerge syslog-ng vixie-cron hotplug udev
rc-update add syslog-ng default
rc-update add vixie-cron default
rc-update add hotplug default (add also hostname, domainname, net.eth?, etc.)
emerge foo bar baz ... (custom packages)
Before we merge the kernel and boot loader, let's modify important files in '/etc'. First, fstab

Code: Select all

# <fs>                  <mountpoint>    <type>          <opts>                  <dump/pass>
none                    /               tmpfs           defaults                0 0
/dev/hdc2               /etc            ext3            noatime                 0 0

none                    /proc           proc            defaults                0 0
none                    /dev/shm        tmpfs           defaults                0 0
Now, modify other '/etc' files as you see fits (e.g. hostname, rc.conf, conf.d/rc for udev, conf.d/*, and so on)

Merge your desired kernel now. I decided to use the 'hardened-dev-sources' since my system will be on the internet and should be armed against evil intruders like 'eve' or 'trudy' :)

When configuring your kernel, make sure the following is compiled in
1. initrd support, set size to 8MB (8192kb)
2. ext2/ext3 filesystem support (which we use for our initrd image and cf-card)
3. tmpfs filesystem support

Code: Select all

emerge hardened-dev-sources
cd /usr/src/linux
make menuconfig 
make -j? && make modules_install && cp arch/i386/boot/bzImage /boot (? = cpu-count+1)
The final step is merging and configuring the boot loader. We're going to use the latest GRUB.

Code: Select all

echo 'sys-boot/grub ~x86 >> /etc/portage/package.keywords'
emerge grub
And here's '/boot/grub/grub.conf'

Code: Select all

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

title globalways gentoo linux
        root (hd0,0)
        kernel /boot/bzImage root=/dev/ram0 rw init=/linuxrc 
        initrd /boot/initrd
creating the initrd image
This is where most of the action occures during booting. It's a very simple task once you get the hang of it. First create the image, I'm using an 8MB initrd but feel free to expand/reduce that if you need more/less, just remember to set the option in your kernel configuration for the maximum ramdisk size properly.

Code: Select all

touch /boot/initrd
dd if=/dev/zero of=/boot/initrd bs=1024k count=8
losetup /dev/loop0 /boot/initrd
mke2fs /dev/loop0
mkdir /mnt/initrd
mount /dev/loop0 /mnt/initrd
Now populate the image with required directories and files:

Code: Select all

cd /mnt/initrd
mkdir etc dev lib bin proc new cf
touch linuxrc
chmod +x linuxrc
touch etc/mtab
touch etc/fstab
linuxrc is what will get executed when linux boots. More on it below.

Now you need to copy necessary files into bin and lib. For bin, copy the following:

Code: Select all

/bin/sh
/bin/cat
/bin/mount
/bin/umount
/bin/mkdir
/bin/chroot
/bin/tar
/sbin/pivot_root
/usr/bin/beep
For lib, you'll need to find out which lib files are needed by each of the binaries above. After having copied the necessary binaries, do the following:

Code: Select all

cd /mnt/initrd/bin
ls | xargs ldd | grep '/' | cut -d '(' -f 1 | sort -n | uniq   
cp /lib/libc.so.6 /mnt/initrd/lib/
cp /lib/ld-linux.so.2 /mnt/initrd/lib/
... (do this for all libraries shown)
This is just one way (maybe not that nice) to get a list of all libraries you need for your binaries, maybe someone has a better idea? i didn't put much brain in the pipe, probably someone likes to write a tiny script copying the binaries over :)

...and there it is. JeffW makes our lives easier with this sweet line:

Code: Select all

carter initrd # find /bin -type f | xargs ldd | grep '/lib/' | awk '{print $3}' | sort -n | uniq | xargs -i, cp , /mnt/initrd,
carter initrd # find
.
./cf
./bin
./dev
./etc
./lib
./lib/libm.so.6
./lib/libacl.so.1
./lib/libresolv.so.2
./lib/libcom_err.so.2
./lib/libncurses.so.5
./lib/libe2p.so.2
./lib/libattr.so.1
./lib/libproc.so.3.1.15
./lib/libcrypt.so.1
./lib/ld-linux.so.2
./lib/libdl.so.2
./lib/libuuid.so.1
./lib/libpthread.so.0
./lib/libpam_misc.so.0
./lib/libpam.so.0
./lib/libc.so.6
./lib/librt.so.1
./new
./usr
./usr/lib
./usr/lib/libcrack.so.2
./usr/lib/liblockfile.so.1
./proc
carter initrd # 
Now, we need to create necessary devices under dev directory:

Code: Select all

mknod /mnt/initrd/dev/console c 5 1
mknod /mnt/initrd/dev/null c 1 3 
mknod /mnt/initrd/dev/hda b 3 0
mknod /mnt/initrd/dev/hdb b 3 64
mknod /mnt/initrd/dev/hdc b 22 0
mknod /mnt/initrd/dev/hdc1 b 22 1
mknod /mnt/initrd/dev/hdc2 b 22 2
mknod /mnt/initrd/dev/hdd b 22 64
mknod /mnt/initrd/dev/tty c 4 0
mknod /mnt/initrd/dev/loop0 b 7 0
note: use the appropriate device files your card-reader/cf-controller works with. mine detects the card as /dev/hdc, so i created 2 partitions for hdc1 and hdc2. I listed the device-numbers above for you, so you can create your own device-files with mknod (just leave the first number and change the last number to the number of your partition, e.g. hdc1 is ...b 22 1)

Finally, we need to create our linuxrc script. The script will do the follwoing:
1. Save whatever is passed to the kernel to pass it later on to /sbin/init
2. Mount hdc1 (fist partitiong on the CF-card) /cf and extract it to /new. This will become our root filesystem, which is read-only
3. Mount hdc2 to /cf/etc and extract the etc-tarball to /new/etc
4. Finally, pivot the root filesystem on newroot and start the real init process

Code: Select all

#!/bin/sh

#
# hdc1 = read-only for /boot and root.tar
# hdc2 = read/write for /etc
#


# we need to access the binaries in the initrd
export PATH=/bin

# get kernel CMDLINE
mount -t proc none /proc
CMDLINE=`cat /proc/cmdline`
umount /proc

# mount compact flash device
mount -t ext3 -o ro /dev/hdc1 /cf &> /dev/null 
if [ $? != 0 ]; then
        echo "[ !! ]   couldn't mount root file-system !"
        exec /bin/sh
else 
        echo "[ ok ]   root file-system successfully mounted (ro) !"
fi

# create the tmpfs for / and untar the system into it
mount -t tmpfs -o size=256m none /new &> /dev/null
cd /new 
tar zxpf /cf/root.tgz &> /dev/null
if [ $? != 0 ]; then
        echo "[ !! ]   couldn't untar root file-system !"
        /bin/beep -f 1500 -r 100000 -l 200 -d 1000
else 
        echo "[ ok ]   root file-system successfully untared !"
        /bin/beep -f 1000  -r 3 -l 200 -d 500
fi

# check for an existing /etc (possibly from the root-tarball)
mkdir /new/etc
if [ $? != 0 ]; then
        echo "[ !! ]   /etc already exists, cleaning ...!"
        rm -rf /new/etc/*
else 
        echo "[ ok ]   /etc created !"
fi

# mount writeable /etc in new root-enviroment
mount -t ext3 /dev/hdc2 /new/etc &> /dev/null
if [ $? != 0 ]; then
        echo "[ !! ]   couldn't mount /etc !"
else 
        echo "[ ok ]   /etc mounted (rw) !"
        /bin/beep -f 1000 -l 200 -d 500
fi


# pivot root and start real init
cd /new
pivot_root . oldroot
exec chroot . /bin/sh <<- EOF >dev/console 2>&1
umount /oldroot/cf
umount /oldroot
exec /sbin/init ${CMDLINE}
EOF
Notice that I'm using 256 MB tmpfs filesystems. Reduce or expand it if your wish. I thought of specifying the system-size as boot-parameter in grub, but haven't realized this idea yet.

Our source directory is ready. Exit 'chroot' and unmount proc and distfiles (and maybe some customized binds).

Building the CF-system
Building the CF-system invloves the follwoing steps:
1. Clean up unnecessary directories in source (like /tmp and /var/tmp)
2. Create the target directory that will contain the files on the CF-card
3. call `geninc` to generate our included files (includes.lst) in our root-tarball
4. create the file-system-tarballs for each CF-partition

To help automate these steps, create a simple 'build' script inside 'base'

Code: Select all

cd base
touch build
chmod +x build
And here's the script:

Code: Select all

#!/bin/bash

INCLUDES='../includes.lst'

# prepare the source-tree
rm -rf source/var/tmp/*
rm -rf source/var/run/*
rm -rf source/var/lock/*
rm -rf source/tmp/*
rm -f source/etc/mtab 
touch source/etc/mtab

# copy /boot and /etc 
rm -rf target 
mkdir target
cp -a source/boot target/
cp -a source/etc target/

# generate the file list
echo "[ >> ]   generating include-list..."
./geninc

# create the rootFS
cd source/
echo "[ >> ]   building root.tgz..."
tar czpf ../target/root.tgz -T $INCLUDES #&> /dev/null

cd ../target
echo "[ >> ]   building exportable tarballs..."
tar cpf ../last-boot.tar boot root.tgz && echo "[ ok ]   /boot & root.tgz built!" 
cd etc
tar cpf ../../last-etc.tar * && echo "[ ok ]   /etc built!" 
this script invokes another script called geninc which generates the list of the files which will be included in our system. geninc generates our 'includes.lst' which is used by the tar. you might now think "what the...", but i'll explain my idea :). the idea behind this is to have script generating an include-list with all files, so you don't have to add every needed library by hand in the include-file (e.g. notice the find-command). with the geninc-approach, you have a 'meta-include-file-generator' making the include.lst on the fly when you ./build your system! here is my geninc-file:

Code: Select all

#!/bin/bash

SOURCETEE='./source'
INC='includes.lst'

############################
# populating root
#
cat << EOF > $INC
bin
dev
home
lib
mnt
oldroot
opt
proc
root
sbin
sys
tmp
EOF

############################
# populating var
#
cat << EOF > $INC
var/cache
var/empty
var/lib
var/lock
var/log
var/mail
var/run
var/spool
var/state
var/tmp
EOF


############################
# populating usr/lib (aka the big guy)
#

# basic libraries
find ${SOURCETREE}/usr/lib -maxdepth 1 -iname '*.so*' >> $INC

# special stuff
find ${SOURCETREE}/usr/lib -iname 'libstdc++.so*' >> $INC

cat << EOF >> $INC
usr/lib/groff
usr/lib/gcc-config
usr/lib/gentoolkit
usr/lib/perl5
usr/lib/pkgconfig
usr/lib/portage
usr/lib/pppd
usr/lib/quagga
usr/lib/tc
EOF

############################
# rest of /usr (what is really necessary?)
cat << EOF >> $INC
usr/bin
usr/i586-pc-linux-gnu
usr/libexec
usr/local
usr/man
usr/sbin
usr/share/consolefonts
usr/share/keymaps
usr/share/misc/file/magic
usr/share/nmap
usr/share/zoneinfo/Europe/Berlin
usr/tmp
EOF

# possible candidates ?!
# -------------------
# usr/lib/hotplug
# usr/lib/binutils
# usr/lib/gconv
# usr/lib/glib
# usr/lib/grub
# usr/share/cracklib
# usr/share/gettext
warning: i haven't played much with the selection of libraries and binaries and how the behave in harmony. this part is up to you. include what you want depending on how much ram you have!

After executing the build-script, you will have to new files in your current directory:
  • last-boot.tar
  • last-etc.tar
these 2 files represent your 2 partitions on your compact flash device. the first is extracted to hdc1 and the second to hdc2.

here is a sample script for deploying the system on a CF-card:

Code: Select all

#!/bin/bash

#
#  this script deploys the latest tarball of the cf-system
#  it should be started from the machine with the cf-card!
#

BOOT='/base/last-boot.tar'
ETC='/base/last-etc.tar'

BOOT_MOUNT='/mnt/base/boot'
ETC_MOUNT='/mnt/base/etc'

# mounting the devices
echo "[ >> ]   creating and mounting the partitions..."
mke2fs /dev/hdc1 
tune2fs -j -i 0 -c 0 /dev/hdc1
mke2fs /dev/hdc2 
tune2fs -j -i 0 -c 0 /dev/hdc2
mount /dev/hdc1 ${BOOT_MOUNT}
mount /dev/hdc2 ${ETC_MOUNT}

# extracting the tarballs
echo "[ >> ]   extracting the tarballs..."
tar xpf ${BOOT} -C ${BOOT_MOUNT}
tar xpf ${ETC} -C ${ETC_MOUNT}

# install grub on hdc1
grub-install --root-directory=${BOOT_MOUNT} /dev/hdc

# unmounting the devices
echo "[ >> ]   unmounting the devices..."
umount ${BOOT_MOUNT}
umount ${ETC_MOUNT}

# say something ;)
if [ $? != 0 ]; then
        echo "[ !! ]   an error occured while deploying the system !"
else 
        echo "[ ok ]   system deployed !"
fi
I use 256MB RAM on my CF-system, so i need to reduce the system-size to a minimum. the more RAM you have the less you have to care about the size of your root-filesystem in the RAM.

I use a simple script to chroot to my build source each time I need to sync portage, merge new packages, customize configuration files. I called it 'work'.

Code: Select all

cd base
touch work
chmod +x work
and the work-script:

Code: Select all

#!/bin/bash

mount -o bind /proc source/proc
mount -o bind /sys source/sys
#mount -o bind /dev source/dev
#mount -o bind /dev/pts source/dev/pts
mount -o bind /usr/portage/distfiles source/usr/portage/distfiles
chroot source/ /bin/bash --login
umount source/proc
umount source/sys
#umount source/dev/pts
#umount source/dev
umount source/usr/portage/distfiles

Mounting /dev is important to get things like X to work from a chroot environment. Depends on the purpose of your system, I don't need it.

Troubleshooting
  • If booting the CF fails at some point during linuxrc script execution, you can always change your grub line to 'init=/bin/sh' instead of linuxrc. This will give you a nice little shell inside the initrd image at boot time. From there you can type the commands in the linuxrc script manually and try to find out with one is failing and why.
Thanks
Actually you shouldn't thank me, but rather veezi who allowed me to copy the scaffold for this HowTo from is own LiveCD-HowTo.
I only copied all his work and modified some essential parts, because I love his chroot-concept. Comments are expressly desired!

Please help me to make this HowTo more robust, i just collected my thoughts during the development of the system, so some steps might miss or seem unclear. your feedback will improve this HowTo and will make it easy reproducable for everyone !!
Last edited by pi-cubic on Fri Aug 05, 2005 1:32 pm, edited 2 times in total.
Top
nife
Tux's lil' helper
Tux's lil' helper
Posts: 87
Joined: Thu Apr 24, 2003 4:46 am

  • Quote

Post by nife » Fri Apr 22, 2005 6:32 am

I really like this idea, I don't think I can use it since I can't afford a card big enough right now, but I just wanted to say that this HOWTO is very very well written. And sounds like great work. I might use this to see if I can get a similar thing going with a usb drive that I have. Thanks
Top
pi-cubic
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 143
Joined: Sun May 25, 2003 5:06 pm

  • Quote

Post by pi-cubic » Fri Apr 22, 2005 7:33 am

i use a CF-card from Kingston with 128 MB. the system size is currently around the half. your card doesn't need to be big! you can even strip down the system to 30 MB, but i am a lazy guy :). just modify the geninc script to define what will be included in your system.
Top
firestrike
n00b
n00b
Posts: 22
Joined: Wed May 05, 2004 5:37 pm

  • Quote

Post by firestrike » Wed Jul 06, 2005 9:24 pm

Great tutorial and exactly what I needed! Thanks for that :)


but I've encountered two problems:

when linuxrc tries to umount oldroot/cf and oldroot I get a segmentation fault. It seems to umount it though. Do you have the same problem?

And on a reboot the init script stops at "can't find /etc/init.d/reboot.sh" and thus does not reboot. Do you have a solution for that? I want to administrate this pc remotely, but it is not good if I always have to drive there for a reboot :)

I made 3 small changes in your geninc script:

Code: Select all

[....snip....]

cat << EOF >> $INC

[....snip....]

cd ${SOURCETREE}
find usr/lib -maxdepth 1 -iname '*.so*' >> ../$INC
cd ..

# special stuff
cd ${SOURCETREE}
find usr/lib -iname 'libstdc++.so*' >> ../$INC
cd ..

[....snip....]
Top
pi-cubic
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 143
Joined: Sun May 25, 2003 5:06 pm

  • Quote

Post by pi-cubic » Wed Jul 06, 2005 9:41 pm

Great tutorial and exactly what I needed! Thanks for that :)
i appreciate you like it, keep on testing!
when linuxrc tries to umount oldroot/cf and oldroot I get a segmentation fault. It seems to umount it though. Do you have the same problem?
yes, i do have the same problem, haven't solved it though...as you said, the umount works :)
And on a reboot the init script stops at "can't find /etc/init.d/reboot.sh" and thus does not reboot. Do you have a solution for that? I want to administrate this pc remotely, but it is not good if I always have to drive there for a reboot :)
yes, i took me a while to find the solution for this problem. since /etc isn't mounted any more when reboot should take place, you have to customize the following (excerpt from my changelog):
----------------------------
changes to the gentoo-files:
----------------------------
* proper reboot & shutdown: /sbin/rc:671
* no fsck.error on boot: /etc/init.d/checkroot:28

/sbin/rc looks in the specified range like this:

Code: Select all

ource /etc/init.d/halt.sh

    if [ "${SOFTLEVEL}" = "reboot" ]
    then
        source /etc/init.d/reboot.sh
    else
        source /etc/init.d/shutdown.sh
    fi

hope this helps you!

bye,

pi
Top
preacher
n00b
n00b
User avatar
Posts: 55
Joined: Fri Jan 09, 2004 7:47 pm
Location: Göteborg, Sweden

  • Quote

Post by preacher » Fri Aug 05, 2005 11:33 am

Great howto, thanks a lot!

I'm thinking about using this approach for my coming Epia-based frontend to mythtv to get a small, fast and silent machine.

However I'm not sure how much space I'm gonna need on the card and for RAM. I was thinking going for a 256mb flash and 1 gb of RAM just to be sure I have enough. Could I "go cheap" and step down to 128mb for the flash and 512mb RAM?

Mythtv needs X and QT, which takes some space. Could the system be stripped down enough to fit?

Thanks again.
Top
pi-cubic
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 143
Joined: Sun May 25, 2003 5:06 pm

  • Quote

Post by pi-cubic » Fri Aug 05, 2005 12:03 pm

preacher wrote: However I'm not sure how much space I'm gonna need on the card and for RAM. I was thinking going for a 256mb flash and 1 gb of RAM just to be sure I have enough. Could I "go cheap" and step down to 128mb for the flash and 512mb RAM?
Thanks again.
our system fits perfectly on a 256 MB RAM and 256 MB CF. we still have 128 MB RAM 'left' as RAM, so i think you definitively could "go cheap"...
Top
metalfan
Apprentice
Apprentice
Posts: 260
Joined: Sat Apr 09, 2005 5:23 pm
Location: 127home0sweet0home1 .endofinternet.net

  • Quote

Post by metalfan » Thu Dec 08, 2005 6:03 am

i got one of these via nehemia boards, mII1200....is the cf slot able to read and write the card?

greets
metalfan
please add [SOLVED] to the topic if you found the answer
Top
TheDauthi
n00b
n00b
Posts: 17
Joined: Thu Oct 10, 2002 8:25 am

  • Quote

Post by TheDauthi » Thu Dec 08, 2005 7:16 am

I like this. It's conceptually similar to something I'm working on right now that uses perl and a set of config files to build the disk. One of the main points of difference being that my ldd for the library listing and linking is a lot uglier. I'm currently working on a clean way to remove perl, python and gcc from the build directory when they're not in use.

One thing that is working well for me, anyway, is to rebind the entire /usr/portage directory, so I don't have to sync inside the build enviroment, as if I were sharing it over NFS. No one else seems to do that, so I assume that it's broken in some way that I haven't found yet. Another has been to use a ramdisk for the /var/tmp/portage directory.
Top
pi-cubic
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 143
Joined: Sun May 25, 2003 5:06 pm

  • Quote

Post by pi-cubic » Thu Dec 08, 2005 10:11 am

TheDauthi wrote: I'm currently working on a clean way to remove perl, python and gcc from the build directory when they're not in use.
perl has a nice use flag called "minimal", you might be interested in it.
One thing that is working well for me, anyway, is to rebind the entire /usr/portage directory, so I don't have to sync inside the build enviroment, as if I were sharing it over NFS.
don't forget to 'emerge --metadata' since you only mount the /usr/portage directory and don't update the portage-cache at the same time!
Top
Root Moose
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 112
Joined: Thu Jan 29, 2004 5:49 pm

  • Quote

Post by Root Moose » Thu Dec 08, 2005 3:50 pm

metalfan wrote:i got one of these via nehemia boards, mII1200....is the cf slot able to read and write the card?

greets
metalfan
Yes, but you cannot boot from that card.
Top
TheDauthi
n00b
n00b
Posts: 17
Joined: Thu Oct 10, 2002 8:25 am

  • Quote

Post by TheDauthi » Thu Dec 08, 2005 7:39 pm

pi-cubiq wrote:
TheDauthi wrote: I'm currently working on a clean way to remove perl, python and gcc from the build directory when they're not in use.
perl has a nice use flag called "minimal", you might be interested in it.
Yes, I've tried it, but it doesn't (didn't) build the Data::Dumper module, which something in the base install complained about if I didn't build. Silly: that's not really a module you'd expect an app to need to build. I should probably look at that, too. Of course, I could just grab that from CPAN, but I thought a generic 'remove-perl' script would be more useful for the case that it's not needed for the boot, at all.
pi-cubiq wrote:
TheDauthi wrote: One thing that is working well for me, anyway, is to rebind the entire /usr/portage directory, so I don't have to sync inside the build enviroment, as if I were sharing it over NFS.
don't forget to 'emerge --metadata' since you only mount the /usr/portage directory and don't update the portage-cache at the same time!
Hmm. Didn't think about the metadata, but isn't that stored in /usr/portage/metadata/?
Top
metalfan
Apprentice
Apprentice
Posts: 260
Joined: Sat Apr 09, 2005 5:23 pm
Location: 127home0sweet0home1 .endofinternet.net

  • Quote

Post by metalfan » Sat Dec 10, 2005 9:47 am

Root Moose: a driver issue or is it in generell not meant to be bootable?

greets
metalfan
please add [SOLVED] to the topic if you found the answer
Top
Root Moose
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 112
Joined: Thu Jan 29, 2004 5:49 pm

  • Quote

Post by Root Moose » Mon Dec 12, 2005 1:01 am

metalfan wrote:Root Moose: a driver issue or is it in generell not meant to be bootable?
Not meant to be bootable.

There wa s rumour that VIA planned to release a BIOS rev to make it bootable but it never happened.
Top
metalfan
Apprentice
Apprentice
Posts: 260
Joined: Sat Apr 09, 2005 5:23 pm
Location: 127home0sweet0home1 .endofinternet.net

  • Quote

Post by metalfan » Mon Dec 12, 2005 1:51 pm

well, maybe bootcds arent that bad ;)

greets
metalfan
please add [SOLVED] to the topic if you found the answer
Top
Root Moose
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 112
Joined: Thu Jan 29, 2004 5:49 pm

  • Quote

Post by Root Moose » Mon Dec 12, 2005 2:37 pm

metalfan wrote:well, maybe bootcds arent that bad ;)
Get one of those CF-2-IDE converter dongles and make it a device on chain 0 right on the built-in IDE bus. Those dongles can't be much more than ~Eu15 I would guess - that is how much they are in Can/US $.
Top
preacher
n00b
n00b
User avatar
Posts: 55
Joined: Fri Jan 09, 2004 7:47 pm
Location: Göteborg, Sweden

  • Quote

Post by preacher » Wed Jan 10, 2007 10:27 am

I've followed the guide to get a system and trying to deploy it on a CF-card, but having some troubles with the grub-install.

You see, I'm trying to deploy it onto a card-reader attached to the computer I used to build the system, and thereafter moving the CF-card to the IDE-dongle.

Just using:

Code: Select all

grub-install --root-directory=${BOOT_MOUNT} /dev/sde
won't work, since grub complains that there is no corresponding bios-drive.

If I run it with:

Code: Select all

grub-install --root-directory=${BOOT_MOUNT} --recheck --no-floppy /dev/sde
it finds my reader as (hd3) and /dev/sde, and says it completed successfully.

But on boot grub is horribly slow on appearing, and never boots correctly even if I wait.

Could this be because my CF is now (hd0) and /dev/hda, instead of /dev/sde?
Even though I of course configured grub.conf to use (hd0,0) and /dev/hda ?
Top
mci_nano
n00b
n00b
Posts: 32
Joined: Sun Nov 28, 2004 5:32 pm
Location: BS; Germany

  • Quote

Post by mci_nano » Thu Jan 18, 2007 8:47 pm

preacher wrote:I've followed the guide to get a system and trying to deploy it on a CF-card, but having some troubles with the grub-install.

You see, I'm trying to deploy it onto a card-reader attached to the computer I used to build the system, and thereafter moving the CF-card to the IDE-dongle.

Just using:

Code: Select all

grub-install --root-directory=${BOOT_MOUNT} /dev/sde
won't work, since grub complains that there is no corresponding bios-drive.

If I run it with:

Code: Select all

grub-install --root-directory=${BOOT_MOUNT} --recheck --no-floppy /dev/sde
it finds my reader as (hd3) and /dev/sde, and says it completed successfully.

But on boot grub is horribly slow on appearing, and never boots correctly even if I wait.

Could this be because my CF is now (hd0) and /dev/hda, instead of /dev/sde?
Even though I of course configured grub.conf to use (hd0,0) and /dev/hda ?
I think this will help you.
I'm trying to build a qemu image to try the build in a vm. So i had to install grub into the image and i got the same bios-device error. I asked qemu geeks from IRC and here is my solution:

Code: Select all

# start grub
grub

# promote the "fake" device
grub> device (hd0) /path/to/image
device (hd0) /path/to/image

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

grub> setup (hd0)
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)"...  15 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded
Done.

grub> quit
quit

My problem actualy is that the linux stops with a kernel panic at boot time... it says it woun't find a /linuxrc wether /bin/sh as init option... any suggiestion?
AMD Athlon 64 3700+; Nvidia 7800GT; 1GB RAM
Top
preacher
n00b
n00b
User avatar
Posts: 55
Joined: Fri Jan 09, 2004 7:47 pm
Location: Göteborg, Sweden

  • Quote

Post by preacher » Thu Jan 18, 2007 9:23 pm

Thanks, I´ve read about the device-command but haven´t had time to try it out, will do. Was your grub also very very slow?

About not being able to load either linuxrc nor /bin/sh, I had that problem too. Did you follow this guide?
My problem was that not all libraries needed were being detected by the script from JeffW.

I used the original command:

Code: Select all

cd /mnt/initrd/bin
ls | xargs ldd | grep '/' | cut -d '(' -f 1 | sort -n | uniq   
cp /lib/libc.so.6 /mnt/initrd/lib/
cp /lib/ld-linux.so.2 /mnt/initrd/lib/
... (do this for all libraries shown) 
Which found one more library, ld-linux.so-something (I´m not able to check it now, sorry).

A good way to make sure your initrd will work before rebooting is just mounting it with -o loop, and chroot to that diretory (chroot /mnt/initrd /bin/sh). Are you able to run /bin/sh? If so, you should be fine.

Good luck!
Top
mci_nano
n00b
n00b
Posts: 32
Joined: Sun Nov 28, 2004 5:32 pm
Location: BS; Germany

  • Quote

Post by mci_nano » Thu Jan 18, 2007 10:11 pm

preacher wrote:Thanks, I´ve read about the device-command but haven´t had time to try it out, will do. Was your grub also very very slow?
No it wasnt. I only wanst able to install grub on a image.
preacher wrote: About not being able to load either linuxrc nor /bin/sh, I had that problem too. Did you follow this guide?
My problem was that not all libraries needed were being detected by the script from JeffW.
Thats it... thx, you made my day.

There is a lib that wount get recognizes by the awk command, because its not a link like the others...

Code: Select all

DRevil bin # ls | xargs ldd | grep '/' | cut -d '(' -f 1 | sort -n | uniq 
        libblkid.so.1 => /lib/libblkid.so.1 
        libc.so.6 => /lib/libc.so.6 
        libdl.so.2 => /lib/libdl.so.2 
        /lib/ld-linux.so.2 
        libncurses.so.5 => /lib/libncurses.so.5 
        libpthread.so.0 => /lib/libpthread.so.0 
        librt.so.1 => /lib/librt.so.1 
        libuuid.so.1 => /lib/libuuid.so.1
Thx to you... Now I can step forward to the next problem ;)
AMD Athlon 64 3700+; Nvidia 7800GT; 1GB RAM
Top
mrdevis
n00b
n00b
Posts: 8
Joined: Sat Dec 02, 2006 4:34 pm

  • Quote

Post by mrdevis » Sat Jan 27, 2007 5:54 pm

Great, the missing lib finally got me to find out why I could not get his past the point of not being able to read from linuxrc...

Quoting mci_nano: getting on to the next problem... This is where I got quite soon: the script wouldn't mount the root file-system...
Also if I try to mount it manually, I get some remarks about /dev/hda1 not being a valid block device.

The CF card is prepared in my laptop, being /dev/hdc1&2, then put into an cf_ide socket, and booted on an epia board. It boots allright, but just up to this point mentioned..

Any ideas??

Cheers, Jeroen
Top
mci_nano
n00b
n00b
Posts: 32
Joined: Sun Nov 28, 2004 5:32 pm
Location: BS; Germany

  • Quote

Post by mci_nano » Sun Jan 28, 2007 10:50 am

mrdevis wrote: Also if I try to mount it manually, I get some remarks about /dev/hda1 not being a valid block device.
what nodes did you create? show us a ls -al of your /dev/hd* nodes. maybe you did wrong node creation in initrd?
if this is the case maybe you wish to have a look at Documentation/devices.txt of your kernel sources.
AMD Athlon 64 3700+; Nvidia 7800GT; 1GB RAM
Top
mrdevis
n00b
n00b
Posts: 8
Joined: Sat Dec 02, 2006 4:34 pm

  • Quote

Post by mrdevis » Sun Jan 28, 2007 1:04 pm

Hi,

Thanks for reacting, here is the devnode list. As the cf card is mounted on ide0 and
is seen (it boots) I suppose this should work, unless I miss something trivial (apparently :-)).

crw-r--r-- 1 root root 5, 1 Jan 27 17:35 console
brw-r--r-- 1 root root 3, 0 Jan 27 17:35 hda
brw-r--r-- 1 root root 3, 1 Jan 27 17:35 hda1
brw-r--r-- 1 root root 3, 2 Jan 27 17:35 hda2
brw-r--r-- 1 root root 3, 64 Jan 27 17:35 hdb
brw-r--r-- 1 root root 22, 64 Jan 27 17:35 hdd
brw-r--r-- 1 root root 7, 0 Jan 27 17:35 loop0
crw-r--r-- 1 root root 1, 3 Jan 27 17:35 null
crw-r--r-- 1 root root 4, 0 Jan 27 17:35 tty

hdb and hdd are not used (well at least not until now...)
Did I read somewhere that dma mode is not supported for CF cards on an ide adapter??

Cheers, Jeroen
Top
mci_nano
n00b
n00b
Posts: 32
Joined: Sun Nov 28, 2004 5:32 pm
Location: BS; Germany

  • Quote

Post by mci_nano » Sun Jan 28, 2007 1:16 pm

Of course you missing hdc but if you never use it, thats nothing to worry about.
I dont realy get it... You have CF card mounted on your laptop as hdc* and at the destination computer it should be hda*... are you sure about this?
did you get the correct ide driver into your kernel?

maybe it would help too post some more information.
and check for the drivers
AMD Athlon 64 3700+; Nvidia 7800GT; 1GB RAM
Top
mrdevis
n00b
n00b
Posts: 8
Joined: Sat Dec 02, 2006 4:34 pm

  • Quote

Post by mrdevis » Sun Jan 28, 2007 4:15 pm

dooh, tx for the tip, I had the wrong driver in the kernel. Working like a charm now!

Yes, hdc in the host, now driving a Epia Nano Itx as a solid state board, as hda1&2.

Now what shall I use this for...

Cheers, and tx again,
Jeroen
Top
Post Reply

42 posts
  • 1
  • 2
  • Next

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic