I was looking for a way to refresh the scsi bus (or any other bus, for that matter) that would allow my kernel ( 2.6.18-194-el5 on CentOS 5.5) to know about the partitions on a drive, and I couldn't find a way. partprobe did it instantly. How?
Since it's important, here's what I was doing:
I wanted to get some practice in partition-specific things like resizing, backing up the MBR and restoring it, and so on. I had created a 20GB partition on /dev/sdb, backed up the MBR:
dd if=/dev/sdb of=sdb.mbr bs=512 count=1
then I went into fdisk, deleted the partition, wrote it, and exited.
showed that there was no partition, and
fdisk -l /dev/sdb'
matched, so I figured I was good.
I then reversed the dd:
dd if=sdb.mbr of=/dev/sdb bs=512 count=1
Of course, I didn't do anything at that point, so
didn't list any partitions, but
showed the partition, presumably because it reads the first 512 bytes on the disk and doesn't rely on the kernel. I knew that I'd have to refresh the bus, so I went into into /sys/class/scsi_host/host1, and did
echo "- - -" > scan
didn't show anything new, so then I went to /sys/bus/scsi/devices and for each of the listed devices, I did
echo 1 > rescan
and that didn't work.
I then did more research on the problem, and came across 'partprobe', which comes with parted. I ran it, and it worked instantly.
If I don't get a likely answer here, I'm probably going to just go get the source and look it up, but I figure there are wizards here beyond me, so I thought I'd appeal to you all.