Replacing non-Alpine Linux with Alpine remotely

From Alpine Linux
Revision as of 09:50, 16 September 2009 by Fabled (talk | contribs) (intial text)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Instructions to replace running Linux installation with Alpine Linux, remotely using ssh connection only.

Tested using alpine-1.9.0_rc2.

CAUTION: Practice with computer with physical access first. If something goes wrong, the remote box will very likely be left into unusable state.

WARNING: UNTESTED INSTRUCTION. WRITING IN PROGRESS.

Create apk overlay suitable for hard disk based tmpfs boot

The first step is to create Alpine configuration file with basic configuration of the host. We need the new box to start networking and ssh in the beginning so we can reconnect to it after reboot.

Create basic layout for the overlay:

mkdir overlay
cd overlay
mkdir -p etc/ssh etc/network etc/runlevels/default root/.ssh

If you want to keep the existing host identity (e.g. SSH key), you can copy them over:

cp -a /etc/{passwd,group,shadow,gshadow,hostname,resolv.conf,network/interfaces,ssh} etc/

You can copy the network/interfaces might not necessarily exists. Some distributions use different configuration file for network. If it does not exists, you need to create it. It should look something like:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
      address ip.ad.dr.es
      netmask 255.255.255.0
      gateway gw.ad.dr.es

Finally, make the essential services start up automatically and create the overlay file:

ln -s /etc/init.d/networking etc/runlevels/default/networking
ln -s /etc/init.d/sshd etc/runlevels/default/sshd
tar czf ../host.apkovl.tar.gz *

Install Alpine cd-rom image on hard disk

Install Alpine on hard-disk