Cvs notes:
Sandbox: A sandbox is a local copy of a project’s files.
Repository:
When you create a sandbox, you need to specify the repository to which to which it is connected. You do this by setting the repository path, either by putting it in the CVSROOT environment variable on you client computer, or by declaring it in the –d command option when you check out the sandbox. CVS stores the repository path in the sandbox.
The cvs checkout command is used to create a sandbox. Once the sandbox is created, checkout no longer needs to be used sandox; update is the preferred command from that point..
Files are edited in the sandbox, but changes to the sandbox have no effect on the repository until the are commited. The cvs commit uploads changes from the sandbox to the repository.
The cvs commit command uploads changes to from the sandbox to the repository, cvs update downloads changes from the repository to the sandbox.
Creating a repository:
To create a repository, create the repository root directory on the computer that will act as the CVS server and ensure that the root directory is owned by the user who will ultimately own the repository. Execute the command:
$> cvs –d repository_root_directory init
Where repository_root_directory is the name of your directory, to setup that directory as a CVS repository. The root must be given an absolute path, not a relative path.
Note: ensure there is enough room for three times the expected final size of the project
If you intend to store binary files then five times the size.
Securing the project.
Sandboxes are checked out of the repository with the username of the user who creates them or does the checking out.
Repository Root Directory:
Secure the repository root directory so that only users who are allowed to create new projects have write access. Users who will be using existing repository projects, even though they may creating and writng to projects files should only have read access to this directory.
Project Directories:
Group ownership of project files and directories controls project security. Ensure that each project is group-owned by a group with appropriate membership, and set the group permissions for the project files to the project’s group.
In UNIX or linux set each directory’s SGID bit to ensure that any new files or directories created in the directory are created with the same group ID as the directory the are created in. Use the command chmod g+s directory to set the SGID bit.
Repository Structure:
A CVS repository is composed of the special CVSROOT administrative directory and any project directories you create. All the CVS administrative files and configuration files are kept in CVSROOT.
CVS Subdirectory:
The only file stored in the CVS subdirectories in a repository is fileattr. Which lists the file attributes of the files in the parent directory.
Locks:
CVS uses read and write locks to prevent processes from simultaneously writing to or reading from the same repository files. These locks are signaled by the presence of a file or directory with a specific name patter in project directories.
CVSROOT Files:
The CVSROOT directory contains administrative files that contain information about the project stored in CVS.
It is good practice to have a specific username to own the CVSROOT directory and the repository root directory, and to be the initial owner of the CVSROOT files.
Create a group to have the group ownership of the CVSROOT directory and files, and include only trusted people in that group.
Configuration Files:
Config:
LockDir=directory
CVS puts lock files in the nominated directory rather than in the repository. This allows you to set the repository directories read-only for people who should not be commiting changes.
LogHistory=value
The text in value controls which actions are logged to the history file in the repository’s CVSROOT directory. The valid values are any combination of the following letters:
A Log when a file is added to the repository.
C Long when a file would have been updated in a sandbox, but needed to be merged and there where conflicts in the merge.
E Log when a file or files are exported.
F Log when a file or files are released.
G Log when a file is updated in a sandbox with a successful merge.
M Log when a file si modified (a sandbox revision is added to the repository).
O Log when a file or files are checked out.
R Log when a file is removed from the repository.
T Log when a file or files are tagged or rtagged.
U Log when a file is updated in a sandbox with no merge required
W Log when a file is deleted from a sandbox during an update because it is no longer active in the repository.
RCSBIN=directory
SystemAuth=value
This option is useful only if the client connects to CVS in pserver mode. It applies to CVS Versions 1.9.14 and later. If value is yes, the server authenticates the connecting user with the passwd file in the repository’s CVSROOT directory. If the user fails to authenticate there, the server authenticates the user against the main user database for the operating system.
If the value is no, the server authenticates the user only against the passwd file.
The default is yes.
Modules:
The modules file contains information about projects in the repository and can group arbitrary files or directories into a single module.Information in this file must be created by the repository or project administrator; CVS does not update this file when a new project is imported. Once a module is defined, the project and directories it defines can be checked out into a sandbox using either the module name or the name of the repository directory it represents.
Backing Up A Repository:
A CVS repository can be backed up using the same backup tools and schedule that you use for ordinary text and binary files.
Quick start guide I have used successfully:
1. Create a CVS user (for example 'cvsuser') using useradd. This will also create a group called 'cvsuser' which will be used to grant CVS access to other users.
For example:
[jdavis]$ su root
Password: {enter password}
[root]# /usr/sbin/useradd -c 'CVS root user' cvsuser
[root]# passwd cvsuser
New password: {enter password}
Retype new password: {enter password}
2. Create a folder for the initial repository using the 'cvsuser' account, or chown / chgrp it to 'cvsuser'.
[root]# mkdir /cvsrepo
[root]# chown cvsuser /cvsrepo
3. Set the 'group sticky bit' on all directories used by CVS (See "CVS File Permissions").
[root]# chmod g+s /cvsrepo
4. Initialize the repository using cvs init
[jdavis]$ su cvsuser
Password: {enter password}
[cvsuser]$ cvs -d :local:/cvsrepo init
5. Set up the lock directory
This is an important step. If lock directory is not set, the CVS daemon will try to create lock files in the repository directory, which will result in 'failed to create lock directory' error message when users perform any operations on the repository.
Create the lock directory first. For example:
[root]# mkdir /var/lock/cvs
[root]# chgrp -R cvsuser /var/lock/cvs
[root]# chmod -R g+w /var/lock/cvs
Then, configure CVS to use the lock directory. Change to a temporary directory, for example /home/cvsuser (which was created by the useradd command above), and check out the CVSROOT module from the repository using the local filesystem mode (not pserver mode). Edit the CVSROOT/config file and either uncomment or add a line 'LockDir=/var/lock/cvs'.
[root]# cd /home/cvsuser
[root]# cvs -d :local:/cvsrepo co CVSROOT
[root]# vi CVSROOT/config
... uncomment or change the line that defines LockDir...
for example: LockDir=/var/lock/cvs
[root]# cvs -d :local:/cvsrepo commit CVSROOT
6. Set up the cvs daemon:
for systems that use inetd - Add a line to the /etc/inetd.conf file
cvspserver stream tcp nowait root /usr/bin/cvs cvs --allow-root=/cvs pserver
Make sure /etc/services contains the line
cvspserver 2401/tcp
for systems that use xinetd - Create a 'cvspserver' file:
Sample /etc/xinet.d/cvspserver file
service cvspserver
{
socket_type = stream
wait = no
user = root
group = cvsgroup
env = HOME=/cvsrepo # Fixes RHL 7.0 problem!
server = /usr/bin/cvs
server_args = -f --allow-root=/cvsrepo pserver
disable = no
}
7. Restart inetd (or xinetd).
[root]# /etc/init.d/xinetd restart
Wednesday, May 10, 2006
Sunday, March 26, 2006
building qemu on fedora core 4(5)
the real pain the butt is getting the kernel sources
installed on the system and getting the
older version of gcc.
take a look at this link
http://www.brandonhutchinson.com/Installing_QEMU_with_Accelerator_Module_on_Fedora_Core.html
./configure --prefix=/usr/local/qemu --cc=gcc32
installed on the system and getting the
older version of gcc.
take a look at this link
http://www.brandonhutchinson.com/Installing_QEMU_with_Accelerator_Module_on_Fedora_Core.html
./configure --prefix=/usr/local/qemu --cc=gcc32
Saturday, August 27, 2005
moving to a linux 2.6 live cd system
the current problems (pros/cons)
the pros.
i know how to use debian/ubuntu content onto the live
cds system. xorg, etc.
i know where to trim un-need files.
the cons
i cant mount a cd using the current kernel and initial ram-disk
this main an largest problem i have to be able
to mount the cdimage and some point preferably /cdrom
once the cdrom is mounted then i can mount the squashfs images.
first thing build a kernel with the squasfs patches applied.
the pros.
i know how to use debian/ubuntu content onto the live
cds system. xorg, etc.
i know where to trim un-need files.
the cons
i cant mount a cd using the current kernel and initial ram-disk
this main an largest problem i have to be able
to mount the cdimage and some point preferably /cdrom
once the cdrom is mounted then i can mount the squashfs images.
first thing build a kernel with the squasfs patches applied.
Thursday, June 02, 2005
after a long hiatus
more about xorg.
xorg makes decision about what driver to load
based on doing a scan of the pci bus.
goal: write a script that calls scanpci
parses the vendor and device tags
if it find a recognized combination
it then creates an xorg.conf file if
it fails to do so the scrip should
say create vesa mode xorg.conf or even
just die and not exec xorg.
if (vendor and device)
make /etc/xorg.conf
else
make vesa based /etc/xorg.conf
exec startx
this would be under a specific user that
is not root!
this same user would have to have correct
dot files:
.xinitrc
.xserverrc
the .xinitrc is where the fun would begin!
parse the output of scanpci would be easy.
but i would need to understand the structure
of the /etc/xorg.conf file well enough to
add/replace the sections to say. what drive
to start and what modeline.
what are the sections of xorg.conf file:
1) Files
2) ServerFlags
3) InputDevices
4) Monitor
5) Modes
6) Device
7) Screen
8) ServerLayout
Files would be the fonts and drivers, i am guessing
but the locations would be fixed this is not
Server Flags i dont know what these would need to be.
Input Devices again this would be fixed and would stay
fixed this distro would run for one type of machine.
the idea would be this there wold a xorg.conf for
a type box in production lets say all the boxen
where of type foo-nvidia-psaux-2005.txt
that is a foo box with all the same kind of nvidia driver
all using psaux as the mouse device that were in production
in 2005 or some other unique identifer. but for testing
there was somethig like foo-vmware-psaxu-2005.txt this would
be a config for vmware so testing could be done on vmware
or qemu or uml. something like that. there would be little
or no shell script it would be
if vendor == someid and device == someide then
cp foo-nvidia-psaux-2005.txt /etc/xorg.conf
the distory
would have all the files
xorg makes decision about what driver to load
based on doing a scan of the pci bus.
goal: write a script that calls scanpci
parses the vendor and device tags
if it find a recognized combination
it then creates an xorg.conf file if
it fails to do so the scrip should
say create vesa mode xorg.conf or even
just die and not exec xorg.
if (vendor and device)
make /etc/xorg.conf
else
make vesa based /etc/xorg.conf
exec startx
this would be under a specific user that
is not root!
this same user would have to have correct
dot files:
.xinitrc
.xserverrc
the .xinitrc is where the fun would begin!
parse the output of scanpci would be easy.
but i would need to understand the structure
of the /etc/xorg.conf file well enough to
add/replace the sections to say. what drive
to start and what modeline.
what are the sections of xorg.conf file:
1) Files
2) ServerFlags
3) InputDevices
4) Monitor
5) Modes
6) Device
7) Screen
8) ServerLayout
Files would be the fonts and drivers, i am guessing
but the locations would be fixed this is not
Server Flags i dont know what these would need to be.
Input Devices again this would be fixed and would stay
fixed this distro would run for one type of machine.
the idea would be this there wold a xorg.conf for
a type box in production lets say all the boxen
where of type foo-nvidia-psaux-2005.txt
that is a foo box with all the same kind of nvidia driver
all using psaux as the mouse device that were in production
in 2005 or some other unique identifer. but for testing
there was somethig like foo-vmware-psaxu-2005.txt this would
be a config for vmware so testing could be done on vmware
or qemu or uml. something like that. there would be little
or no shell script it would be
if vendor == someid and device == someide then
cp foo-nvidia-psaux-2005.txt /etc/xorg.conf
the distory
would have all the files
Sunday, May 01, 2005
http://www15.big.or.jp/~yamamori/sun/tech-linux-2/index_e.html
http://www15.big.or.jp/~yamamori/sun/tech-linux-2/index_e.html
good pointers about single user mode.
good pointers about single user mode.
Wednesday, April 27, 2005
initial ramdisk howto i found
http://inferno.slug.org/lfs-hints/initrd.txt
TITLE: initrd for LFS
LFS VERSION: any
AUTHOR: Jim Gifford
SYNOPSIS:
How to setup initrd for LFS.
HINT:
$Revision: 1.8 $
Introduction to Initial RAMDisk
This hint will help you configure an LFS system for Initial RAMDisk.
Which will allow you to add modules at start-up instead of compiling them
into the kernel.
The script that is enclosed works with SCSI and USB modules only. IDE
devices are recommened to be built-in the kernel. The script will
auto-detect all SCSI and USB modules and add them to the initial ramdisk.
It will also detect the root from the fstab file
---
Assumptions Made in this document
I have made the following assumptions in this document.
Files have been downloaded.
---
Kernel Configuration
You will need to make sure the following items are configured
in your kernel. With out these, the initrd will not work.
Block Devices
Select Loopback Device Support this can be a module
or built-in.
Select RAM Disk Support this needs to be compiled as
built-in or the initrd will not show up.
Set Default RAM Disk size is 4096 which is the default
Select Initial RAM Disk (initrd) support needs be selected.
---
Needed File System Changes
You will need to create a directory for initrd to use.
The default one that is looked for is /initrd.
To Create this directory use mkdir /initrd
Another change that needs to be made is due to a bug
in busybox itself.
You will need to create a symlink to init and call it
linuxrc
cd /sbin
ln -sf init linuxrc
---
Needed Static Modules
In order for the initrd to work properly during boot up
you will need to create to static programs.
The first one being bash.
busybox
----
Busybox has a Config.h file that needs the following options
enabled to enable them remove the //
#define BB_INSMOD
#define BB_FEATURE_SH_STANDALONE_SHELL
You can configure the rest as you need, but remember have at
least the following enabled to make initrd to work properly.
#define BB_ASH
#define BB_CHROOT
#define BB_ECHO
#define BB_INSMOD
#define BB_MKDIR
#define BB_MODPROBE
#define BB_MOUNT
#define BB_PIVOT_ROOT
#define BB_UMOUNT
To create a static version of bash needed for initrd use
the following commands.
cd /usr/src
tar zxvf /usr/src/busybox-*.tar.gz
cd busy*
make LDFLAGS=-static
cp busybox /bin/busybox
Busybox must be in the /bin directory or the links created
during the initrid will fail.
---
mkinitrd
For those who do not want to type out the script. It is
available on my CVS server at
http://www.jg555.com/cvs/cvsweb.cgi/scripts/mkinitrd-lfs
This script will create the initial RAM Disk image file.
By default this script creates /boot/initrd.img
The default location for this file is /sbin
#!/bin/bash
# mkinitrd for LFS by Jim Gifford
# $Revision: 1.8 $
# Variables
TEMP="$1"
KERNEL_VERSION=""
CONFIG_FILE="/etc/modules.conf"
FSTAB="/etc/fstab"
ROOT_DEVICE=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $FSTAB)
SCSI_MODULES="`grep scsi_hostadapter $CONFIG_FILE | grep -v '^[ ]*#' | awk '{ print $3 }'`"
NEEDED_SCSI="scsi_mod sd_mod"
USB_MODULES="`grep usb-controller $CONFIG_FILE | grep -v '^[ ]*#' | awk '{ print $3 }'`"
NEEDED_USB="usbcore"
MODULES="$NEEDED_SCSI $SCSI_MODULES $NEEDED_USB $USB_MODULES"
IMAGE_SIZE=3000
MOUNT_IMAGE="/tmp/initrd.$$"
IMAGE="/tmp/initrd.img-$$"
MOUNT_POINT="/tmp/initrd.mnt-$$"
LINUXRC="$MOUNT_IMAGE/linuxrc"
# Check for initrd Directory
if ! [ -e /initrd ]
then
mkdir /initrd
fi
# Check for RAM Disk Device
if [ -e /dev/.devfsd ]
then
RAM_DEVICE="rd"
else
RAM_DEVICE="ram0"
fi
# Check for input
if [ "$TEMP" == "" ]
then
KERNEL_VERSION="`uname -r`"
else
KERNEL_VERSION="$TEMP"
fi
INITRD="/boot/initrd-$KERNEL_VERSION.img"
if [ "$TEMP" == "-h" ] || [ "$TEMP" == "--h" ] || [ "$TEMP" == "-help" ] || [ "$TEMP" == "--help" ]
then
echo "usage: mkinitrd kernel_version"
echo " : mkinitrd will automatically determin kernel version"
exit 1
fi
# Creating LoopBack Device
dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGE_SIZE 2> /dev/null
for device_number in 0 1 2 3 4 5 6 7 8
do
if losetup /dev/loop$device_number $IMAGE 2>/dev/null
then
break
fi
done
if [ "$device_number" = "8" ]
then
rm -rf $MOUNT_POINT $IMAGE
echo "All of your loopback devices are in use!" >&2
exit 1
fi
LOOP_DEVICE=/dev/loop$device_number
echo y | mke2fs $LOOP_DEVICE $IMAGE_SIZE > /dev/null 2> /dev/null
echo "Using loopback device $LOOP_DEVICE"
mkdir -p $MOUNT_POINT
mount -t ext2 $LOOP_DEVICE $MOUNT_POINT || {
echo "Can't get a loopback device"
exit 1
}
# Creating Directories
mkdir -p $MOUNT_IMAGE
mkdir -p $MOUNT_IMAGE/lib
mkdir -p $MOUNT_IMAGE/bin
mkdir -p $MOUNT_IMAGE/etc
mkdir -p $MOUNT_IMAGE/dev
mkdir -p $MOUNT_IMAGE/proc
ln -s /bin $MOUNT_IMAGE/sbin
rm -rf $MOUNT_POINT/lost+found
# Copying Static Programs
cp -a /bin/busybox $MOUNT_IMAGE/bin/busybox
ln -s /bin/busybox $MOUNT_IMAGE/bin/echo
ln -s /bin/busybox $MOUNT_IMAGE/bin/mount
ln -s /bin/busybox $MOUNT_IMAGE/bin/modprobe
ln -s /bin/busybox $MOUNT_IMAGE/bin/mkdir
ln -s /bin/busybox $MOUNT_IMAGE/bin/sh
ln -s /bin/busybox $MOUNT_IMAGE/bin/umount
ln -s /bin/busybox $MOUNT_IMAGE/bin/insmod
ln -s /bin/busybox $MOUNT_IMAGE/bin/pivot_root
cp -a /etc/fstab $MOUNT_IMAGE/etc/fstab
cp -a /etc/modules.conf $MOUNT_IMAGE/etc/modules.conf
# Copying Modules
for MODULE in $MODULES
do
echo "$MODULE" | {
IFS=':' read module options
module=$module
options=$options
DIR_SEARCH1="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers`"
for DIR_1SEARCH in $DIR_SEARCH1
do
cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
DIR_SEARCH2="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH`"
for DIR_2SEARCH in $DIR_SEARCH2
do
cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$DIR_2SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
done
done
}
done
for i in console null $RAM_DEVICE tty[1234]
do
cp -a /dev/$i $MOUNT_IMAGE/dev
done
# Creating linuxrc File
echo "#!/bin/sh" > $LINUXRC
echo "" >> $LINUXRC
echo "echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
for MODULE in $MODULES
do
echo "$MODULE" | {
IFS=':' read module
module=$module
echo "Loading module $module"
echo "insmod /lib/$module.o" >> $LINUXRC
}
done
echo "echo \"Initial RAMDISK Loading Completed...\"" >> $LINUXRC
echo "mkdir /new_root" >> $LINUXRC
echo "echo \"Mounting proc...\"" >> $LINUXRC
echo "mount -n -t proc none /proc" >> $LINUXRC
echo "echo 0x0100 > /proc/sys/kernel/real-root-dev" >> $LINUXRC
echo "echo \"Mounting real root dev...\"" >> $LINUXRC
echo "mount -n -o ro $ROOT_DEVICE /new_root" >> $LINUXRC
echo "umount /proc" >> $LINUXRC
echo "cd /new_root" >> $LINUXRC
echo "echo \"Running pivot_root...\"" >> $LINUXRC
echo "pivot_root . initrd" >> $LINUXRC
echo "if [ -c initrd/dev/.devfsd ]" >> $LINUXRC
echo " then" >> $LINUXRC
echo " echo \"Mounting devfs...\"" >> $LINUXRC
echo " mount -n -t devfs none dev" >> $LINUXRC
echo "fi" >> $LINUXRC
echo "if [ \$\$ = 1 ]" >> $LINUXRC
echo " then" >> $LINUXRC
echo " echo \"Running init...\"" >> $LINUXRC
echo " exec chroot . sbin/init dev/console 2>&1" >> $LINUXRC
echo " else" >> $LINUXRC
echo " echo \"Using bug circumvention for busybox...\"" >> $LINUXRC
echo " exec chroot . linuxrc dev/console 2>&1" >> $LINUXRC
echo "fi" >> $LINUXRC
chmod +x $LINUXRC
(cd $MOUNT_IMAGE; tar cf - .) | (cd $MOUNT_POINT; tar xf -)
umount $MOUNT_POINT
losetup -d $LOOP_DEVICE
gzip -9 < $IMAGE > $INITRD
rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
lilo -v
---
initrd script
The following script needs to placed in /etc/rc.d/init.d.
You will then need to link it to rcsysinit.d.
It is recommended that this script be run right after
mountfs.
To link the script change to the /etc/rc.d/rcsysinit.d
directory and issue the following command.
ln -sf ../init.d/initrd S41initrd
#!/bin/bash
# Begin $rc_base/init.d/initrd
# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
source /etc/sysconfig/rc
source $rc_functions
echo "Clearing Initial RAM Disk..."
if [ -e /initrd/dev/.devfsd ]
then
umount /initrd/dev
fi
umount /initrd
/sbin/blockdev --flushbufs /dev/ram0
# End $rc_base/init.d/initrd
---
For Lilo
In order to use the initrd.img file is to add the
following entry to you lilo.conf file.
initrd=/boot/initrd.img
So your lilo.conf should look something like this.
image=/boot/vmlinuz-2.4.18
label=test
initrd=/boot/initrd-2.4.18.img
read-only
append="root=/dev/ram0 init=/linuxrc rw"
If you are just testing. You should make a separate
entry in lilo.conf. This will still allow you to boot.
---
For Grub
In order to use the initrd.img file is to add the
following entry to you menu.lst file.
initrd /boot/initrd-2.4.18.img
So your menu.lst should look something like this.
title test
root (hd0,1)
kernel /boot/vmlinuz-2.4.18
initrd /boot/initrd-2.4.18.img
---
For Syslinux
In order to use the initrd.img file is to add the
following to syslinux.cfg file.
append root=/dev/ram0 initrd=initrd-2.4.18.img
So your syslinux.cfg should look something like this.
label test
kernel vmlinuz
append root=/dev/ram0 initrd=initrd.img
---
Mail suggestions to giffordj@linkline.com
New Version of this document can be viewed from
http://www.jg555.com/cvs
this looked interesting, i am going to come back and read
a bit more closesly.
TITLE: initrd for LFS
LFS VERSION: any
AUTHOR: Jim Gifford
SYNOPSIS:
How to setup initrd for LFS.
HINT:
$Revision: 1.8 $
Introduction to Initial RAMDisk
This hint will help you configure an LFS system for Initial RAMDisk.
Which will allow you to add modules at start-up instead of compiling them
into the kernel.
The script that is enclosed works with SCSI and USB modules only. IDE
devices are recommened to be built-in the kernel. The script will
auto-detect all SCSI and USB modules and add them to the initial ramdisk.
It will also detect the root from the fstab file
---
Assumptions Made in this document
I have made the following assumptions in this document.
Files have been downloaded.
---
Kernel Configuration
You will need to make sure the following items are configured
in your kernel. With out these, the initrd will not work.
Block Devices
Select Loopback Device Support this can be a module
or built-in.
Select RAM Disk Support this needs to be compiled as
built-in or the initrd will not show up.
Set Default RAM Disk size is 4096 which is the default
Select Initial RAM Disk (initrd) support needs be selected.
---
Needed File System Changes
You will need to create a directory for initrd to use.
The default one that is looked for is /initrd.
To Create this directory use mkdir /initrd
Another change that needs to be made is due to a bug
in busybox itself.
You will need to create a symlink to init and call it
linuxrc
cd /sbin
ln -sf init linuxrc
---
Needed Static Modules
In order for the initrd to work properly during boot up
you will need to create to static programs.
The first one being bash.
busybox
----
Busybox has a Config.h file that needs the following options
enabled to enable them remove the //
#define BB_INSMOD
#define BB_FEATURE_SH_STANDALONE_SHELL
You can configure the rest as you need, but remember have at
least the following enabled to make initrd to work properly.
#define BB_ASH
#define BB_CHROOT
#define BB_ECHO
#define BB_INSMOD
#define BB_MKDIR
#define BB_MODPROBE
#define BB_MOUNT
#define BB_PIVOT_ROOT
#define BB_UMOUNT
To create a static version of bash needed for initrd use
the following commands.
cd /usr/src
tar zxvf /usr/src/busybox-*.tar.gz
cd busy*
make LDFLAGS=-static
cp busybox /bin/busybox
Busybox must be in the /bin directory or the links created
during the initrid will fail.
---
mkinitrd
For those who do not want to type out the script. It is
available on my CVS server at
http://www.jg555.com/cvs/cvsweb.cgi/scripts/mkinitrd-lfs
This script will create the initial RAM Disk image file.
By default this script creates /boot/initrd.img
The default location for this file is /sbin
#!/bin/bash
# mkinitrd for LFS by Jim Gifford
# $Revision: 1.8 $
# Variables
TEMP="$1"
KERNEL_VERSION=""
CONFIG_FILE="/etc/modules.conf"
FSTAB="/etc/fstab"
ROOT_DEVICE=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $FSTAB)
SCSI_MODULES="`grep scsi_hostadapter $CONFIG_FILE | grep -v '^[ ]*#' | awk '{ print $3 }'`"
NEEDED_SCSI="scsi_mod sd_mod"
USB_MODULES="`grep usb-controller $CONFIG_FILE | grep -v '^[ ]*#' | awk '{ print $3 }'`"
NEEDED_USB="usbcore"
MODULES="$NEEDED_SCSI $SCSI_MODULES $NEEDED_USB $USB_MODULES"
IMAGE_SIZE=3000
MOUNT_IMAGE="/tmp/initrd.$$"
IMAGE="/tmp/initrd.img-$$"
MOUNT_POINT="/tmp/initrd.mnt-$$"
LINUXRC="$MOUNT_IMAGE/linuxrc"
# Check for initrd Directory
if ! [ -e /initrd ]
then
mkdir /initrd
fi
# Check for RAM Disk Device
if [ -e /dev/.devfsd ]
then
RAM_DEVICE="rd"
else
RAM_DEVICE="ram0"
fi
# Check for input
if [ "$TEMP" == "" ]
then
KERNEL_VERSION="`uname -r`"
else
KERNEL_VERSION="$TEMP"
fi
INITRD="/boot/initrd-$KERNEL_VERSION.img"
if [ "$TEMP" == "-h" ] || [ "$TEMP" == "--h" ] || [ "$TEMP" == "-help" ] || [ "$TEMP" == "--help" ]
then
echo "usage: mkinitrd kernel_version"
echo " : mkinitrd will automatically determin kernel version"
exit 1
fi
# Creating LoopBack Device
dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGE_SIZE 2> /dev/null
for device_number in 0 1 2 3 4 5 6 7 8
do
if losetup /dev/loop$device_number $IMAGE 2>/dev/null
then
break
fi
done
if [ "$device_number" = "8" ]
then
rm -rf $MOUNT_POINT $IMAGE
echo "All of your loopback devices are in use!" >&2
exit 1
fi
LOOP_DEVICE=/dev/loop$device_number
echo y | mke2fs $LOOP_DEVICE $IMAGE_SIZE > /dev/null 2> /dev/null
echo "Using loopback device $LOOP_DEVICE"
mkdir -p $MOUNT_POINT
mount -t ext2 $LOOP_DEVICE $MOUNT_POINT || {
echo "Can't get a loopback device"
exit 1
}
# Creating Directories
mkdir -p $MOUNT_IMAGE
mkdir -p $MOUNT_IMAGE/lib
mkdir -p $MOUNT_IMAGE/bin
mkdir -p $MOUNT_IMAGE/etc
mkdir -p $MOUNT_IMAGE/dev
mkdir -p $MOUNT_IMAGE/proc
ln -s /bin $MOUNT_IMAGE/sbin
rm -rf $MOUNT_POINT/lost+found
# Copying Static Programs
cp -a /bin/busybox $MOUNT_IMAGE/bin/busybox
ln -s /bin/busybox $MOUNT_IMAGE/bin/echo
ln -s /bin/busybox $MOUNT_IMAGE/bin/mount
ln -s /bin/busybox $MOUNT_IMAGE/bin/modprobe
ln -s /bin/busybox $MOUNT_IMAGE/bin/mkdir
ln -s /bin/busybox $MOUNT_IMAGE/bin/sh
ln -s /bin/busybox $MOUNT_IMAGE/bin/umount
ln -s /bin/busybox $MOUNT_IMAGE/bin/insmod
ln -s /bin/busybox $MOUNT_IMAGE/bin/pivot_root
cp -a /etc/fstab $MOUNT_IMAGE/etc/fstab
cp -a /etc/modules.conf $MOUNT_IMAGE/etc/modules.conf
# Copying Modules
for MODULE in $MODULES
do
echo "$MODULE" | {
IFS=':' read module options
module=$module
options=$options
DIR_SEARCH1="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers`"
for DIR_1SEARCH in $DIR_SEARCH1
do
cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
DIR_SEARCH2="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH`"
for DIR_2SEARCH in $DIR_SEARCH2
do
cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$DIR_2SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
done
done
}
done
for i in console null $RAM_DEVICE tty[1234]
do
cp -a /dev/$i $MOUNT_IMAGE/dev
done
# Creating linuxrc File
echo "#!/bin/sh" > $LINUXRC
echo "" >> $LINUXRC
echo "echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
for MODULE in $MODULES
do
echo "$MODULE" | {
IFS=':' read module
module=$module
echo "Loading module $module"
echo "insmod /lib/$module.o" >> $LINUXRC
}
done
echo "echo \"Initial RAMDISK Loading Completed...\"" >> $LINUXRC
echo "mkdir /new_root" >> $LINUXRC
echo "echo \"Mounting proc...\"" >> $LINUXRC
echo "mount -n -t proc none /proc" >> $LINUXRC
echo "echo 0x0100 > /proc/sys/kernel/real-root-dev" >> $LINUXRC
echo "echo \"Mounting real root dev...\"" >> $LINUXRC
echo "mount -n -o ro $ROOT_DEVICE /new_root" >> $LINUXRC
echo "umount /proc" >> $LINUXRC
echo "cd /new_root" >> $LINUXRC
echo "echo \"Running pivot_root...\"" >> $LINUXRC
echo "pivot_root . initrd" >> $LINUXRC
echo "if [ -c initrd/dev/.devfsd ]" >> $LINUXRC
echo " then" >> $LINUXRC
echo " echo \"Mounting devfs...\"" >> $LINUXRC
echo " mount -n -t devfs none dev" >> $LINUXRC
echo "fi" >> $LINUXRC
echo "if [ \$\$ = 1 ]" >> $LINUXRC
echo " then" >> $LINUXRC
echo " echo \"Running init...\"" >> $LINUXRC
echo " exec chroot . sbin/init dev/console 2>&1" >> $LINUXRC
echo " else" >> $LINUXRC
echo " echo \"Using bug circumvention for busybox...\"" >> $LINUXRC
echo " exec chroot . linuxrc dev/console 2>&1" >> $LINUXRC
echo "fi" >> $LINUXRC
chmod +x $LINUXRC
(cd $MOUNT_IMAGE; tar cf - .) | (cd $MOUNT_POINT; tar xf -)
umount $MOUNT_POINT
losetup -d $LOOP_DEVICE
gzip -9 < $IMAGE > $INITRD
rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
lilo -v
---
initrd script
The following script needs to placed in /etc/rc.d/init.d.
You will then need to link it to rcsysinit.d.
It is recommended that this script be run right after
mountfs.
To link the script change to the /etc/rc.d/rcsysinit.d
directory and issue the following command.
ln -sf ../init.d/initrd S41initrd
#!/bin/bash
# Begin $rc_base/init.d/initrd
# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
source /etc/sysconfig/rc
source $rc_functions
echo "Clearing Initial RAM Disk..."
if [ -e /initrd/dev/.devfsd ]
then
umount /initrd/dev
fi
umount /initrd
/sbin/blockdev --flushbufs /dev/ram0
# End $rc_base/init.d/initrd
---
For Lilo
In order to use the initrd.img file is to add the
following entry to you lilo.conf file.
initrd=/boot/initrd.img
So your lilo.conf should look something like this.
image=/boot/vmlinuz-2.4.18
label=test
initrd=/boot/initrd-2.4.18.img
read-only
append="root=/dev/ram0 init=/linuxrc rw"
If you are just testing. You should make a separate
entry in lilo.conf. This will still allow you to boot.
---
For Grub
In order to use the initrd.img file is to add the
following entry to you menu.lst file.
initrd /boot/initrd-2.4.18.img
So your menu.lst should look something like this.
title test
root (hd0,1)
kernel /boot/vmlinuz-2.4.18
initrd /boot/initrd-2.4.18.img
---
For Syslinux
In order to use the initrd.img file is to add the
following to syslinux.cfg file.
append root=/dev/ram0 initrd=initrd-2.4.18.img
So your syslinux.cfg should look something like this.
label test
kernel vmlinuz
append root=/dev/ram0 initrd=initrd.img
---
Mail suggestions to giffordj@linkline.com
New Version of this document can be viewed from
http://www.jg555.com/cvs
this looked interesting, i am going to come back and read
a bit more closesly.
initial ramdisk howto i found
http://inferno.slug.org/lfs-hints/initrd.txt
TITLE: initrd for LFS
LFS VERSION: any
AUTHOR: Jim Gifford
SYNOPSIS:
How to setup initrd for LFS.
HINT:
$Revision: 1.8 $
Introduction to Initial RAMDisk
This hint will help you configure an LFS system for Initial RAMDisk.
Which will allow you to add modules at start-up instead of compiling them
into the kernel.
The script that is enclosed works with SCSI and USB modules only. IDE
devices are recommened to be built-in the kernel. The script will
auto-detect all SCSI and USB modules and add them to the initial ramdisk.
It will also detect the root from the fstab file
---
Assumptions Made in this document
I have made the following assumptions in this document.
Files have been downloaded.
---
Kernel Configuration
You will need to make sure the following items are configured
in your kernel. With out these, the initrd will not work.
Block Devices
Select Loopback Device Support this can be a module
or built-in.
Select RAM Disk Support this needs to be compiled as
built-in or the initrd will not show up.
Set Default RAM Disk size is 4096 which is the default
Select Initial RAM Disk (initrd) support needs be selected.
---
Needed File System Changes
You will need to create a directory for initrd to use.
The default one that is looked for is /initrd.
To Create this directory use mkdir /initrd
Another change that needs to be made is due to a bug
in busybox itself.
You will need to create a symlink to init and call it
linuxrc
cd /sbin
ln -sf init linuxrc
---
Needed Static Modules
In order for the initrd to work properly during boot up
you will need to create to static programs.
The first one being bash.
busybox
----
Busybox has a Config.h file that needs the following options
enabled to enable them remove the //
#define BB_INSMOD
#define BB_FEATURE_SH_STANDALONE_SHELL
You can configure the rest as you need, but remember have at
least the following enabled to make initrd to work properly.
#define BB_ASH
#define BB_CHROOT
#define BB_ECHO
#define BB_INSMOD
#define BB_MKDIR
#define BB_MODPROBE
#define BB_MOUNT
#define BB_PIVOT_ROOT
#define BB_UMOUNT
To create a static version of bash needed for initrd use
the following commands.
cd /usr/src
tar zxvf /usr/src/busybox-*.tar.gz
cd busy*
make LDFLAGS=-static
cp busybox /bin/busybox
Busybox must be in the /bin directory or the links created
during the initrid will fail.
---
mkinitrd
For those who do not want to type out the script. It is
available on my CVS server at
http://www.jg555.com/cvs/cvsweb.cgi/scripts/mkinitrd-lfs
This script will create the initial RAM Disk image file.
By default this script creates /boot/initrd.img
The default location for this file is /sbin
#!/bin/bash
# mkinitrd for LFS by Jim Gifford
# $Revision: 1.8 $
# Variables
TEMP="$1"
KERNEL_VERSION=""
CONFIG_FILE="/etc/modules.conf"
FSTAB="/etc/fstab"
ROOT_DEVICE=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $FSTAB)
SCSI_MODULES="`grep scsi_hostadapter $CONFIG_FILE | grep -v '^[ ]*#' | awk '{ print $3 }'`"
NEEDED_SCSI="scsi_mod sd_mod"
USB_MODULES="`grep usb-controller $CONFIG_FILE | grep -v '^[ ]*#' | awk '{ print $3 }'`"
NEEDED_USB="usbcore"
MODULES="$NEEDED_SCSI $SCSI_MODULES $NEEDED_USB $USB_MODULES"
IMAGE_SIZE=3000
MOUNT_IMAGE="/tmp/initrd.$$"
IMAGE="/tmp/initrd.img-$$"
MOUNT_POINT="/tmp/initrd.mnt-$$"
LINUXRC="$MOUNT_IMAGE/linuxrc"
# Check for initrd Directory
if ! [ -e /initrd ]
then
mkdir /initrd
fi
# Check for RAM Disk Device
if [ -e /dev/.devfsd ]
then
RAM_DEVICE="rd"
else
RAM_DEVICE="ram0"
fi
# Check for input
if [ "$TEMP" == "" ]
then
KERNEL_VERSION="`uname -r`"
else
KERNEL_VERSION="$TEMP"
fi
INITRD="/boot/initrd-$KERNEL_VERSION.img"
if [ "$TEMP" == "-h" ] || [ "$TEMP" == "--h" ] || [ "$TEMP" == "-help" ] || [ "$TEMP" == "--help" ]
then
echo "usage: mkinitrd kernel_version"
echo " : mkinitrd will automatically determin kernel version"
exit 1
fi
# Creating LoopBack Device
dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGE_SIZE 2> /dev/null
for device_number in 0 1 2 3 4 5 6 7 8
do
if losetup /dev/loop$device_number $IMAGE 2>/dev/null
then
break
fi
done
if [ "$device_number" = "8" ]
then
rm -rf $MOUNT_POINT $IMAGE
echo "All of your loopback devices are in use!" >&2
exit 1
fi
LOOP_DEVICE=/dev/loop$device_number
echo y | mke2fs $LOOP_DEVICE $IMAGE_SIZE > /dev/null 2> /dev/null
echo "Using loopback device $LOOP_DEVICE"
mkdir -p $MOUNT_POINT
mount -t ext2 $LOOP_DEVICE $MOUNT_POINT || {
echo "Can't get a loopback device"
exit 1
}
# Creating Directories
mkdir -p $MOUNT_IMAGE
mkdir -p $MOUNT_IMAGE/lib
mkdir -p $MOUNT_IMAGE/bin
mkdir -p $MOUNT_IMAGE/etc
mkdir -p $MOUNT_IMAGE/dev
mkdir -p $MOUNT_IMAGE/proc
ln -s /bin $MOUNT_IMAGE/sbin
rm -rf $MOUNT_POINT/lost+found
# Copying Static Programs
cp -a /bin/busybox $MOUNT_IMAGE/bin/busybox
ln -s /bin/busybox $MOUNT_IMAGE/bin/echo
ln -s /bin/busybox $MOUNT_IMAGE/bin/mount
ln -s /bin/busybox $MOUNT_IMAGE/bin/modprobe
ln -s /bin/busybox $MOUNT_IMAGE/bin/mkdir
ln -s /bin/busybox $MOUNT_IMAGE/bin/sh
ln -s /bin/busybox $MOUNT_IMAGE/bin/umount
ln -s /bin/busybox $MOUNT_IMAGE/bin/insmod
ln -s /bin/busybox $MOUNT_IMAGE/bin/pivot_root
cp -a /etc/fstab $MOUNT_IMAGE/etc/fstab
cp -a /etc/modules.conf $MOUNT_IMAGE/etc/modules.conf
# Copying Modules
for MODULE in $MODULES
do
echo "$MODULE" | {
IFS=':' read module options
module=$module
options=$options
DIR_SEARCH1="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers`"
for DIR_1SEARCH in $DIR_SEARCH1
do
cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
DIR_SEARCH2="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH`"
for DIR_2SEARCH in $DIR_SEARCH2
do
cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$DIR_2SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
done
done
}
done
for i in console null $RAM_DEVICE tty[1234]
do
cp -a /dev/$i $MOUNT_IMAGE/dev
done
# Creating linuxrc File
echo "#!/bin/sh" > $LINUXRC
echo "" >> $LINUXRC
echo "echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
for MODULE in $MODULES
do
echo "$MODULE" | {
IFS=':' read module
module=$module
echo "Loading module $module"
echo "insmod /lib/$module.o" >> $LINUXRC
}
done
echo "echo \"Initial RAMDISK Loading Completed...\"" >> $LINUXRC
echo "mkdir /new_root" >> $LINUXRC
echo "echo \"Mounting proc...\"" >> $LINUXRC
echo "mount -n -t proc none /proc" >> $LINUXRC
echo "echo 0x0100 > /proc/sys/kernel/real-root-dev" >> $LINUXRC
echo "echo \"Mounting real root dev...\"" >> $LINUXRC
echo "mount -n -o ro $ROOT_DEVICE /new_root" >> $LINUXRC
echo "umount /proc" >> $LINUXRC
echo "cd /new_root" >> $LINUXRC
echo "echo \"Running pivot_root...\"" >> $LINUXRC
echo "pivot_root . initrd" >> $LINUXRC
echo "if [ -c initrd/dev/.devfsd ]" >> $LINUXRC
echo " then" >> $LINUXRC
echo " echo \"Mounting devfs...\"" >> $LINUXRC
echo " mount -n -t devfs none dev" >> $LINUXRC
echo "fi" >> $LINUXRC
echo "if [ \$\$ = 1 ]" >> $LINUXRC
echo " then" >> $LINUXRC
echo " echo \"Running init...\"" >> $LINUXRC
echo " exec chroot . sbin/init dev/console 2>&1" >> $LINUXRC
echo " else" >> $LINUXRC
echo " echo \"Using bug circumvention for busybox...\"" >> $LINUXRC
echo " exec chroot . linuxrc dev/console 2>&1" >> $LINUXRC
echo "fi" >> $LINUXRC
chmod +x $LINUXRC
(cd $MOUNT_IMAGE; tar cf - .) | (cd $MOUNT_POINT; tar xf -)
umount $MOUNT_POINT
losetup -d $LOOP_DEVICE
gzip -9 < $IMAGE > $INITRD
rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
lilo -v
---
initrd script
The following script needs to placed in /etc/rc.d/init.d.
You will then need to link it to rcsysinit.d.
It is recommended that this script be run right after
mountfs.
To link the script change to the /etc/rc.d/rcsysinit.d
directory and issue the following command.
ln -sf ../init.d/initrd S41initrd
#!/bin/bash
# Begin $rc_base/init.d/initrd
# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
source /etc/sysconfig/rc
source $rc_functions
echo "Clearing Initial RAM Disk..."
if [ -e /initrd/dev/.devfsd ]
then
umount /initrd/dev
fi
umount /initrd
/sbin/blockdev --flushbufs /dev/ram0
# End $rc_base/init.d/initrd
---
For Lilo
In order to use the initrd.img file is to add the
following entry to you lilo.conf file.
initrd=/boot/initrd.img
So your lilo.conf should look something like this.
image=/boot/vmlinuz-2.4.18
label=test
initrd=/boot/initrd-2.4.18.img
read-only
append="root=/dev/ram0 init=/linuxrc rw"
If you are just testing. You should make a separate
entry in lilo.conf. This will still allow you to boot.
---
For Grub
In order to use the initrd.img file is to add the
following entry to you menu.lst file.
initrd /boot/initrd-2.4.18.img
So your menu.lst should look something like this.
title test
root (hd0,1)
kernel /boot/vmlinuz-2.4.18
initrd /boot/initrd-2.4.18.img
---
For Syslinux
In order to use the initrd.img file is to add the
following to syslinux.cfg file.
append root=/dev/ram0 initrd=initrd-2.4.18.img
So your syslinux.cfg should look something like this.
label test
kernel vmlinuz
append root=/dev/ram0 initrd=initrd.img
---
Mail suggestions to giffordj@linkline.com
New Version of this document can be viewed from
http://www.jg555.com/cvs
this looked interesting, i am going to come back and read
a bit more closesly.
TITLE: initrd for LFS
LFS VERSION: any
AUTHOR: Jim Gifford
SYNOPSIS:
How to setup initrd for LFS.
HINT:
$Revision: 1.8 $
Introduction to Initial RAMDisk
This hint will help you configure an LFS system for Initial RAMDisk.
Which will allow you to add modules at start-up instead of compiling them
into the kernel.
The script that is enclosed works with SCSI and USB modules only. IDE
devices are recommened to be built-in the kernel. The script will
auto-detect all SCSI and USB modules and add them to the initial ramdisk.
It will also detect the root from the fstab file
---
Assumptions Made in this document
I have made the following assumptions in this document.
Files have been downloaded.
---
Kernel Configuration
You will need to make sure the following items are configured
in your kernel. With out these, the initrd will not work.
Block Devices
Select Loopback Device Support this can be a module
or built-in.
Select RAM Disk Support this needs to be compiled as
built-in or the initrd will not show up.
Set Default RAM Disk size is 4096 which is the default
Select Initial RAM Disk (initrd) support needs be selected.
---
Needed File System Changes
You will need to create a directory for initrd to use.
The default one that is looked for is /initrd.
To Create this directory use mkdir /initrd
Another change that needs to be made is due to a bug
in busybox itself.
You will need to create a symlink to init and call it
linuxrc
cd /sbin
ln -sf init linuxrc
---
Needed Static Modules
In order for the initrd to work properly during boot up
you will need to create to static programs.
The first one being bash.
busybox
----
Busybox has a Config.h file that needs the following options
enabled to enable them remove the //
#define BB_INSMOD
#define BB_FEATURE_SH_STANDALONE_SHELL
You can configure the rest as you need, but remember have at
least the following enabled to make initrd to work properly.
#define BB_ASH
#define BB_CHROOT
#define BB_ECHO
#define BB_INSMOD
#define BB_MKDIR
#define BB_MODPROBE
#define BB_MOUNT
#define BB_PIVOT_ROOT
#define BB_UMOUNT
To create a static version of bash needed for initrd use
the following commands.
cd /usr/src
tar zxvf /usr/src/busybox-*.tar.gz
cd busy*
make LDFLAGS=-static
cp busybox /bin/busybox
Busybox must be in the /bin directory or the links created
during the initrid will fail.
---
mkinitrd
For those who do not want to type out the script. It is
available on my CVS server at
http://www.jg555.com/cvs/cvsweb.cgi/scripts/mkinitrd-lfs
This script will create the initial RAM Disk image file.
By default this script creates /boot/initrd.img
The default location for this file is /sbin
#!/bin/bash
# mkinitrd for LFS by Jim Gifford
# $Revision: 1.8 $
# Variables
TEMP="$1"
KERNEL_VERSION=""
CONFIG_FILE="/etc/modules.conf"
FSTAB="/etc/fstab"
ROOT_DEVICE=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $FSTAB)
SCSI_MODULES="`grep scsi_hostadapter $CONFIG_FILE | grep -v '^[ ]*#' | awk '{ print $3 }'`"
NEEDED_SCSI="scsi_mod sd_mod"
USB_MODULES="`grep usb-controller $CONFIG_FILE | grep -v '^[ ]*#' | awk '{ print $3 }'`"
NEEDED_USB="usbcore"
MODULES="$NEEDED_SCSI $SCSI_MODULES $NEEDED_USB $USB_MODULES"
IMAGE_SIZE=3000
MOUNT_IMAGE="/tmp/initrd.$$"
IMAGE="/tmp/initrd.img-$$"
MOUNT_POINT="/tmp/initrd.mnt-$$"
LINUXRC="$MOUNT_IMAGE/linuxrc"
# Check for initrd Directory
if ! [ -e /initrd ]
then
mkdir /initrd
fi
# Check for RAM Disk Device
if [ -e /dev/.devfsd ]
then
RAM_DEVICE="rd"
else
RAM_DEVICE="ram0"
fi
# Check for input
if [ "$TEMP" == "" ]
then
KERNEL_VERSION="`uname -r`"
else
KERNEL_VERSION="$TEMP"
fi
INITRD="/boot/initrd-$KERNEL_VERSION.img"
if [ "$TEMP" == "-h" ] || [ "$TEMP" == "--h" ] || [ "$TEMP" == "-help" ] || [ "$TEMP" == "--help" ]
then
echo "usage: mkinitrd kernel_version"
echo " : mkinitrd will automatically determin kernel version"
exit 1
fi
# Creating LoopBack Device
dd if=/dev/zero of=$IMAGE bs=1k count=$IMAGE_SIZE 2> /dev/null
for device_number in 0 1 2 3 4 5 6 7 8
do
if losetup /dev/loop$device_number $IMAGE 2>/dev/null
then
break
fi
done
if [ "$device_number" = "8" ]
then
rm -rf $MOUNT_POINT $IMAGE
echo "All of your loopback devices are in use!" >&2
exit 1
fi
LOOP_DEVICE=/dev/loop$device_number
echo y | mke2fs $LOOP_DEVICE $IMAGE_SIZE > /dev/null 2> /dev/null
echo "Using loopback device $LOOP_DEVICE"
mkdir -p $MOUNT_POINT
mount -t ext2 $LOOP_DEVICE $MOUNT_POINT || {
echo "Can't get a loopback device"
exit 1
}
# Creating Directories
mkdir -p $MOUNT_IMAGE
mkdir -p $MOUNT_IMAGE/lib
mkdir -p $MOUNT_IMAGE/bin
mkdir -p $MOUNT_IMAGE/etc
mkdir -p $MOUNT_IMAGE/dev
mkdir -p $MOUNT_IMAGE/proc
ln -s /bin $MOUNT_IMAGE/sbin
rm -rf $MOUNT_POINT/lost+found
# Copying Static Programs
cp -a /bin/busybox $MOUNT_IMAGE/bin/busybox
ln -s /bin/busybox $MOUNT_IMAGE/bin/echo
ln -s /bin/busybox $MOUNT_IMAGE/bin/mount
ln -s /bin/busybox $MOUNT_IMAGE/bin/modprobe
ln -s /bin/busybox $MOUNT_IMAGE/bin/mkdir
ln -s /bin/busybox $MOUNT_IMAGE/bin/sh
ln -s /bin/busybox $MOUNT_IMAGE/bin/umount
ln -s /bin/busybox $MOUNT_IMAGE/bin/insmod
ln -s /bin/busybox $MOUNT_IMAGE/bin/pivot_root
cp -a /etc/fstab $MOUNT_IMAGE/etc/fstab
cp -a /etc/modules.conf $MOUNT_IMAGE/etc/modules.conf
# Copying Modules
for MODULE in $MODULES
do
echo "$MODULE" | {
IFS=':' read module options
module=$module
options=$options
DIR_SEARCH1="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers`"
for DIR_1SEARCH in $DIR_SEARCH1
do
cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
DIR_SEARCH2="`ls -1 /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH`"
for DIR_2SEARCH in $DIR_SEARCH2
do
cp /lib/modules/$KERNEL_VERSION/kernel/drivers/$DIR_1SEARCH/$DIR_2SEARCH/$module.o $MOUNT_IMAGE/lib > /dev/null 2>&1
done
done
}
done
for i in console null $RAM_DEVICE tty[1234]
do
cp -a /dev/$i $MOUNT_IMAGE/dev
done
# Creating linuxrc File
echo "#!/bin/sh" > $LINUXRC
echo "" >> $LINUXRC
echo "echo \"Initial RAMDISK Loading Starting...\"" >> $LINUXRC
for MODULE in $MODULES
do
echo "$MODULE" | {
IFS=':' read module
module=$module
echo "Loading module $module"
echo "insmod /lib/$module.o" >> $LINUXRC
}
done
echo "echo \"Initial RAMDISK Loading Completed...\"" >> $LINUXRC
echo "mkdir /new_root" >> $LINUXRC
echo "echo \"Mounting proc...\"" >> $LINUXRC
echo "mount -n -t proc none /proc" >> $LINUXRC
echo "echo 0x0100 > /proc/sys/kernel/real-root-dev" >> $LINUXRC
echo "echo \"Mounting real root dev...\"" >> $LINUXRC
echo "mount -n -o ro $ROOT_DEVICE /new_root" >> $LINUXRC
echo "umount /proc" >> $LINUXRC
echo "cd /new_root" >> $LINUXRC
echo "echo \"Running pivot_root...\"" >> $LINUXRC
echo "pivot_root . initrd" >> $LINUXRC
echo "if [ -c initrd/dev/.devfsd ]" >> $LINUXRC
echo " then" >> $LINUXRC
echo " echo \"Mounting devfs...\"" >> $LINUXRC
echo " mount -n -t devfs none dev" >> $LINUXRC
echo "fi" >> $LINUXRC
echo "if [ \$\$ = 1 ]" >> $LINUXRC
echo " then" >> $LINUXRC
echo " echo \"Running init...\"" >> $LINUXRC
echo " exec chroot . sbin/init dev/console 2>&1" >> $LINUXRC
echo " else" >> $LINUXRC
echo " echo \"Using bug circumvention for busybox...\"" >> $LINUXRC
echo " exec chroot . linuxrc dev/console 2>&1" >> $LINUXRC
echo "fi" >> $LINUXRC
chmod +x $LINUXRC
(cd $MOUNT_IMAGE; tar cf - .) | (cd $MOUNT_POINT; tar xf -)
umount $MOUNT_POINT
losetup -d $LOOP_DEVICE
gzip -9 < $IMAGE > $INITRD
rm -rf $MOUNT_IMAGE $MOUNT_POINT $IMAGE
lilo -v
---
initrd script
The following script needs to placed in /etc/rc.d/init.d.
You will then need to link it to rcsysinit.d.
It is recommended that this script be run right after
mountfs.
To link the script change to the /etc/rc.d/rcsysinit.d
directory and issue the following command.
ln -sf ../init.d/initrd S41initrd
#!/bin/bash
# Begin $rc_base/init.d/initrd
# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
source /etc/sysconfig/rc
source $rc_functions
echo "Clearing Initial RAM Disk..."
if [ -e /initrd/dev/.devfsd ]
then
umount /initrd/dev
fi
umount /initrd
/sbin/blockdev --flushbufs /dev/ram0
# End $rc_base/init.d/initrd
---
For Lilo
In order to use the initrd.img file is to add the
following entry to you lilo.conf file.
initrd=/boot/initrd.img
So your lilo.conf should look something like this.
image=/boot/vmlinuz-2.4.18
label=test
initrd=/boot/initrd-2.4.18.img
read-only
append="root=/dev/ram0 init=/linuxrc rw"
If you are just testing. You should make a separate
entry in lilo.conf. This will still allow you to boot.
---
For Grub
In order to use the initrd.img file is to add the
following entry to you menu.lst file.
initrd /boot/initrd-2.4.18.img
So your menu.lst should look something like this.
title test
root (hd0,1)
kernel /boot/vmlinuz-2.4.18
initrd /boot/initrd-2.4.18.img
---
For Syslinux
In order to use the initrd.img file is to add the
following to syslinux.cfg file.
append root=/dev/ram0 initrd=initrd-2.4.18.img
So your syslinux.cfg should look something like this.
label test
kernel vmlinuz
append root=/dev/ram0 initrd=initrd.img
---
Mail suggestions to giffordj@linkline.com
New Version of this document can be viewed from
http://www.jg555.com/cvs
this looked interesting, i am going to come back and read
a bit more closesly.
Monday, April 18, 2005
Xauth problems
Xauth problems
the issue is the hostname is screwed up
$> hostname
returns
(none)
sound familiar
when i removed the section of script
and just said the hostname was "uccd"
no errors
two things of import
there is a file /etc/hostname that contains
the setting for the hostname
and there is a command "hostname"
the issue is the hostname is screwed up
$> hostname
returns
(none)
sound familiar
when i removed the section of script
and just said the hostname was "uccd"
no errors
two things of import
there is a file /etc/hostname that contains
the setting for the hostname
and there is a command "hostname"
Sunday, April 17, 2005
Xauth problems
I am starting x and even getting twm to work
but when i shutdown twm/x11/xvesa
there are two sets of error messages:
xauth: (argv):1: bad display name "(none):0" in "list" command
xauth: (argv):1: bad display name "(none):0" in "add" command
waiting for X server to shut down
xauth: (argv):1 bad display name "(none):0" in "remove" command
what up?
the startx script is as follows:
#!/bin/sh
userclientrc=$HOME/.xinitrc
userserverrc=$HOME/.xserverrc
sysclientrc=/etc/X11/xinit/xinitrc
sysserverrc=/etc/X11/xinit/xserverrc
defaultclient=/usr/X11R6/bin/xterm
defaultserver=/usr/X11R6/bin/X
defaultclientargs=""
defaultserverargs="-screen 800x600x24 -2button"
clientargs=""
serverargs=""
if [ -f $userclientrc ]; then
defaultclientargs=$userclientrc
elif [ -f $sysclientrc ]; then
defaultclientargs=$sysclientrc
fi
if [ -f $userserverrc ]; then
defaultserverargs=$userserverrc
elif [ -f $sysserverrc ]; then
defaultserverargs=$sysserverrc
fi
whoseargs="client"
while [ x"$1" != x ]; do
case "$1" in
# '' required to prevent cpp from treating "/*" as a C comment.
/''*|\./''*)
if [ "$whoseargs" = "client" ]; then
if [ x"$clientargs" = x ]; then
client="$1"
else
clientargs="$clientargs $1"
fi
else
if [ x"$serverargs" = x ]; then
server="$1"
else
serverargs="$serverargs $1"
fi
fi
;;
--)
whoseargs="server"
;;
*)
if [ "$whoseargs" = "client" ]; then
clientargs="$clientargs $1"
else
# display must be the FIRST server argument
if [ x"$serverargs" = x ] && expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
display="$1"
else
serverargs="$serverargs $1"
fi
fi
;;
esac
shift
done
# process client arguments
if [ x"$client" = x ]; then
# if no client arguments either, use rc file instead
if [ x"$clientargs" = x ]; then
client="$defaultclientargs"
else
client=$defaultclient
fi
fi
# process server arguments
if [ x"$server" = x ]; then
# if no server arguments or display either, use rc file instead
if [ x"$serverargs" = x -a x"$display" = x ]; then
server="$defaultserverargs"
else
server=$defaultserver
fi
fi
if [ x"$XAUTHORITY" = x ]; then
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY
fi
removelist=
# set up default Xauth info for this machine
case `uname` in
Linux*)
if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
hostname=`hostname -f`
else
hostname=`hostname`
fi
;;
*)
hostname=`hostname`
;;
esac
authdisplay=${display:-:0}
mcookie=`mcookie`
for displayname in $authdisplay $hostname$authdisplay; do
if ! xauth list "$displayname" | grep "$displayname " >/dev/null 2>&1; then
xauth add $displayname . $mcookie
removelist="$displayname $removelist"
fi
done
xinit $client $clientargs -- $server $display $serverargs
if [ x"$removelist" != x ]; then
xauth remove $removelist
fi
if command -v deallocvt > /dev/null 2>&1; then
deallocvt
fi
but when i shutdown twm/x11/xvesa
there are two sets of error messages:
xauth: (argv):1: bad display name "(none):0" in "list" command
xauth: (argv):1: bad display name "(none):0" in "add" command
waiting for X server to shut down
xauth: (argv):1 bad display name "(none):0" in "remove" command
what up?
the startx script is as follows:
#!/bin/sh
userclientrc=$HOME/.xinitrc
userserverrc=$HOME/.xserverrc
sysclientrc=/etc/X11/xinit/xinitrc
sysserverrc=/etc/X11/xinit/xserverrc
defaultclient=/usr/X11R6/bin/xterm
defaultserver=/usr/X11R6/bin/X
defaultclientargs=""
defaultserverargs="-screen 800x600x24 -2button"
clientargs=""
serverargs=""
if [ -f $userclientrc ]; then
defaultclientargs=$userclientrc
elif [ -f $sysclientrc ]; then
defaultclientargs=$sysclientrc
fi
if [ -f $userserverrc ]; then
defaultserverargs=$userserverrc
elif [ -f $sysserverrc ]; then
defaultserverargs=$sysserverrc
fi
whoseargs="client"
while [ x"$1" != x ]; do
case "$1" in
# '' required to prevent cpp from treating "/*" as a C comment.
/''*|\./''*)
if [ "$whoseargs" = "client" ]; then
if [ x"$clientargs" = x ]; then
client="$1"
else
clientargs="$clientargs $1"
fi
else
if [ x"$serverargs" = x ]; then
server="$1"
else
serverargs="$serverargs $1"
fi
fi
;;
--)
whoseargs="server"
;;
*)
if [ "$whoseargs" = "client" ]; then
clientargs="$clientargs $1"
else
# display must be the FIRST server argument
if [ x"$serverargs" = x ] && expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
display="$1"
else
serverargs="$serverargs $1"
fi
fi
;;
esac
shift
done
# process client arguments
if [ x"$client" = x ]; then
# if no client arguments either, use rc file instead
if [ x"$clientargs" = x ]; then
client="$defaultclientargs"
else
client=$defaultclient
fi
fi
# process server arguments
if [ x"$server" = x ]; then
# if no server arguments or display either, use rc file instead
if [ x"$serverargs" = x -a x"$display" = x ]; then
server="$defaultserverargs"
else
server=$defaultserver
fi
fi
if [ x"$XAUTHORITY" = x ]; then
XAUTHORITY=$HOME/.Xauthority
export XAUTHORITY
fi
removelist=
# set up default Xauth info for this machine
case `uname` in
Linux*)
if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
hostname=`hostname -f`
else
hostname=`hostname`
fi
;;
*)
hostname=`hostname`
;;
esac
authdisplay=${display:-:0}
mcookie=`mcookie`
for displayname in $authdisplay $hostname$authdisplay; do
if ! xauth list "$displayname" | grep "$displayname " >/dev/null 2>&1; then
xauth add $displayname . $mcookie
removelist="$displayname $removelist"
fi
done
xinit $client $clientargs -- $server $display $serverargs
if [ x"$removelist" != x ]; then
xauth remove $removelist
fi
if command -v deallocvt > /dev/null 2>&1; then
deallocvt
fi
Wednesday, April 13, 2005
SAXParser (isn't)
The SAXParser class really isnt a parser classes.
Its Bridge class that gets the xml stream into
the Handler class or the class derived
from the Handler class. The Derived handler
is the parser and its recursive descent
parser.
interesting
http://www.s34.co.jp/cpptechdoc/article/xml/fsm/fsm_sax.cpp
Its Bridge class that gets the xml stream into
the Handler class or the class derived
from the Handler class. The Derived handler
is the parser and its recursive descent
parser.
interesting
http://www.s34.co.jp/cpptechdoc/article/xml/fsm/fsm_sax.cpp
Tuesday, April 12, 2005
Const wierdness found in xerces
static XMLCh* transcode (const char* const toTranscode);
ok wtf?
man i have forgotten const's and constantness
from the c++-faq section 18.5:
[18.5] What's the difference between "const Fred* p", "Fred* const p" and "const Fred* const p"?
You have to read pointer declarations right-to-left.
* const Fred* p means "p points to a Fred that is const" — that is, the Fred object can't be changed via p.
* Fred* const p means "p is a const pointer to a Fred" — that is, you can change the Fred object via p, but you can't change the pointer p itself.
* const Fred* const p means "p is a const pointer to a const Fred" — that is, you can't change the pointer p itself, nor can you change the Fred object via p.
or in my case const char* const p means "p is a const pointer to a const char" i cant change
the pointer location or what is pointed to?
ok wtf?
man i have forgotten const's and constantness
from the c++-faq section 18.5:
[18.5] What's the difference between "const Fred* p", "Fred* const p" and "const Fred* const p"?
You have to read pointer declarations right-to-left.
* const Fred* p means "p points to a Fred that is const" — that is, the Fred object can't be changed via p.
* Fred* const p means "p is a const pointer to a Fred" — that is, you can change the Fred object via p, but you can't change the pointer p itself.
* const Fred* const p means "p is a const pointer to a const Fred" — that is, you can't change the pointer p itself, nor can you change the Fred object via p.
or in my case const char* const p means "p is a const pointer to a const char" i cant change
the pointer location or what is pointed to?
Autotools update
checkout subversion and did a autogen
on the mandrake 9.2 book and got got
the following error:
configure: error: cannot find install-sh or install.sh in . ./.. ./../..
looked on google and found to things.
1) configure.in is now deprecated and the standard is now
configure.ac
2) update automake then autoconf
i updated automake to version 1.9
and autoconf to version 2.59
see this web site for a quicky example
http://freedomink.org/node/100
on the mandrake 9.2 book and got got
the following error:
configure: error: cannot find install-sh or install.sh in . ./.. ./../..
looked on google and found to things.
1) configure.in is now deprecated and the standard is now
configure.ac
2) update automake then autoconf
i updated automake to version 1.9
and autoconf to version 2.59
see this web site for a quicky example
http://freedomink.org/node/100
Sunday, April 10, 2005
Autoconf project that uses Xerces 2.6.0
I started this little project about 2 or 3 times
first looking at how to recognize if
a said library was properly installed on a system.
I found more than one answer on how that should
work. Then I pulled back from that and just
started from basics.
I followed the link "Developing software with GNU"
http://www.amath.washington.edu/~lf/tutorials/autoconf/toolsmanual_toc.html
another good reference is
http://developer.gnome.org/doc/books/WGA/creating-configuration.html
The project has these files.
reconf
Makefile.am
configure.in
src/hello.cc
src/Makefile.am
The Makefile.am has the following lines
-------------------- Makefile.am --------------------------
EXTRA_DIST = reconf configure
SUBDIRS = src
-----------------------------------------------------------
EXTRA_DIST says to "List any files that you want to include
into your source code distribution. "
A file Makfile.in will have a target called dist
The dist target can be used to generate a gzip'd tar file
some files are not covered in the automatic rules.
These files should be listed in the EXTRA_DIST variable.
since configure is normally generated it need not be part
of tar dist but you want to include it as a convience
so anyone how get the the tared dist need only
run configure.
SUBDIRS
SUBDIRS = dir1 dir2 ...
`make' will be recursively invoked in each subdirectory
stated before doing anything on the current directory.
On the same token you will need to supply a `Makefile.am'
for each of the `src' directories you have stated.
configure.in
----------------------- configure.in ---------------------
AC_INIT
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(test,0.1)
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_OUTPUT(Makefile src/Makefile)
----------------------------------------------------------
configure script must call AC_INIT
AC_INIT(package, version, [bug-report], [tar-name])
AC_INIT and AC_OUTPUT are the two only required macros by the
configure script.
AC_INIT generates the following m4 macros,
output variables and preprocessor symbols:
* [AC_]PACKAGE_NAME
* [AC_]PACKAGE_TARNAME
* [AC_]PACKAGE_VERSION
* [AC_]PACKAGE_STRING
* [AC_]PACKAGE_BUGREPORT
AM_CONFIG_HEADER:
AM_CONFIG_HEADER(config.h)
AM_CONFIG_HEADER(config.h:config.in)
Names the header file which will hold the preprocessor
macro definitions for compile time. Normally, this is
config.h. The source files will then #include "config.h".
Requires a accconfig.h file.
AC_PROG_CC first checks to see if the CC environment
variable is set on the end user's system and the other
AC_PROG_* macros work similarly.
AC_OUTPUT
Automake uses this to determine which files to create
Listed files named Makefile are treated as `Makefile's.
The next files are
src/hello.cc
------------------------------- hello.cc ---------------
#if HAVE_CONFIG_H
# include
#endif
#include
#include
using namespace XERCES_CPP_NAMESPACE
int main(int argc,char *argv[])
{
return 0;
}
the above compile and linked seemlessly.
why? because of the file:
src/Makefile.am
-------------------------- src/Makefile.am ---------------
INCLUDES = -I/usr/inlucde/xerces -I/usr/include/xercesc/sax
LDADD = -lxerces-c
bin_PROGRAMS = hello
hello_SOURCES = hello.cc
----------------------------------------------------------
INCLUDES = -I/dir1 -I/dir2 ...
Insert the -I flags that you want to pass to your compiler
when it builds object files.
LDFLAGS = -L/dir1 -L/dir2 ...
Insert the -L flags that you want to pass to your compiler.
bin_PROGRAMS = prog1 prog2 ....
Lists the executable files that will be compiled with `make'
and installed with `make install' under `/prefix/bin',
prog_SOURCES = foo1.c foo2.c ... header1.h header2.h ....
List all the files that compose the source code of the program,
including header files.
there is also specialization.
your can have the following
prog_SOURCES
prog_LDADD apply headers to a specific file
prog_LDFLAGS apply library includes to a specific file
prog_DEPENDENCIES
first looking at how to recognize if
a said library was properly installed on a system.
I found more than one answer on how that should
work. Then I pulled back from that and just
started from basics.
I followed the link "Developing software with GNU"
http://www.amath.washington.edu/~lf/tutorials/autoconf/toolsmanual_toc.html
another good reference is
http://developer.gnome.org/doc/books/WGA/creating-configuration.html
The project has these files.
reconf
Makefile.am
configure.in
src/hello.cc
src/Makefile.am
The Makefile.am has the following lines
-------------------- Makefile.am --------------------------
EXTRA_DIST = reconf configure
SUBDIRS = src
-----------------------------------------------------------
EXTRA_DIST says to "List any files that you want to include
into your source code distribution. "
A file Makfile.in will have a target called dist
The dist target can be used to generate a gzip'd tar file
some files are not covered in the automatic rules.
These files should be listed in the EXTRA_DIST variable.
since configure is normally generated it need not be part
of tar dist but you want to include it as a convience
so anyone how get the the tared dist need only
run configure.
SUBDIRS
SUBDIRS = dir1 dir2 ...
`make' will be recursively invoked in each subdirectory
stated before doing anything on the current directory.
On the same token you will need to supply a `Makefile.am'
for each of the `src' directories you have stated.
configure.in
----------------------- configure.in ---------------------
AC_INIT
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(test,0.1)
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_OUTPUT(Makefile src/Makefile)
----------------------------------------------------------
configure script must call AC_INIT
AC_INIT(package, version, [bug-report], [tar-name])
AC_INIT and AC_OUTPUT are the two only required macros by the
configure script.
AC_INIT generates the following m4 macros,
output variables and preprocessor symbols:
* [AC_]PACKAGE_NAME
* [AC_]PACKAGE_TARNAME
* [AC_]PACKAGE_VERSION
* [AC_]PACKAGE_STRING
* [AC_]PACKAGE_BUGREPORT
AM_CONFIG_HEADER:
AM_CONFIG_HEADER(config.h)
AM_CONFIG_HEADER(config.h:config.in)
Names the header file which will hold the preprocessor
macro definitions for compile time. Normally, this is
config.h. The source files will then #include "config.h".
Requires a accconfig.h file.
AC_PROG_CC first checks to see if the CC environment
variable is set on the end user's system and the other
AC_PROG_* macros work similarly.
AC_OUTPUT
Automake uses this to determine which files to create
Listed files named Makefile are treated as `Makefile's.
The next files are
src/hello.cc
------------------------------- hello.cc ---------------
#if HAVE_CONFIG_H
# include
#endif
#include
#include
using namespace XERCES_CPP_NAMESPACE
int main(int argc,char *argv[])
{
return 0;
}
the above compile and linked seemlessly.
why? because of the file:
src/Makefile.am
-------------------------- src/Makefile.am ---------------
INCLUDES = -I/usr/inlucde/xerces -I/usr/include/xercesc/sax
LDADD = -lxerces-c
bin_PROGRAMS = hello
hello_SOURCES = hello.cc
----------------------------------------------------------
INCLUDES = -I/dir1 -I/dir2 ...
Insert the -I flags that you want to pass to your compiler
when it builds object files.
LDFLAGS = -L/dir1 -L/dir2 ...
Insert the -L flags that you want to pass to your compiler.
bin_PROGRAMS = prog1 prog2 ....
Lists the executable files that will be compiled with `make'
and installed with `make install' under `/prefix/bin',
prog_SOURCES = foo1.c foo2.c ... header1.h header2.h ....
List all the files that compose the source code of the program,
including header files.
there is also specialization.
your can have the following
prog_SOURCES
prog_LDADD apply headers to a specific file
prog_LDFLAGS apply library includes to a specific file
prog_DEPENDENCIES
Friday, April 08, 2005
Autotools
http://www.nevrax.org/tiki-pagehistory.php?page=NeLCompilingLinux&diff=4
the following has a sample automake project:
http://www.openismus.com/documents/linux/automake/automake.shtml
also here is a great online book:
http://sources.redhat.com/autobook
notes: form the above online book.
configure will generate the following
files:
`config.cache' results of the system tests
`config.log` each test run and the result
`config.status` used to recreate the current configuration.
`config.h' examines variability of the C and C++ programming
languages and implementations thereof.
`Makefile' One of the common functions of `configure' is
to generate `Makefile's and other files.
so basically generate config.h and Makefile
if things break look at config.log
NOTE:
The smallest project requires the user to provide only two files.
* `Makefile.am' is an input to automake.
* `configure.in' is an input to autoconf.
----------------------Makefile.am---------------------------------
bin_PROGRAMS = foonly
foonly_SOURCES = main.c foo.c foo.h nly.c scanner.l parser.y
foonly_LDADD = @LEXLIB@
This `Makefile.am' specifies that we want a program called `foonly'
to be built and installed in the `bin' directory when make
install is run. The source files that are used to build `foonly'
are the C source files `main.c', `foo.c', `nly.c' and `foo.h', the
lex program in `scanner.l' and a yacc grammar in `parser.y'.
------------------------------------------------------------------
the following has a sample automake project:
http://www.openismus.com/documents/linux/automake/automake.shtml
also here is a great online book:
http://sources.redhat.com/autobook
notes: form the above online book.
configure will generate the following
files:
`config.cache' results of the system tests
`config.log` each test run and the result
`config.status` used to recreate the current configuration.
`config.h' examines variability of the C and C++ programming
languages and implementations thereof.
`Makefile' One of the common functions of `configure' is
to generate `Makefile's and other files.
so basically generate config.h and Makefile
if things break look at config.log
NOTE:
The smallest project requires the user to provide only two files.
* `Makefile.am' is an input to automake.
* `configure.in' is an input to autoconf.
----------------------Makefile.am---------------------------------
bin_PROGRAMS = foonly
foonly_SOURCES = main.c foo.c foo.h nly.c scanner.l parser.y
foonly_LDADD = @LEXLIB@
This `Makefile.am' specifies that we want a program called `foonly'
to be built and installed in the `bin' directory when make
install is run. The source files that are used to build `foonly'
are the C source files `main.c', `foo.c', `nly.c' and `foo.h', the
lex program in `scanner.l' and a yacc grammar in `parser.y'.
------------------------------------------------------------------
Wednesday, April 06, 2005
SDL linking woes
I have tried to compile a small sdl demo and all i get is grief of this
flavor:
checking for SDL - version >= 1.2.0... no
after some research i found that what is happening
is that a small program is trying to compiled and failing.
the analogue is this.
---------------------- sdltest.c -----------------------------------------
#include <SDL.h>
int main(int argc,char **)
{
return 0;
}
----------------------------------------------------------------------------
the configure script uses a configure script sdl-config
to determine to kick out the need library and header
path information.
all of this fails and you get the error:
checking for SDL - version >= 1.2.0... no
if found via google that details what i did above and then
hacked the sdl-config macro. and i was able to compile
the the above test and the testdrivers in the sdl
source distro.
gcc -o sdltest sdltest.c -L/usr/X11R6/lib/ `sdl-config --cflags` `sdl-config --libs` -lX11 -lXext -lgcc
what now insterests me is why i need to add -L/usr/X11/lib?
no actuall i know that i need this but what does the configure
script know this?
flavor:
checking for SDL - version >= 1.2.0... no
after some research i found that what is happening
is that a small program is trying to compiled and failing.
the analogue is this.
---------------------- sdltest.c -----------------------------------------
#include <SDL.h>
int main(int argc,char **)
{
return 0;
}
----------------------------------------------------------------------------
the configure script uses a configure script sdl-config
to determine to kick out the need library and header
path information.
all of this fails and you get the error:
checking for SDL - version >= 1.2.0... no
if found via google that details what i did above and then
hacked the sdl-config macro. and i was able to compile
the the above test and the testdrivers in the sdl
source distro.
gcc -o sdltest sdltest.c -L/usr/X11R6/lib/ `sdl-config --cflags` `sdl-config --libs` -lX11 -lXext -lgcc
what now insterests me is why i need to add -L/usr/X11/lib?
no actuall i know that i need this but what does the configure
script know this?
Tuesday, April 05, 2005
More on SSH/Pam
1. clean and server exchange (public) host keys.
If the client machine has never encountered
a given public key before, both SSH .... ask
the user whether to accept the untrusted key, ...
next the use these public keys to negotiate a session
key .... As with typical SSL connections, this
initial round of key exchanging and session-key
negotiations is completely transparent to the
end user.
[linux server security oreilly page 118-119]
SSH can secure these [X POP3 LPD] and most other
TCP based services! Forwarding X applications
back to your remote console is simple. First,
on the the remote host, edit /etc/ssh/sshd_config
and set X11Forwarding to yes (in OpenSSH Version
2x, the default is no). Second, open an ssh session using
the authentication method of your choice from your
local console to the remote host.
book [inside network perimeter security, sams second edition]
chapter 16 page 397 The Dangers of SSH
... be sure to ue the latest software versions and to keep
current with all the patchs, Also configure your SSH
servers to only permit the use of the SSH2 protocol,
instead of SSH1.
page 398. SSH Tunnels.
port forwardinging.
SSH has a powerful capability called port forwarding.
In port forwarding, an abitrary local port is chosen and
linked by an SSH connection to a particular remote host
and remote port.
After the connection is established, the SSH client listens
for traffic on the specified local port. Any traffic that
is sent to the that port is then sent through the tunnel
to the the remote SSH server. This technique is know
as SSH tunneling.
[end quote]
plans
finish building 2.6 gento book+udev
emerge ssh ... login to ssh remotely
rc-update ssh.
what risks are associated with ssh?
[more from LINUX Server Security page 125-127]
... to control the behavior of the SSH client and server [ssh],
there are only two files to edit: ssh_config and sshd_config, respectively.
ssh_config is a global configuration file for ssh sessions
intitiated from the local host.
ssh_config consists of a list of parameters, one line per parameter,
in the format:
parameter-name parameter-value1(,parameter-value2,etc.)
If the client machine has never encountered
a given public key before, both SSH .... ask
the user whether to accept the untrusted key, ...
next the use these public keys to negotiate a session
key .... As with typical SSL connections, this
initial round of key exchanging and session-key
negotiations is completely transparent to the
end user.
[linux server security oreilly page 118-119]
SSH can secure these [X POP3 LPD] and most other
TCP based services! Forwarding X applications
back to your remote console is simple. First,
on the the remote host, edit /etc/ssh/sshd_config
and set X11Forwarding to yes (in OpenSSH Version
2x, the default is no). Second, open an ssh session using
the authentication method of your choice from your
local console to the remote host.
book [inside network perimeter security, sams second edition]
chapter 16 page 397 The Dangers of SSH
... be sure to ue the latest software versions and to keep
current with all the patchs, Also configure your SSH
servers to only permit the use of the SSH2 protocol,
instead of SSH1.
page 398. SSH Tunnels.
port forwardinging.
SSH has a powerful capability called port forwarding.
In port forwarding, an abitrary local port is chosen and
linked by an SSH connection to a particular remote host
and remote port.
After the connection is established, the SSH client listens
for traffic on the specified local port. Any traffic that
is sent to the that port is then sent through the tunnel
to the the remote SSH server. This technique is know
as SSH tunneling.
[end quote]
plans
finish building 2.6 gento book+udev
emerge ssh ... login to ssh remotely
rc-update ssh.
what risks are associated with ssh?
[more from LINUX Server Security page 125-127]
... to control the behavior of the SSH client and server [ssh],
there are only two files to edit: ssh_config and sshd_config, respectively.
ssh_config is a global configuration file for ssh sessions
intitiated from the local host.
ssh_config consists of a list of parameters, one line per parameter,
in the format:
parameter-name parameter-value1(,parameter-value2,etc.)
Sunday, April 03, 2005
Created rootfs files: /etc
I want to create premade user accounts
From "Running Linux page 141"
ever account on the system has an entry in the file /etc/passwd.
this file contains entries, one line per user ...
username:password:uid:gid:gecos:homedir:shell
username (obvious)
password and encrypted representation of the users password.
uid
the user id is a unique integer the system uses to identify the account.
... the uid is more important to the system
gid the group id ... refering to the users default group
found in the file /etc/gorup
gecos miscellaneous inforation about the user
homedir: the users home directory
shell: the name of the progr run when the user logs in.
From "Running Linux page 141"
ever account on the system has an entry in the file /etc/passwd.
this file contains entries, one line per user ...
username:password:uid:gid:gecos:homedir:shell
username (obvious)
password and encrypted representation of the users password.
uid
the user id is a unique integer the system uses to identify the account.
... the uid is more important to the system
gid the group id ... refering to the users default group
found in the file /etc/gorup
gecos miscellaneous inforation about the user
homedir: the users home directory
shell: the name of the progr run when the user logs in.
Tossed 2.4.2x and moved 2.6 + udev
In the next interation of the machine build I will start with
the kernel 2.6 and use udev.
I had all the parts working apache+mysql+bugzill and
ssh as a stand alone (no integration with apache)
see the following
http://www.gentoo.org/doc/en/udev-guide.xml
and it eliminated the errors i was getting about
about modprobe
the kernel 2.6 and use udev.
I had all the parts working apache+mysql+bugzill and
ssh as a stand alone (no integration with apache)
see the following
http://www.gentoo.org/doc/en/udev-guide.xml
and it eliminated the errors i was getting about
about modprobe
Subscribe to:
Posts (Atom)