Search This Blog

Showing posts with label Alpine Linux. Show all posts
Showing posts with label Alpine Linux. Show all posts

Monday, April 7, 2025

Disable Kernel modules in Alpine Linux Cloud image for Oracle Cloud

Download Alpine Linux Cloud Image from: https://www.alpinelinux.org/cloud/
Upload the image to OCI and create an instance from it.

I disabled some Kernel modules for security and saving memory.

Remove old drivers from: /etc/mkinitfs/mkinitfs.conf
From:
features="ata base ide scsi usb virtio ext4 nvme"
To:
features="base scsi virtio ext4"


Add 'blacklist drm' to /etc/modprobe.d/blacklist.conf
echo 'blacklist drm' >> /etc/modprobe.d/blacklist.conf
mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / 
reboot
The grub modprobe.blacklist=drm, does not work either.
updating /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash modprobe.blacklist=drm"


I will try [cloud-init] Bootstrap image next time.

Reference:
https://dev.alpinelinux.org/~clandmeter/other/forum.alpinelinux.org/forum/kernel-and-hardware/blacklist-drivers-builtin-kernel.html
https://wiki.alpinelinux.org/wiki/Initramfs_init
https://wiki.alpinelinux.org/wiki/Xen_PCI_Passthrough

Wednesday, September 27, 2023

disable ipv6 on Alpine Linux

Create a file [/etc/sysctl.d/local.conf] with one line:
net.ipv6.conf.all.disable_ipv6 = 1

Then reboot the server.

Reference: /etc/sysctl.d/README
Kernel system variables configuration files

Files found under the /etc/sysctl.d directory that end with .conf are
parsed within sysctl(8) at boot time.  If you want to set kernel variables
you can either edit /etc/sysctl.conf or make a new file.

The filename isn't important, but don't make it a package name as it may clash
with something the package builder needs later. The file name must end
with .conf, or it will not be read.

The recommended location for local system settings is /etc/sysctl.d/local.conf
but as long as you follow the rules for the name of the file, anything will
work. see the sysctl.conf(5) man page for details of the format. This manpage
can be found in the `procps-doc` package.

Please notice this still load the ipv6 kernel module.

I tried add "blacklist ipv6" in /etc/modprobe.d/blacklist.conf.
But the module still loaded after reboot.

The best way to blacklist modules from the bootloader:
/etc/default/grub
GRUB_TIMEOUT=2
GRUB_DISABLE_SUBMENU=y
GRUB_DISABLE_RECOVERY=true
GRUB_CMDLINE_LINUX_DEFAULT="modules=sd-mod,usb-storage,ext4 module_blacklist=ipv6 quiet rootfstype=ext4"

Make sure re-generate the grub.cfg file:
grub-mkconfig -o /boot/grub/grub.cfg

Reboot and verify with command "lsmod"
Reference:
https://wiki.archlinux.org/title/Kernel_module#Using_kernel_command_line_2
https://wiki.archlinux.org/title/Kernel_parameters#GRUB