2020-04-12 01:01:02 +05:30
|
|
|
#!/bin/sh -f
|
|
|
|
#
|
|
|
|
# create /dev/disk/by-* and /dev/mapper/* symlinks
|
|
|
|
|
|
|
|
create_symlink()
|
|
|
|
{
|
2020-05-13 22:12:30 +05:30
|
|
|
dir="$1"; sym="$2"
|
|
|
|
|
2020-04-12 01:01:02 +05:30
|
|
|
sym="${sym%\"}"
|
|
|
|
sym="${sym#\"}"
|
2020-05-07 17:36:34 +05:30
|
|
|
sym="${dir}/${sym}"
|
2020-04-12 01:01:02 +05:30
|
|
|
|
2020-05-07 17:36:34 +05:30
|
|
|
mkdir -p "$dir"
|
2020-05-19 09:59:40 +05:30
|
|
|
ln -s "../../${dev_name}" "$sym"
|
2020-04-12 01:01:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
# int main()
|
|
|
|
{
|
2020-05-23 01:50:01 +05:30
|
|
|
[ -b "/dev/${dev_name=${DEVPATH##*/}}" ] || exit 1
|
2020-05-07 17:36:34 +05:30
|
|
|
|
2020-05-19 09:59:40 +05:30
|
|
|
# prevent race condition
|
2020-06-28 09:28:57 +05:30
|
|
|
blkid "/dev/${dev_name}" || sleep 2
|
2020-05-07 17:36:34 +05:30
|
|
|
|
2020-05-13 22:12:30 +05:30
|
|
|
for line in $(blkid "/dev/${dev_name}"); do case "${line%%=*}" in
|
|
|
|
UUID) create_symlink /dev/disk/by-uuid "${line##*=}" ;;
|
|
|
|
LABEL) create_symlink /dev/disk/by-label "${line##*=}" ;;
|
|
|
|
PARTUUID) create_symlink /dev/disk/by-partuuid "${line##*=}" ;;
|
2020-04-15 22:20:45 +05:30
|
|
|
esac; done
|
2020-04-12 01:01:02 +05:30
|
|
|
|
2020-05-19 09:59:40 +05:30
|
|
|
read -r dm_name < "/sys/block/${dev_name}/dm/name" && {
|
2020-05-07 17:36:34 +05:30
|
|
|
mkdir -p /dev/mapper
|
2020-05-19 09:59:40 +05:30
|
|
|
ln -sf "../${dev_name}" "/dev/mapper/${dm_name:?}"
|
2020-04-12 01:01:02 +05:30
|
|
|
}
|
2020-06-02 16:56:42 +05:30
|
|
|
} > /dev/null 2>&1
|