Skip to content

Commit 19816f5

Browse files
Merge pull request #279678 from pagienge/patch-13
Update expand-disks.md
2 parents 4d1ecc7 + f1e65f3 commit 19816f5

File tree

1 file changed

+35
-38
lines changed

1 file changed

+35
-38
lines changed

articles/virtual-machines/linux/expand-disks.md

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,18 @@ ms.custom: references_regions, devx-track-azurecli, linux-related-content
1212

1313
# Expand virtual hard disks on a Linux VM
1414

15-
> [!CAUTION]
16-
> This article references CentOS, a Linux distribution that is nearing End Of Life (EOL) status. Please consider your use and plan accordingly. For more information, see the [CentOS End Of Life guidance](~/articles/virtual-machines/workloads/centos/centos-end-of-life.md).
17-
1815
**Applies to:** :heavy_check_mark: Linux VMs :heavy_check_mark: Flexible scale sets
1916

20-
This article describes how to expand managed disks for a Linux virtual machine (VM). You can [add data disks](add-disk.md) to provide for additional storage space, and you can also expand an existing data disk. The default virtual hard disk size for the operating system (OS) is typically 30 GB on a Linux VM in Azure. This article covers expanding either OS disks or data disks. You can't expand the size of striped volumes.
17+
This article describes how to expand managed disks for a Linux virtual machine (VM). You can [add data disks](add-disk.md) to provide for more storage space, and you can also expand an existing data disk. The default virtual hard disk size for the operating system (OS) is typically 30 GB on a Linux VM in Azure. This article covers expanding either OS disks or data disks. You can't expand the size of striped volumes.
2118

