Subject: Indirect file system mount
To: None <tech-kern@NetBSD.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-kern
Date: 03/02/2004 11:26:28
Hey all,

Foreword.

For my workstation i have the followind IDE disks configuration:
wd0 - used by Windows 2000, FS is NTFS and FAT32.
wd1 - used by NetBSD 1.6.1, FS is FFS.
wd2 - will be used by some kind of Linux, FS is Ext2 or Ext3.
wd3 - well, maybe will be used same way too.

As a result, i have the following /etc/fstab entries:

---cut---
/dev/wd1a / ffs rw 1 1
/dev/wd1b none swap sw 0 0
/dev/wd1e /var ffs rw 1 2
/dev/wd1f /usr ffs rw 1 2
/dev/wd1g /home ffs rw 1 2
/dev/wd1h /tmp ffs rw 1 2
/kern /kern kernfs rw 0 0
/proc /proc procfs rw 0 0
nbsd1:/home/ftp /disk/ftp nfs ro 0 0
nbsd1:/home /disk/home nfs rw 0 0
nbsd1:/usr/pkgsrc /disk/pkgsrc nfs ro 0 0
/dev/wd0a /disk/archive msdos ro 0 0
/dev/wd0b /disk/work ntfs ro 0 0
/dev/wd0e /disk/system ntfs ro 0 0
---cut---

..so location of NetBSD and DOS/NTFS filesystems is hard coded and cannot be 
changed on-fly at boot time.

Problem.

Well, IMHO the problem is obvious - when i remove wd0 or wd1 disk from my PC, 
the order of detected IDE disks is shifted so i do not have anymore for 
example /dev/wd1a as system root course now it's located on /dev/wd0a. So 
every time i need to fix /etc/fstab manually when something's changed.

Cannot say i swap disks in my workstation oftenly, but sometimes i need to get 
for example my NetBSD disk and boot it on some remote machine -> i got this 
problem.

Sollution ?

Every listed above file system (FFS, FATs, NTFS etc) has this or that user 
definable volume label. So technically, i could assign different and 
relatively unique labels for my FS zoo and configure fstabs something like:

UNUX-SYSTEM / ffs rw 1 1
UNIX-SWAP none swap sw 0 0
UNIX-VAR /var ffs rw 1 2
.....
WIN2K-ARCHIVE /disk/archive msdos ro 0 0
WIN2K-WORK /disk/work ntfs ro 0 0
...

i.e. first fstab entry field allows me to choose between direct device 
indication and logical file system mapping based on fs label.

An existing example of such behavior is selection of root device inside kernel 
like "config netbsd root on ? type ffs" so regardless to how many boot 
devices i have, kernel will most likely find my NetBSD root partition and 
continues to boot.

Any ideas ? Maybe some kind of such functionality already available and i just 
missed it ?

// wbr