We will present coding for data storage in both the device level and the system level. For flash memory, we propose partial rank modulation, which is a scheme based on the work by Jiang et al. but has lower decoding complexity. Partial permutations are induced from a group of flash cells such that overshoot errors for programming are eliminated. We also study the integration of RAID schemes and distributed storage. RAID schemes are based on MDS (maximum distance separable) array codes that enable optimal storage and efficient encoding and decoding algorithms. What is the smallest fraction of information that one needs to access and transmit in order to rebuild or correct a given number of erasures in a code? We will show explicit constructions that achieve optimal rebuilding.