November 21 2015

Arch Linux on 1and1 Cloud Server

Migrated from TimGarrity.me

With the inclusion of 1&1’s VMWare-based cloud servers, comes the ability to finally be able to install our OSes directly using the OS ISO rather than 1and1.com’s pre-created image. The goal of this article is that when we’re finished, we’ve figured out a way to install unsupported operating systems on to an NGCS VM without being able to use VMWare’s DVD or USB drive.

Now, as a disclaimer, this was the first time working on a task like this in all my years of running Linux. How often do you really find yourself without a USB drive or a CD/DVD? Also, 1&1’s stance is to provide support for the Hardware, and not the software, so they don’t support the OS and you can be sure they don’t support an OS that they have vetted. So please don’t do this on a live server that you wish to run your business off of unless you know exactly what it is you’re doing.

Preresequites:

  • Cloud Server S ($4.99)
  • CentOS7 ISO – Don’t choose image, as we want to make sure we parition to our liking.
  • ArchLinux ISO – to be downloaded after VM is spun up

Since we’re installing via the CentOS ISO, we’re going to need the use the KVM. So first, let’s create our VM:

2015-11-16 09_33_29-1&1 Control Panel

When complete, go ahead and load up the KVM Console. The creation strangely takes 2minutes, though creating a container with a preconfigured Image in cache takes 55seconds. IDK.
A few things I did, I used a 1GB swap and an 8GB main partition. Since I’m going to blow the 8GB CentOS install away later for ArchLinux, that seemed like a safe bet. However, you may want more or less swap space.

2015-11-16 09_36_27-ArchLinux Tutorial

2015-11-16 09_36_56-ArchLinux Tutorial

2015-11-16 09_37_23-ArchLinux Tutorial

2015-11-16 09_39_37-ArchLinux Tutorial

Remember to turn your Network Settings on so we don’t have to stay working in the KVM and can do things like Copy/Paste via SSH.

2015-11-16 09_39_56-ArchLinux Tutorial

2015-11-16 09_40_24-ArchLinux Tutorial

 

While you’re waiting for everything, maybe put on some music.

2015-11-16 09_42_34-Program Manager

 

Then finally, when all said and done, you should be able to start booting into CentOS7

2015-11-16 09_46_49-ArchLinux Tutorial

So let’s grab our IP Address and ssh into the machine

2015-11-16 09_47_02-1&1 Control Panel

# ssh [email protected]

[[email protected] ~]#

Now, we’re going to need wget to download our image. So let’s have Yum take over for that:

# yum install -y wget

Now we get our image from the mirror. Find the best one for you by going to https://www.archlinux.org/download/ . I chose http://mirrors.advancedhosters.com/archlinux/iso/2015.11.01/archlinux-2015.11.01-dual.iso

# wget http://mirrors.advancedhosters.com/archlinux/iso/2015.11.01/archlinux-2015.11.01-dual.iso

We’re now going to want to keep everything nice and orderly. This is helpful if you were keeping CentOS7 to stay, and just livebooting other OSes. So let’s create an “/iso” folder and move our file there.

# mkdir /iso 
# mv archlinux-2015.11.01-dual.iso /iso/archlinux.iso

Now, we have our image where we need it, renamed it so it’s easily remembered. Now we need to update grub to boot from it. Luckily I’ve tested this all out in VMWare so I have this down to a science now. First, we’re going to want to do two things. Let’s find out what sda we’re working with, let’s create a partition for Arch, then create a FS for Arch to install into, and THEN we’ll edit grub.

# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000affa2

 Device Boot Start End Blocks Id System
/dev/sda1 * 2048 16386047 8192000 83 Linux
/dev/sda2 16386048 18434047 1024000 82 Linux swap / Solaris

# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type:
 p primary (2 primary, 0 extended, 2 free)
 e extended
Select (default p): p
Partition number (3,4, default 3):
First sector (18434048-62914559, default 18434048):
Using default value 18434048
Last sector, +sectors or +size{K,M,G} (18434048-62914559, default 62914559):
Using default value 62914559
Partition 3 of type Linux and of size 21.2 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

