Are you asking "How is data/files" stored on a spinning magnetic disk within a hard drive, or are you asking how is data/files stored within the flash memory cells of a Solid State [hard] Drive...
Yes both are secondary storage devices. Primary storage devices include RAM & ROM. Secondary storage devices include magnetic disks like hard disks and cds(optical disks)
optical disk storage are read only so they cannot get infected. But if you burn files which are infected by viruses then the optical disks can spread the virus