Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6782511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:45:02+00:00 2026-05-26T16:45:02+00:00

I am working on a very simple script but for some reason parts of

  • 0

I am working on a very simple script but for some reason parts of it seem to run asynchronously.

singlePartDevice() {
# http://www.linuxquestions.org/questions/linux-software-2/removing-all-partition-from-disk-690256/
# http://serverfault.com/questions/257356/mdadm-on-ubuntu-10-04-raid5-of-4-disks-one-disk-missing-after-reboot
# Create single partition
parted -s "$1" mklabel msdos
# Find size of disk
v_disk=$(parted -s "$1" print|awk '/^Disk/ {print $3}'|sed 's/[Mm][Bb]//')
parted -s "$1" mkpart primary ext3 4096 ${v_disk}
parted -s "$1" set 1 raid on
return 0
}

singlePartDevice "/dev/sdc"
singlePartDevice "/dev/sdd"

#/dev/sdc1 exists but /dev/sdd1 does not exist
sleep 5s
#/dev/sdc1 exists AND /dev/sdd1 does also exist

As you see before the call of sleep the script has only partially finished its job. How do I make my script to wait until parted has done its job sucessfully?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:45:03+00:00Added an answer on May 26, 2026 at 4:45 pm

    (I am assuming that you are working on Linux due to the links in your question)

    I am not very familiar with parted, but I believe that the partition device nodes are not created directly by it – they are created by udev, which is by nature an asynchronous procedure:

    • parted creates a partition
    • the kernel updates its internal state
    • the kernel notifies the udev daemon (udevd)
    • udevd checks its rule files (usually under /etc/udev/) and creates the appropriate device nodes

    This procedure allows for clear separation of the device node handling policy from the kernel, which is a Good Thing (TM). Unfortunately, it also introduces relatively unpredictable delays.

    A possible way to handle this is to have your script wait for the device nodes to appear:

    while [ ! -e "/dev/sdd1" ]; do sleep 1; done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on converting a very simple java desktop application to run in java
I am working on a VERY simple script to clean up a few hundred
For some reason my simple jquery bind event isn't working. The funny thing is
I am trying to get jscrollpane working on a very simple page, but for
I've been working on a very simple Jquery script that displays a few mini-dashboards
I'm working on a very simple game (essentially an ice sliding puzzle), for now
I'm working on a very simple iPhone app, that in the end will have
I've been working on a very simple crud generator for pylons. I came up
I'm working on SQL server 2005 and I have a very simple stored procedure:
I have developed a simple location aware iPhone application which is functionally working very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.