All Products
Search
Document Center

Resize SAP System Disk (Based on LVM)

Last Updated: Jun 24, 2020

Resize SAP System Disk (Based on LVM)

Release history

Version Revision date Changes Release date
1.0 2019-03-26
1.1 2019-03-29 1. Updated operation instructions for adding a data disk.
2. Updated document links.
2019-03-29
1.2 2019-04-02 1. Updated the reference for shrinking a disk.
2. Optimized the layout.
2019-04-02
1.3 2019-12-30 1. Updated the resize cloud disk online.
2019-12-30

Overview

This topic describes how to resize the SAP application or database disks on Alibaba Cloud. Disk resizing includes system disk resizing and data disk resizing. Before resizing a disk, read the instructions in

For more information about system disk resizing, see:

Resize cloud disks offline

After resizing a disk, you need to use file system-specific commands to resize the file system to a required size.

In some scenarios, you need to shrink a disk. For more information, see Shrink disk.

The following uses SUSE Linux Enterprise Server for SAP Applications 12 SP3 as an example. In this example, you use Logical Volume Manager (LVM) to manage disk partitions and file systems (XFS and Ext). The commands may vary according to versions or operating systems. For more information, see the manuals for the corresponding operating systems.

Assume that the /hana/data, /usr/sap, and /sapcd file systems of SAP applications need to be resized.

  • The /hana/data, /hana/log, and /hana/shared file systems are of the XFS type. These file systems stripe data across three SSDs based on LVM. This can improve the efficiency of data I/O for SAP HANA. (For more information about SAP HANA storage requirements, see SAP HANA TDI-Storage Requirements.)
  • The /usr/sap partition is an XFS file system. This file system stores data in an ultra disk in a separate volume group.
  • The /sapcd partition is an Ext4 file system. This file system stores data in a raw disk that is not partitioned and managed by LVM.

Example

Disk type File system size before resizing File system size after resizing File system type Volume group Striped based on LVM Mount point
Data disk 30 GB 50 GB XFS datavg Yes /hana/data
Data disk 30 GB 60 GB XFS sapvg No /usr/sap
Data disk 20 GB 40 GB Ext4 N/A No /sapcd

Note
We recommend that you create a snapshot of a disk before resizing the disk. This prevents data loss caused by maloperations. For more information, see Create a snapshot.

Data disk resizing

Create a data disk

You can add a data disk when a new file system is mounted, the capacity of a disk exceeds the upper limit, or multiple disks are striped based on LVM to enhance the I/O performance.

For more information about how to add a disk, seeCreate a Pay-As-You-Go cloud disk andCreate a Subscription cloud disk.

For more information about performance of various block storage services, seeBlock storage performance.

Example: Create a 20 GB disk and attach it to the /usr/sap/T01 file system.

1. Create a 20 GB disk in the Elastic Compute Service (ECS) console and attach the disk to an ECS instance. The system allocates a name to the disk, for example, /dev/vdg.

  1. # lsblk
  2. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  3. vda 253:0 0 40G 0 disk
  4. └─vda1 253:1 0 40G 0 part /
  5. vdb 253:16 0 40G 0 disk
  6. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  7. ├─datavg-lvhdata 254:2 0 50G 0 lvm /hana/data
  8. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  9. vdc 253:32 0 40G 0 disk
  10. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  11. ├─datavg-lvhdata 254:2 0 50G 0 lvm /hana/data
  12. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  13. vdd 253:48 0 40G 0 disk
  14. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  15. ├─datavg-lvhdata 254:2 0 50G 0 lvm /hana/data
  16. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  17. vde 253:64 0 60G 0 disk
  18. └─sapvg-lvusrsap 254:0 0 60G 0 lvm /usr/sap
  19. vdf 253:80 0 40G 0 disk /sapcd
  20. vdg 253:96 0 20G 0 disk

2. Add the disk to an existing volume group and create a logical volume.

