• Elastic Volume Service

evs
  1. Help Center
  2. Elastic Volume Service
  3. User Guide
  4. Management
  5. Expanding the Capacity of an EVS Disk
  6. Performing Post-Expansion Operations for a Linux SCSI Data Disk (fdisk)

Performing Post-Expansion Operations for a Linux SCSI Data Disk (fdisk)

Scenarios

In a Linux OS, after the capacity expansion succeeded, the additional disk space needs to be allocated to an existing partition or a new partition.

This topic uses SUSE Linux Enterprise Server 11 SP4 64bit to describe how to allocate the additional space of an attached SCSI data disk to a partition using fdisk.

Currently, a disk has been attached to a server, the original disk capacity is 10 GB. In addition, a 10-GB space has been added to the disk through the management console, and the total disk capacity should be 20 GB. However, the additional space cannot be viewed on the server. The following operations guide you to query the additional space and expand the partition.

The method for allocating the additional space varies depending on the server OS. This document is used for reference only. For the detailed operations and differences, see the corresponding OS documents.

Based on your service requirements and actual disk condition, you can choose either of the following ways to allocate the additional disk space:
  • Create a new partition (services will not be interrupted)

    Creating a new partition for the expanded disk does not require the original partitions to be unmounted. Therefore, the impacts on services are minor than expanding an existing partition. This method is recommended for system disks or disks carrying services that cannot be interrupted.

    If the MBR partition style is used, the disk capacity cannot exceed 2 TB and the number of partitions cannot exceed the upper limit after the expansion completes.

  • Expand an existing partition (services will be interrupted)

    If the MBR partition style is used and the number of partitions has reached the upper limit, the existing partition needs to be expanded. Expanding an existing partition does not delete its data, but requires the partition to unmount. Therefore, services will be interrupted.

    If the MBR partition style is used and the disk capacity after expansion has exceeded 2 TB, the space exceeding 2 TB cannot be used. To use the excessive space, the disk partition style must be changed from MBR to GPT. Data on the disk will be cleared during such a change. Therefore, back up the disk data before changing the partition style.

    Performing the expansion operations with caution. Misoperation may lead to data loss or exceptions. Therefore, you are advised to back up the disk data using backups or snapshots before expansion. For details about backups and snapshots, see Managing EVS Backup and Creating a Snapshot, respectively.

Prerequisites

  • You have logged in to the server.
    • For how to log in to an ECS, see the Elastic Cloud Server User Guide.
    • For how to log in to a BMS, see the Bare Metal Server User Guide.
  • You have attached the EVS disk to the server, and the additional space has not been allocated.

Expanding an Existing Partition

