2020-04-12 01:01:02 +05:30
|
|
|
#!/bin/sh -f
|
|
|
|
#
|
|
|
|
# create /dev/disk/by-* and /dev/mapper/* symlinks
|
|
|
|
|
|
|
|
create_symlink()
|
|
|
|
{
|
|
|
|
sym="$1"
|
|
|
|
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"
|
|
|
|
ln -s "/dev/${dev_name}" "$sym"
|
2020-04-12 01:01:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
# int main()
|
|
|
|
{
|
2020-05-07 17:36:34 +05:30
|
|
|
[ "${dev_name=${DEVPATH##*/}}" ] || exit 1
|
|
|
|
|
2020-05-09 01:28:48 +05:30
|
|
|
exec > /dev/null 2>&1
|
|
|
|
|
2020-05-07 17:36:34 +05:30
|
|
|
# avoid race condition
|
2020-05-13 19:08:21 +05:30
|
|
|
while ! blkid "/dev/${dev_name}"; do sleep 1; done
|
2020-05-07 17:36:34 +05:30
|
|
|
|
|
|
|
for line in $(blkid "/dev/${dev_name}"); do case "${line%%=*}" in
|
2020-04-15 22:20:45 +05:30
|
|
|
UUID)
|
2020-05-07 17:36:34 +05:30
|
|
|
dir=/dev/disk/by-uuid
|
2020-04-15 22:20:45 +05:30
|
|
|
create_symlink "${line##*=}"
|
|
|
|
;;
|
|
|
|
LABEL)
|
2020-05-07 17:36:34 +05:30
|
|
|
dir=/dev/disk/by-label
|
2020-04-15 22:20:45 +05:30
|
|
|
create_symlink "${line##*=}"
|
|
|
|
;;
|
|
|
|
PARTUUID)
|
2020-05-07 17:36:34 +05:30
|
|
|
dir=/dev/disk/by-partuuid
|
2020-04-15 22:20:45 +05:30
|
|
|
create_symlink "${line##*=}"
|
|
|
|
;;
|
|
|
|
esac; done
|
2020-04-12 01:01:02 +05:30
|
|
|
|
2020-05-07 17:36:34 +05:30
|
|
|
[ -e "/sys/block/${dev_name}/dm/name" ] && {
|
|
|
|
mkdir -p /dev/mapper
|
|
|
|
read -r dm_name < "/sys/block/${dev_name}/dm/name"
|
2020-05-13 19:08:21 +05:30
|
|
|
ln -sf "/dev/${dev_name}" "/dev/mapper/${dm_name}"
|
2020-04-12 01:01:02 +05:30
|
|
|
}
|
|
|
|
}
|