FreeBSD/install_zfs_gpt.md

Thu, 07 Sep 2017 10:36:42 +0200

author
Stéphane P.
date
Thu, 07 Sep 2017 10:36:42 +0200
changeset 9
e542763af261
parent 6
0c4833b61520
permissions
-rw-r--r--

FreeBSD: change place of the warning in poudriere.md

6
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 FreeBSD ZFS on root with GPT
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 ============================
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
3
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 This small guide will show you how to install FreeBSD on root using ZFS from a
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 FreeBSD shell.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
6
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 You need to boot a FreeBSD shell userland, official FreeBSD ISOs have a shell
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 option when booting them.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
9
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 Partitioning
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 ------------
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
12
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 In this example, we will use one disk `/dev/ada0` and one swap partition of 4GB
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 size, adjust to your needs.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
15
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 ### Destroy and create GPT scheme
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
17
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
18 gpart destroy -F ada0
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
19 gpart create -s gpt ada0
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
20
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
21 ### Add partitions
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
22
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
23 gpart add -t freebsd-boot -s 128k -l boot0 ada0
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
24 gpart add -t freebsd-swap -s 4g -l swap0 ada0
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
25 gpart add -t freebsd-zfs -l disk0 ada0
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
26 gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
27
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
28 ### Create zpool
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
29
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
30 kldload zfs
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
31 zpool create -f -o altroot=/mnt -O canmount=off -m none zroot /dev/gpt/disk0
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
32
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
33 ### Create ZFS datasets
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
34
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 The following datasets are mandatory.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
36
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 zfs set checksum=fletcher4 zroot
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
38 zfs set atime=off zroot
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 zfs create -o mountpoint=none zroot/ROOT
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 zfs create -o mountpoint=/ zroot/ROOT/default
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 zpool set bootfs=zroot/ROOT/default zroot
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
42
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 The following datasets are optional.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
44
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
45 zfs create -o mountpoint=/tmp -o compression=lz4 -o setuid=off zroot/tmp
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
46 zfs create -o mountpoint=/usr zroot/usr
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
47 zfs create zroot/usr/local
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 zfs create -o mountpoint=/home -o setuid=off zroot/home
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 zfs create -o compression=lz4 -o setuid=off zroot/usr/ports
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
50 zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/distfiles
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/packages
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 zfs create -o compression=lz4 -o exec=off -o setuid=off zroot/usr/src
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 zfs create zroot/usr/obj
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
54 zfs create -o mountpoint=/var zroot/var
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
55 zfs create -o compression=lz4 -o exec=off -o setuid=off zroot/var/crash
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
56 zfs create -o exec=off -o setuid=off zroot/var/db
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
57 zfs create -o compression=lz4 -o exec=on -o setuid=off zroot/var/db/pkg
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
58 zfs create -o exec=off -o setuid=off zroot/var/empty
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 zfs create -o compression=lz4 -o exec=off -o setuid=off zroot/var/log
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
60 zfs create -o compression=gzip -o exec=off -o setuid=off zroot/var/mail
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
61 zfs create -o exec=off -o setuid=off zroot/var/run
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
62 zfs create -o compression=lz4 -o exec=on -o setuid=off zroot/var/tmp
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
63
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
64 Required if you have created the following datasets.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
65
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
66 chmod 1777 /mnt/tmp
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 chmod 1777 /mnt/var/tmp
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
68
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 Installation
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
70 ------------
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
71
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
72 Now we will fetch our sets for FreeBSD, adjust the version, in this guide we
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 will use 11.1-RELEASE.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
74
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
75 cd /mnt
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 fetch http://ftp.fr.freebsd.org/pub/FreeBSD/releases/amd64/11.1-RELEASE/base.txz
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 fetch http://ftp.fr.freebsd.org/pub/FreeBSD/releases/amd64/11.1-RELEASE/kernel.txz
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
78 tar xJpf base.txz
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
79 tar xJpf kernel.txz
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
80
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
81 Configuration
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
82 -------------
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
83
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
84 Enter the chroot to do minimal mandatory steps.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
85
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
86 ### Setup root password
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
87
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
88 chroot /mnt
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
89 passwd
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
90
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
91 ### Enable ZFS
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
92
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
93 echo "/dev/gpt/swap0 none swap sw 0 0" >> /etc/fstab
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
94 echo "zfs_load=YES" >> /boot/loader.conf
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
95 echo "zfs_enable=YES" >> /etc/rc.conf
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
96
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
97 ### Add an user (optional)
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
98
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
99 pw useradd your_user -c "Real Name" -G wheel,operator -m
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
100 passwd your_user
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
101
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
102 Terminate
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
103 ---------
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
104
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
105 Exit the chroot and reboot.
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
106
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
107 exit
0c4833b61520 FreeBSD: add install_zfs_gpt.md
David Demelier <markand@malikania.fr>
parents:
diff changeset
108 shutdown -r now

mercurial