Sometimes I have a natural attraction to things making my life more complicated. I could have just installed CentOS. Or rented a dedicated server. Or stopped using SELinux. But I wanted it all. So I’d like to show you how you can install Debian 7 on a DigitalOcean droplet and have SELinux enabled.
The problem is that at DO the kernel comes from outside (KVM) and you cannot manipulate it nor it’s parameters. But you can use kexec to replace the kernel as soon as you’re in control.
Before you begin:
- I assume a freshly installed Debian 7 here (tested on 64bit version)
- you should take a backup before proceeding!
Okay, get all the updates and install the required software
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install selinux-basics selinux-policy-default auditd kexec-tools
Run selinux-activate, it modifies grub (no matter here), PAM and touches /.autorelabel:
$ sudo selinux-activate
Then, edit the file /etc/init.d/rcS and put the following in front of exec /etc/init.d/rc S
if grep -v kexeced /proc/cmdline ;then kexec -l /vmlinuz --initrd=/initrd.img --command-line="$(cat /proc/cmdline) selinux=1 security=selinux kexeced" && kexec -e fi
If this is done, you’re ready to reboot!
$ sudo reboot
You can add some extra time for the reboot as it has to relabel all the files for the first time.
When rebooted, check the SELinux status with:
Happy labeling :)