Difference between revisions of "Arch Linux"

From PrgmrWiki
(added some configuration sections from previous edits)
(Explain enabling ipv6)
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
===Fresh Install===
+
The purpose of this document is to provide the minimum necessary information to get Arch up and reasonably secure.
  
====Initial setup====
+
The Arch Wiki has a page devoted to [https://wiki.archlinux.org/index.php/Install_from_existing_Linux installing Arch Linux from within an existing Linux], which effectively describes the underlying steps being performed here. The following steps apply that process to a VM on prgmr.
This guide assumes that you have installed archlinux before, either on a KVM vps or locally. This guide requires you to install archlinux locally, preferably using [https://www.virtualbox.org/ virtualbox].
 
  
First grab the latest and greatest archlinux iso from the archlinux [http://www.archlinux.org/download/ website].
+
== Accessing the Management Console ==
* Open up virtualbox, and create a vm for archlinux.
 
* Make the disk image 1GB, that's all you should need.
 
* Boot it up, and follow the [https://wiki.archlinux.org/index.php/Official_Arch_Linux_Install_Guide official installation guide]. Please read the following sub-points before starting the installation:
 
** Only make a single ext3 partition for everything. <tt># mkfs.ext3 /dev/sda1</tt>
 
** You will need a linux kernel that includes xen drivers. If you trust me, you can use this pre-built x86 kernel (3.5.4): [http://kbar.pro/files/linux/vmlinuz-3.5.4 md5sum: 4d00f77b2a4c5e2c565a7ee9e5796e26]. [http://kbar.pro/files/linux/config Here] is the .config I used to build the kernel.
 
** You may wish to install [http://www.archlinux.org/packages/core/i686/systemd-sysvcompat/ systemd-sysvcompat] to get systemd working.
 
* Before you complete the installation as per the [https://wiki.archlinux.org/index.php/Official_Arch_Linux_Install_Guide official guide], clear out <tt>/var/cache/pacman/pkg</tt> to save on bandwidth + disk space.
 
* Unmount the disk as per the official guide.
 
* Boot your prgmr domU into <code>CentOS 5.5 rescue (2.6.18-194.3.1.el5xen)</code> from pvgrub, and Log in as <tt>root</tt>
 
** Set up partitions. This guide will use one partition, starting with a blank disk for simplicity.
 
<pre>
 
[root@host ~]# dd if=/dev/zero of=/dev/xvda # (optional) wipes all your data
 
[root@host ~]# parted /dev/xvda
 
GNU Parted 1.8.1
 
Using /dev/xvda
 
Welcome to GNU Parted! Type 'help' to view a list of commands.
 
(parted) mklabel msdos
 
(parted) mkpart primary 0% 100%
 
(parted) quit
 
</pre>
 
** Make your one partition, but don't mount it yet:
 
<pre>[root@host ~]# mkfs.ext3 -L ARCHLINUX /dev/xvda1</pre>
 
** Transfer over installed archlinux filesystem using archlinux install media running on your local virtualbox. Here's where it gets kinda interesting, and you may or may not want to do it the way I'm doing it here.
 
*** Since the rescue shell is mounted read-only, you'll need to do some work to get sshd running. First, copy your pubkey into /tmp/authorized_keys.
 
*** Then launch sshd, making sure you don't enter a password when ssh-keygen prompts for a passphrase:
 
<pre>
 
# wget -O /tmp/sshd_config http://kbar.pro/files/linux/sshd_config_rescue
 
# ssh-keygen -f /tmp/ssh_host_rsa_key
 
# /usr/sbin/sshd -f /tmp/sshd_config
 
</pre>
 
*** Now you can ssh into the rescue image! Use the install media running on your local virtualbox to copy over your installed filesystem:
 
<pre>
 
# dd if=/dev/sda1 | ssh root@your.prgmr.ip.here "dd of=/dev/xvda1"
 
</pre>
 
*** After the copying has finished, you should some output that confirms completion.
 
 
 
** Now mount the filesystem on your vps:
 
<pre>
 
# mount -n /dev/xvda1 /mnt
 
# cd /mnt
 
</pre>
 
 
 
====Configuration====
 
 
 
If you installed to somewhere other than <code>/dev/xvda1</code>, you will need to edit <code>boot/grub/menu.lst</code> to reflect the changes.
 
 
 
** Drop this into <tt>/boot/grub/menu.lst</tt>
 
<pre>
 
timeout 5
 
 
 
title          3.5.4-x86
 
root            (hd0,0)
 
kernel          /boot/vmlinuz-3.5.4 root=/dev/xvda ro console=hvc0
 
</pre>
 
** Grab the kernel from earlier in this guide and put it in <tt>/boot/</tt>
 
** Edit <tt>etc/fstab</tt> to look something like this:
 
<pre>
 
#
 
# /etc/fstab: static file system information
 
#
 
# <file system> <dir>  <type>  <options>      <dump>  <pass>
 
devpts                /dev/pts      devpts    defaults            0      0
 
shm                    /dev/shm      tmpfs    nodev,nosuid        0      0
 
 
 
/dev/xvda1      /      ext3    defaults,noatime 0 1
 
</pre>
 
** Comment the following lines in <tt>etc/inttab</tt>:
 
<pre>
 
#c1:2345:respawn:/sbin/agetty -8 -s 38400 tty1 linux
 
#c2:2345:respawn:/sbin/agetty -8 -s 38400 tty2 linux
 
#c3:2345:respawn:/sbin/agetty -8 -s 38400 tty3 linux
 
#c4:2345:respawn:/sbin/agetty -8 -s 38400 tty4 linux
 
#c5:2345:respawn:/sbin/agetty -8 -s 38400 tty5 linux
 
#c6:2345:respawn:/sbin/agetty -8 -s 38400 tty6 linux
 
</pre>
 
** Uncomment or add the following line in <tt>etc/inittab</tt>:
 
<pre>h0:2345:respawn:/sbin/agetty -8 -s 38400 hvc0 linux</pre>
 
 
 
** Get the configuration details for a working network:
 
*** Note the <tt>inet addr</tt> and <tt>mask</tt> in the output of <code>ifconfig eth0</code>
 
*** Note the IP in the <tt>gateway</tt> column in the output of <code>route</code>
 
*** Note the <tt>search</tt> and <tt>nameserver</tt> outputs of <code>cat /etc/resolv.conf</code>
 
 
 
** This is all you need to know to configure Arch to connect to the internet.
 
** Reboot into Arch after taking note of the information.
 
<pre>
 
# shutdown -r now
 
</pre>
 
 
 
** Login as root and set the root password.
 
<pre>
 
Arch Linux 2.6.37-xen  ((none)) (hvc0)
 
(none) login: root
 
[root@(none) ~]# passwd
 
</pre>
 
  
=====Network=====
+
You need to access the Management Console for your VM. If you're not familiar with this, please see [[Management Console]]. The following instructions assume that you are NOT using the legacy console.
* Edit <code>/etc/resolv.conf</code> to look like what you wrote down.
 
  
* Fill in the blanks of <code>/etc/rc.conf</code> to include your hostname, interface, address, netmask, broadcast, and gateway. Your hostname can be whatever you like. Your interface is <tt>eth0</tt>.
+
== Boot from rescue image ==
  
=====Extra/SSH=====
+
The install will be performed from a Rescue image. This is equivalent to booting off a Rescue CD or USB stick, except the process is fully remote. We must configure the VM to boot off the Rescue image, which we will use as a starting point for installing Arch into the VM disk. For more information, see [[accessing your guest from the rescue image]]. After install has completed, the VM will be switched back to booting directly from its main disk which contains the new Arch installation.
 
 
Add a user, add your public key, enable ssh privilege separation, and allow ssh connections.
 
<pre>
 
# adduser kino
 
 
 
# mkdir ~kino/.ssh
 
# echo "paste public key" > ~kino/.ssh/authorized_keys
 
# chown -R kino:users ~kino
 
# chmod 700 ~kino/.ssh
 
# chmod 600 ~kino/.ssh/authorized_keys
 
 
 
# echo "nobody:x:99:99:Nobody:/:/sbin/nologin" >> /etc/passwd
 
 
 
# echo "sshd: ALL" >> /etc/hosts.allow
 
</pre>
 
  
Add sshd to the startup daemons list.
+
=== Shut down the machine ===
<pre>
 
# vim /etc/rc.conf +/DAEMONS=
 
</pre>
 
  
If you don't want to reboot, use your new hostname and start ssh.
+
Check if the machine is currently running by looking at the <code>Current status</code> at the top of the Management Console's main menu. If it's currently running, it needs to be shut down. You may use option 4 in the main menu to force it to power off. It's about to be reformatted so a clean shutdown isn't really necessary.
 
<pre>
 
<pre>
# hostname tabi
+
4. force power off (destroy/hard shutdown)
# rc.d start sshd
 
 
</pre>
 
</pre>
  
Now you should be good to go!
+
=== Switch to rescue mode ===
 
 
===Pre-made tarball===
 
 
 
====Initial setup====
 
Setup is nearly identical to [[Untarring a fresh OS image]].
 
This guide will have some extra bloat just to keep everything in one place.
 
  
Boot into <code>CentOS 5.5 rescue (2.6.18-194.3.1.el5xen)</code> from pvgrub, and Log in as <tt>root</tt>.
+
Now that the machine is shut down, you should configure its bootloader to use the rescue image. For example, from the main menu the options would be something like this:
 
 
Set up partitons. This guide will use one partition, starting with a blank disk for simplicity.
 
 
<pre>
 
<pre>
[root@host ~]# dd if=/dev/zero of=/dev/xvda # (optional) wipes all your data
+
6. set bootloader or rescue mode
[root@host ~]# parted /dev/xvda
 
GNU Parted 1.8.1
 
Using /dev/xvda
 
Welcome to GNU Parted! Type 'help' to view a list of commands.
 
(parted) mklabel msdos
 
(parted) mkpart primary 0% 100%
 
(parted) quit
 
 
</pre>
 
</pre>
 
Make a filesystem, mount it, and enter it.
 
 
<pre>
 
<pre>
# mkfs.ext3 -L ARCHLINUX /dev/xvda1
+
3. Linux-based Live Rescue
# mount -n /dev/xvda1 /mnt
 
# cd /mnt
 
 
</pre>
 
</pre>
 
Download and extract Arch.
 
{|border="1"
 
|File
 
|ArchLinuxBase-i686.tar.gz
 
|ArchLinuxBase-x86_64.tar.gz
 
|-
 
|Download
 
|257 MiB
 
|320 MiB
 
|-
 
|Install
 
|470 MiB
 
|592 MiB
 
|}
 
 
<pre>
 
<pre>
# wget http://dl.dropbox.com/u/34148684/ArchLinuxBase-i686.tar.gz
+
2. Linux Live Rescue, 64 bit
# wget http://dl.dropbox.com/u/34148684/ArchLinuxBase-x86_64.tar.gz
 
# tar -zxf ArchLinuxBase*
 
 
</pre>
 
</pre>
Don't restart yet.
 
  
====Configuration====
+
After selecting the rescue image you will be prompted about adding SSH keys. This is optional, and is only necessary if you intend to SSH into the rescue image while it's running. This is not required for setting up Arch.
  
If you installed to somewhere other than <code>/dev/xvda1</code>, you will need to edit <code>boot/grub/menu.lst</code> to reflect the changes.
+
After enabling the rescue image, hit 0 a couple times until you're back at the main menu again.
  
Get the configuration details for a working network:
+
=== Start in rescue mode ===
Note the <tt>inet addr</tt> and <tt>mask</tt> in the output of <code>ifconfig eth0</code>
 
Note the IP in the <tt>gateway</tt> column in the output of <code>route</code>
 
Note the <tt>search</tt> and <tt>nameserver</tt> outputs of <code>cat /etc/resolv.conf</code>
 
  
This is all you need to know to configure Arch to connect to the internet.
+
Now that you have enabled booting into the rescue image, the machine can be started again. Select option 2 from the main menu:
Reboot into Arch after taking note of the information.
 
 
<pre>
 
<pre>
# shutdown -r now
+
2. create/start, opens OOB console (try this if the machine is not running)
 
</pre>
 
</pre>
  
Login as root and set the root password.
+
At this point the machine will be booted into the rescue image configured above. If you are presented with a GRUB prompt, you should select the option that looks like <code>Debian GNU/Linux, kernel <version>-amd64 Live Rescue</code>. If you don't see any GRUB prompt then don't worry about it.
<pre>
 
Arch Linux 2.6.37-xen  ((none)) (hvc0)
 
(none) login: root
 
[root@(none) ~]# passwd
 
</pre>
 
 
 
Note: nano is installed.
 
=====Network=====
 
Edit <code>/etc/resolv.conf</code> to look like what you wrote down.
 
 
 
Fill in the blanks of <code>/etc/rc.conf</code> to include your hostname, interface, address, netmask, broadcast, and gateway. Your hostname can be whatever you like. Your interface is <tt>eth0</tt>.
 
 
 
Append the hostname you chose to the line with 127.0.0.1 in <code>/etc/hosts</code>
 
 
 
=====General=====
 
 
 
Uncomment your preferred locale in <code>/etc/locale.gen</code> (en_US.UTF-8 uncommented in x86_64 tarball)
 
 
 
Set the same locale in <code>/etc/rc.conf</code>
 
 
 
Apply the locale with <code>locale-gen</code>
 
 
 
=====Extra/SSH=====
 
 
 
Add a user, add your public key, enable ssh privilege separation, and allow ssh connections.
 
<pre>
 
# adduser kino
 
 
 
# mkdir ~kino/.ssh
 
# echo "paste public key" > ~kino/.ssh/authorized_keys
 
# chown -R kino:users ~kino
 
# chmod 700 ~kino/.ssh
 
# chmod 600 ~kino/.ssh/authorized_keys
 
 
 
# echo "nobody:x:99:99:Nobody:/:/sbin/nologin" >> /etc/passwd
 
 
 
# echo "sshd: ALL" >> /etc/hosts.allow
 
</pre>
 
  
Add sshd to the startup daemons list.
+
After a minute or two of startup output, you should be presented with a login prompt:
 
<pre>
 
<pre>
# vim /etc/rc.conf +/DAEMONS=
+
Debian GNU/Linux 8 rescue ttyS0
</pre>
 
  
If you don't want to reboot, use your new hostname and start ssh.
+
rescue login:
<pre>
 
# hostname tabi
 
# rc.d start sshd
 
 
</pre>
 
</pre>
  
Done.
+
Log in as <code>root</code> with no password.
  
===Bootstrap script===
+
== Install Arch ==
  
====Initial setup====
+
You are now booted into a rescue image. Your VM's hard drive is located at <code>/dev/xvda</code> while the rescue image itself is located at <code>/dev/xvdz</code>. Installation of Arch can now proceed against <code>/dev/xvda</code>.
  
Reboot your VPS and select the CentOS rescue image.
+
If you wished to do so, at this point you could [https://wiki.archlinux.org/index.php/Install_from_existing_Linux install Arch by hand], but for the purposes of this guide, we will use some helper scripts which greatly simplify the initial setup. Feel free to examine and customize the scripts to meet your needs. For example, the scripts default to a single large root partition, while you may instead wish to have a customized partition table.
  
If you don't want to set up partitions (I didn't), just go ahead and make it ext3.
+
=== Download/run install scripts ===
  
<pre>
+
The scripts are provided in [https://github.com/prgmrcom/archinstall-scripts this repo] and can be installed as follows (or see the <code>README</code> within the repo):
# mkfs.ext3 /dev/xvda1
 
</pre>
 
  
Mount the drive into /mnt
+
'''WARNING: This is the point of no return. The script will destroy any and all data in your VM. Did you make backups? Did you check that the backups are good?'''
  
 
<pre>
 
<pre>
# mount -n /dev/xvda1 /mnt
+
cd /tmp
# cd /mnt
+
wget https://github.com/prgmrcom/archinstall-scripts/archive/master.zip
 +
unzip master.zip
 +
cd archinstall-scripts-master/
 +
./archinstall.sh
 
</pre>
 
</pre>
  
Download the install script and run it!
+
When the script has finished, it should display a message like the following before exiting:
  
 
<pre>
 
<pre>
# wget http://calimeroteknik.free.fr/arch-guide/install-chroot.sh
+
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
# chmod +x install-chroot.sh
+
finished
# ./install-chroot.sh
+
********
 +
root ~ #
 
</pre>
 
</pre>
  
When prompted give the following answers.
+
=== Follow install guide ===
  
Installation Directory: /mnt
+
The scripts should have taken care of the hardware aspects of configuring an Arch install, however you will still need to set up timezones, user accounts, passwords and so forth. For that you should follow the Arch [https://wiki.archlinux.org/index.php/Installation_guide Installation Guide], specifically starting where it has an <code>arch-chroot</code> command to switch into the Arch environment. In our case we can just perform a regular <code>chroot</code>:
 
 
Architecture: Your choice (32 or 64 bit)
 
 
 
Download Mirror: arm.konnichi.com/2010/12/29/
 
 
 
Using this old mirror is necessary due to the old kernel version of the CentOS rescue image (2.6.18).
 
Once the install script is complete a full system upgrade can be done using "pacman -Syu".
 
 
 
====Configuration====
 
 
 
The install script chroots for you. After entering the root password for your new system, you need to configure your Arch.
 
Specify DNS servers in /etc/resolv.conf. An example, using prgmr nameservers:
 
  
 
<pre>
 
<pre>
domain xen.prgmr.com
+
chroot /mnt
search xen.prgmr.com
 
nameserver 216.218.223.67
 
nameserver 38.99.2.224
 
 
</pre>
 
</pre>
  
Uncomment the desired locale in /etc/locale.gen then run locale-gen. The default is en_US.UTF-8 as seen in /etc/rc.conf.
+
Continue with the Arch installation guide from that point. Once you have finished the installation (and BEFORE restarting the system), see below for a few final steps.
An example /etc/locale.gen:
 
  
<pre>
+
If you do accidentally restart at the wrong time and find yourself with an unbootable system, you can [[#Recover from unbootable instance|regain access]] using the rescue image.
en_US.UTF-8 UTF-8 
 
en_US ISO-8859-1
 
</pre>
 
  
Add your / partition to /etc/fstab. Get your UUID from ls -l /dev/disk/by-uuid/. An example /etc/fstab:
+
== Finalize installation ==
  
<pre>
+
Once you have installed everything you need (for now), a couple additional steps are needed before you can reboot into the new image.
# <file system>        <dir>        <type>    <options>          <dump> <pass>
 
devpts                /dev/pts      devpts    defaults            0      0
 
shm                    /dev/shm      tmpfs    nodev,nosuid        0      0
 
  
UUID=185c4489-6eec-4b72-a479-c4cc207e7413 / ext3 defaults,noatime 0 1
+
=== Enable serial access ===
</pre>
 
  
Remove the default kernel, as we're installing the Xen one.
+
In order for your Arch image to be accessible via the Management Console, you must enable serial access via GRUB and the Linux console. Without these changes, it will not be accessible via the Management Console and it will appear to be unresponsive when booting up. These instructions assume that you're using GRUB2 (the default) and not GRUB Legacy.
  
 +
Edit <code>/etc/default/grub</code> as follows:
 
<pre>
 
<pre>
# pacman -Rsdn kernel26
+
GRUB_TERMINAL_INPUT=serial
</pre>
+
GRUB_TERMINAL_OUTPUT=serial
 +
GRUB_SERIAL_COMMAND="serial --speed 115200 --unit=0 --word=8 --parity=no --stop=1"
  
To build the Xen kernel, you'll need to install the make, gcc, and patch packages from the repositories.
+
GRUB_CMDLINE_LINUX_DEFAULT="YOUR_OPTIONS_HERE console=ttyS0,115200n8"
We'll also need xmlto and docbook-xsl as dependencies to the PKGBUILD.
 
 
 
<pre>
 
# pacman -S make gcc patch xmlto docbook-xsl
 
 
</pre>
 
</pre>
  
Download and untar the latest tarball of the kernel26-xen package.
+
The above settings will do the following:
 +
* The <code>GRUB_TERMINAL_INPUT</code> and <code>GRUB_TERMINAL_OUTPUT</code> lines tell GRUB to output to the Management Console during system startup. These default to <code>console</code>.
 +
* The <code>GRUB_SERIAL_COMMAND</code> setting configures that serial output from GRUB. It shouldn't be strictly required but it silences a configuration warning about default options. This setting is not present by default.
 +
* The added <code>console=...</code> parameter to the <code>GRUB_CMDLINE_LINUX_DEFAULT</code> tells the Linux kernel to enable terminal access via the Management Console. This parameter should be included in addition to any others that you specify, for example <code>"quiet console=ttyS0,115200n8"</code>.
  
 +
The above changes will only take effect after you have regenerated your GRUB configuration as follows:
 
<pre>
 
<pre>
# wget http://aur.archlinux.org/packages/kernel26-xen/kernel26-xen.tar.gz
+
grub-mkconfig -o /boot/grub/grub.cfg
# tar -xf kernel26-xen.tar.gz
 
# cd kernel26-xen
 
 
</pre>
 
</pre>
  
You'll need to uncomment the following line from the PKGBUILD file.
+
=== Enable IPv6 ===
 +
The helper scripts do not currently enable IPv6 for you. To do this, first [[Setting_up_IPv6|fetch your IPv6 address]].
  
 +
Using the example from the linked page with user cnryhilln, we would append the following lines to <code>/etc/systemd/network/prgmrDhcp.network</code> below <code>[Network]</code>
 
<pre>
 
<pre>
#pkgname=('kernel26-xen' 'kernel26-xen-headers') # Build kernel with a different name
+
Address=2605:2700:0:17::4713:9b0f/64
 +
Gateway=2605:2700:0:17::1
 
</pre>
 
</pre>
  
Build the package. This step will take a while, so grab some coffee and a scone.
+
If you've already rebooted into Arch, then <code>systemctl restart systemd-networkd.service && ip link set dev eth0 down && ip link set dev eth0 up</code>. Otherwise, just continue to follow the instructions below.
  
<pre>
+
=== Boot from Arch ===
# makepkg --asroot
 
</pre>
 
  
<blockquote>
+
Once you have finished configuring your new Arch system (including enabling serial access), you can now switch the boot process from the Rescue disk back to Arch.
If makepkg complains about extracting, then do it yourself for both, linux and patch archives and move them to src/. Then try makepkg again with no extract flag:
 
  
 +
# After you've installed and configured everything (don't forget to enable [[#configure serial access|serial access]]!), shut down the system with <code>shutdown -h now</code>. If you are in a chrooted environment then you may need to first exit that with <code>Ctrl+D</code>
 +
# Exit back to the Management Console with <code>Ctrl+]</code>
 +
# From the main menu of the Management Console, set the bootloader to boot from disk:
 
<pre>
 
<pre>
# makepkg --asroot -e
+
6. set bootloader or rescue mode
 
</pre>
 
</pre>
</blockquote>
 
 
Install the packages you just built:
 
 
 
<pre>
 
<pre>
# pacman -U kernel26-xen-VERSION-x86_64.pkg.tar.gz
+
1. Boot from disk
# pacman -U kernel26-xen-headers-VERSION-x86_64.pkg.tar.gz
 
 
</pre>
 
</pre>
 
+
# Go back to the main menu of the Management Console by pressing 0, then start the system again. If it's currently running (did you run <code>shutdown</code>?) then you can just reboot it first.
Add the following xen modules to your initcpio by appending the following to MODULES in /etc/mkinitcpio.conf: "xen-blkfront xen-fbfront xenfs xen-netfront xen-kbdfront" and rebuild your initcpio:
 
 
 
 
<pre>
 
<pre>
mkinitcpio -p kernel26-xen
+
2. create/start, opens OOB console (try this if the machine is not running)
 
</pre>
 
</pre>
  
Install grub
+
At this point you should boot into your new Arch system. If it fails to boot, you don't need to start over again, instead you can just switch back to the rescue image and make any needed repairs:
 
 
<pre>
 
pacman -S grub
 
</pre>
 
  
Edit boot/grub/menu.lst and fill it with the following:
+
== Recover from unbootable instance ==
 
 
<pre>
 
timeout 5
 
default 0
 
  
# (0) Arch Linux
+
If you forgot to do something when setting up your Arch image, it's possible that it will be left in an unbootable state when you attempt to boot into it. These steps will allow you to access and repair the instance without needing to reinstall from scratch:
title  Arch Linux
 
root  (hd0,0)
 
kernel /boot/vmlinuz26-xen root=/dev/xvda1 ro console=hvc0
 
initrd /boot/kernel26-xen.img
 
</pre>
 
  
Edit /etc/inittab and remove/comment these
+
# Follow the [[#Switch to rescue mode|above instructions]] to switch the VM's bootloader back to the rescue image, and then log into the rescue image (again).
 +
# From the rescue image, you can mount your Arch disk as follows (assuming that your root partition is at <code>/dev/xvda1</code>):
  
 
<pre>
 
<pre>
# -8 options fixes umlauts problem on login
+
mount /dev/xvda1 /mnt
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
 
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
 
c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
 
c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
 
c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
 
c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
 
</pre>
 
  
Uncomment this
+
mount --rbind /proc /mnt/proc
 +
mount --rbind /sys /mnt/sys
 +
mount --rbind /dev /mnt/dev
 +
mount --rbind /run /mnt/run
  
<pre>
+
chroot /mnt
# Hypervisor Virtual Console for Xen and KVM
 
# h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux
 
 
</pre>
 
</pre>
  
To avoid hwclock error messages, set HARDWARECLOCK="xen" in /etc/rc.conf (actually you can use any value here except "UTC" and "localtime")
+
From here you should be able to make any needed repairs to your Arch image.
  
Install SSH and configure it (http://wiki.archlinux.org/index.php/SSH)
+
== Bibliography ==
 
 
<pre>
 
# pacman -S openssh
 
</pre>
 
  
Reboot your VPS and you should be good to go!
+
Some reference info that you may find useful. In general, the [https://wiki.archlinux.org Arch Wiki] is an extremely useful resource for getting your new system up and running, even if you aren't necessarily running Arch.
  
{{u}} {{distros}}
+
* [https://wiki.archlinux.org/index.php/General_recommendations#Users_and_groups Setting Up a New User] -- Definitely should do this!!
 +
* [https://wiki.archlinux.org/index.php/General_recommendations#Networking Networking]
 +
* [https://wiki.archlinux.org/index.php/General_recommendations#Console_improvements Console Improvements]
 +
* [https://wiki.archlinux.org/index.php/List_of_applications Available Applications]
 +
* [[Accessing your guest from the rescue image|Booting into the rescue image]]

Latest revision as of 08:29, 21 September 2018

The purpose of this document is to provide the minimum necessary information to get Arch up and reasonably secure.

The Arch Wiki has a page devoted to installing Arch Linux from within an existing Linux, which effectively describes the underlying steps being performed here. The following steps apply that process to a VM on prgmr.

Accessing the Management Console

You need to access the Management Console for your VM. If you're not familiar with this, please see Management Console. The following instructions assume that you are NOT using the legacy console.

Boot from rescue image

The install will be performed from a Rescue image. This is equivalent to booting off a Rescue CD or USB stick, except the process is fully remote. We must configure the VM to boot off the Rescue image, which we will use as a starting point for installing Arch into the VM disk. For more information, see accessing your guest from the rescue image. After install has completed, the VM will be switched back to booting directly from its main disk which contains the new Arch installation.

Shut down the machine

Check if the machine is currently running by looking at the Current status at the top of the Management Console's main menu. If it's currently running, it needs to be shut down. You may use option 4 in the main menu to force it to power off. It's about to be reformatted so a clean shutdown isn't really necessary.

4. force power off (destroy/hard shutdown)

Switch to rescue mode

Now that the machine is shut down, you should configure its bootloader to use the rescue image. For example, from the main menu the options would be something like this:

6. set bootloader or rescue mode
3. Linux-based Live Rescue
2. Linux Live Rescue, 64 bit

After selecting the rescue image you will be prompted about adding SSH keys. This is optional, and is only necessary if you intend to SSH into the rescue image while it's running. This is not required for setting up Arch.

After enabling the rescue image, hit 0 a couple times until you're back at the main menu again.

Start in rescue mode

Now that you have enabled booting into the rescue image, the machine can be started again. Select option 2 from the main menu:

2. create/start, opens OOB console (try this if the machine is not running)

At this point the machine will be booted into the rescue image configured above. If you are presented with a GRUB prompt, you should select the option that looks like Debian GNU/Linux, kernel <version>-amd64 Live Rescue. If you don't see any GRUB prompt then don't worry about it.

After a minute or two of startup output, you should be presented with a login prompt:

Debian GNU/Linux 8 rescue ttyS0

rescue login:

Log in as root with no password.

Install Arch

You are now booted into a rescue image. Your VM's hard drive is located at /dev/xvda while the rescue image itself is located at /dev/xvdz. Installation of Arch can now proceed against /dev/xvda.

If you wished to do so, at this point you could install Arch by hand, but for the purposes of this guide, we will use some helper scripts which greatly simplify the initial setup. Feel free to examine and customize the scripts to meet your needs. For example, the scripts default to a single large root partition, while you may instead wish to have a customized partition table.

Download/run install scripts

The scripts are provided in this repo and can be installed as follows (or see the README within the repo):

WARNING: This is the point of no return. The script will destroy any and all data in your VM. Did you make backups? Did you check that the backups are good?

cd /tmp
wget https://github.com/prgmrcom/archinstall-scripts/archive/master.zip
unzip master.zip
cd archinstall-scripts-master/
./archinstall.sh

When the script has finished, it should display a message like the following before exiting:

~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
finished
********
root ~ #

Follow install guide

The scripts should have taken care of the hardware aspects of configuring an Arch install, however you will still need to set up timezones, user accounts, passwords and so forth. For that you should follow the Arch Installation Guide, specifically starting where it has an arch-chroot command to switch into the Arch environment. In our case we can just perform a regular chroot:

chroot /mnt

Continue with the Arch installation guide from that point. Once you have finished the installation (and BEFORE restarting the system), see below for a few final steps.

If you do accidentally restart at the wrong time and find yourself with an unbootable system, you can regain access using the rescue image.

Finalize installation

Once you have installed everything you need (for now), a couple additional steps are needed before you can reboot into the new image.

Enable serial access

In order for your Arch image to be accessible via the Management Console, you must enable serial access via GRUB and the Linux console. Without these changes, it will not be accessible via the Management Console and it will appear to be unresponsive when booting up. These instructions assume that you're using GRUB2 (the default) and not GRUB Legacy.

Edit /etc/default/grub as follows:

GRUB_TERMINAL_INPUT=serial
GRUB_TERMINAL_OUTPUT=serial
GRUB_SERIAL_COMMAND="serial --speed 115200 --unit=0 --word=8 --parity=no --stop=1"

GRUB_CMDLINE_LINUX_DEFAULT="YOUR_OPTIONS_HERE console=ttyS0,115200n8"

The above settings will do the following:

  • The GRUB_TERMINAL_INPUT and GRUB_TERMINAL_OUTPUT lines tell GRUB to output to the Management Console during system startup. These default to console.
  • The GRUB_SERIAL_COMMAND setting configures that serial output from GRUB. It shouldn't be strictly required but it silences a configuration warning about default options. This setting is not present by default.
  • The added console=... parameter to the GRUB_CMDLINE_LINUX_DEFAULT tells the Linux kernel to enable terminal access via the Management Console. This parameter should be included in addition to any others that you specify, for example "quiet console=ttyS0,115200n8".

The above changes will only take effect after you have regenerated your GRUB configuration as follows:

grub-mkconfig -o /boot/grub/grub.cfg

Enable IPv6

The helper scripts do not currently enable IPv6 for you. To do this, first fetch your IPv6 address.

Using the example from the linked page with user cnryhilln, we would append the following lines to /etc/systemd/network/prgmrDhcp.network below [Network]

Address=2605:2700:0:17::4713:9b0f/64
Gateway=2605:2700:0:17::1

If you've already rebooted into Arch, then systemctl restart systemd-networkd.service && ip link set dev eth0 down && ip link set dev eth0 up. Otherwise, just continue to follow the instructions below.

Boot from Arch

Once you have finished configuring your new Arch system (including enabling serial access), you can now switch the boot process from the Rescue disk back to Arch.

  1. After you've installed and configured everything (don't forget to enable serial access!), shut down the system with shutdown -h now. If you are in a chrooted environment then you may need to first exit that with Ctrl+D
  2. Exit back to the Management Console with Ctrl+]
  3. From the main menu of the Management Console, set the bootloader to boot from disk:
6. set bootloader or rescue mode
1. Boot from disk
  1. Go back to the main menu of the Management Console by pressing 0, then start the system again. If it's currently running (did you run shutdown?) then you can just reboot it first.
2. create/start, opens OOB console (try this if the machine is not running)

At this point you should boot into your new Arch system. If it fails to boot, you don't need to start over again, instead you can just switch back to the rescue image and make any needed repairs:

Recover from unbootable instance

If you forgot to do something when setting up your Arch image, it's possible that it will be left in an unbootable state when you attempt to boot into it. These steps will allow you to access and repair the instance without needing to reinstall from scratch:

  1. Follow the above instructions to switch the VM's bootloader back to the rescue image, and then log into the rescue image (again).
  2. From the rescue image, you can mount your Arch disk as follows (assuming that your root partition is at /dev/xvda1):
mount /dev/xvda1 /mnt

mount --rbind /proc /mnt/proc
mount --rbind /sys /mnt/sys
mount --rbind /dev /mnt/dev
mount --rbind /run /mnt/run

chroot /mnt

From here you should be able to make any needed repairs to your Arch image.

Bibliography

Some reference info that you may find useful. In general, the Arch Wiki is an extremely useful resource for getting your new system up and running, even if you aren't necessarily running Arch.