Fstab

使用 fstab 掛載 posixovl

  • July 1, 2021

以下行:

/path1  /path2  posixovl    none    0   0

失敗並出現錯誤:

/sbin/mount.posixovl: invalid option -- 'o'
Usage: /sbin/mount.posixovl [-F] [-S source] mountpoint [-- fuseoptions]

這是因為mount.posixovl使用了非標準的掛載語法,並且fstab會假設預設的掛載語法來呼叫它,例如。

mount.posixovl /path1 /path2 -o [whatsoever_/etc/fstab_options]

編輯#1: 同樣的問題,在這個 linuxquestions.org Q&A 中用一個更醜陋的黑客解決了,標題為:$$ SOLVED $$如何在啟動時安裝 fuse-posixovl 分區?

我寫了一個包裝器mount.posixovl,使它可以與fstab

首先,重命名/sbin/mount.posixovl為其他名稱,例如/sbin/mount.posixovl.orig

最後,創建一個/sbin/mount.posixovl包含以下內容的新文件:

#!/bin/bash
# wrapper for mount.posixovl to conform with common mount syntax
# with this wrapper posixovl can be used in fstab

# location of the original mount.posixovl
origposixovl="/sbin/mount.posixovl.orig"

# gather inputs
while [ $# -gt 0 ]; do
       if [[ "$1" == -* ]]; then
               # var is an input switch
               # we can only use the -o or -F switches
               if [[ "$1" == *F* ]]; then
                       optsF="-F"
               else
                       optsF=""
               fi
               if [[ "$1" == *o* ]]; then
                       shift
                       optsfuse="-- -o $1"
               else
                       optsfuse=""
               fi
               shift
       else
               # var is a main argument
               sourcedir="$1"
               shift
               if [[ "$1" != -* ]]; then
                       targetdir="$1"
                       shift
               else
                       targetdir="$sourcedir"
               fi
       fi
done

# verify inputs
if [ "$sourcedir" == "" ]; then
       echo "no source specified"
       exit 1
fi
if [ "$targetdir" == "" ]; then
       echo "no target specified"
       exit 1
fi

# build mount.posixovl command
"$origposixovl" $optsF -S "$sourcedir" "$targetdir" $optsfuse

自然,將新創建/sbin/mount.posixovl的設置為可執行(chmod +x /sbin/mount.posixovl

有用的安裝posixovlfstab

引用自:https://unix.stackexchange.com/questions/216727