# shutdown -r now
Connection to 70.35.206.163 closed by remote host.
Connection to 70.35.206.163 closed.

We rebooted so that sda3 could sync. Let’s jump back into the server when it’s back up

# ssh [email protected]
# mkfs.ext4 /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1392640 inodes, 5560064 blocks
278003 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2153775104
170 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Now we’re good to go with editing grub, knowing that we need to mount the ArchISO to boot with sda1, though we’ll be installing to sda3

# vi /etc/grub.d/40_custom
menuentry "Archlinux" {
 set isofile="/iso/archlinux.iso"
 loopback loop (hd0,1)$isofile
 linux (loop)/arch/boot/i686/vmlinuz img_dev=/dev/sda1 img_loop=$isofile earlymodules=loop
 initrd (loop)/arch/boot/i686/archiso.img
 boot
}

:wq
#

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Warning: Please don't use old title `CentOS Linux, with Linux 3.10.0-123.el7.x86_64' for GRUB_DEFAULT, use `Advanced options for CentOS Linux>CentOS Linux, with Linux 3.10.0-123.el7.x86_64' (for versions before 2.00) or `gnulinux-advanced-89f6069e-b33b-4d18-aa43-bf2cd5702846>gnulinux-3.10.0-123.el7.x86_64-advanced-89f6069e-b33b-4d18-aa43-bf2cd5702846' (for 2.00 or later)
Found linux image: /boot/vmlinuz-0-rescue-d1222860536444a9811e04e8990a10ff
Found initrd image: /boot/initramfs-0-rescue-d1222860536444a9811e04e8990a10ff.img
done
#

So now….let’s do this, let’s get back into the KVM and reboot the server

 

We’re going to need to mount sda3 into the /mnt folder, and start the install process.

# mount /dev/sda3 /mnt

Now, we follow the ArchLinux install guide https://wiki.archlinux.org/index.php/Installation_guide#Install_the_base_packages

# pacstrap /mnt base

After you’ve finsihed the install and following that guide, you’ll get to the bootloader. Here we’re going to override and pretend that centOS never existed and just reinstall grub. An alternative approach would have been to add a menuentry for Arch to centOS’s GRUB menu or vice versa, but we’re not dual-booting here.

# pacman -S grub-bios
# grub-install /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg

Now, centOS is lost in the partitions. We are now Arch Linux. Let’s exit out of this chroot and reboot.

# exit
# reboot

So now we’re on ArchLinux, but…..we’re a remote server with no network capability. This is because our network interface doesn’t know it should be turned on and getting an IP from dhcp. So lets use the KVM and find out what the name of our NIC is.

# ls /sys/class/net
lo en01234567

Here we see our LoopBack is lo, and our Ethernet is en01234567. That’s a hell of a name to remember, so let’s change it to something simple like net0. First get the Mac Address and then edit the network interface and reboot

# ip link show en01234567
en01234567: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
    link/ether 08:00:27:23:6f:3a brd ff:ff:ff:ff:ff:ff

# ip link set en01234567 down
# vi /etc/udev/rules.d/10-network.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="08:00:27:23:6f:3a", NAME="net0"
:wq

# udevadm --debug test /sys/class/net/en01234567
# reboot

# systemctl enable [email protected]net0.service
# reboot

Now everything should be working and you should be able to install ssh and get out of the KVM. We’re going to allow root to login for now, but later, stick to better security measures.

# pacman -S openssh

# vi /etc/ssh/sshd_config
....
..
PERMITROOTLOGIN YES
:wq

# systemctl start openssh

 

And that’s it. We can now do what we’d like with our ArchLinux.

Maybe nexttime, we can get rid of the safety nets, mount the ArchLinux iso into /dev/sda3 and install directly onto the primary. I’d suspect that a better setup would have been 1GB Swap as sda1, 25GB SDA2 for Centos, then a 4GB parition to mount archlinux.iso into. Then we could have overridden sda2 with our ArchLinux install, and good, but for now, we have a safety net of going back to centos if things get foobar’d.


Tags: , , ,
Copyright 2020. All rights reserved.

Posted November 21, 2015 by timgarrity89_a1y6u17p in category "1&1 Internet", "Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.