0

I'm trying to make a 40GB ext3 local loopback file system. This loopback filesystem is stored on my NAS which is mounted on a Ubuntu Precise 12.04 x64 machine using NFS. The machine has both read and write permissions on the NAS.

I've created a 40GB file for use by running dd if=/dev/zero of=/media/vps/Ironman.ext3 bs=1024 count=40000000. The file was successfully created, so I mounted is as a loopback system in /dev/loop0 by running sudo losetup /dev/loop0 /media/vps/Ironman.ext3.

I'm now trying to format this as a ext3 file system by running sudo mkfs -t ext3 -q /media/vps/Ironman.ext3. However, whenever I run this command I get the following output:

mke2fs 1.42 (29-Nov-2011)
/media/vps/Ironman.ext3 is not a block special device.
Proceed anyway? (y,n) y
/media/vps/Ironman.ext3: Permission denied while setting up superblock

How can I get around this, and format the loopback device as ext3?

Update 1

I've just tried to format it using the loopback device, as seen below. I am still, however, getting permission denied. You can see in the first set the file was already mounted.

danielsgroves@precise64:/dev$ sudo losetup /dev/loop0
/dev/loop0: [0015]:26378243 (/media/vps/Ironman.ext3)
danielsgroves@precise64:/dev$ sudo mkfs -t ext3 -q /dev/loop0
/dev/loop0: Operation not permitted while setting up superblock

Update 2

With verbose output

danielsgroves@precise64:/dev$ sudo mkfs -t ext3 -v /dev/loop0
mke2fs 1.42 (29-Nov-2011)
fs_types for mke2fs.conf resolution: 'ext3'
/dev/loop0: Operation not permitted while setting up superblock
5
  • Try using -v rather than -q, to hopefully get more details about what's failing.
    – user
    Oct 1, 2013 at 9:22
  • OK, the only thing I can think of is to use mke2fs directly rather than going through mkfs. sudo mke2fs -j -v /dev/loop0 will give you an ext3 file system with defaults otherwise. I just tried it myself (except I used a much smaller image file) and it seems to be working fine for me on Debian Wheezy, which shouldn't be that different.
    – user
    Oct 1, 2013 at 9:29
  • Output is line-for-line the same as using mkfs. I don't recall having these issues last time I did this a few months back. Oct 1, 2013 at 9:31
  • This is really weird. Sorry, but I'm running out of immediate ideas to try. Hopefully someone else will be able to take this and provide some insight!
    – user
    Oct 1, 2013 at 9:38
  • To try to coax some more details out of mkfs, you could run mkfs through strace. I'm not sure how it plays along with sudo, but it's worth a shot. Try sudo strace -o'/tmp/mkfs.syscalls' mkfs -t ext3 -v /dev/loop0 and then post the last 30-50 lines or so from the file mkfs.syscalls created (and particularly anything around printing the "operation not permitted" error message or anything just before it that resulted in such an error). It should tell exactly what mkfs is doing that is not permitted, which might provide a clue pointing toward a solution.
    – user
    Oct 1, 2013 at 13:59

3 Answers 3

0

You need to create the file system on the loop device, not the file that backs the loop device. (This is what the "not a block special device" warning from mke2fs is about.) The backing file is only a matter of consideration for the "loop device" code in the kernel, and you won't be using it directly except in the losetup command. The "permission denied" error may very well be because you are trying to directly modify the backing file of a currently active loop device; doing so could conceivably easily wreak all kinds of havoc, so the kernel likely (sanely) prevents you from doing it even as root.

After running losetup, use sudo mkfs -t ext3 -q /dev/loop0 instead and it should work just fine. Then mount /dev/loop0 wherever you prefer (like, say, sudo mount /dev/loop0 /media/ironman).

This might become more clear if you consider the other options available to losetup, including --offset and --sizelimit (check the man page for more examples).

2
  • Even trying to format the loopback directly I get the same error. I've just added details showing the output the the question. Oct 1, 2013 at 9:21
  • 1
    @DanielGroves Yes, I saw. I'll leave this answer around for now though, as it's an important (and perhaps not completely obvious) point to remember about loop devices.
    – user
    Oct 1, 2013 at 9:22
0

It might not have been the case back in 2013, but these days mkfs.ext* can be run unprivileged on a file. So format the file before creating the loop device, then create the loop device, and mount it.

-1

Okay, this message is very old, but has no answer.

I just had the same problem. The issue for me was that over NFS the root user has no special ability to read & write to a file.

One thing you can do is change the owner of the file to root, or you can put it in the root group and make it group writable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .