aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKARBOWSKI Piotr <piotr.karbowski@gmail.com>2016-07-30 20:37:58 +0200
committerKARBOWSKI Piotr <piotr.karbowski@gmail.com>2016-07-30 20:37:58 +0200
commit74b145b5c7fe6c4027fd64abeb4e129ba7a85c3f (patch)
treed04e017947581d9666d5c7ca07be039569a88f4d
parentMerge pull request #36 from zx2c4/devel (diff)
downloadbetter-initramfs-74b145b5c7fe6c4027fd64abeb4e129ba7a85c3f.tar.xz
better-initramfs-74b145b5c7fe6c4027fd64abeb4e129ba7a85c3f.zip
populate_dev_disk_by_label_and_uuid: do not overwrite symlinks.
This change ensures that in case of for example mdadm-powered raid1 the UUID and LABEL symlinks won't be replaced even if other block devices share the same UUID/LABEL. Thus in case of /dev/dm-0 and /dev/sda2 share the same UUID, the symlink will be created to the first one.
-rwxr-xr-xsourceroot/functions.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/sourceroot/functions.sh b/sourceroot/functions.sh
index a11b296..79ac278 100755
--- a/sourceroot/functions.sh
+++ b/sourceroot/functions.sh
@@ -118,8 +118,8 @@ populate_dev_disk_by_label_and_uuid() {
vars="${blkid_output#*:}"
eval "${vars}"
- [ "${LABEL}" ] && run ln -sf "../../${block_device}" "/dev/disk/by-label/${LABEL}"
- [ "${UUID}" ] && run ln -sf "../../${block_device}" "/dev/disk/by-uuid/${UUID}"
+ [ "${LABEL}" ] && ! [ -e "/dev/disk/by-label/${LABEL}" ] && run ln -s "../../${block_device}" "/dev/disk/by-label/${LABEL}"
+ [ "${UUID}" ] && ! [ -e "/dev/disk/by-uuid/${UUID}" ] && run ln -s "../../${block_device}" "/dev/disk/by-uuid/${UUID}"
done
}