Running scripts in fstab?
I have a PC104 board running Linux (Debian sarge) from a CF card.
Naturally this is set up so that Linux mounts the card using a read
only file system with a ram drive to manage tmp, var, etc... At boot
time I want to give the user a chance to mount the file system
read/write and kill off the ram drive if they so choose. So I pass a
variable to the kernel at boot time 'ROOT_READ_WRITE=1' that gets set
as an environment variable that an init.tab script can pick up on.
This script in turn creates the ramdisk and symlinks fstab to either a
read only or read/write version of fstab.
This works great, except that I am forced to maintain two fstab files
(one read only, one read/write) and substitute the appropriate one in
at boot time. This is a pain from a maintenance standpoint and I would
much prefer to implement a conditional inside of fstab (if [
$ROOT_READ_WRITE eq 1 ]; then...) but it does not seem to work. Is
there a more elegant solution to handle this?
Thanks in advance,
David Tucker
Re: Running scripts in fstab?
Hello,
[color=blue]
> This works great, except that I am forced to maintain two fstab files
> (one read only, one read/write) and substitute the appropriate one in
> at boot time. This is a pain from a maintenance standpoint and I would
> much prefer to implement a conditional inside of fstab (if [
> $ROOT_READ_WRITE eq 1 ]; then...) but it does not seem to work. Is
> there a more elegant solution to handle this?[/color]
You can write a script, which creates your fstab on-the-fly. Something like
#!/bin/sh
echo "/dev/hda1 / ext2 ro 0 0" > /etc/fstab
echo "/dev/hda2 swap swap defaults 0 0" >> /etc/fstab
will do. Then you can use your conditions.
Your script must only be run at the very first stage of booting.
Regards,
Sebastian