Creating a Boot Partition in Microsoft Azure

In order to prepare a Linux VM for system device encryption, you must first create a separate partition for the boot drive. Because many Azure VMs are configured with the growroot option, you first need to turn off this option on the VM. Then you can increase the boot disk size and partition it.

During this procedure the VM must be powered off briefly while it is resized.

Note: The following procedure is based on the November 2018 Microsoft Azure Resource Manager (ARM) interface. If your version of ARM is different from what is described below, please see your Azure documentation.

Before You Begin 

This procedure requires ssh access to the VM. To set up ssh access, see your Azure documentation.

Procedure 

  1. Log into the VM via ssh and do the following:

    1. Make sure that the boot disk is not already on a separate partition using the df -h command and looking at the Mounted on column. If /boot is listed in this column, then the boot device is already running in a separate partition and you can skip to Verifying the Current VM Configuration. For example:

      # df -h
      Filesystem      Size  Used Avail Use% Mounted on
      devtmpfs        1.8G     0  1.8G   0% /dev
      tmpfs           1.9G     0  1.9G   0% /dev/shm
      tmpfs           1.9G   26M  1.8G   2% /run
      tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
      /dev/sda1        30G  1.4G   28G   5% /
      /dev/sbd1        18G   53M   18G   1% /home
      tmpfs           370M   20K  370M   1% /run/user/467
      tmpfs           370M     0  370M   0% /run/user/0
    2. Determine the size of the current boot partition by entering the du -sh /boot command.

      # du -sh /boot
      52M   /boot

      The new partition you create should be about twice the size currently being used by /boot.

    3. Turn off the growroot option on the VM by entering the following command:

      # touch /etc/growroot-disabled

  2. Log out of the ssh session.
  3. Log into the Azure Resource Manager and navigate to the VM.
  4. Click Stop and confirm the action at the prompt to power off the VM.
  5. After the VM has been fully powered off, select Settings > Disks in the left-hand tree menu.
  6. Click the name of the OS disk in the list.
  7. Click Settings > Configuration.
  8. In the Size field, enter the new size for the disk and click Save. You should increase the disk by at least twice the size of the current boot partition.
  9. Navigate back to the main server page and click Start to power the server on.
  10. After the server has powered on, log back into the server via ssh.
  11. To verify that the OS disk did not automatically expand to the new disk size, enter the df -h command. The size of the OS disk should be the same as it was in the first step.

    For example:

    # df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        1.8G     0  1.8G   0% /dev
    tmpfs           1.9G     0  1.9G   0% /dev/shm
    tmpfs           1.9G   26M  1.8G   2% /run
    tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
    /dev/sda1        30G  1.4G   28G   5% /
    /dev/sbd1        18G   53M   18G   1% /home
    tmpfs           370M   20K  370M   1% /run/user/467
    tmpfs           370M     0  370M   0% /run/user/0
  12. Format the new boot partition in ext3 or ext4 and copy the files from the existing boot partition to the new boot partition. Then you can mount the new boot partition and use that to boot the VM.

    How you do this depends on the version of Linux that you are using. For your convenience, we have included the instructions for formatting the new boot partition in Ubuntu, RHEL/CentOS 7, and RHEL/CentOS 6. For more information, see: