Re: mount --bind question.

From: Floyd Davidson (floyd_at_barrow.com)
Date: 09/29/03


Date: 28 Sep 2003 22:27:58 -0800

Andy Baxter <news2@earthsong.null.free-online.co.uk> wrote:
>Is there any advantage in using mount --bind to mount a subdirectory of a
>mounted volume somewhere else in the filesystem, rather than simply using a
>symlink?

I don't know the answer to that.

>The situation in question is I'm trying to split my filesystem between two
>hard disk partitions; one which contains everything which would be
>automatically reinstalled if I had to install from scratch, and another
>which contains all the data I've either created or downloaded.

I would *highly* suggest more than two partitions; more like one
for each of /, /boot, /usr, /var, /home and /usr/local, and then
something specific for whatever disk space you have left.

But, if you insist...

>So far I have a partition which mounts as /mnt/dat which has the home
>directories, /var (because mysql puts data there, apt caches downloaded

One point to note, no matter which way you do this, is that /tmp
and /usr/tmp should be symlinked to /var/tmp.

>.debs there, and apache is configured to use /var/www in debian, though I
>guess I could change these), and /usr/local. At the moment, these are put
>back into the right place in the filesystem through symlinks in the root
>directory tree, but I'm wondering if it would be better to use mount
>--bind?

The concept of symlinks was added to unix for the express
purpose of what you are doing. Prior to that, if you had
guessed wrong and ended up with a filesystem that someday ran
out of space, it was really a case of going back to the drawing
board (it's a royal pain to repartition and restore everything
from backup, and prone to horror stories if the backups turned
out to be bad for some reason).

But, you have the basic idea correct. The only suggestion I
would make is that you not use /mnt/dat as the point to mount
the second partition. Putting a number of directories in /mnt
seems to be something some people do these days, but if you do
that at least make them all *temporary* mount points, not
permanent ones. Personally I use things like /mnt, /mnta, and
/mntb for most temporary mounts such as floppies, cdroms, etc.
(That should pin down, for old timers at least, just how long
I've been using unix.)

There have been a number of ways people traditionally mount
extra disk space, or "utility" partitions that are not directly
in the standard directory tree. One is the use /usr1, /usr2,
/usr3, ... and so on. Another (which I use) is /u1, /u2, /u3,
and so on. Typically some directories that are often mounted as
separate filesytems might instead just be symlinks to
directories like /u2/home or /u1/local (for /usr/local), and so
on. Large packages such as TeX, XEmacs, X11R6 and so on might
actually be linked to directories on these filesystems.

>A problem with this seems to be that there isn't an option I can put in
>fstab to do this, so I'd have to write a custom init script to do it.

Welll, I haven't tried it, but you should be able to use "bind" as
an option, just like "user" or "ro", in the fourth field of your
/etc/fstab file.

That does sound interesting, and it also provides a clean way to
see what you've done too, because df is going to report all such
mounts.

-- 
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com


Relevant Pages

  • Re: Xenix Filesystem
    ... > how do I mount a new filesystem in SCO Open Server 5.0.5? ... There is probably at least 2 or 3 divvy partitions within that fdisk ...
    (comp.unix.sco.misc)
  • Re: multi volume with tar
    ... a disk definitely won't result in a filesystem-like structure. ... won't mount that floppy. ... You *never* write to the raw device node of a mounted filesystem ... because writing directly to the device mangled the ...
    (comp.os.linux.misc)
  • Re: USB stick access freezing up system?
    ... would expect the application to fail, but the stick is just a mount in ... How can it corrupt a filesystem on a device that's been removed? ... corruption of its filesystem, ... I have transported an MFM disk that had not been parked with the ...
    (comp.unix.bsd.freebsd.misc)
  • Re: modify filesystem of linux
    ... Technically, you don't move space from one mount directory to another, you ... Assuming you've just got two ext2 filesystems on a pair of primary partitions, ... Just backup all of the data on all partitions on the disk (make at least two ... The resize2fs program can change the size of an ext2 filesystem. ...
    (comp.os.linux.development.system)
  • Hints for precision benchmarking...
    ... and run into the usual problem of noisy data preventing any ... * Don't mount filesystems you do not need. ... This removes atime updates to disk from your I/O picture. ... This results in a consistent filesystem layout. ...
    (freebsd-current)