22-
An OS disk has a maximum capacity of 4,095 GiB. However, many operating systems are partitioned with [master boot record (MBR)](https://wikipedia.org/wiki/Master_boot_record) by default. MBR limits the usable size to 2 TiB. If you need more than 2 TiB, create and attach data disks and use them for data storage. If you need to store data on the OS disk and require the additional space, convert it to GUID Partition Table (GPT).
19+
An OS disk has a maximum capacity of 4,095 GiB. However, many operating systems are partitioned with [master boot record (MBR)](https://wikipedia.org/wiki/Master_boot_record) by default. MBR limits the usable size to 2 TiB. If you need more than 2 TiB, consider attaching data disks for data storage. If you do need to store data on the OS disk and require extra space, convert it to GUID Partition Table (GPT).
2320

2421
> [!WARNING]
2522
> Always make sure that your filesystem is in a healthy state, your disk partition table type (GPT or MBR) will support the new size, and ensure your data is backed up before you perform disk expansion operations. For more information, see the [Azure Backup quickstart](../../backup/quick-backup-vm-portal.md).
2623
2724
## <a id="identifyDisk"></a>Identify Azure data disk object within the operating system ##
2825

29-
In the case of expanding a data disk when there are several data disks present on the VM, it may be difficult to relate the Azure LUNs to the Linux devices. If the OS disk needs expansion, it is clearly labeled in the Azure portal as the OS disk.
26+
When expanding a data disk, when there are several data disks present on the VM, it may be difficult to relate the Azure LUNs to the Linux devices. If the OS disk needs expansion, it is clearly labeled in the Azure portal as the OS disk.
3027

3128
Start by identifying the relationship between disk utilization, mount point, and device, with the ```df``` command.
3229

@@ -42,9 +39,9 @@ Filesystem Type Size Used Avail Use% Mounted on
4239
/dev/sde1 ext4 32G 49M 30G 1% /opt/db/log
4340
```
4441

45-
Here we can see, for example, the `/opt/db/data` filesystem is nearly full, and is located on the `/dev/sdd1` partition. The output of `df` shows the device path regardless of whether the disk is mounted by device path or the (preferred) UUID in the fstab. Also take note of the Type column, indicating the format of the filesystem. This is important later.
42+
Here we can see, for example, the `/opt/db/data` filesystem is nearly full, and is located on the `/dev/sdd1` partition. The output of `df` shows the device path whether the disk is mounted using the device path or the (preferred) UUID in the fstab. Also take note of the Type column, indicating the format of the filesystem. The format is important later.
4643

47-
Now locate the LUN that correlates to `/dev/sdd` by examining the contents of `/dev/disk/azure/scsi1`. The output of the following `ls` command shows that the device known as `/dev/sdd` within the Linux OS is located at LUN1 when looking in the Azure portal.
44+
Now locate the LUN that correlates to `/dev/sdd` by examining the contents of `/dev/disk/azure/scsi1`. The output of the following `ls` command shows that the device known as `/dev/sdd` within the Linux OS is located at LUN1 when looking in the Azure portal.
4845

4946
```bash
5047
sudo ls -alF /dev/disk/azure/scsi1/
@@ -120,11 +117,11 @@ In the following samples, replace example parameter names such as *myResourceGro
120117
121118
## Expand a disk partition and filesystem
122119
> [!NOTE]
123-
> While there are many tools that may be used for performing the partition resizing, the tools detailed in the remainder of this document are the same tools used by certain automated processes such as cloud-init. As described here, the `growpart` tool with the `gdisk` package provides universal compatibility with GUID Partition Table (GPT) disks, as older versions of some tools such as `fdisk` did not support GPT.
120+
> While there are many tools that may be used for performing the partition resizing, the tools detailed in the remainder of this document are the same tools used by certain automated processes such as cloud-init. As described here, the `growpart` tool with the `gdisk` package provides universal compatibility with GUID Partition Table (GPT) disks, as older versions of some tools such as `fdisk` did not support GPT.
124121
125122
### Detecting a changed disk size
126123
127-
If a data disk was expanded without downtime using the procedure mentioned previously, the disk size won't be changed until the device is rescanned, which normally only happens during the boot process. This rescan can be called on-demand with the following procedure. In this example we have detected using the methods in this document that the data disk is currently `/dev/sda` and has been resized from 256 GiB to 512 GiB.
124+
If a data disk was expanded without downtime using the procedure mentioned previously, the reported disk size doesn't change until the device is rescanned, which normally only happens during the boot process. This rescan can be called on-demand with the following procedure. In this example, we find using the methods in this document that the data disk is currently `/dev/sda` and was resized from 256 GiB to 512 GiB.
128125
129126
1. Identify the currently recognized size on the first line of output from `fdisk -l /dev/sda`
130127
@@ -145,13 +142,13 @@ If a data disk was expanded without downtime using the procedure mentioned previ
145142
/dev/sda1 2048 536870878 536868831 256G 83 Linux
146143
```
147144

148-
1. Insert a `1` character into the rescan file for this device. Note the reference to sda, this would change if a different disk device was resized.
145+
1. Insert a `1` character into the rescan file for this device. Note the reference to sda in the example. The disk identifier would change if a different disk device was resized.
149146

150147
```bash
151148
echo 1 | sudo tee /sys/class/block/sda/device/rescan
152149
```
153150

154-
1. Verify that the new disk size has been recognized
151+
1. Verify that the new disk size is now recognized
155152

156153
```bash
157154
sudo fdisk -l /dev/sda
@@ -170,9 +167,9 @@ If a data disk was expanded without downtime using the procedure mentioned previ
170167
/dev/sda1 2048 536870878 536868831 256G 83 Linux
171168
```
172169

173-
The remainder of this article uses the OS disk for the examples of the procedure for increasing the size of a volume at the OS level. If the expanded disk is a data disk, use the [previous guidance for identifying the data disk device](#identifyDisk), and follow these instructions as a guideline, substituting the data disk device (for example `/dev/sda`), partition numbers, volume names, mount points, and filesystem formats, as necessary.
170+
The remainder of this article uses the OS disk for the examples of the procedure for increasing the size of a volume at the OS level. If the expanded disk is a data disk, use the [previous guidance for identifying the data disk device](#identifyDisk), and follow these instructions as a guideline, substituting the data disk device (for example `/dev/sda`), partition numbers, volume names, mount points, and filesystem formats, as necessary.
174171

175-
All Linux OS guidance should be viewed as generic and may apply on any distribution, but generally matches the conventions of the named marketplace publisher. Reference the Red Hat documents for the package requirements on any distribution claiming Red Hat compatibility, such as CentOS and Oracle.
172+
All Linux OS guidance should be viewed as generic and may apply on any distribution, but generally matches the conventions of the named marketplace publisher. Reference the Red Hat documents for the package requirements on any distribution based on Red Hat or claiming Red Hat compatibility.
176173

177174
### Increase the size of the OS disk
178175

@@ -183,13 +180,13 @@ The following instructions apply to endorsed Linux distributions.
183180
184181
# [Ubuntu](#tab/ubuntu)
185182

186-
On Ubuntu 16.x and newer, the root partition of the OS disk and filesystems will be automatically expanded to utilize all free contiguous space on the root disk by cloud-init, provided there's a small bit of free space for the resize operation. For this circumstance the sequence is simply
183+
On Ubuntu 16.x and newer, the root partition of the OS disk and filesystems are automatically expanded to utilize all free contiguous space on the root disk by cloud-init, provided there's a small bit of free space for the resize operation. In this case, the sequence is simply
187184

188185
1. Increase the size of the OS disk as detailed previously
189186
1. Restart the VM, and then access the VM using the **root** user account.
190187
1. Verify that the OS disk now displays an increased file system size.
191188

192-
As shown in the following example, the OS disk has been resized from the portal to 100 GB. The **/dev/sda1** file system mounted on **/** now displays 97 GB.
189+
As shown in the following example, the OS disk was resized from the portal to 100 GB. The **/dev/sda1** file system mounted on **/** now displays 97 GB.
193190

194191
```bash
195192
df -Th
@@ -213,15 +210,15 @@ user@ubuntu:~#
213210

214211
To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15, and SUSE SLES 15 for SAP:
215212

216-
1. Follow the procedure above to expand the disk in the Azure infrastructure.
213+
1. Follow the procedure previously described to expand the disk in the Azure infrastructure.
217214

218215
1. Access your VM as the **root** user by using the ```sudo``` command after logging in as another user:
219216

220217
```bash
221218
sudo -i
222219
```
223220

224-
1. Use the following command to install the **growpart** package, which will be used to resize the partition, if it isn't already present:
221+
1. Use the following command to install the **growpart** package, which is used to resize the partition, if it isn't already present:
225222

226223
```bash
227224
zypper install growpart
@@ -254,9 +251,9 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
254251
CHANGED: partition=4 start=3151872 old: size=59762655 end=62914527 new: size=97511391 end=100663263
255252
```
256253

257-
1. Run the `lsblk` command again to check whether the partition has been increased.
254+
1. Run the `lsblk` command again to check whether the partition was increased.
258255

259-
The following output shows that the **/dev/sda4** partition has been resized to 46.5 GB:
256+
The following output shows that the **/dev/sda4** partition was resized to 46.5 GB:
260257

261258
```bash
262259
lsblk
@@ -342,11 +339,11 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
342339
tmpfs tmpfs 92M 0 92M 0% /run/user/490
343340
```
344341

345-
In the preceding example, we can see that the file system size for the OS disk has been increased.
342+
In the preceding example, we can see that the file system size for the OS disk was increased.
346343

347-
# [Red Hat/CentOS with LVM](#tab/rhellvm)
344+
# [Red Hat with LVM](#tab/rhellvm)
348345

349-
1. Follow the procedure above to expand the disk in the Azure infrastructure.
346+
1. Follow the procedure previously described to expand the disk in the Azure infrastructure.
350347

351348
1. Access your VM as the **root** user by using the ```sudo``` command after logging in as another user:
352349

@@ -376,7 +373,7 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
376373
└─rootvg-rootlv xfs 4f3e6f40-61bf-4866-a7ae-5c6a94675193 /
377374
```
378375

379-
1. Check whether there's free space in the LVM volume group (VG) containing the root partition. If there's free space, skip to step 12.
376+
1. Check whether there's free space in the LVM volume group (VG) containing the root partition. If there's free space, skip to step 12.
380377

381378
```bash
382379
vgdisplay rootvg
@@ -407,13 +404,13 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
407404

408405
In this example, the line **Free PE / Size** shows that there's 38.02 GB free in the volume group, as the disk has already been resized.
409406

410-
1. Install the **cloud-utils-growpart** package to provide the **growpart** command, which is required to increase the size of the OS disk and the gdisk handler for GPT disk layouts This package is preinstalled on most marketplace images
407+
1. Install the **cloud-utils-growpart** package to provide the **growpart** command, which is required to increase the size of the OS disk and the gdisk handler for GPT disk layouts This package is preinstalled on most marketplace images
411408

412409
```bash
413-
yum install cloud-utils-growpart gdisk
410+
dnf install cloud-utils-growpart gdisk
414411
```
415412

416-
In RHEL/CentOS 8.x VMs you can use `dnf` command instead of `yum`.
413+
In Red Hat versions 7 and below you can use `yum` command instead of `dnf`.
417414

418415
1. Determine which disk and partition holds the LVM physical volume (PV) or volumes in the volume group named **rootvg** by using the **pvscan** command. Note the size and free space listed between the brackets (**[** and **]**).
419416

@@ -452,7 +449,7 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
452449
CHANGED: partition=4 start=2054144 old: size=132161536 end=134215680 new: size=199272414 end=201326558
453450
```
454451

455-
1. Verify that the partition has resized to the expected size by using the `lsblk` command again. Notice that in the example **sda4** has changed from 63G to 95G.
452+
1. Verify that the partition has resized to the expected size by using the `lsblk` command again. Notice that in the example **sda4** changed from 63G to 95G.
456453

457454
```bash
458455
lsblk /dev/sda4
@@ -490,7 +487,7 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
490487
PV /dev/sda4 VG rootvg lvm2 [<95.02 GiB / <70.02 GiB free]
491488
```
492489

493-
1. Expand the LV by the required amount, which doesn't need to be all the free space in the volume group. In the following example, **/dev/mapper/rootvg-rootlv** is resized from 2 GB to 12 GB (an increase of 10 GB) through the following command. This command will also resize the file system on the LV.
490+
1. Expand the LV by the required amount, which doesn't need to be all the free space in the volume group. In the following example, **/dev/mapper/rootvg-rootlv** is resized from 2 GB to 12 GB (an increase of 10 GB) through the following command. This command also resizes the file system on the LV.
494491

495492
```bash
496493
lvresize -r -L +10G /dev/mapper/rootvg-rootlv
@@ -529,26 +526,26 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
529526
> [!NOTE]
530527
> To use the same procedure to resize any other logical volume, change the **lv** name in step **12**.
531528
532-
# [Red Hat/CentOS without LVM](#tab/rhelraw)
529+
# [Red Hat without LVM](#tab/rhelraw)
533530

534-
1. Follow the procedure above to expand the disk in the Azure infrastructure.
531+
1. Follow the procedure previously described to expand the disk in the Azure infrastructure.
535532

536533
1. Access your VM as the **root** user by using the ```sudo``` command after logging in as another user:
537534

538535
```bash
539536
sudo -i
540537
```
541538

542-
1. When the VM has restarted, perform the following steps:
539+
1. When the VM restarts completely, perform the following steps:
543540

544541
1. Install the **cloud-utils-growpart** package to provide the **growpart** command, which is required to increase the size of the OS disk and the gdisk handler for GPT disk layouts. This package is preinstalled on most marketplace images
545542

546543
```bash
547-
yum install cloud-utils-growpart gdisk
544+
dnf install cloud-utils-growpart gdisk
548545
```
549546

550-
In RHEL/CentOS 8.x VMs you can use `dnf` command instead of `yum`.
551-
547+
In Red Hat versions 7 and below you can use `yum` command instead of `dnf`.
548+
552549
1. Use the **lsblk -f** command to verify the partition and filesystem type holding the root (**/**) partition
553550

554551
```bash
@@ -566,7 +563,7 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
566563
└─sdb1 ext4 923f51ff-acbd-4b91-b01b-c56140920098 /mnt/resource
567564
```
568565

569-
1. For verification, start by listing the partition table of the sda disk with **gdisk**. In this example, we see a 48.0 GiB disk with partition #2 sized 29.0 GiB. The disk was expanded from 30 GB to 48 GB in the Azure portal.
566+
1. For verification, start by listing the partition table of the sda disk with **gdisk**. In this example, we see a 48.0 GiB disk with partition #2 sized 29.0 GiB. The disk was expanded from 30 GB to 48 GB in the Azure portal.
570567

571568
```bash
572569
gdisk -l /dev/sda
@@ -597,7 +594,7 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
597594
15 10240 1024000 495.0 MiB EF00 EFI System Partition
598595
```
599596

600-
1. Expand the partition for root, in this case sda2 by using the **growpart** command. Using this command expands the partition to use all of the contiguous space on the disk.
597+
1. Expand the partition for root, in this case sda2 by using the **growpart** command. Using this command expands the partition to use all of the contiguous space on the disk.
601598

602599
```bash
603600
growpart /dev/sda 2
@@ -607,7 +604,7 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
607604
CHANGED: partition=2 start=2050048 old: size=60862464 end=62912512 new: size=98613214 end=100663262
608605
```
609606

610-
1. Now print the new partition table with **gdisk** again. Notice that partition 2 has is now sized 47.0 GiB
607+
1. Now print the new partition table with **gdisk** again. Notice that partition 2 has is now sized 47.0 GiB
611608

612609
```bash
613610
gdisk -l /dev/sda

0 commit comments

Comments
 (0)