Help Center> Dedicated Enterprise Storage Service> User Guide> FAQs> Performing Post-Expansion Operations for a SLES Disk (fdisk)
Updated on 2022-02-22 GMT+08:00

Performing Post-Expansion Operations for a SLES Disk (fdisk)

After the capacity expansion has succeeded, you need to allocate the extended space to an existing partition, or allocate new partitions to the expanded disks.

Prerequisites

  • You have logged in to the BMS. For details, see section "Logging In to a Linux BMS" in Bare Metal Server User Guide.
  • You have attached the EVS disk to the BMS and the additional disk space remains to be allocated.

Context

This section uses SUSE Linux Enterprise Server 11 SP4 (64-bit) 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 BMS, and 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 added space cannot be viewed on the server. The following operations provide guidance for you to query the added 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 disk condition, you can choose either of the following ways to allocate the additional disk space:
  • Create a partition (services will not be interrupted)

    You can create a partition for the expanded disk without the need of detaching the original partitions. The impacts on services are smaller 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, the services will be interrupted.

    If the MBR partition style is used and the disk capacity after expansion has exceeded 2 TB, the excessive disk space cannot be partitioned. In this case, if you change the partition style from MBR to GPT, the original disk data will be cleared. Therefore, back up the disk data before you change the partition style.

Replacing the Existing Partition

In the following example, a disk has been attached to the BMS, and the partition /dev/sda1 has been mounted to /mnt/sdc. During the process of replacing the original partition /dev/sda1 and adding new capacity to it, services will be interrupted.

  1. Run the following command to view information about partitioning:

    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

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

  2. Run the following command to update the data 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 running ll /sys/class/scsi_device/ command.

    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

    Example 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 partition.

    To create a partition, enter n.

    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 partition:
    • p indicates a primary partition.
    • e indicates 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 serial number of the primary partition.

  8. Ensure that the serial number you entered is the same as the original partition's, which is 1 in this example. 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.

    Data will be lost if:
    • The first sector you selected is inconsistent with the original partition.
    • The last sector you selected is smaller than that of the original partition.

  9. Ensure that the entered first sector is the same as that of the original partition. In this example, first sector 2048 is recorded in 3. 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 equal to or larger than the last sector recorded in 3. In this example, the recorded last sector is 20971519, and the default last sector 41943039 is used. 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.)
    CCommand (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.

    If information similar to the following is displayed, the partition is successfully created:
    Command (m for help): w
    The partitI/On table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.

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

  13. 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

  14. 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.

  15. Run the following command to mount the created partition to the /mnt/sdc directory:

    mount /dev/sda1 /mnt/sdc

  16. Run the following command to view the mounting result for /dev/sda1:

    df -TH