Greece has persuaded the vast majority of its private creditors to accept huge losses and take part in a landmark debt swap that may help save the country from a damaging default.