From: Michael Prokop Date: Thu, 4 Jun 2015 07:56:22 +0000 (+0200) Subject: Improve check for identifying underlying block device X-Git-Tag: v0.71~27 X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=commitdiff_plain;h=3814da0657651b293b7e3ef81ef581ca493e1f7d;ds=sidebyside Improve check for identifying underlying block device There's no point in trying to read the partition table for e.g. /dev/loop if we get /dev/loop0. Fixes #42 @ github Closes: #771192 --- diff --git a/grml-debootstrap b/grml-debootstrap index ca4172b..a3db195 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -995,10 +995,19 @@ mkfs() { # make sure /dev/disk/by-uuid/... is up2date, otherwise grub # will fail to detect the uuid in the chroot - if echo "$TARGET" | grep -q "/dev/md" ; then + if [ -n "$VIRTUAL" ] ; then + einfo "Virtual environment doesn't require blockdev --rereadpt, skipping therefore" + elif echo "$TARGET" | grep -q "/dev/md" ; then blockdev --rereadpt "${TARGET}" - elif ! [ -n "$VIRTUAL" ] ; then - blockdev --rereadpt "${TARGET%%[0-9]*}" + else + # if we deploy to /dev/sdX# then let's see if /dev/sdX exists + local main_device="${TARGET%%[0-9]*}" + # sanity check to not try to e.g. access /dev/loop if we get /dev/loop0 + if [ -f "/sys/block/$(basename ${main_device})/$(basename ${TARGET})/dev" ] ; then + blockdev --rereadpt "$main_device" + else + einfo "No underlying block device for $TARGET identified, skipping blockdev --rereadpt." + fi fi # give the system 2 seconds, otherwise we might run into # race conditions :-/