Models of disk galaxy formation commonly predict the existence of an extended reservoir of hot gas surrounding massive spirals at low redshift . As a test of these models , we have obtained X-ray and optical data of the two massive edge-on spirals NGC 5746 and NGC 5170 , in order to investigate the amount and origin of hot gas in their disks and halos . Chandra observations of NGC 5746 reveal evidence for diffuse X-ray emission with a total luminosity of \sim 7 \times 10 ^ { 39 } erg s ^ { -1 } surrounding this galaxy out to at least \sim 20 kpc from the disk , whereas an identical study of the less massive NGC 5170 fails to detect any extraplanar X-ray emission . Unlike the case for other disk galaxies with detected X-ray halos , the halo emission around NGC 5746 is not accompanied by extraplanar H \alpha or radio emission , and there is no evidence for significant nuclear or starburst activity in the disk . In contrast to these other cases , the emission around NGC 5746 therefore appears to arise from the cooling of externally accreted material rather than from disk outflows . To verify this idea , we present results of cosmological simulations of galaxy formation and evolution , showing our observations to be in good agreement with expectations for cosmological accretion , while also confirming that the X-ray halos of other spirals do not fit well into an accretion scenario . We find that the estimated cooling rate of hot halo gas around NGC 5746 would provide sufficient material for star formation in the disk to proceed at its present rate . This lends support to the idea that a supply of hot ambient gas is potentially available as fuel for star formation in massive , nearby spirals , and suggests that accretion of hot gas could be important for maintaining the stellar disks of such galaxies . Finally , our results support the notion that hot halo gas constitutes most of the ” missing ” galactic baryons .