Skip to content

Configuring LXC/LXD ssh keys on Ubuntu 16.04

Adding Authorized Keys to the LXD Default Profile is easy but not really! 🙂

Adding your key is as simple as:

$ lxc profile edit default

You will then need to modify the contents from:

config: {}


  user.user-data: |
     - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDPUdIskr4iSVZnPylV+5QsvHjoh63CbF1Q2bw3ptJZpa2x2UoMT7ikhaXiEVxfOavC4JPYgcPv3hzgZlM6PHfG3mm7vVyL/8CkYiFugjLyL8OQP/dyss7TzrQrE0px9Li+7OyMc3bF3z1SmjooZ1xWFS7QDYRNbb00dXyZ9jdT5H+H8Qt/IfNy7qLRluRCLDQ4VYD6kBjgMCQ+ZIqRiTaGtVLZIhwxenKIpPEfjNwDWFjsq8nEoM6CIsah79SnPnpaeM0
description: Default LXD profile

Where the ssh_authorized_key is your public key, probably identified by cat ~/.ssh/

Posted in Knowledge Base.

Tagged with , , .

March’s presentation at the DevOpsMtl, Metal edition – MAAS and Juju

I have been working a lot with all cloud related these days and this March I gave a talk about MAAS and Juju. You can take a look at it here.

MAAS and Juju Introduction
Description: Introduction to MAAS and Juju. Metal As A Service brings the language of the cloud to physical servers. In other words it delivers real Hardware equipment on demand. MAAS works closely with the service orchestration tool Juju to make deploying services fast, reliable, repeatable and scalable.
Language: English with snippets of French in the middle.

Posted in Knowledge Base.

Tagged with , , , , .

How to configure sysstat/sar on Ubuntu/Debian


This article describes how to install and use sysstat (sar) a system performance tools for Linux. According to the package description it includes the following system performance tools:
– sar: collects and reports system activity information;
– iostat: reports CPU utilization and disk I/O statistics;
– mpstat: reports global and per-processor statistics;
– pidstat: reports statistics for Linux tasks (processes);
– sadf: displays data collected by sar in various formats.

The statistics reported by sar deal with I/O transfer rates,  paging activity, process-related activities, interrupts,  network activity, memory and swap space utilization, CPU  utilization, kernel activities and TTY statistics, among others. Both UP and SMP machines are fully supported.

Step 1.  Install sysstat
sudo apt-get install sysstat

Step 2. Enable stat collection
sudo vi /etc/default/sysstat
change ENABLED=”false” to ENABLED=”true”
save the file

Step 3. Change the collection interval from every 10 minutes to every 2 minutes.
sudo vi /etc/cron.d/sysstat
5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
*/2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
save the file

Step 4. Restart sysstat
sudo service sysstat restart

Step 5. If you want to see all statistics you can type:
sar -A

Step 6. If you want to save the statistics for further analysis to a file use:
sudo sar -A > $(date +`hostname`-%d-%m-%y-%H%M.log)


man sysstat
man sar

Posted in Knowledge Base.

Tagged with , , .

Gdb Series – Attach gdb to a program that is already running – Part 1


This article describes how to attach gdb (GNU Project debugger) to a program that is already running using the gdb [1] command, which is a source-level debugger, capable of breaking programs at any specific line, displaying variable values, and determining where errors occurred. Currently, it works for C, C++, Fortran, Modula 2 and Java programs.

Step 2.1 Attach gdb to a program that is already running

This is useful for debugging processes that started up, but crashed when you perform a particular task.

Make sure the GNU Debugger is installed.

$ sudo apt-get install gdb

Find the process ID of <program>:

$ pidof <program>

Start gdb:

$ gdb 2>&1 | tee gdb-<program>.txt
(gdb) handle SIG33 pass nostop noprint
(gdb) set pagination 0
(gdb) attach <PID>

(If the program is running as root, use sudo gdb instead of just gdb above.)

Continue the <program>:

(gdb) continue

The program will continue running. Now you can perform any actions necessary to reproduce the crash. If the program hangs but doesn’t crash you can press ctrl+c in gdb while the program is frozen and then continue with the next step.

Step 2.2 Retrieve a backtrace

(gdb) backtrace full
(gdb) info registers
(gdb) x/16i $pc
(gdb) thread apply all backtrace
(gdb) quit

Attach the complete output from GDB, contained in gdb-<program>.txt, in your bug report or analyze the file accordingly.

Note that you can also set logging to a file like this:

(gdb) set logging file gdb-<program>.txt
(gdb) set logging on


• [1] – man gdb •| Generating Backtraces


Posted in Knowledge Base.

Tagged with , , , , , , .

How to add a new partition to the fstab file


