Wednesday, May 8, 2013

Installing text-mode Arch Linux in Virtualbox

First install Virtualbox. An installer for Windows is available on the Virtualbox site download page. In another Arch Linux box:

host # pacman --noconfirm -S virtualbox
host # gpasswd -a ant vboxusers
host # echo vboxdrv >/etc/modules-load.d/virtualbox.conf

Replace ant with your username, and use a newly open terminal to run Virtualbox:

master $ Virtualbox &

Then New, Name: Arch Linux Tests, 256 MB, Dynamically allocated virtual HD, 8GB.

Then head to the Arch Linux download page and download latest image, e.g. using Torrent. Machine, Settings, Storage, Controller IDE, Empty, click on the small CD-ROM button on the right hand side, Choose a Virtual CD/DVD disk file, point to archlinux-2013.05.01-dual.iso. Start, Boot Arch Linux (x86_64). Make sure your host computer stays connected to the Internet, because some commands you issue on the guest will need a working network connection.

If you do not have a US keyboard issue:

guest # loadkeys keymap

where keymap is the value of KEYMAP you find in this table row for your country, or using this command (ignore the .map.gz extension and use only the file name as the keymap variable value):

guest # ls /usr/share/kbd/keymaps/i386/qwerty


guest # ntpd -qg
guest # hwclock -w

guest # cgdisk /dev/sda

New, accept all defaults, then Write and confirm by typing yes. Quit.

guest # mkfs.ext4 /dev/sda1
guest # mount /dev/sda1 /mnt
guest # pacstrap /mnt base base-devel
guest # genfstab -U -p /mnt >> /mnt/etc/fstab
guest # arch-chroot /mnt pacman --noconfirm -S syslinux gptfdisk
guest # arch-chroot /mnt /bin/bash
guest # mkinitcpio -p linux

guest # echo "archlinux" > /etc/hostname
You may choose a different hostname than archlinux.

guest # echo "KEYMAP=keymap" > /etc/vconsole.conf

where keymap is that chosen before (e.g. us).

guest # ln -s /usr/share/zoneinfo/Europe/Rome /etc/localtime

Change Europe and Rome if you are not in Italy.

guest # sed -ri -e 's/^#(en_US.UTF-8)/\1/' /etc/locale.gen
guest # locale-gen
guest # echo LANG=en_US.UTF-8 > /etc/locale.conf
guest # hwclock --systohc --utc

guest # passwd

Set a root password.

guest # syslinux-install_update -iam
guest # sed -ri -e 's/sda3/sda1/' /boot/syslinux/syslinux.cfg

guest # exit
guest # umount /mnt
guest # poweroff

Machine, Settings, Storage, right click on archlinux-2013.05.01-dual.iso, Remove Attachment, Remove, Machine, Start. Login as root.

guest # useradd -m -g users -s /bin/bash ant
guest # passwd ant

guest # systemctl enable dhcpcd@enp0s3.service
guest # systemctl start dhcpcd@enp0s3
guest # pacman --noconfirm -S virtualbox-guest-utils
guest # echo -e 'vboxguest\nvboxsf\nvboxvideo' >/etc/modules-load.d/virtualbox.conf
guest # modprobe -a vboxguest vboxsf vboxvideo

Console mouse support:
guest # pacman --noconfirm -S gpm
guest # systemctl start gpm.service
guest # systemctl enable gpm.service

Synchronize clock with host:
guest # systemctl enable vboxservice.service
guest # systemctl start vboxservice.service

Optional: ability to locate files:
guest # pacman --noconfirm mlocate

Optional: text mode browser

guest # pacman --noconfirm elinks

Optional: Support for host-only and bridged network interface:
guest # pacman --noconfirm -S net-tools
host #  pacman --noconfirm -S virtualbox-host-modules
host # modprobe -a vboxnetadp vboxnetflt vboxpci
host # echo -e 'vboxnetadp\nvboxnetflt\nvboxpci' >>/etc/modules-load.d/virtualbox.conf
host # pacman --noconfirm -S net-tools

Optional: install yaourt
guest # pacman --noconfirm -S wget yajl
guest # su - ant
guest $ cd /tmp
guest $ wget
guest $ tar zxf package-query.tar.gz
guest $ cd package-query
guest $ makepkg -c
guest $ su -c 'pacman --noconfirm -U package-query-*.tar.gz'
guest $ cd ..
guest $ wget
guest $ tar zxf yaourt.tar.gz
guest $ cd yaourt
guest $ makepkg -c
guest $ exit
guest # cd /tmp/yaourt
guest # pacman --noconfirm -U yaourt-1.3-*.tar.xz

Optional: ssh access (useful if you have to copy and paste a lot of commands between host and guest or viceversa). Requires bridge interface, see above.
guest # pacman --noconfirm -S openssh
guest # systemctl start sshd
guest # systemctl enable sshd.service
guest # poweroff
Settings,Network,Attached to,Bridged Adapter,Start.


1 comment:

Louis Tim Larsen said...

Nice post.

Had a problem with the network in Arch in Virtualbox.

Your guide gave a quick and nice solution and some other useful tips too - thank you :)