User:Tuurlijk
From Gentoo Linux Wiki
[edit] Notepad
Load raid driver and create device nodes
modprobe raid1 cd /dev && MAKEDEV md
Partition layout
/dev/sda1 * 1 13 104391 fd Linux raid autodetect /dev/sda2 14 622 4891792+ fd Linux raid autodetect /dev/sda3 623 866 1959930 82 Linux swap / Solaris /dev/sda4 867 38913 305612527+ 5 Extended /dev/sda5 867 1475 4891761 fd Linux raid autodetect /dev/sda6 1476 1598 987966 fd Linux raid autodetect /dev/sda7 1599 38913 299732706 fd Linux raid autodetect
Assemble raid devices
mdadm --assemble /dev/md1 /dev/sda1 /dev/sdb1 mdadm --assemble /dev/md2 /dev/sda2 /dev/sdb2 mdadm --assemble /dev/md5 /dev/sda5 /dev/sdb5 mdadm --assemble /dev/md6 /dev/sda6 /dev/sdb6
Enable swap
swapon /dev/sda3 swapon /dev/sdb3
Mount raid devices
mount /dev/md2 /mnt/gentoo/ mount /dev/md1 /mnt/gentoo/boot/ mount /dev/md5 /mnt/gentoo/var/ mount /dev/md6 /mnt/gentoo/tmp/
Mount proc and dev
mount -t proc none /mnt/gentoo/proc mount -o bind /dev /mnt/gentoo/dev
Setup networking
cp /etc/resolv.conf /mnt/gentoo/etc/
Chroot
chroot /mnt/gentoo
Update environment
env-update source /etc/profile
Cleanup
umount /mnt/gentoo/dev/ umount /mnt/gentoo/proc/ umount /mnt/gentoo/tmp/ umount /mnt/gentoo/var/ umount /mnt/gentoo/boot/ umount /mnt/gentoo/
[edit] snippets for building embedded system
[edit] target system
The purpose of the system is to be a silent audio server.
The medium is a usb stick or CF disk.
[edit] Nehemia
The target system is a fanless Mini-ITX motherboard: 1GHz C3 CPU; CLE266+VT8235 chipset supporting CRT up to 1920 x 1440 and LCD displays up to 1600 x 1200.
[edit] EPIA 5000
[edit] hardware
Alsa device:
#0: VIA 8235 with ALC655 at 0xe000, irq 11
[edit] profile
/etc/make.profile -> /usr/portage/profiles/uclibc/x86
[edit] make.conf Nehemia
ACCEPT_KEYWORDS="~x86"
AUTOCLEAN="yes"
CFLAGS="-Os -march=c3-2 -pipe -fomit-frame-pointer -mmmx"
CHOST="i386-gentoo-linux-uclibc"
CXXFLAGS="${CFLAGS}"
FEATURES="buildpkg keepwork parallel-fetch fixpackages nodoc noman noinfo"
LDFLAGS="-Wl,-O1"
PORTAGE_STRIP_FLAGS="--strip-unneeded -R .comment"
UCLIBC_CPU="NEHEMIAH"
USE="aac acpi audiofile id3 mikmod minimal mmx mod mp3 mp4 mp4live mpd nltp
nodoc noman ogg oss posix threads vorbis wav zeroconf"
[edit] make.conf EPIA 5000
USE="acpi alsa audiofile bash-completion flac id3 mikmod mmx mod mp3 mp4 mp4live mpd nltp ogg oss posix savedconfig threads vorbis wav" UCLIBC_CPU="CYRIXIII" UCLIBC="CYRIXIII" CHOST="i386-gentoo-linux-uclibc" PORTAGE_STRIP_FLAGS="--strip-unneeded -R .comment" CFLAGS="-Os -march=c3 -pipe -fomit-frame-pointer -m3dnow -mmmx" ACCEPT_KEYWORDS="~x86" AUTOCLEAN="yes" FEATURES="buildpkg parallel-fetch fixpackages nodoc noman noinfo"
[edit] base
mkdir -p /tmp/tinygentoo/lib/modules mkdir -p /tmp/tinygentoo/sys
[edit] emerge
Now when building packages for the ROOT, enable the minimal and create-symlinks flags.
export KERNEL_DIR=/usr/src/linux ROOT="/tmp/tinygentoo" USE="savedconfig make-symlinks" emerge baselayout-lite uclibc busybox mpd mpc aumix
[edit] kernel
cd /usr/src/linux make allnoconfig make menuconfig make make INSTALL_MOD_PATH=/tmp/tinygentoo modules_install cp /usr/src/linux/arch/i386/boot/bzImage /tmp/kernel-2.6.22 /sbin/depmod -a -b /tmp/tinygentoo/ -v 2.6.22-gentoo-r8
If you get this error:
HOSTLD scripts/kconfig/mconf scripts/kconfig/mconf.o: In function `set_config_filename': mconf.c:(.text+0x2f): undefined reference to `libintl_gettext' scripts/kconfig/mconf.o: In function `show_help': mconf.c:(.text+0x8d7): undefined reference to `libintl_gettext' scripts/kconfig/mconf.o: In function `conf': mconf.c:(.text+0x9a6): undefined reference to `libintl_gettext' mconf.c:(.text+0xa31): undefined reference to `libintl_gettext' mconf.c:(.text+0xa60): undefined reference to `libintl_gettext' scripts/kconfig/mconf.o:mconf.c:(.text+0xa80): more undefined references to `libintl_gettext' follow scripts/kconfig/mconf.o: In function `main': mconf.c:(.text+0x1187): undefined reference to `libintl_bindtextdomain' mconf.c:(.text+0x1193): undefined reference to `libintl_textdomain' mconf.c:(.text+0x1369): undefined reference to `libintl_gettext' mconf.c:(.text+0x13b1): undefined reference to `libintl_gettext' mconf.c:(.text+0x13db): undefined reference to `libintl_gettext' mconf.c:(.text+0x13fd): undefined reference to `libintl_gettext' scripts/kconfig/zconf.tab.o: In function `conf_write': zconf.tab.c:(.text+0x41ca): undefined reference to `libintl_gettext' scripts/kconfig/zconf.tab.o:zconf.tab.c:(.text+0x42ec): more undefined references to `libintl_gettext' follow collect2: ld returned 1 exit status make[1]: *** [scripts/kconfig/mconf] Error 1 make: *** [menuconfig] Error 2
Then please try:
HOSTLOADLIBES_mconf=-lintl make menuconfig
. . . Or unmerge gettext. The explanation; because uclibc does not provide libintl (http://purl.rikers.org/%23uclibc/20051208.html.gz)
[edit] devices
I want to be able to hook up a usb drive tot the system so I need /dev/sd*.
DEVDIR=/tmp/tinygentoo/dev mknod $DEVDIR/sdb1 b 8 17 mknod $DEVDIR/sdb2 b 8 18 mknod $DEVDIR/sdb3 b 8 19 mknod $DEVDIR/sdb4 b 8 20 mknod $DEVDIR/sdc1 b 8 33 mknod $DEVDIR/sdc2 b 8 34 mknod $DEVDIR/sdc3 b 8 35 mknod $DEVDIR/sdc4 b 8 36
[edit] grub menu.lst huge
# Setup serial (COM1) here with baudrate 115200
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
# Now setup terminal as both Serial Line(/dev/ttyS0) and
# Monitor Console(/dev/tty0) depending upon where you press key
# with in timeout (10 sec) period. Otherwise first entry
# (console(Monitor)=>tty0) is selected here.
terminal --timeout=10 console serial
default 0
timeout 5
title Linux mouth
root (hd0,1)
kernel (hd0,1)/kernel-2.6.22 root=/dev/ram0 ramdisk_size=15500 console=tty0 console=ttyS0,115200n8
initrd /initrd.img.gz
[edit] grub menu.lst tiny
timeout 0
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal serial
hiddenmenu
title Linux mouth
root (hd0,1)
kernel (hd0,1)/kernel-2.6.22 root=/dev/ram0 ramdisk_size=10240 console=ttyS0,115200n8
initrd /initrd.img.gz
[edit] grub menu.list for embedded initrd
timeout 0
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal serial
hiddenmenu
title Linux mouth
root (hd0,1)
kernel (hd0,1)/kernel-2.6.22 console=ttyS0,115200n8
[edit] grub setup
export DEVICE=sdb2 mkdir /mnt/$DEVICE mount /dev/$DEVICE /mnt/$DEVICE/ mkdir /mnt/$DEVICE/grub cp /boot/grub/*stage* /mnt/$DEVICE/grub/ umount /mnt/$DEVICE/
grub grub> device (hd0) /dev/[handwork . . .] grub> root (hd0,0) grub> setup (hd0) grub> quit
mount /dev/$DEVICE /mnt/$DEVICE rm /mnt/$DEVICE/grub/e2fs_stage1_5
[edit] create an initrd.img
#!/bin/sh EXCLUDE=/root/tinker/initrd.exclude SOURCE=/tmp/tinygentoo/ TARGET=/mnt/initrd IMAGE=/tmp/initrd.img rm -f $IMAGE* dd if=/dev/zero of=$IMAGE bs=1MB count=15 mke2fs -F $IMAGE mkdir $TARGET mount -o loop $IMAGE $TARGET rsync -av --exclude-from=$EXCLUDE $SOURCE $TARGET umount $TARGET gzip -9 $IMAGE
[edit] create a cpio archive
#!/bin/sh EXCLUDE=/root/tinker/initrd.exclude SOURCE=/tmp/tinygentoo/ TARGET=/tmp/initrd/ IMAGE=/tmp/initramfs-tinygentoo.cpio rm -f $IMAGE rm -rf $TARGET mkdir $TARGET rsync -av --exclude-from=$EXCLUDE $SOURCE $TARGET cd $TARGET find . | cpio -H newc -o > $IMAGE
[edit] intird.exclude file for rsync
*.h .keep* /etc/portage /usr/include /usr/lib/pkgconfig /usr/share/aclocal /var/cache /var/db /var/lib/portage
[edit] transfer system to usb stick
mount /dev/sda2 /mnt/usb cp /tmp/kernel-2.6.23 /tmp/initrd.img.gz /mnt/usb/ umount /mnt/usb
[edit] mount
Here is what I use to remount rw/ro at will
mount -o remount,rw,noatime -n /dev/root / mount -o remount,ro -n /dev/root /
Create some mountpoints
mkdir /tmp/tinygentoo/mnt/music mkdir /tmp/tinygentoo/mnt/stick
Link mtab to /proc/mounts
cd /tmp/tinygentoo/etc rm mtab ln -s /proc/mounts mtab
[edit] S01.sh
#!/bin/ash echo echo echo " Welcome to Mouth." echo echo #echo " * Setting umask.." umask 022 echo " * Remounting root filesystem rw.." /bin/mount -o remount,rw,noatime -n /dev/root / echo " * Mounting usbfs.." /bin/mount -t usbfs none /proc/bus/usb echo " * Mounting sys.." /bin/mount -t sysfs none /sys echo " * Starting udev.." /sbin/udevstart /sbin/udevtrigger echo " * Loading usb-storage.." /sbin/modprobe usb-storage echo " * Setting up codepages.." /sbin/modprobe nls_cp437 /sbin/modprobe nls_iso8859-1 /sbin/modprobe nls_utf8
[edit] fstab
# default ram disk as root none /proc proc defaults 0 0 /dev/ram0 / ext2 rw,defaults,noatime 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) # Adding the following line to /etc/fstab should take care of this: none /dev/shm tmpfs defaults 0 0
[edit] sound
This command will pull in all the needed libs and alsa-utils:
ROOT="/tmp/tinygentoo" USE="minimal nodoc noman -doc" emerge mpd mpc
[edit] sound devices
run the snddevices script that comes with the alsa-driver package to create the sound devices in /dev
./snddevices --dev-dir /tmp/tinygentoo/dev
[edit] mpd/mpc
mpd --create-db
mpc ls music_subfolder/some_band | mpc add mpc play
[edit] root prompt
Put this in your /root/.profile
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:."
case $TERM in
*xterm*)
export PS1=`echo -n -e "\033]0;$HOSTNAME: -$USER-\007\n$HOSTNAME: -$USER-\n# "`
;;
*)
export PS1=`echo -n -e "\n$HOSTNAME: -$USER-\n# "`
;;
esac
cdx() { cd $* ; export PS1="`hostname` `pwd | sed -e 's/.*\//\//g'` # " ; }
alias cd="cdx"
cdx
umask 022
[edit] Reference
base
- TinyGentoo . . . a great howto!
- http://purl.rikers.org/%23uclibc/20051208.html.gz
- http://www.gentoo.org/doc/en/prelink-howto.xml
- http://gentoo-wiki.com/HOWTO_USB_Mass_Storage_Device
- http://buildroot.uclibc.org/
- http://www.busybox.net/downloads/BusyBox.html
- http://www.gnu.org/software/grub/manual/grub.html
- http://www.gentoo.org/proj/en/base/embedded/
sound
- http://www.alsa-project.org/main/index.php/Matrix:Module-via82xx
- http://www.musicpd.org/
- http://mpd.wikia.com/wiki/Client:MpcOSX
wireless
