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
?
Best Answer
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.