Install Alpine on Rackspace: Difference between revisions

From Alpine Linux
m (typos)
(i)
Line 57: Line 57:


Download an alpine iso and mount it; for example
Download an alpine iso and mount it; for example
 
   wget http://dl-3.alpinelinux.org/alpine/v3.2/releases/x86_64/alpine-xen-3.2.2-x86_64.iso
   wget http://dl-4.alpinelinux.org/alpine/v2.6/releases/x86_64/alpine-2.6.2-x86_64.iso
  # We will grab the sha512 sum from another mirror
  wget http://nl.alpinelinux.org/alpine/v3.2/releases/x86_64/alpine-xen-3.2.2-x86_64.iso.sha512
  sha512sum -c alpine-xen-3.2.2-x86_64.iso.sha512
   mkdir /cdrom
   mkdir /cdrom
   mount alpine*.iso /cdrom -o loop
   mount alpine*.iso /cdrom -o loop
Line 66: Line 68:
cp -a /cdrom/* /
cp -a /cdrom/* /


cat - >target/boot/grub/grub.conf <<EOF  
cat - >/boot/grub/grub.cfg <<EOF  
default=0
set default="0"
timeout=3
set timeout="3"
hiddenmenu


title Alpine Linux
menuentry "Alpine Linux" {
root (hd0)
insmod gzio
kernel /boot/grsec alpine_dev=xvda1:ext3 modules=loop,squashfs,sd-mod,ext3 console=hvc0 pax_nouderef BOOT_IMAGE=/boot/grsec
insmod part_msdos
initrd /boot/grsec.gz
insmod ext2
set root='(hd0,msdos1)'
linux /boot/vmlinuz-grsec root=$(blkid /dev/xvda1 | awk '{ print $2 }' | sed 's/UUID=//; s/"//g') modules=sd-mod,usb-storage,ext3 quiet
        initrd /boot/initramfs-grsec
}
EOF
EOF
ln -sf ./grub.conf target/boot/grub/menu.lst
</pre>
</pre>



Revision as of 18:06, 28 July 2015

Create a minimal rackspace server

Debian 7

512MB, 20GB


Copy settings from existing server into apkovl

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,boot,sysinit,shutdown} root/.ssh etc/lbu etc/apk

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/
cp /etc/network/interfaces etc/network

Copy over your ssh authorized_keys and make sure its included in future:

cp -a /root/.ssh/authorized_keys root/.ssh
echo "/root/.ssh" > etc/lbu/include


Edit etc/passwd and change bash to /bin/sh.

sed -i -e '/^root:/s:/bin/bash:/bin/sh:' etc/passwd
Note: If you don't do this, nobody (even with physical access) will be able to log into the machine.

Make sure there is no whitespace at end of lines in interfaces file. Busybox ifup is very picky.

sed -i -e 's/ *$//' etc/network/interfaces

Create the apk world (/etc/apk/world) with essential packages:

echo "alpine-base iproute2 openssh bash" > etc/apk/world

(bash is technically not needed, but include it in case you forgot to edit your etc/passwd file correctly)

Double check the IP configuration and ssh keys.

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

ln -s /etc/init.d/{hwclock,modules,sysctl,hostname,bootmisc,syslog} etc/runlevels/boot/
ln -s /etc/init.d/{devfs,dmesg,mdev,hwdrivers} etc/runlevels/sysinit/
ln -s /etc/init.d/{networking,sshd} etc/runlevels/default/
ln -s /etc/init.d/{mount-ro,killprocs,savecache} etc/runlevels/shutdown/
tar czf ../host.apkovl.tar.gz *

Verify the overlay with "tar tzf" to see that it contains everything in proper places, and ensure it is in the / directory

tar tzvf ../host.apkovl.tar.gz
cp ../host.apkovl.tar.gz /

Install Alpine cd-rom image to hard disk

We need to copy over two sets of information: the boot kernel (kernel, initramdisk and boot configuration) and operating system boot data (overlay, apk packages and kernel modules).

Download an alpine iso and mount it; for example

 wget http://dl-3.alpinelinux.org/alpine/v3.2/releases/x86_64/alpine-xen-3.2.2-x86_64.iso
 # We will grab the sha512 sum from another mirror
 wget http://nl.alpinelinux.org/alpine/v3.2/releases/x86_64/alpine-xen-3.2.2-x86_64.iso.sha512
 sha512sum -c alpine-xen-3.2.2-x86_64.iso.sha512 
 mkdir /cdrom
 mount alpine*.iso /cdrom -o loop

Copy the contents of cd-rom image to root of current installation, then setup grub:

cp -a /cdrom/* /

cat - >/boot/grub/grub.cfg <<EOF 
set default="0"
set timeout="3"

menuentry "Alpine Linux" {
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='(hd0,msdos1)'
	linux /boot/vmlinuz-grsec root=$(blkid /dev/xvda1 | awk '{ print $2 }' | sed 's/UUID=//; s/"//g') modules=sd-mod,usb-storage,ext3 quiet
        initrd /boot/initramfs-grsec
}
EOF

Reboot and check that all came back as expected.