Hello,
Following the recommendation of moving swapping and logging off the SD card, I have created a swap partition and mounted /var/log in an external HDD connected to the Pi via USB.
While the system is up and running, I assume I did something wrong as I don’t see any logs being updated on /var/log/openhab2/ since the changes were made. However, if I go to openhab-cli console and do log:tail, then I see recent logs there.
In a nutshell, this is what I did:
-
Shrank the existing NTFS partition on the HDD to make room for a new ext4 and a Linux swap (1 GB) partition.
-
Edited fstab to mount the new partitions - having /var/log as a bind mount to the HDD
-
Disabled usage of the local swapfile
-
Copied log files from SD card to USB HDD - preserving filesystem permissions
-
Made a backup of current logs
-
Start openHAB and restart frontail
These are the main commands used:
ntfsresize -s 500085M /dev/sda1
ntfsfix -d /dev/sda1
fdisk /dev/sda
partprobe
mkfs.ext4 /dev/sda2
vi /etc/fstab
mount -a
dphys-swapfile swapoff
swapoff -a
cd /var
sudo rm swap
dphys-swapfile uninstall
mkswap /dev/sda3
swapon /dev/sda3
cp -rp /var/log/* /media/linux/openhabianpi/logs
systemctl start openhab2
systemctl restart frontail
These are the relevant lines form /etc/fstab:
UUID=[...] /media/linux ext4 noatime 0 0
/media/linux/openhabianpi/logs /var/log none bind 0 0
/usr/share/openhab2 /srv/openhab2-sys none bind 0 0
/etc/openhab2 /srv/openhab2-conf none bind 0 0
/var/lib/openhab2 /srv/openhab2-userdata none bind 0 0
/var/log/openhab2 /srv/openhab2-logs none bind 0 0
/usr/share/openhab2/addons /srv/openhab2-addons none bind 0 0
UUID=[...] none swap defaults 0 0
Did I do anything wrong or there is anything missing? If I go /var/log/openhab2, files there are simply not being updated while I can see the new log lines through the openHAB console.