linuxrootfs

mount rootfs on loopback


I have a rootfs boot image that I want to test by mounting on my local file system. How can I do this ?

EDIT: The file was a rootfs.img but it turned out I did not have the correct filesystem support in my custom kernel. pjz's answer works once the fs support is there.


Solution

  • Need more info - what kind of image is it?

    is it a file that's a filesystem? if so you mount it like:

      mount -o loop rootfs.img /mnt/rootfs
    

    if it's a subdir of your filesystem that you're exporting via NFS, you can simulate the environment you've created by chrooting to it:

      chroot /path/to/nfs/rootdir/