Add the disk to an existing volume group.

  1. # vgextend sapvg /dev/vdg
  2. Volume group "sapvg" successfully extended
  3. # pvs -a
  4. PV VG Fmt Attr PSize PFree
  5. /dev/datavg/lvhdata --- 0 0
  6. /dev/datavg/lvhlog --- 0 0
  7. /dev/datavg/lvhshared --- 0 0
  8. /dev/root --- 0 0
  9. /dev/sapvg/lvusrsap --- 0 0
  10. /dev/vdb datavg lvm2 a-- 40.00g 13.33g
  11. /dev/vdc datavg lvm2 a-- 40.00g 13.33g
  12. /dev/vdd datavg lvm2 a-- 40.00g 13.33g
  13. /dev/vde sapvg lvm2 a-- 60.00g 0
  14. /dev/vdf --- 0 0
  15. /dev/vdg sapvg lvm2 a-- 20.00g 20.00g
  16. # lvcreate -l 100%FREE -n lvsapsid sapvg
  17. Logical volume "lvsapsid" created.
  18. # mkfs.xfs /dev/sapvg/lvsapsid
  19. meta-data=/dev/sapvg/lvsapsid isize=256 agcount=4, agsize=1310464 blks
  20. = sectsz=512 attr=2, projid32bit=1
  21. = crc=0 finobt=0, sparse=0
  22. data = bsize=4096 blocks=5241856, imaxpct=25
  23. = sunit=0 swidth=0 blks
  24. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
  25. log =internal log bsize=4096 blocks=2560, version=2
  26. = sectsz=512 sunit=0 blks, lazy-count=1
  27. realtime =none extsz=4096 blocks=0, rtextents=0

3. Mount a new file system to the specified mount point.

Note: Before you mount a new partition to a non-empty directory, move or copy all subdirectories and files to another directory. After the mounting succeeds, move or copy all subdirectories and files back.

  1. mount /dev/mapper/sapvg-lvsapsid /usr/sap/T01
  2. # df -Th
  3. Filesystem Type Size Used Avail Use% Mounted on
  4. devtmpfs devtmpfs 3.9G 8.0K 3.9G 1% /dev
  5. tmpfs tmpfs 8.0G 0 8.0G 0% /dev/shm
  6. tmpfs tmpfs 3.9G 660K 3.9G 1% /run
  7. tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
  8. /dev/vda1 ext4 40G 3.6G 34G 10% /
  9. /dev/vdf ext4 40G 48M 38G 1% /sapcd
  10. /dev/mapper/datavg-lvhdata xfs 50G 33M 50G 1% /hana/data
  11. /dev/mapper/datavg-lvhlog xfs 10G 33M 10G 1% /hana/log
  12. /dev/mapper/datavg-lvhshared xfs 20G 33M 20G 1% /hana/shared
  13. /dev/mapper/sapvg-lvusrsap xfs 60G 33M 60G 1% /usr/sap
  14. tmpfs tmpfs 799M 0 799M 0% /run/user/0
  15. /dev/mapper/sapvg-lvsapsid xfs 20G 33M 20G 1% /usr/sap/T01

4. Add the file system configuration to the fstab file.

  1. echo "/dev/mapper/sapvg-lvsapsid /usr/sap/T01 xfs defaults 0 0" >>/etc/fstab

Data disk resizing

View the file system type

To view information about the file system of the current ECS instance, you need to log on to the operating system of the instance.
The operating system is SUSE Linux Enterprise 12. The file system types of data disks include XFS and Ext4.

  1. # df -Th
  2. Filesystem Type Size Used Avail Use% Mounted on
  3. devtmpfs devtmpfs 3.9G 8.0K 3.9G 1% /dev
  4. tmpfs tmpfs 8.0G 0 8.0G 0% /dev/shm
  5. tmpfs tmpfs 3.9G 624K 3.9G 1% /run
  6. tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
  7. /dev/vda1 ext4 40G 3.6G 34G 10% /
  8. tmpfs tmpfs 799M 0 799M 0% /run/user/0
  9. /dev/mapper/sapvg-lvusrsap xfs 30G 33M 30G 1% /usr/sap
  10. /dev/mapper/datavg-lvhdata xfs 30G 33M 30G 1% /hana/data
  11. /dev/mapper/datavg-lvhlog xfs 10G 33M 10G 1% /hana/log
  12. /dev/mapper/datavg-lvhshared xfs 20G 33M 20G 1% /hana/shared
  13. /dev/vdf ext4 20G 44M 19G 1% /sapcd

