Only get rootfs when we need to calculate the image size

Fixes #3468