Start-up/boot script

friendodevil

Member
Apr 5, 2022
39
3
8
How can I create a start up script for proxmox for when the system boots... e.g.: I would like to update "ethtool -K eno1 tso off gso off" to be written each time the system starts
 
Option 1.) You can add a cron line (crontab -e) like this: @reboot /usr/sbin/ethtool -K eno1 tso off gso off > /dev/null 2>&1.
Option 2.) You create a oneshot systemd service like described here: https://trstringer.com/simple-vs-oneshot-systemd-service/
Option 3.) In case it is network related you also might want to use the "pre-up", "post-up" and so on constructs in your /etc/network/interfaces file. Adding a line like pre-up /usr/sbin/ethtool -K eno1 tso off gso off below your eno1 interface ( iface eno1 inet ...) should run that command each time before bringing the eno1 NIC up.

So for your specific example I would prefer option 3. For simple stuff that just has to run once but its not important when, I would use option 1. Option 2 is the most powerful but also the most complex one that for example would allow you at which point in time in the boot sequence you want your command to be run.
 
Last edited:
Option 1.) You can add a cron line (crontab -e) like this: @reboot /usr/sbin/ethtool -K eno1 tso off gso off > /dev/null 2>&1.
Option 2.) You create a oneshot systemd service like described here: https://trstringer.com/simple-vs-oneshot-systemd-service/
Option 3.) In case it is network related you also might want to use the "pre-up", "post-up" and so on constructs in your /etc/network/interfaces file. Adding a line like pre-up /usr/sbin/ethtool -K eno1 tso off gso off below your eno1 interface ( iface eno1 inet ...) should run that command each time before bringing the eno1 NIC up.

So for your specific example I would prefer option 3. For simple stuff that just has to run once but its not important when, I would use option 1. Option 2 is the most powerful but also the most complex one that for example would allow you at which point in time in the boot sequence you want your command to be run.
Thank you @Dunuin, I've opted for #3 as you've recommended; so far looks good
 
Option 1.) You can add a cron line (crontab -e) like this: @reboot /usr/sbin/ethtool -K eno1 tso off gso off > /dev/null 2>&1.
Option 2.) You create a oneshot systemd service like described here: https://trstringer.com/simple-vs-oneshot-systemd-service/
Option 3.) In case it is network related you also might want to use the "pre-up", "post-up" and so on constructs in your /etc/network/interfaces file. Adding a line like pre-up /usr/sbin/ethtool -K eno1 tso off gso off below your eno1 interface ( iface eno1 inet ...) should run that command each time before bringing the eno1 NIC up.

So for your specific example I would prefer option 3. For simple stuff that just has to run once but its not important when, I would use option 1. Option 2 is the most powerful but also the most complex one that for example would allow you at which point in time in the boot sequence you want your command to be run.
I did option 3 to run "pre-up pvecm expected 1" but for some reason it does not work. Here is my file :


auto lo
iface lo inet loopback

iface eno1 inet manual
pre-up pvecm expected 1

iface eno3 inet manual

iface eno4 inet manual

iface enp5s0 inet manual

iface eno2 inet manual

auto vmbr0
iface vmbr0 inet static
address 192.168.0.102/24
gateway 192.168.0.1
bridge-ports eno1
bridge-stp off
bridge-fd 0



What am I doing wrong?
 
First question would be why you want to set "pvecm expected 1" at all? This is dangerous and shouldn't be run as default. You should only manually run this after verifying that the other node is dead or you might run into a dangerous split brain situation. Proper solution when running a 2 node cluster would be to get something to act as a qdevice for the third vote so you don't have to temper with "pvecm expected 1" when shutting down one node of your two node cluster: https://pve.proxmox.com/wiki/Cluster_Manager#_corosync_external_vote_support
 
First question would be why you want to set "pvecm expected 1" at all?

During the winter here I only run 1 VM that is not that critical and I have 3 node setup. For like 6 months it will be like that and I want to save power since my nodes are actual 4U servers and consume a lot of power and this place only has solar power during the winter so I need to run it like that during winter.
Please help me run this on every startup.
 
Then I would try option 1:

So: @reboot /usr/bin/pvecm expected 1 > /dev/null 2>&1 to your crontab.
I run this command and just now power went off and on again and seems it did not work since I had to manually run the command again to run the VM...
 
I run this command and just now power went off and on again and seems it did not work since I had to manually run the command again to run the VM...
Thats not a command you run, you write that line in your crontab file.
 
I run this command and just now power went off and on again and seems it did not work since I had to manually run the command again to run the VM...
Ok so Here's a step by step guide:
1. You open the shell in the required node and run the command (crontab -e)
2. You will probably be asked to choose a text editor, choose nano
3. Scroll all the way down in the opened file and add this line: @reboot /usr/bin/pvecm expected 1 > /dev/null 2>&1
4. Save the File
5. Reboot
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!