Great thanks for explanation!
Something like that I wanted that was to start, just for learn.
Will soon try to pass that way.
Hi,
I found this thread because I was trying to create a zil on my SSD I used for the FreeNAS disk and was finding harder than I should. I'm from a Linux background so the differences in FreeBSD where confusing. I found a few threads saying that 4 slices was the max; but this thread gave me a few clues (thanks jgreco!) about how to get around this problem.
This thread hasn't been updated for almost a year so I decided to post how I achieved both swap and zil on my 64GB SSD (which FreeNAS was only taking ~3GB). I've included an explanation rather than just a crib as if your going to be changing your NAS system you'll probably need to know whats going on as I suspect, as jgreco has mentioned, upgrades will probably be interesting and you'll need to know what you've done to fix your system after upgrade. If anyone sees any mistakes or any pending doom I may run into due to these changes... please let me know
The FreeNAS system I'm using is as follows:
- HP Proliant N45L Microserver
- AMD Turion(tm) II Neo duel core processor
- 4GB of memory (wish I'd had upgraded to 8GB)
- 4x 2TB Seagate Barracuda 7200rpm as Zpool
- 1x 64GB Sandisk SSD
- FreeNAS-8.3.1-RELEASE-p2-x64
1) Make sure you backup you config, this is done on the web interface and is well worth it as I had to reinstall once due to not being able to recreate partitions on the 2nd slice after deleting (if anyone knows why please let me know... There error I got was ada4s2 file exists!)
2) Now you have your backup open a shell on the system (not remote) and go into runlevel 1. This will allow you to umount the /cfg and /data partitions.
3) The root (/) filesystem is mounted read only. Remount it rw so you can create a backup directory for /cfg and /data
4) Mount both /cfg and /data for backup. They may already be mounted so if you get an busy device error it's probably already mounted
5) Make a backupdir in / and copy the /cfg and /data mount point data
mkdir /backupparts
cp -rp /data /backupparts/
cp -rp /cfg /backupparts/
6) Unmount /cfg and /data
7) Now for some math. You'll probably want different partition sizes than me (as you may have different memory size). You'll need these as you need to know how far to create your 3rd and 4th slice to allow your 2nd slice to grow to the required size. Have a look at you disk geom and work out from the partitions you have how big a single block is. Then work out what block offset you need for your partitions. Remember to include the ~1GB that is used for the 2nd slice as it is. Sum all these together and add to the offset given by "gpart list ada4". If you want just a zil you'll need 2 partitions in the 2nd slice.. if like me you want to create zil and swap then 3 partitions.
8) Now we start the destructive stuff, so if you have your FreeNAS system in use, make sure you REALLY want to do this. Now delete both the 3rd and 4th slice which are /cfg and /data. This _may_ change on future releases so is best to check by looking in fstab. My disk is ada4 so will be using this in my examples, your's will most likely be different so you need to find out which disk has the 4 FreeNAS slices on. If you can't find this then you probably don't want to continue with this howto. Please also read the gpart and newfs man pages.
gpart delete -i3 ada4
gpart delete -i4 ada4
9) Recreate your 3rd and 4th slice using the offset calculated from point 7 and the same original size. I'm going to use placeholders for these values. Then format the partitions giving them the same name as before so that the mount points in fstab still work.
gpart add -tfreebsd -b <offset> -s <size> -i3 ada4
gpart add -tfreebsd -b <offset> -s <size> -i ada4
newfs -L FreeNASs3 -U ada4s3
newfs -L FreeNASs4 -U ada4s4
10) IF the last step was correct you should now be able to mount the new slices as per usual. Do this then copy in the backup data. If you can't mount as per usual you'll need to find the label for data and cfg mount points in fstab and redo the steps above .
mount /cfg
mount /data
cp -rp /backuppart/data/* /data
cp -rp /backuppart/cfg/* /cfg
11) Now to resize your 2nd slice so you can partition as required. I don't know what the 2nd slice is for BUT it didn't seem to have any data in… in fact it looked like it wasn't even formatted. I tried to run FreeNAS without it and it runs fine. However, I would leave the same amount of space at the beginning of your second slice just in case. It's the same size as the main 1st slice so I think it's some sort of upgrade partition. You don't need to specify a size as gpart will do this for you and fill unto slice 3.
12) Now you need to create a partition schema andcreate the partitions with the offsets you calculated in step 7. Remember to use the correct types to the partition your adding. I forgot to change one to swap and could not undo. I had to delete the 2nd slice and couldn't create partitions in it once recreated. This is why I had a 2nd go at it and used my very helpful backup. If anyone knows why I couldn't create partitions in a newly created 2nd slice please let me know.
gpart create -sbsd ada4s2
gpart add -t freebsd-swap -b <offset> -s <size> ada4s2
gpart add -t freebsd-ufs -b <offset> -s <size> ada4s2
13) Now to add one of the partitions as a zil to the zpool. I used the first partition I created in the 2nd slice so the geom number I used is ada4s2a. Check with all is ok with "zpool status <zpool name>"
zpool add <zpool name> log /dev/ada4s2a
14) Now to add the swap. jgreco was right in that they write the fstab out via a script in /etc/rc.d/ix-fstab on boot. If you change this script it's cobblered on boot; this means the script has to be copied over from some where and it's that copy that requires modification. The script is in /conf/base/etc/rc.d/ix-fstab. A word of warning here and this is probably where my hack goes bad. I changed the script just to output a mount point for swap to my new swap partition created on slice 2. This however is _NOT_ encrypted. The swap partitions in the zpool are and I'm not sure if I'm going to come unstuck due to this difference. I think because the zpool is public, it is encrypted for security. The FreeNAS drive is not public so I think it's ok … ? If anyone has any info on this please let me know
Once you have changed your script then reboot and check where you swap is mounted.
Thats it.. Thanks for listening
Eroteme