[Tip] fast reboots with kexec

Discussion in 'Proxmox VE: Installation and configuration' started by morph027, Jul 11, 2017.

Tags:
  1. morph027

    morph027 Active Member

    Joined:
    Mar 22, 2013
    Messages:
    390
    Likes Received:
    43
    Install the package:

    Code:
    echo "kexec-tools kexec-tools/load_kexec boolean false" | debconf-set-selections
    apt-get -y install kexec-tools
    
    Create /etc/systemd/system/kexec-pve.service with content:

    Code:
    [Unit]
    Description=boot into into the current pve kernel
    Documentation=man:kexec(8)
    DefaultDependencies=no
    Before=shutdown.target umount.target final.target
    
    [Service]
    Type=oneshot
    ExecStart=/sbin/kexec -l /boot/pve/vmlinuz --initrd=/boot/pve/initrd.img --reuse-cmdline
    
    [Install]
    WantedBy=kexec.target
    
    Enable:

    Code:
    systemctl enable kexec-pve.service
    
    Now you can reboot without the whole UEFI/BIOS/OpROM stuff with

    Code:
    systemctl kexec
    
     
    #1 morph027, Jul 11, 2017
    Last edited: Jul 12, 2017
  2. neonmaus

    neonmaus New Member

    Joined:
    Sep 11, 2015
    Messages:
    25
    Likes Received:
    1
    Thanks for this very good tip :)
     
  3. bogo22

    bogo22 Member

    Joined:
    Nov 4, 2016
    Messages:
    36
    Likes Received:
    0
    Really nice, thanks. The proxmox dev's should integrate it and make it as alternative reboot option to the "real" reboot with bios :)
    Small nit: Is the "into into" in the description right?
     
  4. homozavrus

    homozavrus New Member

    Joined:
    Oct 22, 2010
    Messages:
    5
    Likes Received:
    0
    Thanks, work like a charm! :)
    Better to place this thread as page in wiki
     
  5. Rhinox

    Rhinox Active Member

    Joined:
    Sep 28, 2016
    Messages:
    272
    Likes Received:
    35
    Just to make things clear: it does not boot into the current (running) kernel, but into the kernel defined as primary in boot-loader. So if kernel was updated, it boots into the new one...
     
  6. eXtremeSHOk

    eXtremeSHOk New Member

    Joined:
    Mar 15, 2016
    Messages:
    22
    Likes Received:
    12
    fireon likes this.
  7. fireon

    fireon Well-Known Member
    Proxmox VE Subscriber

    Joined:
    Oct 25, 2010
    Messages:
    2,681
    Likes Received:
    146
    Not it boots into current kernel. Because there is no grub at kexec. Tested here on my two machines.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. morph027

    morph027 Active Member

    Joined:
    Mar 22, 2013
    Messages:
    390
    Likes Received:
    43
    In fact, it is loading /boot/pve/vmlinuz with /boot/pve/initrd.img which is a symlink to the latest installed kernel.

    Code:
    root@proxmox:~# cat /etc/systemd/system/kexec-pve.service
    [Unit]
    Description=boot into into the current pve kernel
    Documentation=man:kexec(8)
    DefaultDependencies=no
    Before=shutdown.target umount.target final.target
    
    [Service]
    Type=oneshot
    ExecStart=/sbin/kexec -l /boot/pve/vmlinuz --initrd=/boot/pve/initrd.img --reuse-cmdline
    
    [Install]
    WantedBy=kexec.target
    root@proxmox:~# ls -la /boot/pve/
    total 20
    drwxr-xr-x 2 root root  8 Apr  3 11:30 .
    drwxr-xr-x 5 root root 15 Apr  5 08:50 ..
    lrwxrwxrwx 1 root root 25 Apr  3 11:30 initrd.img -> /boot/pve/initrd.img-4.13
    lrwxrwxrwx 1 root root 30 Apr  3 11:30 initrd.img-4.13 -> /boot/initrd.img-4.13.16-1-pve
    lrwxrwxrwx 1 root root 30 Mar 27 08:20 initrd.img-4.15 -> /boot/initrd.img-4.15.10-1-pve
    lrwxrwxrwx 1 root root 22 Apr  3 11:30 vmlinuz -> /boot/pve/vmlinuz-4.13
    lrwxrwxrwx 1 root root 27 Apr  3 11:30 vmlinuz-4.13 -> /boot/vmlinuz-4.13.16-1-pve
    lrwxrwxrwx 1 root root 27 Mar 27 08:20 vmlinuz-4.15 -> /boot/vmlinuz-4.15.10-1-pve
    
     
  9. fireon

    fireon Well-Known Member
    Proxmox VE Subscriber

    Joined:
    Oct 25, 2010
    Messages:
    2,681
    Likes Received:
    146
    Strange, this day i've installed 4.15
    Code:
    total 20
    drwxr-xr-x 2 root root  8 Apr  7 13:29 ./
    drwxr-xr-x 5 root root 19 Apr  7 13:29 ../
    lrwxrwxrwx 1 root root 25 Mar 26 23:16 initrd.img -> /boot/pve/initrd.img-4.13
    lrwxrwxrwx 1 root root 30 Apr  4 21:21 initrd.img-4.13 -> /boot/initrd.img-4.13.16-1-pve
    lrwxrwxrwx 1 root root 30 Apr  7 13:29 initrd.img-4.15 -> /boot/initrd.img-4.15.10-1-pve
    lrwxrwxrwx 1 root root 22 Mar 26 23:16 vmlinuz -> /boot/pve/vmlinuz-4.13
    lrwxrwxrwx 1 root root 27 Apr  4 21:21 vmlinuz-4.13 -> /boot/vmlinuz-4.13.16-1-pve
    lrwxrwxrwx 1 root root 27 Apr  7 13:29 vmlinuz-4.15 -> /boot/vmlinuz-4.15.10-1-pve
    
    You see default is 4.13. But yes i can force manualy with an other line
    Code:
    ExecStart=/sbin/kexec -l /boot/pve/vmlinuz-4.15 --initrd=/boot/pve/initrd.img-4.15 --reuse-cmdline
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. morph027

    morph027 Active Member

    Joined:
    Mar 22, 2013
    Messages:
    390
    Likes Received:
    43
    Jip, same here. Probably because it's a beta kernel..
     
  11. fabian

    fabian Proxmox Staff Member
    Staff Member

    Joined:
    Jan 7, 2016
    Messages:
    3,103
    Likes Received:
    473
    correct.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. fireon

    fireon Well-Known Member
    Proxmox VE Subscriber

    Joined:
    Oct 25, 2010
    Messages:
    2,681
    Likes Received:
    146
    Ah ok, thanks.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. homozavrus

    homozavrus New Member

    Joined:
    Oct 22, 2010
    Messages:
    5
    Likes Received:
    0
    there is no script in repo :)
     
  14. eXtremeSHOk

    eXtremeSHOk New Member

    Joined:
    Mar 15, 2016
    Messages:
    22
    Likes Received:
    12
    Script was renamed to install-post.sh
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice