Extending the Partition for a Boot Volume

When you create a new virtual machine (VM) instance or bare metal instance based on an Oracle-provided image or custom image, you have the option of specifying a custom boot volume size. You can also expand the size of the boot volume for an existing instance; see Resizing a Volume for more information. In order to take advantage of the larger size, you need to extend the partition for the boot volume. For block volumes, see Extending the Partition for a Block Volume.

Note

After a boot volume has been resized, the first backup on the resized boot volume will be a full backup. See Boot Volume Backup Types for more information about full versus incremental boot volume backups.

Required IAM Policy

Extending a partition on an instance does not require a specific IAM policy. However, you may need permission to run the necessary commands on the instance's guest OS. Contact your system administrator for more information.

Extending the Root Partition on a Linux-Based Image

For instances running Linux-based images, you need to extend the root partition and then grow the file system.

Extending the Linux Partition

Perform the following steps to extend the partition.

Extending the root partition
  1. Run the following command to edit the volume's partition table with parted:

    parted <volume_id>

    <volume_id> is the volume identifier for the root volume.

  2. When you run parted, you may encounter the following error message:

    Warning: Not all of the space available to <volume_id> appears to be used, 
    you can fix the GPT to use all of the space (an extra volume_size blocks) 
    or continue with the current setting?

    You are then prompted to fix the error or ignore the error and continue with the current setting. Specify the option to fix the error.

  3. Run the following command to change the display units to sectors so that you can see the precise start position for the volume:

    (parted) unit s
  4. Run the following command to display the current partitions in the partition table:

    (parted) print

    Make note of the values in the Number, Start, and File system columns for the root partition.

  5. Run the following command to remove the existing root partition:

    (parted) rm <partition_number>

    <partition_number> is the value from the Number column.

  6. Run the following command to recreate the partition:

    (parted) mkpart

    At the Start? prompt, specify the value from the Start column. At the File system type? prompt, specify the value from the File system column. Specify 100% for the End? prompt.

  7. Run the following command to exit parted:

    (parted) quit

    This command forces a rewrite of the partition table with the new partition settings that you specified.

  8. To verify that the root partition was extended, run the following command to list the attached block volumes:

    lsblk

After you extend the root partition, you need to grow the file system. The steps in the following procedure apply only to xfs file systems.

Growing the file system for the root partition
  1. Before you grow the file system, repair any issues with the file system on the extended partition by running the following command:

    xfs_repair <partition_id>

    <partition_id> is the partition identifier, for example /dev/sdc3. See Checking and Repairing an XFS File System for more information.

  2. After you have confirmed that there are no more issues to repair, you need to create a mount point to run the xfs_growfs against. To do this, create a directory and mount the partition to that directory by running the following commands:

    mkdir <directory_name>
    mount <partition_id> <directory_name> -o nouuid

    <partition_id> is the partition identifier, for example /dev/sdc3, and <directory_name> is the directory to create and mount.

  3. After you have created the mount point run the following command to grow the file system:

    xfs_growfs -d <directory_name>

    <directory_name> is the name for the directory you created in the previous step.

  4. To verify that the file system size is correct, run the following command to display the file system details:

    df -lh
  5. Once you have verified that the file system size is correct, run the following command to unmount the partition:

    umount <partition_id>

Extending the System Partition on a Windows-Based Image

On Windows-based images, you can extend a partition using the Windows interface or from the command line using the DISKPART utility.

Windows Server 2012 and Later Versions

The steps for extending a system partition on instances running Windows Server 2012, Windows Server 2016, or Windows Server 2019 are the same, and are described in the following procedures.

Extending the system partition using the Windows interface
  1. Open the Disk Management system utility on the instance.

  2. Right-click the boot volume and select Extend Volume.

  3. Follow the instructions in the Extend Volume Wizard:

    1. Select the disk that you want to extend, enter the size, and then click Next.

    2. Confirm that the disk and size settings are correct, and then click Finish.

  4. Verify that the boot volume's system disk has been extended in Disk Management.

Extending the system partition using the command line with DISKPART
  1. Open a command prompt as administrator on the instance.

  2. Run the following command to start the DISKPART utility:

    diskpart
  3. At the DISKPART prompt, run the following command to display the instance's volumes:

    list volume
  4. Run the following command to select the boot volume:

    select volume <volume_number>

    <volume_number> is the number associated with the boot volume that you want to extend the partition for.

  5. Run the following command to extend the partition:

    extend size=<increased_size_in_MB>

    <increased_size_in_MB> is the size in MB that you want to extend the partition to.

    Caution

    When using the DISKPART utility, do not overextend the partition beyond the current available space. Overextending the partition could result in data loss.
  6. To confirm that the partition was extended, run the following command and verify that the boot volume's partition has been extended:

    list volume