Here is my simple tutorial to create an Arch Linux based Vagrant base box.
First, download the Arch Linux iso on this page.
Now, create a new virtual machine:
- Click „New“
- Name „Vagrant Arch Linux“
- Set „Memory size“ to 1024MB
- Select „Create a virtual hard disk now“
- Click „Create“
- Set „File size“ to 100GB
- Click „Create“
After creating the virtual machine, change the settings:
- Select the virtual machine and click „Settings“
- Select „Storage“, select the „empty“ under „Controller: IDE“
- Click on the upper right corner on the DVD icon an select „Choose Virtual Optical Disk File…“
- Select the downloaded Arch Linux iso and click „Open“
- Click „OK“
Finally, you can run the virtual machine by clicking „Start“. You will prompted with several boot options, choose the first (or the second, if you have an x86 system).
For the installation, I’m using the following commands to create a real minimalistic Arch Linux installation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# loadkezs de (y=z) # loadkeys de-latin1 # nano /etc/pacman.d/mirrorlist - copy any server entry to the first line - ctrl+x (exit) - y (confirm write) # gdisk /dev/sda Command (? for help): n Partition number (1-128, default 1): ENTER First Sector [...]: ENTER Last Sector [...]: ENTER Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): ENTER Changed type of partition to 'Linux filesystem' - w (write) - y (confirm write) # mkfs.ext4 /dev/sda1 # mount /dev/sda1 /mnt # pacstrap /mnt base # genfstab -p /mnt > /mnt/etc/fstab # arch-chroot /mnt # echo archlinux > /etc/hostname # echo LANG=de_DE.UTF-8 > /etc/locale.conf # echo LC_COLLATE=C >> /etc/locale.conf # echo KEYMAP=de-latin1 > /etc/vconsole.conf # ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime # nano /etc/locale.gen - uncomment: de_DE.UTF-8 UTF-8 de_DE ISO-8859-1 de_DE@euro ISO-8859-15 - ctrl+x (exit) - y (confirm write) # locale-gen # nano /etc/pacman.conf - uncomment: [multilib] Include = /etc/pacman.d/mirrorlist - ctrl+x (exit) - y (confirm write) # pacman -Sy gptfdisk syslinux xz sudo networkmanager openssh rsync nfs-utils ntp virtualbox-guest-utils-nox - y (confirm) # nano /etc/mkinitcpio.conf - change: HOOKS="base udev autodetect ..." - to: HOOKS="systemd autodetect ..." - uncomment: COMPRESSION="xz" - uncomment and change: COMPRESSION_OPTIONS="" - to: COMPRESSION_OPTIONS="-9" - ctrl+x (exit) - y (confirm write) # mkinitcpio -p linux # passwd Enter new UNIX password: vagrant Retype new UNIX password: vagrant passwd: password updated successfully # nano /boot/syslinux/syslinux.cfg - change: APPEND root=/dev/sda3 rw - to: APPEND root=/dev/sda1 rw - comment following labels: archfallback, hdt, reboot and poweroff - ctrl+x (exit) - y (confirm write) # syslinux-install_update -iam # nano /etc/sudoers - uncomment: %wheel ALL=(ALL) NOPASSWD: ALL - ctrl+x (exit) - y (confirm write) # nano /etc/ntp.conf - change: server [0-3].arch.pool.ntp.org - to: server [0-3].de.pool.ntp.org # ntpd -gq # useradd -m -g users -s /bin/bash vagrant # gpasswd -a vagrant wheel # gpasswd -a vagrant vboxsf # passwd vagrant Enter new UNIX password: vagrant Retype new UNIX password: vagrant passwd: password updated successfully # systemctl enable sshd # systemctl enable vboxservice # systemctl enable rpcbind # systemctl enable ntpd # systemctl enable NetworkManager # mkdir -p /home/vagrant/.ssh # wget -L -o /home/vagrant/.ssh/authorized_keys http://git.io/vagrant-insecure-public-key # chmod 0600 /home/vagrant/.ssh/authorized_keys # chmod 0700 /home/vagrant/.ssh # chown -R vagrant:users /home/vagrant # exit # umount -R /mnt # systemctl reboot - cleanup, login as root # pacman -Scc --noconfirm # rm -rf /var/log/journal/* /var/log/old/* /var/log/faillog /var/log/lastlog /var/log/pacman.log # rm -f /home/vagrant/.bash_history # rm -f /root/.bash_history # cd /root # dd if=/dev/zero of=zerofillfile bs=1M # rm -f zerofillfile # history -c # systemctl poweroff |
Now you can create and add a base box by the following command:
1 2 |
vagrant package --base "Vagrant Arch Linux" vagrant box add "archlinux/base" package.box |
Done!