Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbd: add auto mount options #473

Merged
merged 1 commit into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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