Util-Linux Archive on lore.kernel.org
 help / Atom feed
* Suggestion for new multi-mount option
@ 2018-08-18 20:21 João Miguel
  0 siblings, 0 replies; 1+ messages in thread
From: João Miguel @ 2018-08-18 20:21 UTC (permalink / raw)
  To: util-linux

Hi there,

First, some background: recently I've setup a few (too many) hard-drive
backups and new systems with LVM, lots of partitions and weird options
I'd put in the respective /etc/fstab. I don't want to write all that
shit every time I want to mount a system in /mnt/something, I wanted
«mount» to read my fstab, but although it has the «--fstab» option, it
doesn't allow me to mount anywhere but in /.

So I'm not sure if this is welcome here, but I don't really know C to
make the suggestion a patch, although it seems simple enough. Here's a
script, let's call it mount-relative:

#!/bin/bash
_dev="$1"
_mnt="$2"
_tmp="$(mktemp /tmp/fstab-XXXXX)"
mount -v "$1" "$2"
grep -Ev '(^#|swap|^$)' "$_mnt/etc/fstab" \
   | sed -E -e 's#\s+([^\s]+)# '"$_mnt"'\1#' \
            -e 's/(noauto,|,noauto|noauto)//g' \
   | cat >"$_tmp"
mount -av --fstab "$_tmp"
rm -vi "$_tmp"

(Note: I'm filtering «noauto» in a dumb way because I'm lazy and it's a
simple script)

As I've been using:

   mount-relative /dev/something /mnt/somewhere

I think it would be useful for it to be doable with «mount» as:

   mount --relative-root /dev/something /mnt/somewhere

Or at least:

   mount /dev/something /mnt/somewhere
   mount -a --fstab /mnt/somewhere/etc/fstab --relative /mnt/somewhere


Maybe also a «--ignore-noauto», as using «-o auto» in the script doesn't
seem to work (probably because «-o» is not made for usage with «--fstab»
and «-a»).

In case you don't consider this a good option for mount, well, have the
script, it has been very useful to me.

Best regards,
João Miguel

^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-18 20:21 Suggestion for new multi-mount option João Miguel

Util-Linux Archive on lore.kernel.org

Archives are clonable: git clone --mirror https://lore.kernel.org/util-linux/0 util-linux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 util-linux util-linux/ https://lore.kernel.org/util-linux \
		util-linux@vger.kernel.org util-linux@archiver.kernel.org
	public-inbox-index util-linux


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.util-linux


AGPL code for this site: git clone https://public-inbox.org/ public-inbox