Mechanical discs seem to suffer from dirt ingress slightly less than V-brakes. Corrosion in the cables will still make the brakes feel sluggish, though, and frayed or kinked cables will need replacing.
Line up slots in barrel-adjuster and lockring, then pull cable forwards
Cut the cable end off the old cable. Undo the cable clamp bolt and free the end of the cable. Unthread the cable from inside the casing, leaving the casing in place. Keep any rubber boots. Once back at the lever, look to work out how the nipple is seated (it’s usually in a pivoted nest attached to the lever blade). Pull in the lever and look at the exposed section from underneath. Most are variants on the type shown in the picture. Undo the lockring on the barrel-adjuster until its slot lines up with that on the front of the lever body, then undo the barrel to line up its slot too. (Shimano XT and XTR levers don’t have lockrings anymore.)
Pull the cable forward, so it slips out of the lined-up slots, then pull the lever towards the bars. The nest that the nipple sits in has a key-shaped hole so the cable cannot pull out under pressure. Wiggle the cable to line it up with the slot in the nest and pull it out gently. Remove each section of outer casing and cut a fresh piece to length. Cut the end of each section squarely, making sure you don’t leave a ragged tang of metal across the hole. If the cable lining has got squashed where you cut it, use the point of a sharp knife to open it out. Each end of each section will need a ferrule. The cable stops on disc brake bikes are often larger than usual to accommodate hydraulic hoses. If this is the case, reuse the ferrules from the old casing. The far end of the last section may not need a ferrule, but fit one if there is room.
Reverse the procedure you used for removing the old cable to fit the new cable back into the lever: line the nipple up with the key-shaped hole in the nest, wiggle it into place, line the slots on the barrel-adjuster and lockring up with the slots on the lever body, guide the cable into the lever body and barrel-adjuster through the slots, then turn the barrel-adjuster a quarter-turn to trap the cable in place. Feed the cable through each section of outer casing in turn. Fit a ferrule on each end of each section. Make sure you don’t allow the cable to drop onto the ground and pick up dirt. Drip a drop of oil onto any section of cable that will end up inside the outer casing. Feed the cable through the last section, then through the barrel-adjuster or cable stop on the disc brake. Finally, pass the cable under the cable clamp bolt, pull through until the brake pads almost touch the rotor and tighten the cable clamp bolt firmly – see below. Lift the wheel and turn it. It should spin freely. A slight rub is fine, but the wheel shouldn’t drag. The brakes should lock on when you pull the brake lever without the lever touching the handlebar.
Step 1: Refit any rubber boots – give them a clean first if they’re grubby – and slide the cable in under the cable clamp bolt. It is clear where it should fit – make sure it lies in the groove under the clamp bolt. Leave about 5cm (2 inches) of spare cable, cut the rest off and fit a cable end.
Step 2: Pull the cable through the clamp bolt to take up any slack, and hold it with one hand while you tighten the cable clamp bolt up with the other. Then pull the lever firmly several times to settle the casing and ferrules into place. You will probably find that the cable is so slack that you can pull the lever all the way to the bars without locking the wheel. If this is the case, undo the cable clamp bolt and pull more cable through. Retighten the cable clamp and retest.
Step 3: Usually, the stationary pad (on the inside, nearest the wheel) is adjustable. Most adjust by turning a 3 or 5mm Allen key on the back of the pad clockwise to move the pad closer, and anticlockwise to move it farther away. Get it as close as possible without touching the rotor.
See also bike maintenance tips, tricks and techniques “Mechanical disc brakes”
Source : BIKE MAINTENANCE TIPS, TRICKS & TECHNIQUES