Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question
    
Try using -v rather than -q, to hopefully get more details about what's failing. –  Michael Kjörling Oct 1 '13 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. –  Michael Kjörling Oct 1 '13 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. –  Daniel Groves Oct 1 '13 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! –  Michael Kjörling Oct 1 '13 at 9:38
    
Thanks, I appreciate your help :) –  Daniel Groves Oct 1 '13 at 13:06

1 Answer 1

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).

share|improve this answer
    
Even trying to format the loopback directly I get the same error. I've just added details showing the output the the question. –  Daniel Groves Oct 1 '13 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. –  Michael Kjörling Oct 1 '13 at 9:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.