11

A task in my homework assignment asks me to create a virtual file system, mount it, and perform some operations on it.

I am supposed to create a file of 10 MB whose bits are all set to 0, format it as ext3 and mount it. This is how I've done that:

dd if=/dev/zero of=~/filesyst bs=10485760 count=1
sudo mkfs.ext3 ~/filesyst
sudo mount –o loop ~/filesyst /media/fuse

Even though I've used /dev/zero, the file i still full of gibberish characters (mostly at-signs). The permissions on /media/fuse are drw-rw-rw- (which are alright), but the permissions on the files inside it are something like this:

d????????? ? ? ? ?          ? lost+found
-????????? ? ? ? ?          ? secret_bin

Where have I gone wrong?

6
  • I think the problem is related to your mkfs.ext3 command. IIRC, There are different arguments you need to use when doing this on a file instead of a device.
    – user606723
    Dec 14, 2011 at 21:44
  • 1
    Maybe I'm wrong, per adamsinfo.com/…, you're doing it correctly. Can you try following the exact commands on this url and see if you still have issues?
    – user606723
    Dec 14, 2011 at 21:46
  • Also, try mkfs.ext3 -F ~/filesyst
    – user606723
    Dec 14, 2011 at 21:49
  • @user606723 Thanks, I solved it. The problem was the bs and count arguments. If I write bs=1MiB count=10, as in that link you posted, it works.
    – Paul
    Dec 14, 2011 at 23:01
  • 1
    By the way, you don't actually need to fill the file with zeros. You can just create an empty file of arbitrary size with truncate -s 400m filesyst. The difference is that until you actually write data to the file, it uses no space on the disk, so you can make a virtual filesystem that is larger than your whole disk drive, as long as you don't try to actually fill it up. You can see how much space the file is actually using with du -h filesyst.
    – psusi
    Dec 15, 2011 at 15:39

1 Answer 1

7

Hmmm... the correct way to do it is:

dd if=/dev/zero of=./filesyst bs=10485760 count=1
sudo losetup /dev/loop0 ./filesyst
sudo mkfs.ext3 /dev/loop0
sudo mount /dev/loop0 /tmp/lalla

and it works:

(0)romano-asus:~/tmp% ls -l /tmp/lalla
total 12
drwx------ 2 root root 12288 2011-12-20 22:21 lost+found
(0)romano-asus:~/tmp% df /tmp/lalla
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/loop0                9911      1121      8278  12% /tmp/lalla

You should check the first loop device free with losetup -f.

You must log in to answer this question.

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