WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Wait between fdisk and mkfs  (Read 3996 times)

Offline ost

  • Newbie
  • *
  • Posts: 41
Wait between fdisk and mkfs
« on: October 12, 2011, 04:32:13 AM »
Im making a script to partition an IDE/CF disk and it appears that there is a critical time between fdisk and mkfs where I have to wait for the core to reread the partition table, orelse the mkfs will fail.
Does anyone know how to wait until the core is done so I can continue with mkfs?

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Wait between fdisk and mkfs
« Reply #1 on: October 12, 2011, 05:08:31 AM »
Yep, I can confirm that I've run into exactly the same problem. What I did end up doing was to put a sync ; sleep 1 sequence between the 'fdisk' and the 'mkfs' command (as a 'sync' on it's own did not seem to be sufficient).

That might be a bit of a kludge as there is no proper check and there might be situations where one seconds could be not enough. But I really did not want to spend too much time in finding a proper solution, when a simple work-around appeared to do as well (at least in my case).

Offline ost

  • Newbie
  • *
  • Posts: 41
Re: Wait between fdisk and mkfs
« Reply #2 on: October 14, 2011, 04:05:59 AM »
It appears there is a similar problem between mkfs and mount. I doubt the sync does anything to these transitions. I bet sync only works on a mounted filesystem.

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Wait between fdisk and mkfs
« Reply #3 on: October 15, 2011, 01:15:51 AM »
hdparm -z device is what I have used in the installation scripts.

See: hdparm --help
10+ Years Contributing to Linux Open Source Projects.

Offline ost

  • Newbie
  • *
  • Posts: 41
Re: Wait between fdisk and mkfs
« Reply #4 on: October 17, 2011, 08:40:30 AM »
Thanks, hdparm did the job between fdisk and mkfs :) Not sure if it does between mkfs and mount.. I guess it shouldn't...

Offline rmrichesjr

  • Newbie
  • *
  • Posts: 19
Re: Wait between fdisk and mkfs
« Reply #5 on: October 24, 2011, 12:13:48 PM »
hdparm -z device is what I have used in the installation scripts.

See: hdparm --help

Is that known to work with /dev/sd* and /dev/vd* (TinyCore running in a qemu/libvirt VM)?
Is it known whether a 'udevadm settle' is necessary afterward to ensure that udev has finished whatever it does with a new partition?

Thanks.