How does Linux tell an LSI Megaraid card to flush its cache before shutdown?

During shutdown the system will unmount most of the filesystems. Those that can not be unmounted are remounted read-only. Umount syscall will flush the disk caches via VFS, and disk buffers using the driver behind the block device. The block device driver in your case is the generic SCSI driver sg. This will send the data to the SCSI device using the specific driver for your device and a SCSI flush command so that the data is written from internal disk cache to the disk storage medium. All of this is synchronous and the umount will not return until the data is on the disk. For remounted read-only FS the shutdown scripts will just run the sync syscall.

Tags:

Linux

Megaraid