Subject: [INSTALL][CHROOT] Ethernet module/driver is not loaded after install from chroot

From: Sevan Murriguian-Watrin <[email-masked]>
Date: Thu, 2 Apr 2020 18:31:28 +0200

Hello everyone,

I want to install Alpine Linux on a dedicated server but I have no
access to the server via anything else than SSH. This access is given
to me on a rescue live session on an Ubuntu.

So I tried and more or less succeeded to install Alpine via a chroot
env. Here is the list of thing I did for context.

# Prepare chroot
- boot on Ubuntu using PXE (on the provider interface)
- mkdir /alpine
- mount -t tmpfs -o size=2G tmpfs /alpine/
- apt install git
- git clone https://github.com/alpinelinux/alpine-chroot-install.git
- cd alpine-chroot-install/
- ./alpine-chroot-install

# Enter Chroot
- /alpine/enter-chroot
- apk add vim
- vim /sbin/setup-alpine +211
     - add `-k lts` to `DEFAULT_DISK=none $PREFIX/sbin/setup-disk
     -q ${DISKOPTS} || exit`
(I have to do this because the kernel on Ubuntu is labelled
`linux...-generic`.)
- vim /sbin/setup-disk +441
     - remove the if to always enable nomodset
(I have to do this because Ubuntu is not boot with `nomodset` in his
boot cmdline.)

# Install Alpine on the disk
- setup-alpine
- Follow instructions
(https://wiki.alpinelinux.org/wiki/Install_to_disk)
     - Select your drive (sda for the rest of the procedure)
     - Use mode sys

# Ensure access to the Alpine Install after reboot
- mount /dev/sda3 /mnt
- mount /dev/sda1 /mnt/boot
- chroot /mnt
- vim /etc/ssh/sshd_config to allow access on the server
- rc-update add sshd
(to enable sshd at boot)
- vim /etc/network/interfaces
     - change the interface name by eth0 which is the default on Alpine
     whereas it's something like `enp0s3` on Ubuntu
- quit the chroot env
- reboot

The problem is that after the reboot, I only have the loopback
interface, no ethernet interface is detected/available which mean no
access using SSH. The kernel module is not loaded. I've replicated this
issue on a VirtualBox VM.

The quick fix is to install `lshw` on the Ubuntu live session, execute
`lshw -C network` and look for the Ethernet driver, than manually add it
in a file like `/etc/modules` on the newly installed Alpine so it's
loaded at boot.

I wonder what I could do to get the same behavior as if I had booted on
a Alpine LiveCD instead of a chroot env? I've done it on an other server
and the system booted without any issues.

Is this install method even possible? I mean, can I use the chroot
script to perform a full install ? Will I encounter other issues in the
future ?

PS: I've tried to manually trigger a `mkinitfs` after the reboot to
force the generation of the initramfs but it didn't change anything.

-- 
Sevan

---

From: Daniel Kulesz <[email-masked]>
Date: Thu, 2 Apr 2020 20:25:51 +0200

Hi Sevan,

I recommend the following approach (assuming you are using a x86 or amd64 server) that worked for me in a similar setting:

- install alpine on another machine (or in a VM) using the "sys" variant
- boot some live system
- mount the previously installed alpine and create a tar archive of the whole installation (be careful to include /boot as well which might be on a separate partition)
- transfer the tar archive to your target machine
- unpack the tar archive
- chroot into the installation
- install the bootloader

Cheers, Daniel

On Thu, 2 Apr 2020 18:31:28 +0200