The following example shows you how to make use of the additional capacity of a disk attached to a server by recreating the /dev/sda1 partition and mounting the partition on /mnt/sdc. During this process, the services will be interrupted.

  1. Run the following command to view the disk partition information:

    fdisk -l

    Information similar to the following is displayed:
    ecs-xen-02:/home/linux # fdisk -l
    
    Disk /dev/xvda: 107.4 GB, 107374182400 bytes
    255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00065c40
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/xvda1            2048    41945087    20971520   82  Linux swap / Solaris
    /dev/xvda2   *    41945088    83892223    20973568   83  Linux
    /dev/xvda3        83892224   209715199    62911488   83  Linux
    
    Disk /dev/sda: 10.7 GB, 10737418240 bytes
    64 heads, 32 sectors/track, 10240 cylinders, total 20971520 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x2f1c057a
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            2048    20971519    10484736   83  Linux

    In the command output, the 10 GB has been added to the /dev/sda data disk on the management console, and the total capacity should be 20 GB. However, the additional space is not included in the command output. In this case, run the desired command to update the disk capacity of the server.

  2. Run the following command to update the disk capacity of the server:

    echo 1 > /sys/class/scsi_device/%d:%d:%d:%d/device/rescan &

    In the command, %d:%d:%d:%d indicates a folder in the /sys/class/scsi_device/ directory and can be obtained using ll /sys/class/scsi_device/.

    Information similar to the following is displayed: ( 2:0:0:0 indicates the folder to be obtained.)
    cs-xen-02:/sys/class/scsi_device # ll /sys/class/scsi_device/
    total 0
    lrwxrwxrwx 1 root root 0 Sep 26 11:37 2:0:0:0 -> ../../devices/xen/vscsi-2064/host2/target2:0:0/2:0:0:0/scsi_device/2:0:0:0

    For example, run the following command:

    echo 1 > /sys/class/scsi_device/2:0:0:0/device/rescan &

  3. After the update is complete, run the following command to view the disk partition information again:

    fdisk -l

    Information similar to the following is displayed:
    ecs-xen-02:/sys/class/scsi_device # fdisk -l
    
    Disk /dev/xvda: 107.4 GB, 107374182400 bytes
    255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00065c40
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/xvda1            2048    41945087    20971520   82  Linux swap / Solaris
    /dev/xvda2   *    41945088    83892223    20973568   83  Linux
    /dev/xvda3        83892224   209715199    62911488   83  Linux
    
    Disk /dev/sda: 21.5 GB, 21474836480 bytes
    64 heads, 32 sectors/track, 20480 cylinders, total 41943040 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x2f1c057a
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            2048    20971519    10484736   83  Linux

    In the command output, the additional space has been added to the /dev/sda data disk, and the update is successful. The /dev/sda disk has only one partition, /dev/sda1. Take note of first and last sectors of the /dev/sda1 partition. These values will be used during the partition recreation. The partition's first sector is 2048, and its last sector is 20971519.

  4. Run the following command to unmount the disk partition:

    umount /mnt/sdc

  5. Run the following command to enter fdisk and enter d to delete the /dev/sda1 partition:

    fdisk /dev/sda1

    Information similar to the following is displayed:
    [ecs-xen-02:/sys/class/scsi_device # fdisk /dev/sda
    
    Command (m for help): d
    Selected partition 1
    
    Command (m for help): 

  6. Enter n and press Enter to create a new partition.

    Entering n creates a new partition.

    Information similar to the following is displayed:
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    There are two types of disk partitions:
    • Choosing p creates a primary partition.
    • Choosing e creates an extended partition.

  7. Ensure that the entered partition type is the same as the partition had before. In this example, a primary partition is used. Therefore, enter p and press Enter to create a primary partition.

    Information similar to the following is displayed:
    p
    Partition number (1-4, default 1):

    In the command output, Partition number specifies the primary partition number.

  8. Ensure that entered partition number is the same as the partition had before. In this example, the partition number 1 is used. Therefore, enter 1 and press Enter.

    Information similar to the following is displayed:
    Partition number (1-4, default 1): 1
    First sector (2048-41943039, default 2048):

    In the command output, First sector specifies the first sector.

    NOTE:
    Data will be lost if the following operations are performed:
    • Select a first sector other than the partition had before.
    • Select a last sector smaller than the partition had before.

  9. Ensure that the entered first sector is the same as the partition had before. In this example, first sector 2048 is recorded in 3. Therefore, enter 2048 and press Enter.

    Information similar to the following is displayed:
    First sector (2048-41943039, default 2048): 
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 

    In the command output, Last sector specifies the last sector.

  10. Ensure that the entered last sector is greater than or equal to the last sector recorded in 3. In this example, the recorded last sector is 20971519, and the default last sector is used. Therefore, enter 41943039 and press Enter.

    Information similar to the following is displayed:
    Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): 
    Using default value 41943039
    
    Command (m for help):

    The primary partition is successfully created.

  11. Enter p and press Enter to view the details about the created partition.

    Information similar to the following is displayed: (Details about the /dev/sda1 partition are displayed.)
    Command (m for help): p
    
    Disk /dev/sda: 21.5 GB, 21474836480 bytes
    64 heads, 32 sectors/track, 20480 cylinders, total 41943040 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x2f1c057a
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            2048    41943039    20970496   83  Linux
    Command (m for help): 
    

  12. Enter w and press Enter to write the changes into the partition table.

    Information similar to the following is displayed: (The partition is successfully created.)
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    NOTE:

    In case that you want to discard the changes made before, you can exit fdisk by entering q.

  13. Perform the following operations based on the file system of the disk:

    • For the ext3 or ext4 file system
      1. Run the following command to check the correctness of the file system on /dev/sda1:

        e2fsck -f /dev/sda1

        Information similar to the following is displayed:
        ecs-xen-02:/sys/class/scsi_device # e2fsck -f /dev/sda1
        e2fsck 1.41.9 (22-Aug-2009)
        Pass 1: Checking inodes, blocks, and sizes
        Pass 2: Checking directory structure
        Pass 3: Checking directory connectivity
        Pass 4: Checking reference counts
        Pass 5: Checking group summary information
        /dev/sda1: 11/655360 files (0.0% non-contiguous), 79663/2621184 blocks
      2. Run the following command to expand the size of the file system on /dev/sda1:

        resize2fs /dev/sda1

        Information similar to the following is displayed:
        ecs-xen-02:/sys/class/scsi_device # resize2fs /dev/sda1
        resize2fs 1.41.9 (22-Aug-2009)
        Resizing the filesystem on /dev/sda1 to 5242624 (4k) blocks.
        The filesystem on /dev/sda1 is now 5242624 blocks long.
      3. Run the following command to mount the created partition to the /mnt/sdc directory:

        mount /dev/sda1 /mnt/sdc

    • For the xfs file system
      1. Run the following command to mount the created partition to the /mnt/sdc directory:

        mount /dev/sda1 /mnt/sdc

      2. Run the following command to expand the size of the file system on /dev/sda1:

        sudo xfs_growfs /dev/sda1

  14. Run the following command to view the mount result for /dev/sda1:

    df -TH