![]() Standard Compact and Low Power Linux Servers |
![]() |
|
|
LinkGear Series 100 FAQ How do I login to the LinkGear?
How can I cross-compile applications for the LinkGear? How can I build applications natively on the the LinkGear? How do I build a root file system on a USB drive? Why does lilo throw an exception when booting from a USB hard drive? Why did my USB drive not mount on /dev/sda1? How do I install rpms on the LinkGear internal flash block device if it doesn't have rpm installed? How do I setup an NFS server to mount the LinkGear file system? How do I start NFS on the LinkGear? How do I configure the NFS export directory? Where can I get the kernel source? How do I build the kernel? How do I install and boot a newly built the kernel? How do I configure the LinkGear as a diskless network computer? Can I extract a binary kernel image the compressed kernel image vmlinuz? How do I backup and restore the internal flash block device? How do I shutdown the LinkGear? Can I build my own file system? How does the LinkGear keep time? Why is the NFS server not working? I think I set everything up correctly Why can I not login as root? I only get the message "Login incorrect" I get the following message "error: cannot open Packages index using db1 - No such file or directory (2)" when I run rpm. How do I get additional help if I still have questions about running Linux on the LinkGear? How do I login to the LinkGear?There are two ways to login to the LinkGear, a RS-232 serial console or a ssh. Directions to connect from either method is explained in the startup guide. [top] How can I cross-compile applications for the LinkGear?Cross development is simply running the software development tools (gcc, make, ld, etc.) on the host machine to create an executable file which runs on a different machine, the LinkGear in this case. Therefore, when cross-compiling, it is possible to build on the host PC then run and debug the executable on the target platform. Install the Tools First install the following tool packages on your host machine (thanks to the people at linuxsh supporting the SH4 linux port):
These and other SH cross development packages, other than the linux-libc-headers, can also be found at rpm.sh-linux.org/rpm-index-2004/index.html. After installing the packages, proceed with the standard GNU procedure to build a program using configure and make. To setup the make environment for a sh4 target, it may be necessary to execute some or all of the following commands:
host> export CC=sh4-linux-gcc (sometimes necessary)
host> export CC_FOR_BUILD=gcc (sometimes necessary)
host> ./configure --host=sh4-linux --build=i686-linux --target=sh4-linux- --prefix=/mnt
The configure script may fail to recognize the sh4-linux-target or is not able to build because it attempts to execute test code on the host machine, which will fail. It may be possible to edit the configure script, but not always. If configure fails switching to a native build on the LinkGear is recommended. Otherwise, build the application: host> makeInstall the application With GNU tools, the next step is usually make install. But before you do this, make absolutely sure the prefix option is added to the configure command line to install the sh-linux application to the target file system, not the default host file system. After the build is successful and the target file system is mounted via nfs, run host> make installWarning: do not run make install without the --prefix=target_mount_point set on the ./configure command line. If the --prefix= option is not used, SH binaries will be installed on your host machine and could potentially corrupt your the linux installation of your host machine. [top] How can I build applications natively on the LinkGear?To build an application on the LinkGear, you will need to boot the development file system. The development filesystem includes the GNU GCC compiler and other build tools not included in the minimum file system on the internal flash block device. For a description of the file systems shipped with the LinkGear see Root File Systems on the startup page. The simplest way to boot an alternate file system is with an external USB storage device, such as USB flash or hard drive (512MB or greater is recommended). On your host machine, download the development file system tar file and follow the procedure described below to copy and boot this file system on an external USB drive. You may need to become the super user to run these commands successfully. Warning: this procedure will erase all data on the disk. Attach a USB drive to the host machine. Type dmesg or view the syslog to find the device name of the inserted USB drive. Here we assume it is sda1). Run fdisk /dev/sda to create a single partition on the USB device, if necessary. Now copy the file system onto the drive as follows: host> mke2fs -j /dev/sda1
host> mount /dev/sda1 /mount_point
host> pushd /mount_point
host> tar -jxf lg100-Develfs.tar.bz2
host> mv /mount_point/lg100-Develfs/* .
host> rm -fr /mount_point/lg100-Develfs/*
host> popd
host> sync
host> umount /mount_point
The sync command will ensure all buffers are written to the drive. Remove the USB drive from host PC and attach it to the LinkGear. The following steps are necessary to make the disk bootable. target# mount /dev/sda1 /mount_point
target# vi /mount_point/etc/lilo.conf
target# lilo -r /mount_point -b /dev/sda
target# umount /mount_point
Editing lilo.conf is not necessary in most cases. Reboot the LinkGear and hit the F2 function key to enter setup. Move the the USB drive to the top of the boot order. Directions for this are in the User Guide. The LinkGear should now boot from the USB drive. You can access the internal block device, for rpm installation etc, by mounting the internal device, target# mount /dev/sm0p1 /mount_point.[top] Why does lilo throw an exception when booting from a USB hard drive?Lilo, the LInux LOader, either loaded the second stage loader or the kernel from a file located above cylinder 1024 of the USB hard drive. The LinkGear runs a modified lilo based on version 21, which still has the 1024 cylinder limitation. The cyclinder number was truncated by lilo, causing an incorrect sector read. Executing this garbage code caused an exception. The solution is to create a boot partition before cyclinder 1024. Both boot.b and vmlinuz should be placed in the boot partition mounted on at /boot on the root file system. [top] Why did my USB drive not mount on /dev/sda1?Block device files sda,sdb, etc, are assigned to the first USB drive detected; the first drive detected by the usb-storage driver will be assigned to /dev/sda, the second drive inserted will be assigned to /dev/sdb, and so on. If two USB drives are installed on boot-up, detection starts from USB port 1 and continues to port 5. The three external USB ports are ports 1, 2 and 5. 1 being closest to the DB9 serial console and 5 closest to the network RJ45 receptacle. The optional internal USB-IDE/CF-ATA adapter is USB 3. Example: the root file system is installed on an internal USB drive. It will be assigned /dev/sdb if a USB storage drive is installed in port 1 or 2. This will cause problems booting if the root device was set to /dev/sda1 on the command line argument appended by lilo or in /etc/fstab. To safely add an additional drive in this situation, attach it to port 5. [top] How do I install rpms on the LinkGear flash block device if it doesn't have rpm installed?Mount a development file system as root and use the rpm option -r /mount_point, where mount_point is the mount point for the the internal flash block device at /dev/sm0p1. The development file system can be mounted either via the network with NFS, or on a USB storage device. In either case, mount the internal flash block device, target# mount /dev/sm0p1 /mount_pointInstall rpm binary package(s), target# rpm -Uvh --root /mount_point --excludedocs package_name.sh4.rpmor target# rpm -Uvh --root /mount_point --excludedocs package_name.noarch.rpmQuery installed packages, target# rpm -qa --root /mount_pointUninstall (erase) package(s), target# rpm -e --root /mount_point package_nameIf the --excludedocs command line option is omitted, the filesystem will quickly fill up with man pages and info files. Also RPM performs a dependency check during install and uninstall. If you decide the dependency is not required, use the --nodeps option on the install and uninstall command line. To learn more about how to use the rpm package manager, go to www.rpm.org. [top] How do I setup an NFS server to mount the LinkGear file system?The LinkGear is shipped with an NFS server and can be used to access the target filesystem. Because the nfs server is not enabled by default, a few steps are necessary. First, connect the LinkGear to the network. In this example the eth1 port is used. The default setting for eth1 is a static IP address of 192.168.0.1. There is also, as shipped, a dhcp server running on eth1. If your setup requires a different IP address or eth1 configured as a dhcp client, see Appendix B in the Startup Guide. To identify the ip address, login to the LinkGear and type, target# ip link show eth1
3: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:15:61:00:00:01 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.1/24 brd 192.168.1.255 scope global eth1
Second, define the nfs access rights necessary for the host machine to mount the target file system. Using vi, the default text editor, add an entry to the /etc/exports file. A very insecure entry, but useful in this example, is,
target# cat /etc/exports
/ *(rw,sync,no_root_squash)
target# exportfs -v
/ <world>(rw,wdelay,no_root_squash)
Once the exports file is edited, the server will need to be started. target# /etc/initd/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
Mount the target file system onto the development host as follows: host> mount
target_ip:/ /mount_point -t nfs
Troubleshooting Tip Confirm the iptables kernel packet filter, running on the host, is not blocking ports used by NFS or portmap. To check, turn packet filtering off with the following command, host> /etc/init.d/iptables stopFor more info on NFS see http://nfs.sourceforge.net/nfs-howto/ [top] Where can I get the kernel source?A source RPM is available on the downloads page. This source rpm includes a patched version of the official kernel from kernel.org. The LinkGear kernel patch is included for reference. Alternatively, this patch can be downloaded directly and applied to the official linux kernel, see below for the necessary steps to retrieve the kernel and patch. [top] How do I build the kernel?For those who want to build or modify the linux kernel, the SH4 cross development tools and a patched Linux kernel source tree are necessary to build a kernel on a linux host machine that will run on the LinkGear. See this FAQ for instructions on downloading the SH4 build tools. Of course, it is also possible to build the kernel directly on the LinkGear platform. This requires less setup, but the kernel build time will be considerable longer. There are two ways to retrieve the kernel sources, download the source rpm and install it on the host system. host> rpm -i http://linux-kernel-download-link.src.rpmthe rpm package manager should install a kernel tar.bz2 file into the rpm _topdir/SOURCES directory. The _topdir directory is /usr/src/unknown. Untar the file into a build directory. host> cd kernel_build_dir
host> tar -jxf _topdir/SOURCES/kernel-source.tar.bz2
Or, download this Linkgear linux kernel patch and apply it to the official linux-2.6.16 kernel from kernel.org. In both cases, apply any mainline kernel patches, e.g patch-2.6.16.27 host> tar -jxf kernel-2.6.16.tar.bz2
The simplest way to build the kernel is to build a kernel rpm package. The rpm make target will build the full kernel binary and modules in one step. The added benefit is an rpm package that can be applied to any number of LinkGear installations as an update package. The steps to make a kernel rpm are explained here. The standard kernel build procedure is explained below. Build a Kernel RPM host> bunzip2 patch-2.6.16.27.bz2
host> cd kernel-2.6.16
host> patch -p1 < ../kernel-2.6.16-4.patch
host> patch -p1 < ../patch-2.6.16.27
host> cp arch/sh/configs/linkgear100_defconfig .config
host> make ARCH=sh CROSS_COMPILE=sh4-linux- rpm
Build the Kernel and Modules using the Patch File host> tar -jxf linux-2.6.16.tar.bz2
host> bunzip2 patch-2.6.16.27.bz2
host> cd kernel-2.6.16
host> patch -p1 < ../linkgear-linux-1.1-2.6.16-4.patch
host> patch -p1 < ../patch-2.6.16.27
host> cp arch/sh/configs/linkgear100_defconfig .config
host> make ARCH=sh CROSS_COMPILE=sh4-linux- oldconfig
host> make ARCH=sh CROSS_COMPILE=sh4-linux-
The first make command updates the build directory with settings in the .config file. The second make command has no target,defaults to 'all', building the kernel, modules and compressed image. [top] How do I install and boot a newly built kernel?The installation of the kernel is different for the internal flash block device, a USB storage device, or a network root file system. Installation to the Internal Block Device host> cp arch/sh/boot/zImage /mount_point/boot/vmlinux-2.6.16.27
host> make ARCH=sh CROSS_COMPILE=sh4-linux- INSTALL_MOD_PATH=/mount_point modules_install
The next step is very important. From a target console, run lilo, target# lilo
Added usb
Added default *
Installation to a USB Storage Device target# rpm -Uvh kernel-2.x.x-x.sh4.rpm
Otherwise, if the kernel will be installed using the install and modules_install make targets, the target file system will need to be mounted on the host machine. Install the kernel to the target file system as follows, host> mount /dev/sda1 mount_point
host> cp arch/sh/boot/zImage /mount_point/boot/vmlinux-2.6.16.27
host> make ARCH=sh CROSS_COMPILE=sh4-linux- INSTALL_MOD_PATH=/mount_point modules_install
The next step is very important. Mount the USB drive on a LinkGear and run lilo, target# mount /dev/sda1 /mount_point
mount_point
target# chroot /mount_point lilo
Added default *
Added internal_flash
Installation to a Network Root file System For simplicity, these directions assume the build host machine is the same network server running DHCP and TFTP. First, build the kernel as before and copy the kernel binary vmlinux.bin to the TFTP directory, host> cp vmlinux.bin /tftpboot
Next, install the modules to the root file system on the host, host> make ARCH=sh CROSS_COMPILE=sh4-linux- INSTALL_MOD_PATH=target_root_file_system modules_install
See also the network boot FAQ. [top] How do I configure the LinkGear as a diskless network computer?A diskless, or network computer, uses a network file system as the root device. The kernel is downloaded via a TFTP server and the root device is mounted via an NFS server. The following servers are required on the host machine.
The network boot process consists of three phases:
If a new linuux kernel is built, the following two options should ne included in the kernel configuration, Linux Kernel Configuration
Device Drivers --->
[*] Networking support
Networking options --->
[*] IP: kernel Level autoconfiguration
[*] IP: DHCP support
and
File systems --->
Network File Systems --->
[*] Root file system on NFS
Copy the development file system into an NFS exportable directory on the host machine. Then, to make this directory mountable as a root file system, modify the file /etc/fstab in this root file system, replacing the root mount with the NFS mount point nfsserveripaddress:/dir / nfs exec,suid,rw The default LinkGear Linux kernel includes the configuration shown above. However, in normal operation, network auto-configuration is supressed by a command line option ip=off. This option can be found in the file /etc/lilo.conf The LinkGear boots from the onboard flash by default. To boot from the network, there are two methods.
[top] Can I extract a binary kernel image the compressed kernel image vmlinuz?Yes. Although the kernel binary image, vmlinux.bin, is included in the development file system and in the top directory when the kernel is compiled, the binary image can also be extracted from vmlinuz files. Here are the steps to extract this binary image. First find the start of the image. It will be in the .data section which probably starts on a 4k boundary. The image may be a few bytes into the 4k page (in the 2.6.16.27 release the stack pointer and image length were at the start of the page). use the dd command on vmlinuz and search for the gzip header (in this case it was found in the third page at 0x3000 into vmlinuz). target# dd < /boot/vmlinuz-2.6.16.27 count=1 bs=512 skip=24 | hexdump -C
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000103 seconds, 5.0 MB/s
00000000 00 00 b4 88 9b 7c 12 00 1f 8b 08 00 35 a5 f8 44 |.....|......5..D|
00000010 02 03 ec 7d 6d 54 5b d7 b5 e0 b9 ba 42 5c 71 f9 |...}mT[.....B\q.|
00000020 90 ae f8 12 08 f4 85 b1 04 d8 42 12 c6 38 76 12 |..........B..8v.|
00000030 09 92 98 38 4e 84 24 fc 91 d6 6d f5 89 01 3b a9 |...8N.$...m...;.|
The gzip header will start with the hex bytes 0x1f and 0x8b, followed by 7 bytes and then 0x03. The second step is to extract the compressed binary image from vmlinuz. target# dd < /boot/vmlinuz-2.6.16.27 bs=512 skip=24 > tmpfile
Now, using the offset into the 4k page, in this case 8 bytes, redirect the compressed image data to gzip. target# dd < tmpfile ibs=8 skip=1 obs=4k | gzip -d -c > tmpfile2
Extra bytes beyond the image size copied by dd will be ignored by gzip. The last step is to add the empty zero page removed during the building of vmlinuz. target# dd < /dev/zero bs=512 count=8 > vmlinux.bin
target# cat tmpfile >> vmlinux.bin
target# rm tmpfile
[top] How do I backup and restore the internal flash block device?Boot the LinkGear from an alternate file system, either a NFS mounted file system or a USB
mounted file system. To save a copy of the file system image, login to LinkGear and copy the internal
flash block device to a file, To restore the internal block device to the factory-installed filesystem or a
previously saved image, first copy the saved image or the minimum flash file system image to
the root file system. Next copy the flash image to the internal
flash block device, It will take approximately 5 minutes to write the 128MB image to the internal flash block device. [top] How do I shutdown the LinkGear?Do not just disconnect power. As with all linux machines, the file system could be
damaged. The linux file system caches block writes to disks. A sudden
shutdown will prevent the the write buffers from being written to the disk.
To shutdown the system type Unintended power loss can also cause disk corruption. A read-only file system configuration using a custom /linuxrc file and the bind properties of mount, has been developed for the LinkGear. This configuration will run with the internal flash file system mounted as read-only. All read-writeable directories are redirected to a file system copy mounted using the tmpfs file system in RAM. [top] Can I build my own file system?Yes. However, the boot sequence and certain kernel requirements need to be satisfied. Refer to the Bootdisk-Howto. Note: the device name of internal flash block device is /dev/sm0 and partitions are enumerated as /dev/sm0p1, /dev/sm0p2, etc. The device name for USB external drives are the standard SCSI disk device names sd[a-z][0-9]. After you copy the new file system to the device, you will need to run lilo, target# chroot /mount_point lilo
Added default *
Added internal_flash
where /mount_point is the USB storage device or the internal flash block device. [top] How does the LinkGear keep time?The LinkGear does not have a battery. The time is lost when power is removed. Therefore, a network time protocol (NTP) daemon is used to set and maintain the system time of day. The default time server is time.nist.gov. To change the time server edit /etc/ntp.conf and /etc/ntp/step-tickers. [top] Why is the NFS server not working? I think I set everything up correctlyFirst, verify the /etc/exports file is correct. Second, if the error message "rpc.mountd: getfh failed: Operation not permitted" appears, check the system time. The NFS server requires a reasonable system time. If neither of these suggestions helps, see http://nfs.sourceforge.net/nfs-howto/ [top] Why can I not login as root on the serial console? I only get the message "Login incorrect"Add ttySC1 to /etc/securetty. This file lists the ttys from which the root can log in. It may be necessary to login from the network through a secure shell, or mount the file system from a different root file system to edit this file. [top] I get the message "error: cannot open Packages index using db1 - No such file or directory (2)" when I run rpm.The rpm package manager version used to install some packages was different than the rpm version used to build the file systems. Also, the rpm package manager may have been run from a host of a different architecture. RPM packages should be installed natively. This will allow all pre- and post-installation scripts to execute properly. To repair the LinkGear database run, target# rpm --rebuilddb
[top] How do I get additional help if I still have questions about running Linux on the LinkGear?The LinkGear Linux User Forum is available for the LinkGear support team, system integrators, developers and other users to answer questions about running linux on the LinkGear. While the LinkGear support team will attempt to answer all questions posted to the forum, the universe of linux questions that apply to the LinkGear is too immense to guarantee a useful response to every post. [top] |
|
jjplus home | LinkGear home | products | support | tour all contents copyright ©2006 JJPLUS Corporation |