-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblockdev.sh
More file actions
32 lines (26 loc) · 801 Bytes
/
blockdev.sh
File metadata and controls
32 lines (26 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
[ -f /etc/sysconfig/blockdev ] || exit 0
blockdevs=$(awk -F= '!/^#/ && !/^$/ {if ($2) print $1}' /etc/sysconfig/blockdev)
[ -n "$blockdevs" ] || exit 0
# Source blockdev configuration.
. /etc/sysconfig/blockdev
for var in $blockdevs; do
realdrive=
drive=${var#BLOCKDEV_}
if [ -d "/sys/block/${drive}" -a -e "/dev/${drive}" ]; then
realdrive="/dev/${drive}"
elif [ -e "/dev/mapper/${drive}" ]; then
realdrive="/dev/mapper/${drive}"
elif drive=$(echo $drive | tr _ -) && [ -d "/sys/block/${drive}" -a -e "/dev/${drive}" ]; then
realdrive="/dev/${drive}"
elif [ -e "/dev/mapper/${drive}" ]; then
realdrive="/dev/mapper/${drive}"
fi
if [ -n "$realdrive" ]; then
eval PARAMS=\$$var
if [ -n "${PARAMS}" ]; then
/sbin/blockdev ${PARAMS} $realdrive
fi
fi
done
exit 0