Minimal compatible solutions of linear equations