move bootrec again with only common codes

this commit reverts 09b1561439 & 811d175918 with slight changes