Trinux Documentation Matthew Franz http://trinux.sf.net/docs.txt 27 July 2003 0. Introduction 0.1 What is Trinux? Trinux is a ramdisk-based Linux distribution that was first released in April of 1998 and has been maintained on and off since then. Like other Linux distributions it consists of a Linux kernel, base utilities, and a variety of packages. Like many embedded distributions, Trinux uses Busybox, which contains small versions of common utilities. See http://www.busybox.net. 0.2 Where can I get the source? Many of the standard utilities came from Slackware 7.1 or when components needed to be upgraded, I pulled the source from the Debian stable. The "original code" would be in the /linuxrc script that is executed within 0.3 Installation Trinux is released in either 1.4 meg floppy images or small ISO images. For the floppy images use dd on unix boxes or rawrite on Windows. Search the web for info. 0.4 If in doubt look at the /linuxrc script! 1. Boot Media 1.1 Common Format * bzImage - compressed linux kernel * tux - trinux configuration directory (like /etc on Unix) that gets copied to /etc/tux when trinux boots * bootpkg - packages that need to be loaded early * kpkg - modular kernel packages * initrd.gz - compressed initial ramdisk * modules - raw (*.o) modules will be automatically loaded 1.2 Floppy Disks Trinux uses MS-DOS (vfat actually) formatted disks and syslinux as the bootloader. The files/directories described in 1.1 are directly off the root of the drive. * syslinux.cfg - bootloader configuration file * ldlinux.sys - SYSLINUX bootloader (http://syslinux.zytor.com/) 1.3 CD-ROM Bootable CD's are ISO9660 filesytem contain 2 directories: * isolinux - bzImage, initrd.gz, isolinux.bin, isolinux.cfg * trinux - bootpkg, kpkg, modules, tux 1.4 Fixed Partition (IDE Drive) Trinux can also be booted from a Windows 95/98, MS-DOS, or FreeDOS partition using loadlin.exe. This is an option for older hardware that might not have a CD-ROM (or a bootable one) or if you want to load packages from a compact Flash drive using an IDE Compact-Flash Adapter. 1.4.1 Prepping the Drive Use a Windows 95/98 or MS-DOS boot disk or the Trinux FreeDOS Utility Disk (available on the downloads page) to create a FAT 32 partition. This involves running FDISK, FORMAT, and SYS. You should copy loadlin.exe to the drive and it is also useful to have a text editor (FreeDOS has TE) to edit batch files. You will need to create trinux directory. My C:\ drive (mounted from within Trinux as a vfat) looks like this: trinux> ls -al root root 16384 Jul 24 23:28 . root root 832 Sep 3 2002 .. root root 2048 Jul 20 18:51 .links root root 50 Jul 20 17:35 autoexec.bat root root 618999 Jul 20 18:11 bzimage root root 86561 Aug 15 2001 command.com root root 45836 Jul 20 17:35 fdisk.exe root root 13741 Jul 20 17:35 format.exe root root 600357 Jul 21 01:01 initrd.gz root root 75663 Sep 3 2001 kernel.sys root root 32177 Jul 20 17:35 loadlin.exe root root 32719 Jul 20 17:35 loadlin.txt root root 2048 Jul 20 18:33 old root root 8634 Jul 20 17:36 sys.com root root 44706 Jul 20 17:35 te.exe root root 2048 Jul 21 12:31 trinux TRINUX.BAT on the FreeDOS boot floppy contains the following which I renamed to AUTOEXEC.BAT once I new it was stable. loadlin bzimage initrd=initrd.gz root=/dev/ram0 rw Copy a kernel that has IDE support (all the kernels on the boot floppies after Trinux 0.90 should have the or a kernel from the CD-ROM will work to) and an initrd.gz to the c:\ drive. You can do this from DOS or from Linux. 1.4.2 Copying necessary files to the DOS partition Boot with a Trinux floppy (or CD-ROM) that has IDE support and then mount the MS-DOS partition with the following command # mount -t vfat /dev/hda1 /mnt This assumes the first IDE drive and should work for most cases. Now create (or cd) the trinux directory on that partition and create the subdirectories for packages # cd /mnt/trinux # mkdir bootpkg kpkg pkg modules # mkdir -p tux/config # mkdir tux/ Now you need to get a minimum set of packages into the bootpkg directory. If you have network access you can download them with links (getpkg links) or you can copy them to floppies. I have the following in mine: root root 245776 Jul 20 19:17 baselib.tgz root root 15932 Jul 20 18:17 dhcpcd.tgz root root 90312 Jul 20 18:17 dnslibs.tgz root root 163951 Jul 21 12:28 iptables.tgz root root 131200 Jul 21 12:28 netfilter.tgz root root 77834 Jul 20 19:22 pthread.tgz root root 378444 Jul 20 19:22 term.tgz These will always get loaded. You can also put packages in the pkg directory and these may/may not load depending on your configuration. Remember, after you are through modifying the partition, it needs to be unmounted with: #umount /dev/hda1 or #umount /mnt 1.4.3 Configuarition 2. Networking 2.1 Hardware Detection In order for you to use networking your interface(s) must be detected by the kernel. In order for this to occur you must either have support for your NIC compiled into the kernel or use a kernel module. Older versions of Trinux had support for the most common NiCs built in, but that is no longer the case. If your hardware was succuessfully found # dmesg | grep eth0 eth0: OEM i82557/i82558 10/100 Ethernet, 00:03:47:B9:12:08, IRQ 11 2.2 Module Selection 3. Kernel Modules Raw (non-packaged kernel modules are available at: http://trinux.sf.net/kernel/ Packaged kernel modules are available at http://trinux.sf.net/pkg/2.4.x/ and may be installed with the "getkpkg " Trinux puts all packages in /lib/modules or /usr/lib/modules instead of the standard linux convention of /lib/modules/2.4.x/... 4. Packages 4.1 Package Format Packages are simply tarballs with an initialization script that will be executed from within /etc/init.d/package_name or /etc/init.m/kernel_package_name 4.2 Scripts * pkgadd - loads a package from a local filesystem * getpkg - loads the package from the network * getkpkg - loads a kernel package from the network * pkglist - lists available packages * rmpkg - deletes package 4.3 Building your own All the Trinux packages are compiled with glibc 2.1.3 using Slackware 7.1. I upgraded the compiler to gcc 2.95 and have upgraded libraries as necessary. 4.4 Adding packages after bootup You can either use the getpkg/getkpkg commands to load a package from the network 5. Filesystems 5.1 Supported Filesytems Trinux may only have support for a few filesystems such as minix vfat (Windows) and ISO9660 (for CDROMs). To see which filesystems are currently supported in the kernel: # cat /proc/filesystems | grep -v nodev minix vfat iso9660 reiserfs In this case I installed the reiserfs module: # lsmod reiserfs 165600 1 3c59x 24560 1 8139too 13396 1 mii 2092 0 [8139too] To mount a device you use the following command: mount -t hda4 hde: LEXAR ATA FLASH, ATA DISK drive hde: 96384 sectors (49 MB) w/1KiB Cache, CHS=753/4/32 hde: hde1 So assuming hde1 were a vfat partition, you would use: # mount -t vfat /dev/hde1 /mnt # mount /dev/hda2 on / type ext3 (rw,errors=remount-ro) proc on /proc type proc (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/hda4 on /alt type reiserfs (rw) /trinux/boot/trinux.img on /loop type vfat (rw,loop=/dev/loop0) /dev/hde1 on /mnt type vfat (rw) This was from my laptop. Within Trinux, the following is more typical: # mount /dev/ram0 on / type minix (rw) /proc on /proc type proc (rw) /dev/null on /usr type tmpfs (rw) /dev/null on /home type tmpfs (rw) /dev/null on /var type tmpfs (rw) /dev/hda2 on /hda2 type reiserfs (rw) 5.3 Swap Usually, you probably have enough memory (otherwise you wouldn't be running ramdisks) but if you want to set up a swap file or swap filesystem, put the name of the file (within an existing filesytem) the name of the partition (/dev/hda3) in /etc/tux/config/swap and the linuxrc will automatically run mkswap and swapon. You may want to make sure the swaputils.tgz package is included, although it will be loaded automatically if /sbin/makeswap isn't found. 5.4 Tmpfs A neat feature that came out in 2.4 was the ability to use the temporary or shared memory filesystem instead of ramdisks. The key advantage is that ramdisks are completed allocated when the are created, but tmpfs partitions only use RAM as they are filled. Trinux only has support for a minimal set of filesystems 6. Management and Monitoring Although it is probably not the most common option, Trinux can be used in a headless server capacity 6.1 Serial Console 6.2 SSH Remote Logins 6.3 Enabling Cisco Discovery Protocol (CDP) 6.4 Building a Local Package Server 7. Miscellaneous 6.1 Troubleshooting Recent versions of trinux have a /sbin/hwinfo script that gathers hardware information about the system and saves it to the file /tmp/hwinfo. It basically saves the output of the dmesg command and copies the values of some /proc files that can be used to help troubleshoot hardware problems. The following commands allow you to save this file to the boot floppy (assuming you have enough room) # fmount # cp /tmp/hwinfo /floppy # fumount You can then post some or all of this file to the trinux-talk mailing list when you have a problem. 6.2 Where to get help You should subscribe to the trinux-talk mailing list