|
| 1 | +User friendly, zero to hero, build from source till working guide (Ubuntu based) |
| 2 | +============ |
| 3 | + |
| 4 | +GitHub Repositories |
| 5 | +~~~~~~~~~~~~~~~~~~~ |
| 6 | + |
| 7 | +The official source for OpenZFS is maintained at GitHub by the |
| 8 | +`openzfs <https://github.com/openzfs/>`__ organization. The primary |
| 9 | +git repository for the project is the `zfs |
| 10 | +<https://github.com/openzfs/zfs>`__ repository. |
| 11 | + |
| 12 | +Installing Dependencies |
| 13 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 14 | + |
| 15 | +The first thing you'll need to do is prepare your environment by |
| 16 | +installing a full development tool chain. In addition, development |
| 17 | +headers for both the kernel and the following packages must be |
| 18 | +available. It is important to note that if the development kernel |
| 19 | +headers for the currently running kernel aren't installed, the modules |
| 20 | +won't compile properly. |
| 21 | + |
| 22 | +The following dependencies should be installed to build the latest ZFS release. |
| 23 | + |
| 24 | +- **Debian, Ubuntu**: |
| 25 | + |
| 26 | +.. code:: sh |
| 27 | +
|
| 28 | + sudo apt install build-essential autoconf automake libtool gawk alien fakeroot dkms libblkid-dev uuid-dev libudev-dev libssl-dev zlib1g-dev libaio-dev libattr1-dev libelf-dev linux-headers-generic python3 python3-dev python3-setuptools python3-cffi libffi-dev python3-packaging git libcurl4-openssl-dev |
| 29 | +
|
| 30 | +- **Ansible**: |
| 31 | + |
| 32 | +.. code:: ansible |
| 33 | +
|
| 34 | + - ansible.builtin.package: |
| 35 | + name: |
| 36 | + - build-essential |
| 37 | + - autoconf |
| 38 | + - automake |
| 39 | + - libtool |
| 40 | + - gawk |
| 41 | + - alien |
| 42 | + - fakeroot |
| 43 | + - dkms |
| 44 | + - libblkid-dev |
| 45 | + - uuid-dev |
| 46 | + - libudev-dev |
| 47 | + - libssl-dev |
| 48 | + - zlib1g-dev |
| 49 | + - libaio-dev |
| 50 | + - libattr1-dev |
| 51 | + - libelf-dev |
| 52 | + - linux-headers-generic |
| 53 | + - python3 |
| 54 | + - python3-dev |
| 55 | + - python3-setuptools |
| 56 | + - python3-cffi |
| 57 | + - libffi-dev |
| 58 | + - python3-packaging |
| 59 | + - git |
| 60 | + - libcurl4-openssl-dev |
| 61 | + state: latest |
| 62 | + update_cache: true |
| 63 | + become: true |
| 64 | +
|
| 65 | +Getting the sources |
| 66 | +~~~~~~~~~~~~~~~~~~ |
| 67 | + |
| 68 | +Clone from GitHub |
| 69 | +^^^^^^^^^^^^^^^^^ |
| 70 | + |
| 71 | +Start by cloning the ZFS repository from GitHub. The repository has a |
| 72 | +**master** branch for development and a series of **\*-release** |
| 73 | +branches for tagged releases. After checking out the repository your |
| 74 | +clone will default to the master branch. Tagged releases may be built |
| 75 | +by checking out zfs-x.y.z tags with matching version numbers or |
| 76 | +matching release branches. |
| 77 | + |
| 78 | +- **Debian, Ubuntu**: |
| 79 | + |
| 80 | +.. code:: sh |
| 81 | +
|
| 82 | + git clone https://github.com/openzfs/zfs |
| 83 | +
|
| 84 | +- **Ansible**: |
| 85 | + |
| 86 | +.. code:: ansible |
| 87 | +
|
| 88 | + - ansible.builtin.file: |
| 89 | + path: /opt |
| 90 | + mode: '0777' |
| 91 | + become: true |
| 92 | +
|
| 93 | + - ansible.builtin.uri: |
| 94 | + url: https://github.com/api/repos/openzfs/zfs/releases/latest |
| 95 | + return_content: true |
| 96 | + register: json_reponse |
| 97 | +
|
| 98 | + - ansible.builtin.git: |
| 99 | + repo: https://github.com/openzfs/zfs.git |
| 100 | + dest: /opt/zfs |
| 101 | + version: "{{ json_reponse.json.tag_name | default('master') }}" |
| 102 | +
|
| 103 | +Preparing the rest of the system |
| 104 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 105 | + |
| 106 | +Now pay attention to how your distribution handles kernel modules. On Ubuntu, |
| 107 | +for example, the modules from this repository install in the ``extra`` kernel |
| 108 | +module path, which is not in the standard ``depmod`` search path. Therefore, |
| 109 | +for the duration of your testing, edit ``/etc/depmod.d/ubuntu.conf`` and add |
| 110 | +``extra`` to the beginning of the search path. |
| 111 | + |
| 112 | +- **Debian, Ubuntu**: |
| 113 | + |
| 114 | +.. code:: sh |
| 115 | +
|
| 116 | + sudo vim /etc/depmod.d/ubuntu.conf |
| 117 | +
|
| 118 | +- **Ansible**: |
| 119 | + |
| 120 | +.. code:: ansible |
| 121 | +
|
| 122 | + - ansible.builtin.lineinfile: |
| 123 | + dest: /etc/depmod.d/ubuntu.conf |
| 124 | + regexp: '^(search updates ubuntu built-in)$' |
| 125 | + line: '\1 extra' |
| 126 | + backrefs: yes |
| 127 | + become: true |
| 128 | +
|
| 129 | +Building |
| 130 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 131 | + |
| 132 | +The ZFS build system is based on GNU Autoconf and GNU Automake. So the |
| 133 | +first step is to run the ``autogen.sh`` script to generate the |
| 134 | +``configure`` script. This script is used to configure the build |
| 135 | +environment and generate the ``Makefile`` used to build the ZFS |
| 136 | +modules. |
| 137 | + |
| 138 | +- **Debian, Ubuntu**: |
| 139 | + |
| 140 | +.. code:: sh |
| 141 | +
|
| 142 | + git clean -fx |
| 143 | + ./autogen.sh |
| 144 | + ./configure --enable-systemd |
| 145 | + make -s -j$(nproc) deb-utils deb-dkms |
| 146 | +
|
| 147 | +- **Ansible**: |
| 148 | + |
| 149 | +.. code:: ansible |
| 150 | +
|
| 151 | + - ansible.builtin.shell: | |
| 152 | + git clean -fx |
| 153 | + args: |
| 154 | + executable: /bin/bash |
| 155 | + chdir: /opt/zfs |
| 156 | +
|
| 157 | + - ansible.builtin.shell: | |
| 158 | + ./autogen.sh |
| 159 | + args: |
| 160 | + executable: /bin/bash |
| 161 | + chdir: /opt/zfs |
| 162 | +
|
| 163 | + - ansible.builtin.shell: | |
| 164 | + ./configure --enable-systemd |
| 165 | + args: |
| 166 | + executable: /bin/bash |
| 167 | + chdir: /opt/zfs |
| 168 | +
|
| 169 | + - ansible.builtin.shell: | |
| 170 | + make -j$(nproc) deb-utils deb-dkms |
| 171 | + args: |
| 172 | + executable: /bin/bash |
| 173 | + chdir: /opt/zfs |
| 174 | +
|
| 175 | +Installing |
| 176 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 177 | + |
| 178 | +The ZFS packages are built using the `Debian Package`_ format. The |
| 179 | +packages are built using the ``make deb-utils deb-dkms`` command. The |
| 180 | +``deb-utils`` package contains the ``zfs`` and ``zpool`` user space |
| 181 | +utilities. The ``deb-dkms`` package contains the ZFS kernel modules |
| 182 | +and a DKMS configuration file. DKMS is used to automatically rebuild |
| 183 | +and install the kernel modules when a new kernel is installed. |
| 184 | + |
| 185 | +- **Debian, Ubuntu**: |
| 186 | + |
| 187 | +.. code:: sh |
| 188 | +
|
| 189 | + sudo apt install ./*.deb |
| 190 | +
|
| 191 | +- **Ansible**: |
| 192 | + |
| 193 | + - ansible.builtin.shell: | |
| 194 | + shopt -s extglob |
| 195 | + apt install ./*.deb |
| 196 | + args: |
| 197 | + executable: /bin/bash |
| 198 | + chdir: /opt/zfs |
| 199 | + become: true |
| 200 | +
|
| 201 | +Post Install |
| 202 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 203 | + |
| 204 | +After installing the ZFS packages, the ZFS services must be enabled |
| 205 | +and started. The ``zfs-import-cache`` service is responsible for |
| 206 | +importing the ZFS pools during system boot. The ``zfs-mount`` |
| 207 | +service is responsible for mounting all filesystems in the system's |
| 208 | +root pool. The ``zfs-zed`` service is responsible for monitoring the |
| 209 | +system for events and taking appropriate actions. The ``zfs-share`` |
| 210 | +service is responsible for automatically sharing any ZFS filesystems |
| 211 | +marked as shareable. The ``zfs.target`` is a convenience target that |
| 212 | +will start all of the ZFS services. The ``zfs-import.target`` is a |
| 213 | +convenience target that will start the ``zfs-import-cache`` and |
| 214 | +``zfs-import-scan`` services. |
| 215 | + |
| 216 | +- **Debian, Ubuntu**: |
| 217 | + |
| 218 | +.. code:: sh |
| 219 | +
|
| 220 | + sudo service enable zfs-import-cache zfs-import.target zfs-mount zfs-zed zfs-share zfs-volume-wait zfs.target |
| 221 | + sudo service start zfs-import-cache zfs-import.target zfs-mount zfs-zed zfs-share zfs-volume-wait zfs.target |
| 222 | +
|
| 223 | +- **Ansible**: |
| 224 | + |
| 225 | +.. code:: ansible |
| 226 | +
|
| 227 | + - ansible.builtin.service: |
| 228 | + name: |
| 229 | + - zfs-import-cache |
| 230 | + - zfs-import.target |
| 231 | + - zfs-mount |
| 232 | + - zfs-share |
| 233 | + - zfs-zed |
| 234 | + - zfs-volume-wait |
| 235 | + - zfs.target |
| 236 | + state: started |
| 237 | + enabled: yes |
| 238 | + become: true |
| 239 | +
|
| 240 | +Final step |
| 241 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 242 | + |
| 243 | +Now reboot, and you should be able to use ZFS. |
0 commit comments