util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "João Miguel" <jmcf125@bitmessage.ch>
To: util-linux@vger.kernel.org
Subject: Suggestion for new multi-mount option
Date: Sat, 18 Aug 2018 21:21:40 +0100	[thread overview]
Message-ID: <20180818202140.GE4715@jmcf125-Acer-GNU-Linux.home> (raw)

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

             reply	other threads:[~2018-08-19  0:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-18 20:21 João Miguel [this message]
2020-02-18 12:46 ` Suggestion for new multi-mount option Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180818202140.GE4715@jmcf125-Acer-GNU-Linux.home \
    --to=jmcf125@bitmessage.ch \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).