Virus Scanning

Key Notes

Rosetta uses ClamAV (↗ web site), the scanner most often recommended for a Raspberry Pi. Files mostly arrive on a Rosetta from USB sticks (G-code, settings) and web downloads, so those are what the regular scan covers.

  • The installer (Rosetta_Install_Debian_13_Trixie.sh) installs ClamAV and creates /home/reuben/ClamAv/SuspiciousFiles.
  • ClamAV keeps its virus signatures up to date by itself (below) - nothing needs scheduling for that.
  • A scan uses a lot of the Raspberry Pi's processor and memory (about 1 GB for the signatures). Never scan while a program is cutting - the weekly scan below skips itself if LinuxCNC is running.

Installation

Done by the installer. By hand:

sudo apt install -y clamav
mkdir -p /home/reuben/ClamAv/SuspiciousFiles

Installing clamav also installs clamav-freshclam, a background service that checks for new signatures several times a day.


Signature Updates

Check that the update service is running, and when it last updated:

systemctl status clamav-freshclam
sudo tail -n 20 /var/log/clamav/freshclam.log

Don't run sudo freshclam by hand while the service is running - the two lock each other out and freshclam fails with “Failed to lock the log file”. To force an update now:

sudo systemctl stop clamav-freshclam
sudo freshclam
sudo systemctl start clamav-freshclam


Scanning a USB Stick

Before copying files from a USB stick, insert it, wait for it to appear on the desktop, then:

clamscan -r -i /media/reuben

-i lists only infected files. The last lines give a summary - “Infected files: 0” means nothing was found.


Scheduling the Weekly Scan

This scans the operator's files and any inserted USB stick each Monday at 03:00, at the lowest priority, and skips the scan if LinuxCNC is running. Files found are moved to /home/reuben/ClamAv/SuspiciousFiles.

Open a terminal emulator, and enter this command (it edits root's schedule, so the scan doesn't need sudo):

sudo crontab -e

Choose option 1 if asked. At the bottom of the file, add this line (it is a single line):

0 3 * * 1 pgrep -x linuxcncsvr >/dev/null || nice -n 19 ionice -c3 clamscan -r -i --exclude-dir=/home/reuben/ClamAv --move=/home/reuben/ClamAv/SuspiciousFiles --log=/home/reuben/ClamAv/ScanLog.txt /home/reuben /media

Press Ctrl-O then Enter to save, and Ctrl-X to exit.

The scan only runs if the machine is switched on at that time.

Machines set up with the earlier instructions

Earlier instructions scheduled ClamAV differently. Remove those entries - they either fail or scan the whole system with --move, which could move a system file:

  1. Applications > Settings > Session and Startup > Application Autostart: select ClamAV (sudo nice -n 19 freshclam) and click Remove.
  2. Run crontab -e (without sudo) and delete the two lines with freshclam and clamscan in them.
  3. Then add the line above with sudo crontab -e.

Checking the Results

sudo tail -n 30 /home/reuben/ClamAv/ScanLog.txt
sudo grep FOUND /home/reuben/ClamAv/ScanLog.txt
ls -l /home/reuben/ClamAv/SuspiciousFiles

Each run adds a section to ScanLog.txt ending with a summary. Lines ending in FOUND name a file that was detected and moved.

  • A file was moved: it is in /home/reuben/ClamAv/SuspiciousFiles. If it is a file the customer recognises and trusts (e.g. their own G-code - a false alarm is possible), move it back with sudo mv. Otherwise delete it, and check where it came from (usually a USB stick - scan that stick on another computer too).
  • Nothing has run: check the cron line with sudo crontab -l, and that the machine was on and LinuxCNC closed on Monday at 03:00.

Scanning the Whole System

Only occasionally, with LinuxCNC closed - it takes hours. This one only reports (no --move), because moving a system file because of a false alarm could stop the Raspberry Pi from starting:

sudo nice -n 19 ionice -c3 clamscan -r -i --exclude-dir="^/(proc|sys|dev|run)" --log=/home/reuben/ClamAv/FullScanLog.txt /

Report anything it finds before deleting it.

########## Standard Footer for all pages ##########
 

About the Rosetta System
Terms of Use

eMail comments to
ColvinTools @ Gmail [period] com -> mailto:ColvinTools [snail] Gmail [period] com