|
| 1 | +Greyhole Installation Instructions |
| 2 | +================================== |
| 3 | + |
| 4 | +The following instructions are for Fedora 12. |
| 5 | +If you know what you're doing, you should have no problem installing on any other operating system that runs Samba (http://www.samba.org). |
| 6 | + |
| 7 | +Note: I tried using Ubuntu 9.10 first, but had bad experiences with the CIFS server & client there... so I switched to FC12. I still have the install notes I used for Ubuntu; feel free to use that if you want. |
| 8 | + |
| 9 | +1. Install Greyhole into /usr/local/greyhole/: |
| 10 | + (Or any other directory of your choice; just substitute your path for the rest of the installation instructions.) |
| 11 | + |
| 12 | + Get the latest version from http://code.google.com/p/greyhole/downloads/list |
| 13 | + tar zxf greyhole-*.tar.gz |
| 14 | + mv greyhole-* /usr/local/greyhole |
| 15 | + |
| 16 | +2. Install the required applications: PHP 5 (cli) with MySQL extension, MySQL server, Samba, GCC: |
| 17 | + |
| 18 | + Fedora: sudo yum install mysql-server php php-mysql samba samba-common patch gcc |
| 19 | + Ubuntu: sudo apt-get install mysql-server php5-cli php5-mysql samba samba-common samba-common-bin build-essential |
| 20 | + |
| 21 | +3. Samba, before 3.4.3, has a bug when trying to delete symbolic links (which Greyhole use extensively); we need Samba 3.4.3 or more. |
| 22 | + Plus, we need to compile our own VFS module. |
| 23 | + If you already run version 3.4.3 or higher, you'll just need to compile vfs_greyhole.c, and install it. |
| 24 | + |
| 25 | + Fedora: |
| 26 | + sudo yum install samba-common samba --enablerepo=updates-testing |
| 27 | + wget ftp://rpmfind.net/linux/fedora/updates/testing/12/SRPMS/samba-3.4.3-50.fc12.src.rpm |
| 28 | + rpm -ivh samba-3.4.3-50.fc12.src.rpm |
| 29 | + cd rpmbuild/SOURCES |
| 30 | + tar zxf samba-3.4.3.tar.gz |
| 31 | + cd samba-3.4.3/source3/modules |
| 32 | + cp /usr/local/greyhole/samba-module/vfs_greyhole.c . |
| 33 | + cd .. |
| 34 | + cp /usr/local/greyhole/samba-module/Makefile.patch . |
| 35 | + patch -p1 < Makefile.patch |
| 36 | + ./configure && make |
| 37 | + sudo cp bin/greyhole.so /usr/lib64/samba/vfs/greyhole.so |
| 38 | + sudo service smb restart |
| 39 | + |
| 40 | + Ubuntu: |
| 41 | + wget http://samba.org/samba/ftp/stable/samba-3.4.3.tar.gz |
| 42 | + tar zxf samba-3.4.3.tar.gz && rm samba-3.4.3.tar.gz |
| 43 | + cd samba-3.4.3/source3/modules |
| 44 | + wget http://www.pommepause.com/blog/wp-content/uploads/2009/12/vfs_greyhole.c |
| 45 | + cd .. |
| 46 | + wget http://www.pommepause.com/blog/wp-content/uploads/2009/12/Makefile.patch |
| 47 | + patch -p1 < Makefile.patch |
| 48 | + ./configure --cache-file=./config.cache --with-fhs --enable-shared --enable-static --disable-pie --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --with-privatedir=/etc/samba --with-piddir=/var/run/samba --localstatedir=/var --with-rootsbindir=/sbin --with-pammodulesdir=/lib/security --with-pam --with-syslog --with-utmp --with-readline --with-pam_smbpass --with-libsmbclient --with-winbind --with-shared-modules=idmap_rid,idmap_ad --with-automount --with-ldap --with-ads --with-dnsupdate --with-cifsmount --with-acl-support --with-quotas && make |
| 49 | + sudo make install |
| 50 | + sudo /etc/init.d/samba restart |
| 51 | + |
| 52 | +4. Setup Samba: |
| 53 | + |
| 54 | + Edit /etc/samba/smb.conf |
| 55 | + Change or add the following values in the [global] section: |
| 56 | + |
| 57 | + log file = /var/log/samba/samba.log |
| 58 | + max log size = 0 |
| 59 | + syslog = 0 |
| 60 | + follow symlinks = yes |
| 61 | + wide links = yes |
| 62 | + log level = 0 vfs:2 |
| 63 | + |
| 64 | + For each of your shares, add a 'dfree command' and 'vfs objects' lines, as seen below. |
| 65 | + |
| 66 | + Example share definition: |
| 67 | + [share_name] |
| 68 | + path = /path/to/share_name |
| 69 | + create mask = 0770 |
| 70 | + directory mask = 0770 |
| 71 | + read only = no |
| 72 | + available = yes |
| 73 | + browseable = yes |
| 74 | + writable = yes |
| 75 | + guest ok = no |
| 76 | + printable = no |
| 77 | + dfree command = /usr/local/greyhole/smb_dfree |
| 78 | + vfs objects = greyhole:share_name |
| 79 | + |
| 80 | + Notes: |
| 81 | + /path/to/ will be the value of your Landing Zone in Greyhole configuration file (later). |
| 82 | + All your shares needs to be subdirectories of that folder, and have no space in their names. |
| 83 | + Make sure the string after the colon on the 'vfs objects' line is the same as the share directory name under /path/to/. |
| 84 | + |
| 85 | + Fedora: sudo service smb restart |
| 86 | + Ubuntu: sudo /etc/init.d/samba restart |
| 87 | + |
| 88 | +5. Remove any old samba.log you might have; that will only contain invalid entries that Greyhole won't understand: |
| 89 | + |
| 90 | + sudo rm /var/log/samba/samba.log |
| 91 | + |
| 92 | +6. Setup the MySQL database: |
| 93 | + |
| 94 | + mysql -u root -p -e "create database greyhole; grant all on greyhole.* to greyhole_user@localhost identified by '89y63jdwe';" |
| 95 | + mysql -u greyhole_user -p89y63jdwe greyhole < /usr/local/greyhole/mysql.sql |
| 96 | + |
| 97 | +7. Cutomize the Greyhole configuration file: |
| 98 | + |
| 99 | + sudo cp /url/local/greyhole/greyhole.example.conf /etc/greyhole.conf |
| 100 | + |
| 101 | + Cutomize /etc/greyhole.conf as needed. |
| 102 | + |
| 103 | +8. Make sure Samba can use our custom dfree command: |
| 104 | + |
| 105 | + sudo chown root /usr/local/greyhole/smb_dfree |
| 106 | + sudo chmod 755 /usr/local/greyhole/smb_dfree |
| 107 | + |
| 108 | +9. For each directory you defined as 'storage_pool_directories', execute the following command, while the partition is mounted: |
| 109 | + |
| 110 | + touch <dir>/.greyhole_uses_this |
| 111 | + |
| 112 | + Example: touch /mnt/hdd0/gh/.greyhole_uses_this |
| 113 | + |
| 114 | + Those files will be used to differentiate an empty mount from a now-gone mount. |
| 115 | + i.e. Greyhole will output a warning if this file is not in the root directory where it is about to try to save a file, and it won't use that directory. This will prevent Greyhole from filling the / partition when a partition is unmounted! |
| 116 | + |
| 117 | +10. Schedule a daily fsck. Add this in the root crontab (or cron.d / cron.daily if you prefer): |
| 118 | + |
| 119 | + 0 0 * * * /usr/local/greyhole/greyhole-executer --fsck --email-report > /dev/null |
| 120 | + |
| 121 | + fsck should take about 10 minutes per 50,000 files (depends on how many storage pool directories you have). |
| 122 | + If you use the --email-report option, make sure your PHP can send emails. Gust configure sendmail or postfix to be able to send email from the command line and you should be fine. |
| 123 | + |
| 124 | +11. Add Greyhole to services that start on boot: |
| 125 | + |
| 126 | + sudo ln -s /usr/local/greyhole/initd_script.sh /etc/init.d/greyhole |
| 127 | + |
| 128 | + Fedora: sudo chkconfig --add greyhole; sudo chkconfig greyhole on |
| 129 | + Ubuntu: sudo update-rc.d greyhole defaults 98 20 |
| 130 | + |
| 131 | +12. Setup logrotate for /var/log/greyhole.log: |
| 132 | + |
| 133 | + sudo cp /usr/local/greyhole/logrotate.example /etc/logrotate.d/greyhole |
| 134 | + |
| 135 | + Customize /etc/logrotate.d/greyhole as needed. |
| 136 | + |
| 137 | +13. Setup logrotate for the Samba log; edit /etc/logrotate.d/samba: |
| 138 | + |
| 139 | + prerotate |
| 140 | + /usr/local/greyhole/greyhole-executer --prerotate |
| 141 | + endscript |
| 142 | + ... |
| 143 | + postrotate |
| 144 | + /usr/local/greyhole/greyhole-executer --postrotate > /dev/null || true |
| 145 | + endscript |
| 146 | + |
| 147 | +14. Work around problems with the CIFS client; edit /etc/rc.local: |
| 148 | + |
| 149 | + # cifs client workaround |
| 150 | + # Ref: http://blog.dhampir.no/content/cifs-vfs-no-response-for-cmd-n-mid |
| 151 | + modprobe cifs |
| 152 | + echo 0 > /proc/fs/cifs/OplockEnabled |
| 153 | + |
| 154 | +15. Start the Greyhole service: |
| 155 | + |
| 156 | + Fedora: sudo service greyhole start |
| 157 | + Ubuntu: sudo /etc/init.d/greyhole start |
| 158 | + |
| 159 | + |
| 160 | +Check for errors in the Greyhole log file: /var/log/greyhole.log |
| 161 | + |
| 162 | + |
| 163 | +If you use any application that needs to use files on your shares, you'll need to mount the shares locally, and point those applications to those mounts. |
| 164 | +You should not touch the files in your storage pool directories, or in your landing zone. |
0 commit comments