Manjaro cloud instance using cloud-init

Minimal CLI system using VirtualBox

Use any Manjaro ISO but at the boot menu edit the free drivers item by pressing e and append 3 to the linux line.

When booted to the terminal - login using root:manjaro

1. Keyboard If tyou need a differenct keyboard than us then use loadkeys followed by a country code e.g. for Denmark

# loadkeys dk

2. System time Ensure system time is correct - necessary for SSL certificates

# systemctl enable --now systemd-timesyncd

3. Mirror and branch We use pacman-mirrors to set a mirror and the desired branch.

# pacman-mirrors --api --set-branch unstable --url

You can replace the branch with stable or testing and you can remove the --url argument and use e.g. --continent for closer mirrors.

4. Database and keyrings Ensure pacman is up-to-date, download the databases and install keyrings

# pacman -Syy pacman archlinux-keyring manjaro-keyring

5. Trust database Create trust database, populate and refresh keys

# pacman-key --init
# pacman-key --populate archlinux manjaro
# pacman-key --refresh-keys

If for some reason the above fails on the last command you need to specify a keyserver - and to mention a few


3. Partitioning disk

root@ubuntu:~# lsblk 
loop0     7:0    0   31M  1 loop /snap/snapd/9607
loop1     7:1    0 55.3M  1 loop /snap/core18/1885
loop2     7:2    0 70.6M  1 loop /snap/lxd/16922
vda     252:0    0   25G  0 disk 
├─vda1  252:1    0 24.9G  0 part /
├─vda14 252:14   0    4M  0 part 
└─vda15 252:15   0  106M  0 part /boot/efi
# cfdisk --zero /dev/sda

Using MBR

  • Select dos partition type
  • Create one partition primary
  • Format
    # mkfs.ext4 -L MJROROOT  /dev/sda1
  • Mount
    # mount /dev/sda1 /mnt

Using GPT

  • Select gpt
  • Create a small (8MB) unformatted partition - partition type BIOS boot (0xEF02)
  • Create the root partition
  • Format
    # mkfs.ext4 -L MJROROOT /dev/sda2
  • Mount
    # mount /dev/sda2 /mnt

6. Base installation

Use basestrap command to install a base set of packages into the newly mounted root

# basestrap /mnt base linux54 dhcpcd grub mkinitcpio vi nano sudo links openssh firewalld

7. Base configuration

# manjaro-chroot /mnt /bin/bash

Console keyboard

Set console keyboard in /etc/vconsole.conf



To generate the messages edit /etc/locale.gen and remove the comment for locale(s) to be generated (UTF-8 is the recommend choice).

Select locale Example for a system in Denmark using english messages

en_US.UTF-8 UTF-8

Generate the messages

# locale-gen

locale.conf Edit your locale configuration in /etc/locale.conf to match above choice - example for Denmark



Set the time zone for location (the available zones is listed in /usr/share/zoneinfo/ using the Continent/Capitol format).

Symlink the time zone as /etc/localtime - example for Denmark

# ln -sf /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime


Linux clock runs using the timezone info and UTC time.

# hwclock --systohc --utc


Set hostname

# echo manjaro > /etc/hostname

Hosts configuration

# nano /etc/hosts    localhost
::1          localhost    manjaro.localdomain manjaro

Note: If the system has a static IP replace with the IP.

System administration

Allow members of the wheel group to perform administrative tasks.

Run visudo

# visudo

Locate the line reading # %wheel ALL=(ALL) ALL and remove the # in the beginning of the line

%wheel ALL=(ALL) ALL

Enable dhcp network

# systemctl enable dhcpcd

Enable ssh service

# systemctl enable sshd

Time syncronization

Enable timesync daemon

# systemctl enable systemd-timesyncd

Root password

Set a password the root user

# passwd


# pacman -S cloud-init

Edit /etc/cloud/cloud.cfg add the line

datasource_list: [ ConfigDrive, OpenNebula, DigitalOcean, Azure, AltCloud, OVF, MAAS, GCE, OpenStack, CloudSigma, SmartOS, None, NoCloud  ]

In the section cloud_init_modules remember to remove the line specifying growpart unless you have build and installed the growpart package from AUR.

Edit the section system_info - edit the section as preferred.

Enable the following services

# systemctl enable cloud-init.service cloud-final.service

8. Bootloader

Build the initramfs and install and setup grub


Build the initramfs according to your chosen kernel e.g. linux54

# mkinitcpio -p linux54


# grub-install --target=i386-pc /dev/sda

Edit the default grub configuration /etc/default/grub and adjust to match your setup e.g. you can use the label or you can use device path for your root partition

GRUB_CMDLINE_LINUX_DEFAULT=".. root=/dev/sdaX ..."



and uncomment the following line


Generate grub configuration

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

Close chroot

# exit

Unmount the partitions

# umount -R /mnt

Testing the image is booting

After you have booted your image - check the folder /run/cloud-init for non-trivial messages. Remember to eject the ISO you used for installation Clean your image and the cloud-init before shutting down

# pacman -Scc
# cloud-init clean
# systemctl poweroff

Then compress the VDI image - best result

# bzip2 --best -k your-vm-disk.vdi