disk naming proposal & devfs

Larry McVoy (lm@who.net)
Sun, 11 Jan 1998 12:09:19 +0800


My apologies if this has been discussed in the various messages flying
around about devfs. I have a little suggestion that has a lot to do
with ease of use.

The short summary is: can we please add a mechanism to the system that
names the /name/ of the data we want, not the /location/ of the data
we want? Something like /dev/usr that is a symlink to the real name of
where ever /usr plugged into the system today? This is most helpful to
people that move stuff around in their system.

The details:

Since devfs is going to have to probe all the devices anyway, to see if
something is there, it would be nice if the operating system was extended
to do something like this:

/*
* Find all the existing block devices and remember them.
*/
for dev in each block device {
if (device_probe() == DEV_FOUND) {
add_dev_to_list(dev);
}
}

....

/*
* Automagically make dev nodes for the file systems.
*/
for fs in each file system type {
for dev in each found block device {
if (fs.read_super() == THIS_IS_MY_FS_TYPE) {
add_fs_mount_pount_node(fs, dev);
}
}
}

...

/*
* Take a file system pointer and a dev pointer, read the last
* mount point from the super block, and add a node in for that
* mount point.
*
* I.e., if /dev/sda3 was "/usr", then add a symlink like so:
*
* /dev/usr -> /dev/sda3
*
* Handle "/" specially, make that one be
*
* /dev/root -> /dev/sda1
*/
add_fs_mount_pount_node(fs, dev)
{
...
}

Actually, I have the names wrong if there is movement towards /dev/c1d2s0
(or something, I'm sure I have the details wrong there).

The point is to be able to have the different partitions be //location
idependent//. So if a disk is added, or moved from controller to
controller, then the system can come up without needing to ask any
questions or having /etc/fstab changed. fstab can look something like

/dev/root / ext2 defaults 1 1
/dev/usr /usr ext2 defaults 1 2

As far as I know, no other Unix system (or VMS/NT for that matter) has
such a system. IRIX did something like this (has a /dev/root symlink)
but I don't think it is used to mount the file system, it is made after
booting up.

There is an issue with copied file systems (if you copied it with a dd
if=/dev/sda1 of=/dev/sdb1 bs=1024000 then both super blocks would look
like they wanted to be at the same place). In this case, I think mount
should do two things:

. ask the user (via the console if booting up) which one they meant
. mark the other one as "usr~1" or something like that.

You could have a date based scheme where the most recently unmounted one
wins. So when the system goes down, it stashes the date along with the
mount point in the super block.

Anyway, that's a corner case and one that can be handled. The main thing I
want is, in spite of the niceness of /dev/c1d2s0 or whatever, I'd just as
soon think about /dev/root rather than the exact name. Exact names can be
used for those people that want exact names.