The missing baryon and the missing metals problems are the two major challenges for galaxy formation. Circumgalactic Medium (CGM), where cosmic inflows interact with galactic outflows, bears critical information for solving these problems. Current cosmological simulations can model cosmic inflows but their galactic outflows usually rely on ad hoc sub-grid models. The path forward requires better understanding the feedback physics and using physically-based models in large-scale simulations. In this talk, I will first summarize the recent progress of small-box hydrodynamical simulations focusing on the nature of supernovae (SNe) feedback; particularly, the hot outflows are much more powerful than cool outflows while also appearing very simple. Then, I will introduce our galactic scale simulations, which adopt the outflow models from the small-box simulations. For a Milky Way-mass galaxy, when the star formation surface density is low, hot outflows form large-scale fountains in the halo. The warm-hot CGM has a universal density profile, which produces the observed column density of O VI, VII, and VIII, and X-ray emission. Cool gas condenses out of the hot CGM and falls toward the galaxy. In contrast, when the star formation surface density is high, the outflows are bipolar in shape and funnel metals into the intergalactic medium; cool phase is formed en route, with a fraction moving outward at several hundred km/s at large radii. I will discuss the implications of our results to the missing baryon and the missing metals problems.