0 Голосов

Исходный код вики How to install ZFS in Debian 12 “Bookworm”

Редактировал(а) Сергей Коршунов 2024/01/07 19:34

Скрыть последних авторов
Сергей Коршунов 1.1 1 == How to install ZFS in Debian Linux 12 “Bookworm” ==
2
3 The procedure is as follows:
4
5 1. Open your terminal application.
6 1. For remote server login using the ssh command:
7
8 * ssh user@debian-12-server
9 * Add or enable contrib repo to /etc/apt/sources.list using sed command:
10 * sed -r -i'.BAK' 's/^deb(.*)$/deb\1 contrib/g' /etc/apt/sources.list
11 Here is how it looks when ##contrib## is appended to each line:(((
12
13 {{{deb http://deb.debian.org/debian bookworm main non-free non-free-firmware contrib
14 deb http://deb.debian.org/debian bookworm-updates main non-free non-free-firmware contrib
15 deb http://deb.debian.org/debian-security/ bookworm-security main non-free non-free-firmware contrib
16 }}}
17 )))
18 * Update apt repo database, type:
19 * apt update
20 * Install zfs package on a Debian Linux 12:
21 * apt install linux-headers-amd64 zfsutils-linux zfs-dkms zfs-zed
22 Are you using a cloud server with cloud Linux kernel? Try:
23 *
24 * apt install linux-headers-cloud-amd64 zfsutils-linux zfs-dkms zfs-zed
25 * \\
26 * Test it by running ##zfs version## command:
27 * (((
28 modprobe zfs #<~-~-load the module1. (((
29 zfs version
30 Outputs:(((
31
32 {{{zfs-2.1.11-1
33 zfs-kmod-2.1.11-1}}}
34 )))
35
36 (((
37 == Help! ZFS is eating all my RAM in a Debian machine ==
38
39 No, ZFS is not eating all RAM. But, ensure that your system meets the requirements for running ZFS, such as having enough RAM and storage capacity. Additionally, it’s always a good idea to back up your important data before changing your file system. There are ways to tame ZFS ram usage so that all applications can run smoothly. Please see the following pages:
40
41 * [[How to set up ZFS ARC size on Ubuntu/Debian Linux>>url:https://www.cyberciti.biz/faq/how-to-set-up-zfs-arc-size-on-ubuntu-debian-linux/]] ([[FreeBSD specific info is here.>>url:https://www.cyberciti.biz/faq/freebsd-set-up-zfs-arc-size-freebsd-unix/]])
42 * [[How to check ZFS File system storage pool on Linux/Unix>>url:https://www.cyberciti.biz/faq/how-to-check-zfs-file-system-storage-pool-on-linux-unix/]]
43
44 == Turning a simple disk ##/dev/xvdf## into ZFS ==
45
46 **WARNING!** Please be cautious when using the following commands, as they will delete all data stored on the disk drive. It is crucial to ensure the device name is correct before executing these commands. The nixCraft or author cannot be held responsible for any data loss. It is highly recommended to maintain verified backups at all times.
47
48 Say you have a cloud-based block storage disk named /dev/xvdf. Here is how to create ZFS disks under Linux:
49
50
51 * Remove all data from the /dev/xvdf (replace the ##/dev/xvdf## with correct device name):
52 )))
53 )))
54 )))
55 * sudo sgdisk ~-~-zap-all /dev/xvdf
56 * Next, you must create a Solaris ZFS partition. For example:
57 * sudo sgdisk ~-~-new=1:0:0 ~-~-typecode=1:BF00 /dev/xvdf
58 * Create a new ZFS pool for Linux:
59 * sudo zpool create -f -d -m none -o ashift=12 -O atime=off -o feature@lz4_compress=enabled backup /dev/xvdf1
60 The above command creates a new ZFS pool named ##backup## using the following ##zpool create## command switches:(((
61
62 * ##**-f**## : Forces the creation of the pool
63 * ##**-d**## : Disables automatic device discovery.
64 * ##**-m none**## : Does not use a mirror to protect the pool because I’ve a single disk here.
65 * ##**-o ashift=12**## : Sets the alignment shift to 12, which improves performance for large files.
66 * ##**-O atime=off**## : Disables access time tracking, which improves performance.
67 * ##**-o feature@lz4_compress=enabled**## : Enables LZ4 compression for the pool to save disk space.
68 * ##**/dev/xvdf1**## : The block storage device to use for the pool.
69 )))
70 * Create a new dataset:
71 * sudo zfs create backup/rsnapshot
72 sudo zfs set compression=lz4 backup/rsnapshot
73 sudo zfs set atime=off backup/rsnapshot
74 * \\
75 * sudo zfs set mountpoint=/backup backup
76 * You can now use the /backup/rsnapshot/ to store files and verify using the mount command or [[df command>>url:https://www.cyberciti.biz/faq/df-command-examples-in-linux-unix/]]/du command. Use the following command to get space info about zfs storage pool:
77
78 * sudo zpool list
79 Outputs:(((
80
81 {{{NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
82 backup 127G 15.4G 112G - - - 12% 1.00x ONLINE -}}}
83 )))
84
85 == Summing up ==
86
87 That is all. Now ZFS is installed on your Debian Linux 12 “Bookworm” system. You can now use zfs and zpool commands to create new pools and do ZFS maintenance. For more info, see the following manual pages using the [[man command>>url:https://bash.cyberciti.biz/guide/Man_command]] or [[help command>>url:https://bash.cyberciti.biz/guide/Help_command]]:
88
89 man zpool
90 man zfs
91 man apt
92 man apt-get
93 man sources.list