File system in a file

Translation of the original in Catalan. Read it in: CatalàCastellano

I don't feel like writing too much either nor do I intend to explain anything out of this world, but for more than one person like me this morning it can help to save one of those situations where we often don't know which way to turn.

While I take the chance to wish you happy holidays and tell you that last night I had a little kit-kat during my holidays but this afternoon I'm back. I hope everything goes well for all of you.

Picture that we have a very typical configuration in everyone's computers, a pindows partition (usually bigger than the linux one) and a linux one.

It could happen to us as it did to me today, that we suddenly need more space in the linux unit, to compile a program or whatever, but we're not interested in changing the size of the partitions nor in getting tangled up in tricky, complex, dangerous, long subjects, etc...

Well very easily we can create a file in our 'pindows' partition format it in the linux format we like most and then mount it as if it were a hard disk.

In my case I needed at least 1Gb to compile the XFree and I only had 300Mb left in the linux partition.

-Mount point of the windows partition with 6Gb free: /mnt/win

-Mount point where I need the space in linux: /var/tmp/portage, it's where the programs are compiled in gentoo.

· We create the 1Gb file:

That creates a completely empty file of 1,048,576 sectors of 1024bytes each sector, that is: 1Gb.

· We format the created file as if it were an ext2:

· We mount the file as if it were a partition, through the loopback interface:

The /dev/loop0 device needs support for CONFIG_BLK_DEV_LOOP=m/y, I have set it to m (module) and I have loaded loop.o

Well that's it if we now run a df we'll be able to see that we already have a new file system mounted where we were short of space. I hope it's useful to you.

2 comments

Comments from the old blog, as they were written. Comments are closed.

  1. Daph

    Ahh doncs esta molt bé la idea i molt simple tb. ... q total aquestes
    hores i aquests díes segur q coses molt complicades tampoc cal...

    Desde aquí envio felicitacions de Nadal i cap d'any a tots els
    "amigüitos", tonets al benja i a la luce q fa tela q no la veig ...
    nosaltres farem la "Crónica a Toralla" suposo q el MUR ja penjará
    la noticia...

    ahhh i un tonet a tu...fins ara...

  2. MoKi

    Molt bona idea. La veritat es que mai vaig pensar-hi. Un dia d'aquest ho provarem.

    Per cert, molt bona la pagina. M'esta agradant força.