8.8 KiB
| utworzone | tag |
|---|---|
| 2022-05-17 | wikipage |
referencje:: Linux
https://wiki.archlinux.org/index.php/ZFS
Instalacja przygotowanie
sudo -i
apt install zfsutils-linux
apt install --yes debootstrap gdisk zfs-initramfs
systemctl stop zed
Partycje
Boot pool
zpool create \
-o cachefile=/etc/zfs/zpool.cache \
-o ashift=12 -o autotrim=on -d \
-o feature@async_destroy=enabled \
-o feature@bookmarks=enabled \
-o feature@embedded_data=enabled \
-o feature@empty_bpobj=enabled \
-o feature@enabled_txg=enabled \
-o feature@extensible_dataset=enabled \
-o feature@filesystem_limits=enabled \
-o feature@hole_birth=enabled \
-o feature@large_blocks=enabled \
-o feature@lz4_compress=enabled \
-o feature@spacemap_histogram=enabled \
-O acltype=posixacl -O canmount=off -O compression=lz4 \
-O devices=off -O normalization=formD -O relatime=on -O xattr=sa \
-O mountpoint=/boot -R /mnt \
bpool ${DISK}-partXX
Root
zpool create \
-o ashift=12 -o autotrim=on \
-O acltype=posixacl -O canmount=off -O compression=zstd \
-O dnodesize=auto -O normalization=formD -O relatime=on \
-O xattr=sa -O mountpoint=/ -R /mnt \
rpool ${DISK}-partXX
Zmienić compression = zstd
Instalacja
Create filesystem datasets to act as containers:
zfs create -o canmount=off -o mountpoint=none rpool/ROOT
zfs create -o canmount=off -o mountpoint=none bpool/BOOT
Create filesystem datasets for the root and boot filesystems:
UUID=$(dd if=/dev/urandom bs=1 count=100 2>/dev/null | tr -dc 'a-z0-9' | cut -c-6)
zfs create -o mountpoint=/ \
-o com.ubuntu.zsys:bootfs=yes \
-o com.ubuntu.zsys:last-used=$(date +%s) rpool/ROOT/ubuntu_$UUID
zfs create -o mountpoint=/boot bpool/BOOT/ubuntu_$UUID
Create datasets:
zfs create -o com.ubuntu.zsys:bootfs=no \
rpool/ROOT/ubuntu_$UUID/srv
zfs create -o com.ubuntu.zsys:bootfs=no -o canmount=off \
rpool/ROOT/ubuntu_$UUID/usr
zfs create rpool/ROOT/ubuntu_$UUID/usr/local
zfs create -o com.ubuntu.zsys:bootfs=no -o canmount=off \
rpool/ROOT/ubuntu_$UUID/var
zfs create rpool/ROOT/ubuntu_$UUID/var/games
zfs create rpool/ROOT/ubuntu_$UUID/var/lib
zfs create rpool/ROOT/ubuntu_$UUID/var/lib/AccountsService
zfs create rpool/ROOT/ubuntu_$UUID/var/lib/apt
zfs create rpool/ROOT/ubuntu_$UUID/var/lib/dpkg
zfs create rpool/ROOT/ubuntu_$UUID/var/lib/NetworkManager
zfs create rpool/ROOT/ubuntu_$UUID/var/log
zfs create rpool/ROOT/ubuntu_$UUID/var/mail
zfs create rpool/ROOT/ubuntu_$UUID/var/snap
zfs create rpool/ROOT/ubuntu_$UUID/var/spool
zfs create rpool/ROOT/ubuntu_$UUID/var/www
zfs create -o canmount=off -o mountpoint=/ \
rpool/USERDATA
zfs create -o com.ubuntu.zsys:bootfs-datasets=rpool/ROOT/ubuntu_$UUID \
-o canmount=on -o mountpoint=/root \
rpool/USERDATA/root_$UUID
chmod 700 /mnt/root
Mount a tmpfs at /run:
mkdir /mnt/run
mount -t tmpfs tmpfs /mnt/run
mkdir /mnt/run/lock
A tmpfs is recommended later, but if you want a separate dataset for /tmp:
zfs create -o com.ubuntu.zsys:bootfs=no \
rpool/ROOT/ubuntu_$UUID/tmp
chmod 1777 /mnt/tmp
Install the minimal system:
debootstrap hirsute /mnt
Copy in zpool.cache:
mkdir /mnt/etc/zfs
cp /etc/zfs/zpool.cache /mnt/etc/zfs/
Konfiguracja
HOSTNAME=***HOSTNAME***
Configure the hostname:
Replace HOSTNAME with the desired hostname:
echo $HOSTNAME > /mnt/etc/hostname
echo "127.0.1.1 $HOSTNAME" >> /mnt/etc/hosts
Find the interface name:
ip addr show
-
Adjust
NAMEbelow to match your interface name:vi /mnt/etc/netplan/01-netcfg.yamlnetwork: version: 2 ethernets: ***NAME***: mtu: 1280 dhcp4: true -
If you are installing a full GUI environment, you will likely want to manage your network with NetworkManager:
//rm /etc/netplan/01-netcfg.yaml vi /etc/netplan/01-network-manager-all.yamlnetwork: version: 2 renderer: NetworkManager
Configure the package sources:
vi /mnt/etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu hirsute main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu hirsute-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu hirsue-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu hirsute-security main restricted universe multiverse
Bind the virtual filesystems from the LiveCD environment to the new system and chroot into it:
mount --rbind /dev /mnt/dev
mount --rbind /proc /mnt/proc
mount --rbind /sys /mnt/sys
chroot /mnt /usr/bin/env DISK=$DISK UUID=$UUID bash --login
Configure a basic system environment:
apt update
Even if you prefer a non-English system language, always ensure that en_US.UTF-8 is available:
dpkg-reconfigure locales tzdata keyboard-configuration console-setup
-
Install GRUB/Linux/ZFS for legacy (BIOS) booting:
apt install --yes grub-pc linux-image-generic zfs-initramfs zsysSelect (using the space bar) all of the disks (not partitions) in your pool.
-
Install GRUB/Linux/ZFS for UEFI booting:
apt install --yes \ grub-efi-amd64 grub-efi-amd64-signed linux-image-generic \ shim-signed zfs-initramfs zsys
Setup system groups:
addgroup --system lpadmin
addgroup --system lxd
addgroup --system sambashare
Verify that the ZFS boot filesystem is recognized:
grub-probe /boot
Refresh the initrd files:
update-initramfs -c -k all
Grub
vi /etc/default/grub
# Add init_on_alloc=0 to: GRUB_CMDLINE_LINUX_DEFAULT
# Save and quit (or see the next step).
# Comment out: GRUB_TIMEOUT_STYLE=hidden
# Set: GRUB_TIMEOUT=5
# Below GRUB_TIMEOUT, add: GRUB_RECORDFAIL_TIMEOUT=5
# Remove quiet and splash from: GRUB_CMDLINE_LINUX_DEFAULT
# Uncomment: GRUB_TERMINAL=console
# Save and quit.
Update the boot configuration:
update-grub
-
For legacy (BIOS) booting, install GRUB to the MBR:
grub-install $DISKNote that you are installing GRUB to the whole disk, not a partition.
If you are creating a mirror or raidz topology, repeat the
grub-installcommand for each disk in the pool. -
For UEFI booting, install GRUB to the ESP:
grub-install --target=x86_64-efi --efi-directory=/boot/efi \ --bootloader-id=ubuntu --recheck --no-floppy
Fix filesystem mount ordering:
We need to activate zfs-mount-generator. This makes systemd aware of the separate mountpoints, which is important for things like /var/log and /var/tmp. In turn, rsyslog.service depends on var-log.mount by way of local-fs.target and services using the PrivateTmp feature of systemd automatically use After=var-tmp.mount.
mkdir /etc/zfs/zfs-list.cache
touch /etc/zfs/zfs-list.cache/bpool
touch /etc/zfs/zfs-list.cache/rpool
ln -s /usr/lib/zfs-linux/zed.d/history_event-zfs-list-cacher.sh /etc/zfs/zed.d
zed -F &
Verify that zed updated the cache by making sure these are not empty:
cat /etc/zfs/zfs-list.cache/bpool
cat /etc/zfs/zfs-list.cache/rpool
If either is empty, force a cache update and check again:
zfs set canmount=on bpool/BOOT/ubuntu_$UUID
zfs set canmount=on rpool/ROOT/ubuntu_$UUID
If they are still empty, stop zed (as below), start zed (as above) and try again.
Once the files have data, stop zed:
fg
Press Ctrl-C.
Fix the paths to eliminate /mnt:
sed -Ei "s|/mnt/?|/|" /etc/zfs/zfs-list.cache/*
Optional: Disable log compression:
As /var/log is already compressed by ZFS, logrotate’s compression is going to burn CPU and disk I/O for (in most cases) very little gain. Also, if you are making snapshots of /var/log, logrotate’s compression will actually waste space, as the uncompressed data will live on in the snapshot. You can edit the files in /etc/logrotate.d by hand to comment out compress, or use this loop (copy-and-paste highly recommended):
for file in /etc/logrotate.d/* ; do
if grep -Eq "(^|[^#y])compress" "$file" ; then
sed -i -r "s/(^|[^#y])(compress)/\1#\2/" "$file"
fi
done
Upgrade the minimal system:
apt dist-upgrade --yes
Install a regular set of software:
Choose one of the following options:
-
Install a command-line environment only:
apt install --yes ubuntu-standard -
Install a full GUI environment:
apt install --yes ubuntu-desktop -
Kubuntu
apt install --yes kubuntu-desktop