[systemd-devel] Can udev assist?

Reindl Harald h.reindl at thelounge.net
Fri Nov 20 09:29:03 PST 2015



Am 20.11.2015 um 18:08 schrieb Aaron_Wright at selinc.com:
> I have a script that creates a partition (using pyparted) and then tries
> to format it (using mkfs.ext4). Most of the time this works OK. However,
> sometimes the format fails because it can't find the device. There seems
> to be a race condition due to a delay between creating a partition and
> the device node in /dev being created.
>
> Is there a tool in udev or udevadm that can help my script know when it
> safe to proceed?

just call "partprobe" for that device, that works even when you clone 
MBR including partition table with dd
__________________________

[root at srv-rhsoft:~]$ cat /scripts/raid-recovery.sh
#!/usr/bin/bash

GOOD_DISK="/dev/sda"
BAD_DISK="/dev/sdb"

# --------------------------------------------------------------------------

echo "NOT NOW"
exit

# --------------------------------------------------------------------------

# clone MBR
dd if=$GOOD_DISK of=$BAD_DISK bs=512 count=1

# force OS to read partition tables
partprobe $BAD_DISK

# start RAID recovery
mdadm /dev/md0 --add ${BAD_DISK}1
mdadm /dev/md1 --add ${BAD_DISK}3
mdadm /dev/md2 --add ${BAD_DISK}2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20151120/42d6a257/attachment.sig>


More information about the systemd-devel mailing list