This article will cover the scenario where we want to add new partitions to be mounted upon system start-up. The /etc/fstab [2] is the file that contains the necessary information for the operating system mount partitions at the system start-up.

The syntax of a fstab entry is described below :

[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]


  • Device – Device/partition (/dev location or UUID)
  • Mount Point – The directory on your root file system (mount point)
  • File System Type – Type of file system (ext4, ext3, ext2, jfs, reiserfs, vfat, and others)
  • Options – Device/partition ( Mount options for accessing the device/partition (see the man page for mount)
  • Dump – Used by the dump utility to decide when to make a backup. Default is 0
  • Pass – Used by fsck to decide which order filesystems are to be checked. Possible entries are 0, 1 and 2. The root file system should have the highest priority 1 – other file systems you want to have checked must have a 2 and they will be checked sequentially. File systems with a value 0 will not be checked by the fsck utility.


By default Ubuntu uses UUID [1] to identify partitions. To list your partitions you must use the blkid command.

$ sudo blkid

You will find all the new disks found by the operation system. An example of the output can be seen below.

/dev/sda1: UUID="2746087f-0e00-4429-a2f6-1ddae8a56cc0" TYPE="ext4"
/dev/sda5: UUID="bf4200b2-b938-48a2-bf77-c5ec1f4d86a8" TYPE="swap"
/dev/sdb1: UUID="bf4200b2-b938-48a2-bf77-c5ec1f4d86b9" TYPE="ext4"

Once you know the UUID for the partition you want to configure in /etc/fstab you can proceed and create a mount point for the new partition. In this example we will be using /data. The mount point is the location where you will mount the new disk and/or partition

$ mkdir /data

Add the new partition to the /etc/fstab file

Before you edit system files, make a backup.

$ sudo cp /etc/fstab /etc/fstab.old

Add the following line to the /etc/fstab file.

# /data on /dev/sdb1
UUID=bf4200b2-b938-48a2-bf77-c5ec1f4d86b9	/data	ext4	errors=remount-ro	0	2

Save the file and then run mount in order to make the changes effective without booting the system.

$ sudo mount -a

To view the current partitions mounted, run:

$ sudo mount -v

fstab entries for other filesystems


nfs-server:/share /media/nfs-share	nfs4	_netdev,auto	0	0


sshfs#user@server:/share  fuse  user,allow_other  0  0


Posted in Knowledge Base.

Tagged with , , , , .

Easily convert vdi to vmdk images

Converting images from one format to another should not be that hard that’s why I wrote the article How to clone a vbox virtualbox disk and how to convert vdi to vmdk in Sun VirtualBox Vbox. Even though these articles have been written I still find a bit hard since there are other ways to convert VirtualBox to VMware.

In this article I am going to show how to convert vdi images to vmdk using the latest version of Oracle VM VirtualBox. This was tested using Windows although the steps should not change if performing them on a Linux machine.

1. If you’re running a Windows virtual machine make sure to uninstall Oracle VM VirtualBox guest. Go to the “Programs and Features” and unistall it.

2. Just to be safe make a backup of the current vdi. You can copy it to c:\\backup\\images

3. We will be using the VBoxManage command. First you need to identify the VM vdi file path of the VirtualBox machine you want to convert. To do so run the following:

VBoxManage list hdds

For a Linux OS you must run the following

$ /usr/bin/vboxmanage list hdds

4. Take notes of the VM vdi file path

UUID:        368116e4-1c4a-49c4-9723-0e973f072948
Parent UUID: base
Format:      VDI
Location:    C:\\Images\\VirtualBox_VMs\\Windows_XP\\Windows_XP.vdi

5. Convert your .vdi to .vmdk image

The syntax for VBoxManage is:

VBoxManage clonehd "<vdi file format>" <NewVM.vmdk> --format vmdk
VBoxManage clonehd "C:\\Images\\VirtualBox_VMs\\Windows_XP\\Windows_XP.vdi" WinXP.vmdk --format vmdk

The output will be similar to the one below:

VBoxManage clonehd "C:\\Images\\VirtualBox_VMs\\Windows_XP\\Windows_XP.vdi" WinXP.vmdk --format vmdk
Clone hard disk created in format 'vmdk'. UUID: 17c15f43-4d10-4b92-b8c7-9143d3c63a0a

6. Create a new virtual machine in VMware and replace the provided disk with the one created previously.

Gotchas: If you are converting a linux machine, you must change at the boot time to boot from root=/dev/hda1 instead of root=/dev/sda1. To do so in the grub menu, press ‘e’ and adjust root=/dev/sda1 to be root=/dev/hda1.

That’s it!

Posted in Knowledge Base.

Tagged with , , , , .

“mount” command using CIFS protocol does not mount Windows 2008R2 / Windows Vista partitions – STATUS_INVALID_PARAM


When upgrading an Active Directory Domain to Windows 2008R2 the “mount” command does not work when an ubuntu machine tries to mount a partition on a remote Windows server. This problem occurs because of an additional security check [1] in Windows Server 2008 and in Windows Vista.


instead of using:

mount -t cifs //<ip_address>/dir_to_mount /mnt/directory -o user=USERNAME,password=PASSWORD,domain=DOMAINNAME


mount -t cifs //<ip_address>/dir_to_mount /mnt/directory -o user=USERNAME,password=PASSWORD,domain=DOMAINNAME,sec=ntlmv2


[1] – | MS KB #957441 – Client connections return a “STATUS_INVALID_PARAM” error code when you use a “Send NTLMv2 response only” authentication level in Windows Server 2008 or in Windows Vista


Posted in Knowledge Base.

Tagged with , , , , . – Ubuntu / Debian

Some time ago I wrote this article “what does mean ?” and I explained why some applications like GNOME expects that the hostname to be resolved to an ip address with a canonical fully qualified domain name – FQDN.

Another interesting thing that I have not said about it is that the range (IANA – Loopback) is entirely reserved for Loopback (RFC 5735).

In other words anything that you ping within that range ( – will reply back to the localhost (loopback).

$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=64 time=0.072 ms

One piece of advice is to not change the defaults in Ubuntu / Debian systems otherwise you can expect weird errors from some applications. Also do not configure anything to listen on port If you want to know what is currently running on the loopback range type the following

$ sudo netstat -tunelp | grep 127.0.[0-255].[0-255]
tcp        0      0*               LISTEN      117        11880       1099/mysqld
tcp        0      0  *               LISTEN      0          13907       2061/dnsmasq
tcp        0      0 *               LISTEN      0          11116       1019/cupsd
tcp        0      0*               LISTEN      0          10944       1393/tor
udp        0      0  *                           0          13906       2061/dnsmasq
udp        0      0 *                           0          9455        963/rpc.statd
udp        0      0*                           1000       18458       2410/skype

Posted in Knowledge Base.

Tagged with , , , , , .

Making wget downloads file with proper filenames

How many times have you tried to download files from a web page that has the following format: and you get ?filename=foobar as the filename?

That’s because wget is not reading the Content-Disposition header. In order to make wget read that header one must add the following parameter:

wget --content-disposition

wget --content-disposition

PS: This only works for newer wget versions though. eg: wget (1.12-1)

keywords: nova, openstack, wget, content-disposition

Posted in Knowledge Base.

Tagged with .

How to add/change preseed files on Ubuntu DVD/CD

Automation is usually the best thing you can do when you perform things/tasks more than once. When you automate a process you have more time and more time means more time spent doing things that you really enjoy. In this scenario I will explain how to add a Ubuntu / Debian preseed file into a Ubuntu Alternate DVD iso so you can automate the installation process from a CD install. It can be used for doing automatic Ubuntu cd installations.
Important: This article does not explain how to create Ubuntu / Debian preseed files. If you’re interested in how to create a preseed file, please go to

1. Create environment
mkdir ~/lts-remaster
mkdir ~/lts-remaster/iso
mkdir ~/lts-remaster/cd-remaster
cd ~/lts-remaster

2. Mount ISO
sudo mount -o loop ubuntu-10.04.3-dvd-amd64.iso ~/lts-remaster/iso

2.1 Copy the ISO contents to the cd-remaster
rsync -avr iso/ cd-remaster/

3. Copy your already created seed file into the preseed directory.
sudo cp -v seed.seed ~/lts-remaster/cd-remaster/preseed/

4. Make changes to isolinux/text.cfg if necessary. Text.cfg is the file where you can configure the options menu.
sudo vi cd-remaster/isolinux/text.cfg

5. Burn the cd again
sudo mkisofs -r -V "Custom Ubuntu Install CD" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/ -no-emul-boot -boot-load-size 4 -boot-info-table -o custom-lts1043.iso ~/lts-remaster/cd-remaster

7. Boot the cd and add the following boot options or change the file isolinux/text.cfg :
file=/cdrom/preseed/seed.seed locale=en_US priority=critical console-setup/ask_detect=false console-setup/layoutcode=us hostname=your-hostname domain=your-domain initrd=/install/initrd.gz quiet --

PS: You must add those additional entries at boot time otherwise those questions/answers do not work.

You may have to play a bit with your preseed file in order to have all the questions answered. Dustin Kirkland has made available a preseed file as an example.


Posted in Knowledge Base.

Tagged with , , , , .