FreeNas Follies


Made the mistake of editing my zfs pools from the command line on FreeNas 8.0.2.  Ended up discovering something.  FreeNas uses a database to keep track of things like volumes and the like.  Manually messing with things from the command line throws things out of whack to the point that you have to go in and manually repair them.  So the procedure goes like this.

ssh into freenas.  su to root.  
Then sqlite3 /data/freenas-v1.db

Then list the tables

sqlite> .tables
account_bsdgroupmembership
account_bsdgroups
account_bsdusers
auth_group
auth_group_permissions
auth_message
auth_permission
auth_user
auth_user_groups
auth_user_user_permissions
django_content_type
django_session
network_alias
network_globalconfiguration
network_interfaces
network_lagginterface
network_lagginterfacemembers
network_staticroute
network_vlan
services_activedirectory
services_afp
services_cifs
services_dynamicdns
services_ftp
services_iscsitarget
services_iscsitargetauthcredential
services_iscsitargetauthorizedinitiator
services_iscsitargetextent
services_iscsitargetglobalconfiguration
services_iscsitargetportal
services_iscsitargettoextent
services_ldap
services_nfs
services_rsyncd
services_rsyncmod
services_services
services_smart
services_snmp
services_ssh
services_tftp
services_ups
sharing_afp_share
sharing_cifs_share
sharing_nfs_share
south_migrationhistory
storage_disk
storage_diskgroup
storage_mountpoint
storage_replication
storage_replremote
storage_task
storage_volume
system_advanced
system_cronjob
system_email
system_rsync
system_settings
system_smarttest
system_ssl
Then sqlite> select id, disk_description from storage_disk

Output for me was

1|Member of tank raidz
2|Member of tank raidz
3|Member of tank raidz
4|Member of tank raidz
5|Member of BigWest stripe
6|Member of BigWest stripe1

Now, delete your mistakes.

sqlite> delete from storage_disk where id=5;
sqlite> delete from storage_disk where id=6;

Now do the same for storage_volume and storage_diskgroup

I’m sure there are other ways you can make FreeNas unhappy, so maybe this little hint will help with that too.

Hacking Freenas – zfs replication


If you are trying to replicate your zfs volume to a remote system that doesn’t have port 22 forwarded to it…you can hack Freenas to use a different port.

Cliff notes version for myself is as follows:
ssh into freenas…su to root
“mount -uw /”
“vi /usr/local/www/freenasUI/tools/autorepl.py”
search for sshcmd using “/sshcmd”
After sshcmd = ‘/usr/bin/ssh insert -p and the port needed. Use i to insert in vi. then type -p 2020 or some port that works for you. hit esc then “:wq” to save and quit.

OK…that’s more than the cliff notes for myself. If you have any questions…feel free to ask.    Any hack changes like this will get squashed next time you upgrade freenas.  That said, I’ve heard from a reliable source that this is an option that is headed for a future release.

Also discovered that when you are setting the remote zfs filesystem…that if the filesystem is an existing zfs filesystem, you only need to use the name of the filesystem and not the path.