A device that can fail by shocks or ageing under policy N of maintenance is presented. The interarrival times between shocks follow phase-type distributions depending on the number of cumulated shocks. The successive shocks deteriorate the system, and some of them can be fatal. After a prefixed number k of nonfatal shocks, the device is preventively repaired. After a fatal shock the device is correctively repaired. Repairs are as good as new, and follow phase-type distributions. The system is governed by a Markov process whose infinitesimal generator, stationary probability vector, and availability are calculated, obtaining well-structured expressions due to the use of phase-type distributions. The availability is optimized in terms of the number k of preventive repairs. Copyright © 2009 John Wiley & Sons, Ltd.