Extend partitions

You can run the lsblk command to display information about all partitions in the ECS instance. For more information about LVM partitions, see LVM Howto.

The following command output indicates the disk status before resizing:

  1. # lsblk
  2. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  3. vda 253:0 0 40G 0 disk
  4. └─vda1 253:1 0 40G 0 part /
  5. vdb 253:16 0 20G 0 disk
  6. ├─datavg-lvhshared 254:0 0 20G 0 lvm /hana/shared
  7. ├─datavg-lvhdata 254:1 0 30G 0 lvm /hana/data
  8. └─datavg-lvhlog 254:2 0 10G 0 lvm /hana/log
  9. vdc 253:32 0 20G 0 disk
  10. ├─datavg-lvhshared 254:0 0 20G 0 lvm /hana/shared
  11. ├─datavg-lvhdata 254:1 0 30G 0 lvm /hana/data
  12. └─datavg-lvhlog 254:2 0 10G 0 lvm /hana/log
  13. vdd 253:48 0 20G 0 disk
  14. ├─datavg-lvhshared 254:0 0 20G 0 lvm /hana/shared
  15. ├─datavg-lvhdata 254:1 0 30G 0 lvm /hana/data
  16. └─datavg-lvhlog 254:2 0 10G 0 lvm /hana/log
  17. vde 253:64 0 30G 0 disk
  18. └─sapvg-lvusrsap 254:3 0 30G 0 lvm /usr/sap
  19. vdf 253:80 0 20G 0 disk /sapcd

Log on to the ECS console. Select a disk and resize it. After resizing is completed, restart the ECS instance for the disk.

  1. # lsblk
  2. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  3. vda 253:0 0 40G 0 disk
  4. └─vda1 253:1 0 40G 0 part /
  5. vdb 253:16 0 40G 0 disk
  6. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  7. ├─datavg-lvhdata 254:2 0 30G 0 lvm /hana/data
  8. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  9. vdc 253:32 0 40G 0 disk
  10. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  11. ├─datavg-lvhdata 254:2 0 30G 0 lvm /hana/data
  12. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  13. vdd 253:48 0 40G 0 disk
  14. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  15. ├─datavg-lvhdata 254:2 0 30G 0 lvm /hana/data
  16. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  17. vde 253:64 0 60G 0 disk
  18. └─sapvg-lvusrsap 254:0 0 30G 0 lvm /usr/sap
  19. vdf 253:80 0 40G 0 disk /sapcd

Each of the /dev/vdb, /dev/vdc, and /dev/vdd disks has three partitions, namely, /hana/shared, /hana/data, and /hana/log. These partitions stripe data across the three disks. The space of each disk has been resized from 40 GB to 120 GB, but the logical volume space remains unchanged (30 GB). You need to resize the volume group, and then resize the logical volume.

The /dev/vde disk has only one logical volume, /usr/sap. The disk space has been resized to 60 GB, but the logical volume space remains unchanged (30 GB). You need to resize the volume group, and then resize the logical volume.

The /dev/vdf disk is not partitioned. The disk size after resizing equals to the partition size (40 GB).

Extend the volume group and logical volume

You can use LVM commands to resize file systems.
1. Extend physical volumes.

  1. # pvresize /dev/vdb /dev/vdc /dev/vdd /dev/vde
  2. Physical volume "/dev/vdb" changed
  3. Physical volume "/dev/vdc" changed
  4. Physical volume "/dev/vdd" changed
  5. Physical volume "/dev/vde" changed
  6. 4 physical volume(s) resized / 0 physical volume(s) not resized

2. Resize logical volumes as required. In this example, logical volumes are resized as follows:

  1. # lvresize -L +20G /dev/datavg/lvhdata
  2. Using stripesize of last segment 64.00 KiB
  3. Rounding size (12800 extents) up to stripe boundary size for segment (12801 extents)
  4. Size of logical volume datavg/lvhdata changed from 30.00 GiB (7680 extents) to 50.00 GiB (12801 extents).
  5. Logical volume lvhdata successfully resized
  6. # lvresize -L +30G /dev/sapvg/lvusrsap
  7. Size of logical volume sapvg/lvusrsap changed from 30.00 GiB (7679 extents) to 60.00 GiB (15359 extents).
  8. Logical volume lvusrsap successfully resized

