Merge pull request #189 from saveriomiroddi/remove_trimming_service

Remove trimming service (autotrim is now enabled)
This commit is contained in:
Saverio Miroddi 2021-04-27 19:58:29 +02:00 committed by GitHub
commit 30bc95f109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 41 deletions

View File

@ -24,7 +24,7 @@ The program currently supports:
- Linux Mint 19.x, 20 - Linux Mint 19.x, 20
- ElementaryOS 5.1 - ElementaryOS 5.1
The ZFS version installed is 0.8, which supports native encryption and trimming (among the other improvements over 0.7). The required repositories are automatically added to the destination system. The ZFS version installed is 0.8 (optionally, 2.x), which supports native encryption and trimming (among the other improvements over 0.7). The required repositories are automatically added to the destination system.
EFI boot is required (any modern (2011+) system will do); legacy boot is currently not supported. EFI boot is required (any modern (2011+) system will do); legacy boot is currently not supported.
@ -41,11 +41,10 @@ The advantages of this project over the Ubuntu installer are:
1. it supports pools configuration; 1. it supports pools configuration;
1. it allows specifying the RAID type; 1. it allows specifying the RAID type;
1. it allows customization of the disk partitions; 1. it allows customization of the disk partitions;
1. it supports additional features (e.g. encryption); 1. it supports additional features (e.g. encryption and trimming);
1. it supports new OpenZFS versions, via PPA `jonathonf/zfs`. 1. it supports new OpenZFS versions, via PPA `jonathonf/zfs`.
1. it supports many more operating systems; 1. it supports many more operating systems;
1. it supports unattended installations, via custom scripts; 1. it supports unattended installations, via custom scripts;
1. it installs a convenient trimming job for ZFS pools;
1. it's easy to extend. 1. it's easy to extend.
The disadvantages are: The disadvantages are:

View File

@ -167,6 +167,7 @@ function invoke {
# #
function hot_swap_script { function hot_swap_script {
if [[ -f $c_hotswap_file ]]; then if [[ -f $c_hotswap_file ]]; then
# shellcheck disable=1090 # can't follow; the file might not exist anyway.
source "$c_hotswap_file" source "$c_hotswap_file"
fi fi
} }
@ -1339,43 +1340,6 @@ function fix_filesystem_mount_ordering {
chroot_execute "sed -Ei 's|$c_zfs_mount_dir/?|/|' /etc/zfs/zfs-list.cache/*" chroot_execute "sed -Ei 's|$c_zfs_mount_dir/?|/|' /etc/zfs/zfs-list.cache/*"
} }
# We don't care about synchronizing with the `fstrim` service for two reasons:
#
# - we assume that there are no other (significantly) large filesystems;
# - trimming is fast (takes minutes on a 1 TB disk).
#
# The code is a straight copy of the `fstrim` service.
#
function configure_pools_trimming {
chroot_execute "cat > /lib/systemd/system/zfs-trim.service << UNIT
[Unit]
Description=Discard unused ZFS blocks
ConditionVirtualization=!container
[Service]
Type=oneshot
ExecStart=/sbin/zpool trim $c_bpool_name
ExecStart=/sbin/zpool trim $v_rpool_name
UNIT"
chroot_execute " cat > /lib/systemd/system/zfs-trim.timer << TIMER
[Unit]
Description=Discard unused ZFS blocks once a week
ConditionVirtualization=!container
[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true
[Install]
WantedBy=timers.target
TIMER"
chroot_execute "systemctl daemon-reload"
chroot_execute "systemctl enable zfs-trim.timer"
}
function configure_remaining_settings { function configure_remaining_settings {
[[ $v_swap_size -gt 0 ]] && chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab" || true [[ $v_swap_size -gt 0 ]] && chroot_execute "echo /dev/zvol/$v_rpool_name/swap none swap discard 0 0 >> /etc/fstab" || true
chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume" chroot_execute "echo RESUME=none > /etc/initramfs-tools/conf.d/resume"
@ -1480,7 +1444,6 @@ invoke "configure_and_update_grub"
invoke "sync_efi_partitions" invoke "sync_efi_partitions"
invoke "update_initramfs" invoke "update_initramfs"
invoke "fix_filesystem_mount_ordering" invoke "fix_filesystem_mount_ordering"
invoke "configure_pools_trimming"
invoke "configure_remaining_settings" invoke "configure_remaining_settings"
invoke "prepare_for_system_exit" invoke "prepare_for_system_exit"