# Help understanding filespace usage with vimage



## sdad (Jan 24, 2011)

FreeBSD 8.1, working toward a 4 jail system with vimage.

I have a pair of hd's in raid 1 for the host (18gb), and have setup 4 additional 18gb hd's each hd for a jail.  Each jail uses full (nearly) 18gb scsi. After installing the host, I initially set up each jail with this code:


```
mkdir /1/img
mkdir /1/dir
cd /1
dd if=/dev/zero of=img/one bs=3500k count=4096
mkdir dir/one
```

I run this code only once, to set up structure

Other 3 jails in a similar fashion.

I then got the jail running:


```
# Jail One
#
cd /1
mdconfig -a -t vnode -f img/one -u 1
newfs -U /dev/md1
mount /dev/md1 dir/one
mount_unionfs -o below base dir/one
mount -t devfs devfs dir/one/dev
cp /etc/resolv.conf dir/one/etc/resolv.conf
jail -c vnet host.hostname=one.domain.tld path=/1/dir/one persist
#
```

I run above code at each reboot

I did networking, entered jail, and pkg'd in xorg and firefox. (Only for jail 1, so far)
I exit'd jail and did a df from host:


```
$ df
Filesystem      1K-blocks     Used    Avail Capacity  Mounted on
/dev/da0s1a       2026030   319472  1544476    17%    /
devfs                   1        1        0   100%    /dev
/dev/da1s1d      17214062 16959314 -1122376   107%    /1
/dev/da2s1d      17214062 14539506  1297432    92%    /2
/dev/da3s1d      17214062 14539506  1297432    92%    /3
/dev/da4s1d      17214062 14539506  1297432    92%    /4
/dev/da0s1e        487790       12   448756     0%    /tmp
/dev/da0s1f       9839986  2630904  6421884    29%    /usr
/dev/da0s1d        966894      470   889074     0%    /var
/dev/md1         13880078       20 12769652     0%    /1/dir/one
<below>:/1/base  31094140 17214082 12769652    57%    /1/dir/one
devfs                   1        1        0   100%    /1/dir/one/dev
/dev/md2         13880078       20 12769652     0%    /2/dir/two
<below>:/2/base  31094140 17214082 12769652    57%    /2/dir/two
devfs                   1        1        0   100%    /2/dir/two/dev
/dev/md3         13880078       20 12769652     0%    /3/dir/three
<below>:/3/base  31094140 17214082 12769652    57%    /3/dir/three
devfs                   1        1        0   100%    /3/dir/three/dev
/dev/md4         13880078       20 12769652     0%    /4/dir/four
<below>:/4/base  31094140 17214082 12769652    57%    /4/dir/four
devfs                   1        1        0   100%    /4/dir/four/dev
$
```

Jail 1 is on /dev/da1s1d.  Please look at what happened to my file space.  I am noticing that my drive is now beyond fully allocated. My intention, of course, was to set up a dummy file that occupied the entire drive and that anything that I added after the construction, would go in place of the nulls that I first entered, filesize should not have changed. I know xorg is big, but 17g's? It appears that my assumption is incorrect and I would really like to understand why.  If my additional software adds to the original filesize, then I should make the initial file very small ???? (bs<<1M)  This isn't setting right with me, though. Why would I allocate at all?  In Virtualbox, the same sort of allocation is done(fixed size mode)and all code, data resides within that initial space.  I am way off on something, but what. BTW, jail 1, before installing xorg and firefox was the same size as jails 2-4.


----------



## SirDice (Jan 25, 2011)

sdad said:
			
		

> anything that I added after the construction, would go in place of the nulls that I first entered, filesize should not have changed.



FreeBSD's UFS uses sparse files.


----------

