Generate an EXT2 image without being root

Jan 05, 2005 4 Replies

Hi all,



I'd like to be able to generate an ext2 filesystem image for a ramdisk. I can do that at the moment by mounting an ext2 image on a loopback device, but that requires me to be root. Are there any ways of generating an image without using this mechanism ?



I'm not aware of any other method, however you can do this without being root (man mount, man fstab). If you apply the following to a loop back device, you should be able to get mount to mount an ext2 file system as a mortal user.

see manual pages for ... losetup, fstab, and mount

(iii) Normally, only the superuser can mount file systems. However, when fstab contains the user option on a line, then anybody can mount the corresponding system.

CB

But if the file-system needs to contain special files (device nodes, e.g., /dev/ttyS0 et all), you'll still need to be root unless I'm missing something. Of course, not all EXT2 file systems need nodes owned by someone other than yourself but if it's a bootable filesystem, I don't think you have much choice. Root is it.

Look at the following links:

formatting link
formatting link

I have not tried these, but appear to be the type of program with the characteristics you want.

Also, the ext2 utility program debugfs has all the tools needed to populate a ramdisk, using the commands mkdir, mknod, and write. The filesystem needs to have been created first by using the traditional dd if=null of=filesys count=4k, and mke2fs filesys method.

John Haller

John, you're a genius. Those are exactly what I need, thanks.

Cheers to everyone else who replied.

I may take a look at this.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required