Hello,
I wonder if somebody is familiar with the way to create multiple hardware
configurations (profiles) on Linux? This is required, for instance, when
booting laptop not connected to the network.
Thanks in advance,
Giga
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gregory Giguashvili
Senior Software Engineer
Email: [email protected]
Tel: 972-9-9709379 Fax: 972-3-9709337
Paradigm Geophysical Ltd.
http://www.math.tau.ac.il/~gregoryg
On Thu, 27 Jun 2002 11:30:03 +0200, Gregory Giguashvili wrote:
>Hello,
>
>I wonder if somebody is familiar with the way to create multiple hardware
>configurations (profiles) on Linux? This is required, for instance, when
>booting laptop not connected to the network.
>
>Thanks in advance,
>Giga
There is no way to create multiple profiles on Linux. But there may be a way
on particular distributions or installations. Multiple hardware
configurations mostly have to do with:
1) What kernel gets loaded.
2) What initial root disk is used.
3) What modules are loaded.
4) What configuration scripts are run, how they setup hardware during the
bootup process, and so on.
All of these things are handled by things that vary from Linux machine to
Linux machine. How you choose which kernel to boot depends upon your boot
manager. How your configuration scripts work depends upon how those scripts
are constructed.
DS
>I wonder if somebody is familiar with the way to create
>multiple hardware configurations (profiles) on Linux?
Sorry for not being clear enough. I got several replies saying that this is
not a kernel list question, I suppose because of the example with the
network. In reality, this problem is much broader...
One might think of external devices (tapes, scaners, disks, etc.) constanly
being moved from machine to machine. I understand I can twist /etc/init.d/*
to support all the configurations. However, I don't see a reason why it
cannot be the responsibility of Linux kernel to "see" different hardware
configurations on boot.
>From the replies I got, I understand that Linux kernel doesn't provide such
functionality. That's all I wanted to know.
Best,
Giga
P.S. BTW, I needed this for RH distribution.
On Thu, 27 Jun 2002, David Schwartz wrote:
> There is no way to create multiple profiles on Linux. But there may be a way
Actually there is. We call them runlevels. init seems to be pretty
standard on Linux systems.
Regards
Oliver
--------- Received message begins Here ---------
>
> >I wonder if somebody is familiar with the way to create
> >multiple hardware configurations (profiles) on Linux?
>
> Sorry for not being clear enough. I got several replies saying that this is
> not a kernel list question, I suppose because of the example with the
> network. In reality, this problem is much broader...
>
> One might think of external devices (tapes, scaners, disks, etc.) constanly
> being moved from machine to machine. I understand I can twist /etc/init.d/*
> to support all the configurations. However, I don't see a reason why it
> cannot be the responsibility of Linux kernel to "see" different hardware
> configurations on boot.
Now you got specific.
Most tapes/scanners/disks that are removable/detachable are using the USB.
If that is the case, then yes - they can be handled automatically.
You do have to setup the USB daemon and drivers. Once configured they should
be connected automatically. Depending on the type of disk (hard disk,
filesystem type, access authorizations) you run into additional complications.
Not everything SHOULD be automatically done. For instance - overriding
authorizations on a disk drive can allow a workstation user to violate the
security policy established for the disk drive. The same can be said for
a tape or floppy. Such policies are NOT implementable inside the kernel
(at least not portably).
This is one reason an automatic mount is not necessarily valid. That policy
cannot be supported (or even identified) by the kernel.
Scanners and printers however, are more policy neutral - they don't inherently
store data that is policy controlled. At least not in the US. These devices
are usually immediately available after connection. (Though I'm still working
on getting my HP G55 scanner/printer working - it is recognized by the USB
subsystem as soon as it is attached).
I believe in other countries scanners are required to be able to label the data
being scanned and/or printed to identify the source of the data (doesn't prevent
tampering, but it is still a policy).
> >From the replies I got, I understand that Linux kernel doesn't provide such
> functionality. That's all I wanted to know.
-------------------------------------------------------------------------
Jesse I Pollard, II
Email: [email protected]
Any opinions expressed are solely my own.
>Most tapes/scanners/disks that are removable/detachable are
>using the USB.
And what about non-removable non-USB devices? I understand I need to use
runlevels to achieve the goal...
Thanks,
Giga
On Thu, 27 Jun 2002 14:22:07 +0200 (MET DST),
[email protected] wrote:
>On Thu, 27 Jun 2002, David Schwartz wrote:
>
>> There is no way to create multiple profiles on Linux. But there may be
>>a
>>way
>Actually there is. We call them runlevels. init seems to be pretty
>standard on Linux systems.
True, though runlevels don't allow you to change the kernel you're using,
its command line, or the initrd. In addition, many distributions' preferred
means of creating profiles is not by means of runlevels.
DS
#!/bin/bash
#
# This installs the kernel on a system that requires an initial
# RAM Disk and with an initial SCSI driver.
#
export VER=$1
RAMDISK_DEVICE=/tmp/RAM.DATA
RAMDISK_MOUNT=/tmp/Ramdisk
DISKSIZE=1800
SYS=/usr/src/linux-${VER}/arch/i386/boot/bzImage
MAP=/usr/src/linux-${VER}/System.map
if [ "$1" = "" ] ;
then
echo "Usage:"
echo "make_ramdisk <version>"
exit 1
fi
if [ ! -f ${SYS} ] ;
then
echo "File not found, ${SYS}"
exit 1
fi
if [ ! -f ${MAP} ] ;
then
echo "File not found, ${MAP}"
exit 1
fi
if ! depmod -a ${VER} ;
then
echo "This won't work! There are some unresolved symbols."
exit 1
fi
umount /initrd 2>/dev/null
umount ${RAMDISK_DEVICE} 2>/dev/null
umount ${RAMDISK_MOUNT} 2>/dev/null
mkdir ${RAMDISK_MOUNT} 2>/dev/null
dd if=/dev/zero of=${RAMDISK_DEVICE} bs=1k count=${DISKSIZE}
mke2fs -Fq ${RAMDISK_DEVICE} ${DISKSIZE}
mount -o loop ${RAMDISK_DEVICE} ${RAMDISK_MOUNT}
rmdir ${RAMDISK_MOUNT}/lost+found
mkdir ${RAMDISK_MOUNT}/dev
mkdir ${RAMDISK_MOUNT}/etc
mkdir ${RAMDISK_MOUNT}/lib
mkdir ${RAMDISK_MOUNT}/bin
mkdir ${RAMDISK_MOUNT}/sbin
mknod ${RAMDISK_MOUNT}/dev/null c 1 3
mknod ${RAMDISK_MOUNT}/dev/ram0 b 1 0
mknod ${RAMDISK_MOUNT}/dev/ram1 b 1 1
mknod ${RAMDISK_MOUNT}/dev/sr0 b 11 0
mknod ${RAMDISK_MOUNT}/dev/scd0 b 11 0
mknod ${RAMDISK_MOUNT}/dev/tty0 c 4 0
mknod ${RAMDISK_MOUNT}/dev/tty1 c 4 1
mknod ${RAMDISK_MOUNT}/dev/tty2 c 4 2
mknod ${RAMDISK_MOUNT}/dev/tty3 c 4 3
mknod ${RAMDISK_MOUNT}/dev/tty4 c 4 4
ln -s /dev/tty0 ${RAMDISK_MOUNT}/dev/systty
ln -s /dev/tty0 ${RAMDISK_MOUNT}/dev/console
ln -s /dev/ram1 ${RAMDISK_MOUNT}/dev/ram
ln -s /dev/sr0 ${RAMDISK_MOUNT}/dev/cdrom
ln -s / ${RAMDISK_MOUNT}/dev/root
cp /bin/ash.static ${RAMDISK_MOUNT}/bin/sh
cp /sbin/insmod.static ${RAMDISK_MOUNT}/bin/insmod
cat >/tmp/fake.c << EOF
main(){return 0;}
EOF
gcc -o ${RAMDISK_MOUNT}/sbin/modprobe /tmp/fake.c --static
rm -f /tmp/fake.c
#
# Add modules to this list in the exact order you need them installed
#
modules="scsi_mod.o sd_mod.o BusLogic.o cdrom.o sr_mod.o loop.o isofs.o"
#
echo "#!/bin/sh" >${RAMDISK_MOUNT}/linuxrc
for x in $modules ; do
cp `find /lib/modules/${VER} -name "$x"` ${RAMDISK_MOUNT}/lib
echo "/bin/insmod /lib/$x" >>${RAMDISK_MOUNT}/linuxrc
done
chmod +x ${RAMDISK_MOUNT}/linuxrc
df ${RAMDISK_MOUNT}
sync
umount ${RAMDISK_MOUNT}
rmdir ${RAMDISK_MOUNT}
dd if=${RAMDISK_DEVICE} bs=1k count=${DISKSIZE} | gzip >/boot/initrd-${VER}
rm -f ${RAMDISK_DEVICE}
cp ${SYS} /boot/vmlinuz-${VER}
cp ${MAP} /boot/System.map-${VER}
rm -rf /boot/System.map
ln -s /boot/System.map-${VER} /boot/System.map
psupdate
#
echo >/boot/message
echo " Booting Linux version ${VER}" >>/boot/message
echo " Hit tab key to see alternatives" >>/boot/message
echo " This machine will self-destruct in 15 seconds" >>/boot/message
echo >>/boot/message
#
lilo -C - <<EOF
#
# Lilo boot-configuration script.
#
boot = /dev/sda
message = /boot/message
compact
delay = 15 # optional, for systems that boot very quickly
vga = normal # force sane state
image = /boot/vmlinuz-${VER}
initrd = /boot/initrd-${VER}
root = current
label = new
append = "nmi_watchdog=0"
image = /boot/vmlinuz-${VER}
initrd = /boot/initrd-${VER}
root = /dev/scd0
label = cdrom
image = /vmlinuz
root = current
label = linux
image = /boot/vmlinuz-${VER}
initrd = /boot/initrd-${VER}
root = /dev/sdc3
label = maint
image = /boot/vmlinuz-${VER}
initrd = /boot/initrd-${VER}
root = /dev/sdc1
label = maint-su
append="init=/bin/bash"
image = /vmlinuz.old
root = current
label = linux_old
other = /dev/sda1
table = /dev/sda
label = dos
EOF
On Thu, 27 Jun 2002 23:19, Gregory Giguashvili wrote:
> One might think of external devices (tapes, scaners, disks, etc.) constanly
> being moved from machine to machine. I understand I can twist /etc/init.d/*
> to support all the configurations. However, I don't see a reason why it
> cannot be the responsibility of Linux kernel to "see" different hardware
> configurations on boot.
We can do this, for some device types. Not just for boot, but for hotplug type
devices as well. The kernel option is CONFIG_HOTPLUG, and it signals
userspace to describe what went on.
It is not appropriate for the kernel to decide what goes on (eg, if you attach
a USB scanner, whether you'd like to load the necessary kernel modules, start
up KDE and kooka, start a scan and save to /tmp/pr0n; or just ignore it for
now because the scanner is noisy, and you'll start it running overnight from
a cron job). So we make such policy decisions in userspace. This is normally
some shell script run as /sbin/hotplug (although you can change the script
name using a /proc interface). Sample scripts can be downloaded from
http://linux-hotplug.sf.net, which has lots more documentation on this.
Does this address your concern?
Brad
--
http://conf.linux.org.au. 22-25Jan2003. Perth, Australia. Birds in Black.