Browse Source

Add notes on zfs and moving /var/log for advanced and storage focused users

pull/130/head
KemoNine 3 months ago
parent
commit
4bb18645e5
Signed by: KemoNine <kemonine@lollipopcloud.solutions> GPG Key ID: 3BC2928798AE11AB
2 changed files with 133 additions and 0 deletions
  1. 26
    0
      advanced/var_log_move.md
  2. 107
    0
      advanced/zfs.md

+ 26
- 0
advanced/var_log_move.md View File

@@ -0,0 +1,26 @@
1
+# Move ```/var/log```
2
+
3
+ You can disable logging to ram by setting `ENABLED=false´ in  `/etc/default/armbian-ramlog´. 
4
+
5
+``` bash
6
+
7
+systemctl stop rsyslog.service
8
+systemctl stop syslog.socket
9
+lsof /var/log # (make sure it's empty)
10
+systemctl stop log2ram
11
+systemctl disable log2ram
12
+systemctl stop armbian-ramlog.service
13
+systemctl disable armbian-ramlog.service
14
+systemctl stop armbian-zram-config.service
15
+systemctl disable armbian-zram-config.service
16
+nano -w /etc/default/armbian-ramlog
17
+    # Disable
18
+nano -w /etc/default/armbian-zram-config
19
+    # Disable if *not* using swap in ram
20
+
21
+mv /var/log /var/oldlog
22
+mkdir /var/log
23
+rsync -aPr /var/oldlog/ /var/log/
24
+systemctl reboot
25
+
26
+```

+ 107
- 0
advanced/zfs.md View File

@@ -0,0 +1,107 @@
1
+# ZFS
2
+
3
+How to setup zfs on 64 bit arm boards.
4
+
5
+*Note: this is wholly untested and likely to be broken on 32 bit arm boards*
6
+
7
+## Initial Install / Setup
8
+
9
+``` bash 
10
+
11
+apt-add-repository universe
12
+apt install zfs-dkms spl-dkms zfsutils-linux
13
+cat > /etc/modprobe.d/zfs.conf <<EOF
14
+# Minimize RAM pain
15
+#options zfs zfs_arc_max=268435456 zfs_arc_meta_limit=201326592
16
+options zfs zfs_arc_max=134217728 zfs_arc_meta_limit=67108864
17
+#options zfs zfs_arc_max=100663296 zfs_arc_meta_limit=50331648
18
+EOF
19
+
20
+```
21
+
22
+## Disk Setup and Pool Creation
23
+
24
+Partition the disk and setup the zfs pool with basic settings
25
+
26
+``` bash
27
+
28
+parted /dev/disk/by-id/ata-Samsung_Portable_SSD_T5_S3UKNP0K601164R
29
+  mklabel gpt
30
+  mkpart
31
+zpool create -o ashift=12 \
32
+     -O copies=2 \
33
+     -O atime=off -O compression=lz4 \
34
+     -O normalization=formD \
35
+     tank \
36
+       /dev/disk/by-id/usb-JMicron_Tech_0000000055A1-0\:0-part1
37
+
38
+zpool status
39
+
40
+cat /sys/module/zfs/parameters/zfs_arc_max
41
+cat /sys/module/zfs/parameters/zfs_arc_meta_limit
42
+
43
+```
44
+
45
+## zfs Backed Swap
46
+
47
+Move swap from zram to zfs volumes on disk
48
+
49
+``` bash
50
+
51
+zfs create tank/swap
52
+zfs create -V 1G -b $(getconf PAGESIZE) -o compression=zle \
53
+      -o logbias=throughput -o sync=always \
54
+      -o primarycache=metadata -o secondarycache=none \
55
+      -o com.sun:auto-snapshot=false tank/swap/swap.1
56
+zfs create -V 1G -b $(getconf PAGESIZE) -o compression=zle \
57
+      -o logbias=throughput -o sync=always \
58
+      -o primarycache=metadata -o secondarycache=none \
59
+      -o com.sun:auto-snapshot=false tank/swap/swap.2
60
+
61
+mkswap -f /dev/zvol/tank/swap/swap.1
62
+mkswap -f /dev/zvol/tank/swap/swap.2
63
+echo /dev/zvol/tank/swap/swap.1 none swap defaults 0 0 >> /etc/fstab
64
+echo /dev/zvol/tank/swap/swap.2 none swap defaults 0 0 >> /etc/fstab
65
+swapon -af
66
+
67
+nano -w /etc/fstab # Add above swap and remove exiting ones
68
+
69
+nano -w /etc/default/armbian-zram-config
70
+    # Disabe if NOT using /var/log in RAM
71
+
72
+```
73
+
74
+## Regular scrubs and integrity checks
75
+
76
+``` bash
77
+
78
+crontab -e
79
+22 0 14 * * /sbin/zpool scrub tank
80
+
81
+```
82
+
83
+## Bulk storage and Samba filesystem shares
84
+
85
+``` bash
86
+
87
+# Samba toolchain
88
+apt install samba tdb-tools
89
+
90
+# Samba user setup
91
+useradd -g users -s /usr/sbin/nologin [username]
92
+passwd [username]
93
+smbpasswd -a [username]
94
+
95
+nano -w /etc/samba/smb.conf
96
+workgroup = non-default
97
+comment out all share definitions
98
+
99
+systemctl restart smbd
100
+
101
+# Bulk storage for all the things
102
+zfs create -o sharesmb=on tank/downloads
103
+zfs create -o sharesmb=on tank/scratch
104
+
105
+cat /var/lib/samba/usershares/*
106
+
107
+```

Loading…
Cancel
Save