When I want Linux to consider newly created partitions without rebooting, I have several tools available to force a refresh of the kernel "partition cache":

  • partx -va /dev/sdX
  • kpartx -va /dev/sdX
  • hdparm -z /dev/sdX
  • sfdisk -R /dev/sdX
  • partprobe /dev/sdX
  • ...

I'm not sure about the difference between these techniques, but I think they don't use the same ioctl, like BLKRRPART or BLKPG. So, what is the difference between those ioctl?

  • Probably none at all. kpartx is derived from partx, sfdisk is another partition edit tool. hdparm is for other uses, but also has a way to read partition table into kernel. If you really need to know, then look at the source code. Jul 9 '14 at 9:13

BLKRRPART tells the kernel to reread the partition table. man 4 sd

With BLKPG you can create, add, delete partitions as you please (from the kernel, not on disk of course). You have to tell the kernel the offset and size of individual partition, which implies that you must have parsed the partition table yourself beforehand. See Linux kernel: /include/uapi/linux/blkpg.h

I personally use partprobe (part of parted), which uses the latter approach, probably to support partition tables not supported by the kernel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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