# Web server Disk layout and  jail?



## fred974 (Nov 14, 2011)

Best disk layout for web server with 8.2 with jail?

Hi guys,

I'm new to FreeBSD and after hostmonster.com has lost all my data due to a â€˜major hardware failureâ€™ Iâ€™m left with no confidence with third party hosting of my website. So here I am trying to sort myselft out. Iâ€™m trying to set up a reliable web server on my HP DL385 Dual AMD Opteron 2.6GHZ 4GB RAM 146GB scsi before I consider doing anything live with real data. I'm struggling to see what I should have for the server disk layout. 

My plan is to have my web server setup with FreeBSD and have 3 jails in it for security. 

1x for webserver
1x for database
1x for Email Server

Now, looking at the FreeBSD manual, the jail get installed in the /usr/ directory so itâ€™ll be:


```
/usr/jail/webserver
/usr/jail/database
/usr/jail/email
```
Is there any way I could have a jail in a different directory like in /home?

So far I thought of having the following:

```
/ 2Gb
swap:	10Gb
/var:	2Gb
/tmp:	1GB (or tmpfs ??? please someone explain this to me)
/usr:	5Gb
/home: rest of the disk
```

Do you think the disk allocation is correct as I read that having a  /home is better to have for the backup purposes as it would otherwise mean that I would have to backup everything in "/usr". Then the backup includes the "/usr/{bin,sbin,local}" directories which roughly make up 80% of the FreeBSD base install. So by having a separate home, I can backup less.

Should the jail be setup in the /home?

Thank you very much for your help.


----------



## SirDice (Nov 14, 2011)

You can put a jail anywhere you want. I have mine all under /jails/.


----------



## gkontos (Nov 14, 2011)

You can set up your jails in any directory you like. The directory /usr/jails is just a common example.

You might want to have a look at ezjail witch provides a very nice framework and also supports jails in ZFS.
Speaking of ZFS, you might also want to have a look at and maybe utilize its amazing features. For example, assuming that your webserver jail resides in /usr/home/jails/web, you can very easily create a snapshot and send it to a backup device or a different server.

[CMD=""]# zfs snapshot /tank/jails/web@today[/CMD]
[CMD=""]# zfs send /tank/jails/web@today | zfs receive -F /backup/web[/CMD]

Of course this is only a simple example.

For a traditional UFS2 set up, I would recommend the following:
/     1GB
/tmp 1GB
swap 4GB
/var 20% (remaining)
/usr 80% (remaining)

Your /home partition will reside inside /usr. Don't forget that backups are always essential, no matter the raid level you are using.

Regards,
George


----------



## fred974 (Nov 14, 2011)

Wow,
Is ZFS the same principle as snapshot in vmware?
Have you got any good link about it?

If i use this, do still do a traditional disk layouit?


----------



## gkontos (Nov 14, 2011)

ZFS is an advanced file system created by Sun, now Oracle. ZFS was ported to FreeBSD in 7.0-RELEASE but it was considered stable only after 8.0-RELEASE.

For more information please read:

http://download.oracle.com/docs/cd/E19253-01/819-5461/index.html
http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide

If you have no prior experience with ZFS I strongly suggest that you stick to UFS2 for production. However, if you have a server sitting at home, like the one you mentioned before, then its a great opportunity to experiment.   


			
				fred974 said:
			
		

> Wow,
> Is ZFS the same principle as snapshot in vmware?
> If i use this, do still do a traditional disk layouit?



1) No, it is even better and faster !
2) Yes and No! To put it is a simple manner, you don't partition your disk with different filesystems and assign mount points. Instead you usually assign your full disk(s) to ZFS and create datasets inside. If you come from a Linux background think of it as a LVM.

Cheers,


----------



## fred974 (Nov 15, 2011)

Hi gkontos,

Thank you very much for the information.

I'll give that a good go as i'm got nothing to loose.

Fred


----------



## fbsd1 (Dec 7, 2011)

You should look at the QJAIL port, it's far better than ezjail.


----------



## fred974 (Dec 8, 2011)

Thank you fbsd1, i'll research it


----------



## olav (Dec 14, 2011)

QJail may be better, but I find documentation for it quite sparse.


----------



## fbsd1 (Dec 17, 2011)

Qjail jail documentation quite sparse! You must not know how to launch the man pages. If any thing the man page documentation spoon feeds the user with details.


----------

