home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] a compelling application for bind mounts?

  • Subject: Re: [OCLUG-Tech] a compelling application for bind mounts?
  • From: Alex Pilon <alp [ at ] alexpilon [ dot ] ca>
  • Date: Sun, 29 Dec 2013 00:58:56 -0500
On Thu, Dec 26, 2013 at 06:42:11AM -0500, Robert P. J. Day wrote:
> does anyone here use bind mounts on a regular basis, and for what?

‘Path shortening’.

Example:

    $ mount /dev/mapper/oldvg-homelv /mnt
    $ ls /mnt
    foo lost+found
    $ mount -o bind /mnt/foo /mnt
    $ ls /mnt
    [contents of foo's old home]

Another example would apply to EFI-booting. You decided that you want to
keep the ESP clean, so you put your kernel and initramfs under a
separate directory under /EFI (rooted from the root of the ESP
filesystem, not your root filesystem).

/EFI
  /archlinux
   vmlinuz-linux
   initramfs-linux.img
   initramfs-linux-fallback.img
   ⋮
  /windows # yes, for games
   ⋮

Your distribution's package installs the kernel normally under /boot.
Your initramfs generator (mkinitcpio, dracut, etc.) puts the generated
initramfs images under /boot too. You could reconfigure the initramfs
generator (e.g., modify /etc/mkinitcpio.d/linux.preset, or whatever your
system uses), and have to deal with merging your configuration with
upstream's once in a while during package updates (or every update if
your package mangement system is not enough). You could instead use
incron, a custom init script calling inotifywait (yay, one more
daemon!), or systemd ‘filesystem events’ (just uses inotify) to copy
over the kernel and initramfs images from /boot into /boot/EFI/archlinux
every time the file gets written (yay, race conditions!).

Or… you could just `mount -o bind /boot/EFI/archlinux /boot` and
everything's transparent.

Attachment: pgpq9QtKrTX_W.pgp
Description: PGP signature