Shuffling a file on disk using $O(\log n)$ memory
The algorithm you suggest doesn't result in a uniform permutation. An in-place algorithm which works for every file size is the Fisher&ndash;Yates shuffle.