Clean up install-to-disk.sh

This shouldn't change any behaviour, it just puts some more code inside
a function, to make things a bit more clear.