<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Alex Tomkins - digitalocean</title>
    <link>https://www.alextomkins.com/tag/digitalocean/</link>
    <atom:link href="https://www.alextomkins.com/tag/digitalocean/feed.xml" rel="self" type="application/rss+xml" />
    <description>Posts tagged with digitalocean</description>
    <language>en</language>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    <item>
      <title>DigitalOcean Debian kernel</title>
      <link>https://www.alextomkins.com/2013/11/digitalocean-debian-kernel/</link>
      <guid>https://www.alextomkins.com/2013/11/digitalocean-debian-kernel/</guid>
      <pubDate>Sat, 16 Nov 2013 16:38:00 +0000</pubDate>
      <description><![CDATA[<p><a href="https://www.digitalocean.com/?refcode=1ad7cea15b72">DigitalOcean</a> offers some fantastic KVM
powered virtual machines for low prices, however the technical decisions they've made in various
places leaves something to be desired.</p>
<p>One of the problems which you may face at some point is that you're stuck with whatever kernel they
provide, you can't
<a href="https://digitalocean.uservoice.com/forums/136585-digital-ocean/suggestions/2814988-give-option-to-use-the-droplet-s-own-bootloader-">use your own bootloader</a>.
They've attempted to solve this by providing kernels from every Linux distribution they support -
but sadly this isn't the solution which I'd expect a KVM provider to use.</p>
<p>To work around this, we can use kexec to change the kernel on boot. Install kexec:</p>
<pre><code>$ sudo apt-get install kexec-tools</code></pre>
<p>Move <code>/sbin/init</code> to <code>/sbin/init.distrib</code>:</p>
<pre><code>$ dpkg-divert --add --local --rename /sbin/init creates=/sbin/init.distrib</code></pre>
<p>And create a script to replace <code>/sbin/init</code></p>
<pre><code>#!/bin/bash

if grep -qv " kexeced$" /proc/cmdline; then
    /sbin/kexec --load /vmlinuz \
        --reuse-cmdline \
        --initrd=/initrd.img \
        --append="init=/sbin/init.distrib kexeced" \
    &amp;&amp; /bin/mount -o ro,remount / \
    &amp;&amp; /sbin/kexec --exec
fi

exec /sbin/init.distrib "$@"</code></pre>
<p>Make it executable:</p>
<pre><code>$ sudo chmod 755 /sbin/init</code></pre>
<p>And then you can reboot. Next time your server restarts, the script will run before any other init
scripts and will change the running kernel with kexec. You can change the kernel parameters in this
file if you need custom options, or just leave it as is - and you'll be able to stick with your
standard Debian kernel.</p>
<p>Credit to Joe Johnston for the
<a href="https://github.com/simple10/guides/blob/fa8261c17d3bade13da0644a38c3c38b24dc5b96/digitalocean.md#debian-selinux">original script</a>.</p>
<h2>Update</h2>
<p>A couple of years later, DigitalOcean eventually created new images which use the virtual machines
bootloader - which means this hack is no longer needed for newer Linux distributions.</p>
]]></description>
    </item>
    
    
    
    
    
    
    
  </channel>
</rss>
