Some Common Paths
These paths will be used for subsequent virtual machine migration and backup.
Storage configuration file:
/etc/pve/storage.cfg
Storage path local:
ISO storage path: /var/lib/vz/template/iso/
VM backup path: /var/lib/vz/dump/
ZFS disk path: /dev/rpool/data/
Storage path local-lvm, including mounted NFS, SMB, and other storage devices: mnt/pve/
PVE One-Click Optimization Script
It is recommended to use the PVE one-click optimization script for simple optimizations and auxiliary settings. It saves a lot of time. For the tutorial, refer to: https://github.com/ivanhao/pvetools
By default, PVE has SSH enabled, and you can connect directly.
First, remove the enterprise source:
rm /etc/apt/sources.list.d/pve-enterprise.list
Install:
export LC_ALL=en_US.UTF-8
apt update && apt -y install git && git clone https://github.com/ivanhao/pvetools.git
Start the tool (cd to the directory, then start the tool):
cd ~/pvetools
./pvetools.sh
How to Uninstall?
Simply delete the downloaded `pvetools` directory.
I will use it for basic settings, which is very convenient, such as configuring email notifications, etc.
System Installation and Scheduled Tasks
The installation steps are omitted; there are many online tutorials, and it’s not difficult.
Personally, I use ZFS to set up a Mirror during the installation of PVE because I found that my SATA SSD sometimes causes errors when running PVE, possibly due to the aging of the SSD and data loss. Therefore, I use ZFS to avoid system-level errors in PVE, which could cause future troubles.
Additionally, ZFS requires manual scrubbing to ensure the system’s correctness. So, I set up a daily scrub command to run at 00:30 AM.
Edit system crontab
crontab -e
Choose the `vim` editor, paste the following content, and save. This means the system will scrub errors at 00:30 AM every day.
30 0 * * * /usr/sbin/zpool scrub rpool
Once the crontab is set, it won’t take effect immediately. You can restart cron using the command:
/etc/rc.d/cron restart
Using the online tool [https://crontab.guru/](https://crontab.guru/), you can generate the correct time expressions.
Check running scheduled tasks
crontab -l
Check the most recent scrub run status. If there’s no issue, it should show 0 errors:
zpool status rpool
This method can also be used for other tasks:
Scheduled VM Shutdown
Shutdown VM 106 every 5 minutes:
crontab -e
*/5 * * * * /usr/sbin/qm shutdown 106
Scheduled System Shutdown
Shutdown the system at 1:30 AM every day:
crontab -e
30 01 * * * /sbin/shutdown -h now
Additional Note: If shutdown fails, use the following command instead:
#! /bin/sh
/sbin/init 0 # Shut down the power
/sbin/init 6 # Restart the system
Other Examples
30 3 10,20 * * ls
# Execute the ‘ls’ command at 3:30 AM on the 10th and 20th of each month [Note: Use ‘,’ to separate multiple non-continuous time periods]
25 8-11 * * * ls
# Execute the ‘ls’ command at the 25th minute of each hour between 8 and 11 AM every day [Note: Use ‘-‘ for continuous periods]
*/15 * * * * ls
# Execute the ‘ls’ command every 15 minutes [i.e., at 0, 15, 30, 45, and 60 minutes of each hour]
30 6 */10 * * ls
# Execute the ‘ls’ command at 6:30 AM every 10 days of the month
Leave a Reply