Reread partition table without rebooting?
Posted
by
Teddy
on Server Fault
See other posts from Server Fault
or by Teddy
Published on 2009-07-05T12:10:43Z
Indexed on
2010/12/29
19:56 UTC
Read the original article
Hit count: 200
Sometimes, when resizing or otherwise mucking about with partitions on a disk, cfdisk will say:
Wrote partition table, but re-read table failed. Reboot to update table.
(This also happens with other partitioning tools, so I'm thinking this is a Linux issue rather than a cfdisk issue.) Why is this, and why does it only happens sometimes, and what can I do to avoid it?
Note: Please assume that none of the partitions I am actually editing are opened, mounted or otherwise in use.
Update:
cfdisk uses ioctl(fd, BLKRRPART, NULL)
to tell Linux to reread the partition table. Two of the other tools recommended so far (hdparm -z
DEVICE
, sfdisk -R
DEVICE
) does exactly the same thing. The partprobe
DEVICE
command, on the other hand, seems to use a new ioctl called BLKPG, which might be better; I don't know. (It also falls back on BLKRRPART if BLKPG fails.)
BLKPG seems to be a "this partition has changed; here is the new size" operation, and it looked like partprobe
called it individually on all the partitions on the device passed, so it should work if the individual partitions are unused. However, I have not had the opportunity to try it.
© Server Fault or respective owner