On Fri, 20 Nov 2015 09:08:35 -0800
<[email protected]> wrote:

> 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?

Try to use:

<create the partition>
udevadm settle --exit-if-exists=/dev/<devname>
<format the partition>

True, you need to come up with the <devname>, but if you are using
mkfs.ext4, you need to know the <devname> anyway.

Or you can do a loop for about 5-10 seconds and you
watch /dev/<devname>, but is about the same thing as with 'udevadm
settle'.

-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: [email protected]
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to