Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using fdisk to resize the partitions on a raw QEMU image. When I write the new partition table, it hangs at "Syncing disks."

Note that I'm running fdisk as non-root since I don't need root to edit the image file.

What would cause "Syncing disks" to hang like this?

share|improve this question
Run strace -o fdisk.strace fdisk to see what it's hanging on. – Gilles Feb 28 '12 at 23:54
It's dead now... I tried strace -p to attach to the process, but it hung, and I couldn't kill it either! – Lorin Hochstein Feb 29 '12 at 3:55
up vote 2 down vote accepted

After printing the "Syncing disk" message, fdisk calls sync(2) syscall, which causes all buffered modifications to file metadata and data to be written to the underlying file systems. It is expected that this operation can take some time, but it shouldn't hang forever. If it does, you might see in which function in the kernel it hangs in /proc/FDISK_PID/stack.

The question is why fdisk calls sync() while working with the image file (not real device). It should not be needed IMHO.

share|improve this answer

Possible workaround:
I had the same problem, and the way around it was to use sfdisk instead of fdisk. You will find that you can do anything with sfdisk fdisk can do.

For example, instead of doing:

  fdisk $image <<FDISK

I did:

echo ",+," | sfdisk -N2 $image

Suddenly no sync problems.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.