3. Extend logical volumes.
Example: Resize XFS file systems.

  1. # xfs_growfs /usr/sap
  2. meta-data=/dev/mapper/sapvg-lvusrsap isize=256 agcount=4, agsize=1965824 blks
  3. = sectsz=512 attr=2, projid32bit=1
  4. = crc=0 finobt=0 spinodes=0
  5. data = bsize=4096 blocks=7863296, imaxpct=25
  6. = sunit=0 swidth=0 blks
  7. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
  8. log =internal bsize=4096 blocks=3839, version=2
  9. = sectsz=512 sunit=0 blks, lazy-count=1
  10. realtime =none extsz=4096 blocks=0, rtextents=0
  11. data blocks changed from 7863296 to 15727616
  12. # xfs_growfs /hana/data
  13. meta-data=/dev/mapper/datavg-lvhdata isize=256 agcount=16, agsize=491504 blks
  14. = sectsz=512 attr=2, projid32bit=1
  15. = crc=0 finobt=0 spinodes=0
  16. data = bsize=4096 blocks=7864064, imaxpct=25
  17. = sunit=16 swidth=48 blks
  18. naming =version 2 bsize=4096 ascii-ci=0 ftype=1
  19. log =internal bsize=4096 blocks=3840, version=2
  20. = sectsz=512 sunit=16 blks, lazy-count=1
  21. realtime =none extsz=4096 blocks=0, rtextents=0
  22. data blocks changed from 7864064 to 13108224

Example: Run the resize2fs command to resize Ext file systems (Ext2, Ext3, and Ext4) for each volume.

  1. # resize2fs /dev/vdf
  2. resize2fs 1.42.11 (09-Jul-2014)
  3. Filesystem at /dev/vdf is mounted on /sapcd; on-line resizing required
  4. old_desc_blocks = 2, new_desc_blocks = 3
  5. The filesystem on /dev/vdf is now 10485760 blocks long.

4. Verify the resizing.

  1. # df -Th
  2. Filesystem Type Size Used Avail Use% Mounted on
  3. devtmpfs devtmpfs 3.9G 8.0K 3.9G 1% /dev
  4. tmpfs tmpfs 8.0G 0 8.0G 0% /dev/shm
  5. tmpfs tmpfs 3.9G 648K 3.9G 1% /run
  6. tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
  7. /dev/vda1 ext4 40G 3.6G 34G 10% /
  8. /dev/vdf ext4 40G 48M 38G 1% /sapcd
  9. tmpfs tmpfs 799M 0 799M 0% /run/user/0
  10. /dev/mapper/datavg-lvhdata xfs 50G 33M 50G 1% /hana/data
  11. /dev/mapper/datavg-lvhlog xfs 10G 33M 10G 1% /hana/log
  12. /dev/mapper/datavg-lvhshared xfs 20G 33M 20G 1% /hana/shared
  13. /dev/mapper/sapvg-lvusrsap xfs 60G 33M 60G 1% /usr/sap
  14. # lsblk
  15. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  16. vda 253:0 0 40G 0 disk
  17. └─vda1 253:1 0 40G 0 part /
  18. vdb 253:16 0 40G 0 disk
  19. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  20. ├─datavg-lvhdata 254:2 0 50G 0 lvm /hana/data
  21. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  22. vdc 253:32 0 40G 0 disk
  23. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  24. ├─datavg-lvhdata 254:2 0 50G 0 lvm /hana/data
  25. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  26. vdd 253:48 0 40G 0 disk
  27. ├─datavg-lvhshared 254:1 0 20G 0 lvm /hana/shared
  28. ├─datavg-lvhdata 254:2 0 50G 0 lvm /hana/data
  29. └─datavg-lvhlog 254:3 0 10G 0 lvm /hana/log
  30. vde 253:64 0 60G 0 disk
  31. └─sapvg-lvusrsap 254:0 0 60G 0 lvm /usr/sap
  32. vdf 253:80 0 40G 0 disk /sapcd