Skip to content

Commit

Permalink
nbd: add auto mount options
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanHai committed Jul 27, 2021
1 parent 40dd94e commit a5cf65f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions nbd/nbd-package/etc/curve/curvetab
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# this file record the correspondence of curve nbd images/ devices
# add record when 'curve-nbd map' and 'curve-nbd unmap'
#
# format: device image map-options mount
# /dev/nbd0 cbd:pool//curvefile_test_ defaults or try-netlink,timeout=7200,nebd-conf=/etc/nebd/nebd-client.conf /curve
# format: device image map-options mount mount-options
# /dev/nbd0 cbd:pool//curvefile_test_ defaults or try-netlink,timeout=7200,nebd-conf=/etc/nebd/nebd-client.conf /curve -o discard
11 changes: 6 additions & 5 deletions nbd/nbd-package/usr/bin/map_curve_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function usage() {
echo "Usage: ./map_curve_disk.sh start"
echo " -c/--confPath: set the confPath (default /etc/curve/curvetab)"
echo " file format is:dealflag \t device \t image \t map-options \t mountpoint(option)"
echo " example: + /dev/nbd0 cbd:pool//curvefile_test_ defaults or try-netlink,timeout=7200 /test"
echo " example: + /dev/nbd0 cbd:pool//curvefile_test_ defaults or try-netlink,timeout=7200 /test -t ext4 -o discard"
echo " -h/--help: get the script usage"
echo "Examples:"
echo " ./map_curve_disk.sh start //use the default configuration"
Expand All @@ -45,8 +45,8 @@ function dealcurvetab() {
declare -A recordmap
while read line
do
flag=$(echo $line | awk '{print $1}')
device=$(echo $line | awk '{print $2}')
flag=$(echo "$line" | awk '{print $1}')
device=$(echo "$line" | awk '{print $2}')
if [ "$flag" = "+" ]
then
recordmap["$device"]=$line
Expand All @@ -56,7 +56,7 @@ function dealcurvetab() {
fi
done < ${confPath}
for key in ${!recordmap[@]}; do
echo ${recordmap[$key]} >> ${confPath}.bak
echo "${recordmap[$key]}" >> ${confPath}.bak
done
}

Expand Down Expand Up @@ -91,13 +91,14 @@ function map() {
image=$(echo "$line" | awk -F'\t' '{print $3}')
mapopt=$(echo "$line" | awk -F'\t' '{print $4}')
mountpoint=$(echo "$line" | awk -F'\t' '{print $5}')
option=$(echo "$line" | awk -F'\t' '{print $6}')

mapopt=$(convert_map_opts "${mapopt}")
curve-nbd map $image --device $device ${mapopt}

if [ "$mountpoint" != "" ]
then
mount $device $mount
mount $option $device $mountpoint
fi
done
mv ${confPath}.bak ${confPath}
Expand Down

0 comments on commit a5cf65f

Please sign in to comment.