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. 690 D. MONTORO-CAZORLA AND R. PÉREZ-OCÓN earthquakes, or to sabotages (induced risks). It can also fail due to the structure of the componentes of the quality of the elements (internal risks).The literature on the study of a device under shocks and wear is extensive, following from [1], and is discussed below. The first paper in which the survival function for the shock model is explicitly calculated is [2], where the shocks arrive following a phase-type renewal process. This is also the first paper in which matrix-analytic methods are introduced for studying these types of systems. In [3], a system that undergoes external failures (shocks) and internal failures, with replacement after a prefixed number of repairable shocks and involving phase-type distributions, is studied in stationary regime. In [4] this system is studied in transient regime, obtaining expressions for the performance measures; degradation is introduced by means of good and bad phases in the system. In [5,6], two shock models are considered: one under a Poisson process arrival and another with a jump Markov process modeling the environment. The failure is only due to shocks, the number of shocks is not limited, and the repairs are instantaneous. In these papers, the availability of the systems is calculated under different assumptions, using matrix-analytic methods. In [7,8], the number of shocks that the device can receive is limited and the interarrival times depend on the number of previous shocks; the reliability function is calculated following different methodologies. The maintenance of an n-system governed by a quasibirth-and-death-process is presented in [9, 10]; in these, the matrix-analytic methods are applied to calculate the performance measures of the systems. In all these papers, repairing has not been introduced or its time is instantaneous.Following different methodologies to the matrix-analytic methods are the works of Lam et al. [11], where geometric processes for modeling the successive times of lifetime and repair are studied. In [12] the model in [1] is considered under new modifications: the shocks arrive following a non-homogeneous Poisson process; the system is replaced when a fatal shock arrives. Moreover, the block replacement policy is incorporated. F...