Ubuntu – How to refresh Disk Utility

disk-utility

I do a lot of live system building, which eventually involves imaging a USB drive with the built binary image:

dd if=binary.img of=/dev/sdX
sync

Where /dev/sdX is a USB drive. As part of my workflow, I like to have Ubuntu's Disk Utility open so I can verify the drive letter and unmount anything that gets mounted automatically. I also use it to create extra partitions for persistence.

The trouble is, after writing the image to the device — and even after the sync operation — Disk Utility doesn't show the new partition. It just shows free space. GParted sees it and fdisk sees it. Even after closing and opening Disk Utility, it still shows only free space.

If I click "Safe Removal" and physically unplug and replug the USB drive, Disk Utility will then see the partition.

Why do I need to remove and re-insert the drive for Disk Utility to see the partitions on it? Can I force Disk Utility to update its information without needing to do this?

(using Disk Utility 3.0.2 under Ubuntu 11.10.)

Best Answer

The kernel probably doesn't know about the change. A good tool which helps in this case is partprobe. Just call it with sudo partprobe. The software will test all drives and if it finds new partitions it informs the kernel. After a successful run you'll see your image instead of free space.

Related Question