# Dynamic size file-backed filesystem



## cahimira (Jul 7, 2013)

Hello,

_I_s _it_ possible to create a dynamically sized file-backed filesystem in FreeBSD?

Thanks.


----------



## Chris_H (Jul 17, 2013)

Greetings,

 Yep. It's totally possible. Think of mounting an .ISO file on your system. But there are many more possibilities. You'll want to visit the FreeBSD documentation. The Handbook should be your first stop. Especially the parts on installing, and as I recall, I first noticed it, in a paragraph about increasing SWAP space, when you run out, using file based swap.

HTH

--chris


----------



## wblock@ (Jul 17, 2013)

Dynamically sized, though?  Not with a file.  People periodically try to create a sparse swap file with bad results.  tmpfs(5) is dynamic, but not file-backed.

What is the application?


----------



## fonz (Jul 17, 2013)

wblock@ said:
			
		

> Dynamically sized, though?  Not with a file.


This does make me wonder, though. On several occasions I have mounted USB install images, added files to them (typically pre-made configuration files), unmounted the images and written the result to a flash drive without any ill effects. But I've also heard reports from others that such a procedure failed for them. Have I just been lucky all the time?


----------



## Chris_H (Jul 17, 2013)

fonz said:
			
		

> This does make me wonder, though. On several occasions I have mounted USB install images, added files to them (typically pre-made configuration files), unmounted the images and written the result to a flash drive without any ill effects. But I've also heard reports from others that such a procedure failed for them. Have I just been lucky all the time?



I've done _exactly_ the same -- in fact, just recently, with 9.x. It worked perfectly. But past experiences were quite troublesome. I'm guessing either hardware used, or just better support in FreeBSD (drivers are now more robust).

--chris


----------



## wblock@ (Jul 17, 2013)

fonz said:
			
		

> This does make me wonder, though. On several occasions I have mounted USB install images, added files to them (typically pre-made configuration files), unmounted the images and written the result to a flash drive without any ill effects.



Sure, that works fine.  The contents change, but the image file does not change size.


----------



## fonz (Jul 17, 2013)

wblock@ said:
			
		

> Sure, that works fine.  The contents change, but the image file does not change size.


Does that mean the USB install image has (some) room to spare? I'm _adding_ files, after all.


----------



## wblock@ (Jul 17, 2013)

A little room, yes.  For 9.1-RELEASE amd64:

```
Filesystem            Size    Used   Avail Capacity  Mounted on
/dev/md0a             731M    683M
```


----------



## fonz (Jul 17, 2013)

Ah, a few dozen MB, which is plenty for a bunch of configuration files. That explains a lot.


----------



## cahimira (Jul 19, 2013)

wblock@ said:
			
		

> What is the application?



Have an encrypted file-backed filesystem which I can put onto a flash drive along with other unprotected files. I know how to do that, but if the filesytem has a fixed size.

Thanks.


----------



## wblock@ (Jul 19, 2013)

In that case, creating a new filesystem big enough to hold everything is the standard method.


----------

