mirror of
https://github.com/nchevsky/systemrescue-zfs.git
synced 2026-04-04 13:57:29 +00:00
add --readonly option to mountall
This commit is contained in:
parent
e3b7b2079e
commit
c0cddfc630
1 changed files with 17 additions and 5 deletions
|
|
@ -15,10 +15,11 @@ print_help()
|
|||
echo "mountall - mount all suitable block devices"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo "mountall [-n|--no-bind] [-v|--verbose]"
|
||||
echo "mountall [-n|--no-bind] [-o|--ro|--readonly] [-v|--verbose]"
|
||||
echo ""
|
||||
echo "--no-bind Don't try to bind-mount /dev /proc and /sys when"
|
||||
echo " the partition has these dirs"
|
||||
echo "--readonly Mount read-only"
|
||||
echo "--verbose Verbose output."
|
||||
echo ""
|
||||
echo "See https://www.system-rescue.org/scripts/mountall/ for details."
|
||||
|
|
@ -51,11 +52,12 @@ parse_args()
|
|||
exit 1
|
||||
fi
|
||||
|
||||
local OPTIONS="nvh"
|
||||
local LONGOPTS="no-bind,verbose,help"
|
||||
local OPTIONS="novh"
|
||||
local LONGOPTS="no-bind,readonly,ro,verbose,help"
|
||||
|
||||
# option variables as globals, set to default values
|
||||
declare -g BIND=1
|
||||
declare -g READONLY=0
|
||||
declare -g VERBOSE=0
|
||||
|
||||
# -regarding ! and PIPESTATUS see above
|
||||
|
|
@ -79,6 +81,10 @@ parse_args()
|
|||
BIND=0
|
||||
shift
|
||||
;;
|
||||
-o|--readonly|--ro)
|
||||
READONLY=1
|
||||
shift
|
||||
;;
|
||||
-v|--verbose)
|
||||
VERBOSE=1
|
||||
shift
|
||||
|
|
@ -263,8 +269,14 @@ try_mount()
|
|||
|
||||
create_mountpoint "$DEV" || return
|
||||
|
||||
if ! mount "$DEV" "$MOUNTPOINT"; then
|
||||
echo "error mounting $DEV"
|
||||
local OPTIONS=""
|
||||
if [[ $READONLY -eq 1 ]]; then
|
||||
[[ $VERBOSE -eq 1 ]] && echo "mounting read-only"
|
||||
OPTIONS="--read-only"
|
||||
fi
|
||||
|
||||
if ! mount $OPTIONS "$DEV" "$MOUNTPOINT"; then
|
||||
echo "error mounting $DEV to $MOUNTPOINT (options $OPTIONS)"
|
||||
return
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue