2024-11-03 15:27:01 +00:00
# Alpine Initramfs Dropbear
2024-11-03 15:17:34 +00:00
This script took a huge references from:
* [https://github.com/Deeplerg/fork-alpine-initramfs-dropbear ](https://github.com/Deeplerg/fork-alpine-initramfs-dropbear )
* [https://github.com/mk-f/alpine-initramfs-dropbear ](https://github.com/mk-f/alpine-initramfs-dropbear )
* [https://gitlab.alpinelinux.org/alpine/mkinitfs/-/blob/master/initramfs-init.in ](https://gitlab.alpinelinux.org/alpine/mkinitfs/-/blob/master/initramfs-init.in )
This script is modified from [alpine/mkinitfs - initramfs-init.in ](https://gitlab.alpinelinux.org/alpine/mkinitfs/-/blob/master/initramfs-init.in )
significant changes:
* Add dropbear
2024-11-03 17:39:03 +00:00
* After unlocked, kill all remainings dropbear and nlplug-findfs process, so no struck process reached the system.
2024-11-03 15:17:34 +00:00
2024-12-10 09:30:44 +00:00
* optional support IPv6 unlock
## Fileinfo:
`alpine-initramfs-base` : normal alpine initramfs file which the code is based on
`initramfs-dropbear` : normal dropbear version
`initramfs-dropbear-ipv6` : dropbear with IPv6 support
`*.patch` : patch file version of the code
## Install
2024-11-03 15:17:34 +00:00
Please install `dropbear` before continuing
1. copy `dropbear/unlock_disk` to `/etc/dropbear/unlock_disk`
2024-12-04 08:59:13 +00:00
* Also Make sure `/etc/dropbear/unlock_disk` is executable! else dropbear will exit with "failed child"W
2024-11-03 15:17:34 +00:00
2. copy `authorized_keys` to `/etc/dropbear/authorized_keys`
3. copy `features.d` to /`etc/mkinitfs/features.d`
2024-12-10 09:30:44 +00:00
* If using IPv6 mode, don't forget to also include `features.d` from `alpine-initramfs-ipv6` folder.
2024-11-03 15:17:34 +00:00
2024-11-03 15:36:01 +00:00
Note:
* if you're using Deeplerg/mk-f scripts before don't forget to change `unlock_disk` as i modified that one too.
* If you're using `grub` make sure to install `syslinux` and possibly checkout `/etc/default/grub` and commented CMDLINE that's conflicted with `update-extlinux` like `GRUB_CMDLINE_LINUX_DEFAULT` and `default_kernel_opts` after that `grub-mkconfig -o /boot/grub/grub.cfg`
2024-11-03 15:17:34 +00:00
### /etc/mkinitfs.conf
2024-11-03 15:27:01 +00:00
```
features="ata base ide scsi usb virtio ext4 cryptsetup keymap dropbear network"
```
2024-11-03 15:17:34 +00:00
* features+= `dropbear` `network`
2024-12-10 09:30:44 +00:00
* add `ip` if using in ipv6 mode
2024-11-03 15:17:34 +00:00
### /etc/update-extlinux.conf
2024-11-03 15:27:01 +00:00
```
modules=sd-mod,usb-storage,ext4,ata_piix,virtio_net,e1000e,virtio_pci
```
2024-11-03 15:17:34 +00:00
* if network is not working (/sys/class/net/*/address not found etc.) try adding `e1000e` or `virtio_net` `virtio_pci`
2024-11-03 15:27:01 +00:00
```
2024-12-10 09:30:44 +00:00
default_kernel_opts="cryptroot=UUID=xxx cryptdm=root quiet rootfstype=ext4 dropbear=< dropbear_port > ip=< ip > ip6=< ip6 > "
2024-11-03 15:27:01 +00:00
```
2024-11-03 15:17:34 +00:00
* ip= can be both static and dhcp(if supported) `ip=<ip>::<gw>:<mask>::<interface>` `ip=dhcp`
2024-12-10 09:30:44 +00:00
* ip6= only static is supported `ip6=client-ip/gateway-ip/interface/dns1/dns2`
* `ip` and `ip6` is not compatible with each others! only use one.
2024-11-03 15:17:34 +00:00
2024-11-03 15:27:01 +00:00
```
update-extlinux
```
2024-11-03 15:17:34 +00:00
2024-11-03 15:27:01 +00:00
```
mkinitfs -i path/to/initramfs-dropbear < Kernel Version ( from / lib / modules ) incase in emergency CD >
2024-11-03 15:17:34 +00:00
```