Skip to content

Commit 21cb4ce

Browse files
authored
Update expand-disks.md
1 parent cba3e8a commit 21cb4ce

File tree

1 file changed

+51
-19
lines changed

1 file changed

+51
-19
lines changed

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

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,51 @@ In the following samples, replace example parameter names such as *myResourceGro
128128
> [!NOTE]
129129
> 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.
130130
131-
The remainder of this article describes uses the OS disk for the examples of the procedure for increasing the size of a volume at the OS level. If the disk which needs to be expanded 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 (for example `/dev/sda`), partition numbers, volume names, mount points, and filesystem formats, as necessary.
131+
### Detecting a changed disk size
132+
133+
If a data disk was expanded without downtime using the procedure mentioned previously, the disk size will not 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 256GB to 512GB.
134+
135+
1. Identify the currently recognized size on the first line of output from `fdisk -l /dev/sda`
136+
137+
```
138+
root@linux:~# fdisk -l /dev/sda
139+
Disk /dev/sda: 256 GiB, 274877906944 bytes, 536870912 sectors
140+
Disk model: Virtual Disk
141+
Units: sectors of 1 * 512 = 512 bytes
142+
Sector size (logical/physical): 512 bytes / 4096 bytes
143+
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
144+
Disklabel type: dos
145+
Disk identifier: 0x43d10aad
146+
147+
Device Boot Start End Sectors Size Id Type
148+
/dev/sda1 2048 536870878 536868831 256G 83 Linux
149+
```
150+
151+
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.
152+
153+
```
154+
root@linux:~# echo 1 > /sys/class/block/sda/device/rescan
155+
```
156+
157+
1. Verify that the new disk size has been recognized
158+
159+
```
160+
root@linux:~# fdisk -l /dev/sda
161+
Disk /dev/sda: 512 GiB, 549755813888 bytes, 1073741824 sectors
162+
Disk model: Virtual Disk
163+
Units: sectors of 1 * 512 = 512 bytes
164+
Sector size (logical/physical): 512 bytes / 4096 bytes
165+
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
166+
Disklabel type: dos
167+
Disk identifier: 0x43d10aad
168+
169+
Device Boot Start End Sectors Size Id Type
170+
/dev/sda1 2048 536870878 536868831 256G 83 Linux
171+
```
172+
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.
174+
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.
132176
133177
### Increase the size of the OS disk
134178
@@ -139,7 +183,7 @@ The following instructions apply to endorsed Linux distributions.
139183
140184
# [Ubuntu](#tab/ubuntu)
141185
142-
On Ubuntu 16.x and newer, the root partition and filesystems will be automatically expanded to utilize all free contiguous space on the root disk by cloud-init, provided there is a small bit of free space for the resize operation. For this circumstance the sequence is simply
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 is a small bit of free space for the resize operation. For this circumstance the sequence is simply
143187
144188
1. Increase the size of the OS disk as detailed previously
145189
1. Restart the VM, and then access the VM using the **root** user account.
@@ -342,17 +386,9 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
342386
VG UUID lPUfnV-3aYT-zDJJ-JaPX-L2d7-n8sL-A9AgJb
343387
```
344388

345-
In this example, the line **Free PE / Size** shows that there is 38.02 GB free in the volume group. No disk resizing is required before adding space to the volume group
346-
347-
1. To increase the size of the OS disk in RHEL 7 and newer with LVM:
348-
349-
1. Stop the VM.
350-
1. Increase the size of the OS disk from the portal.
351-
1. Start the VM.
352-
353-
1. When the VM has restarted, complete the following steps:
354-
355-
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
389+
In this example, the line **Free PE / Size** shows that there is 38.02 GB free in the volume group, as the disk has already been resized.
390+
391+
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
356392

357393
```bash
358394
[root@rhel-lvm ~]# yum install cloud-utils-growpart gdisk
@@ -415,7 +451,7 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
415451
PV /dev/sda4 VG rootvg lvm2 [<95.02 GiB / <70.02 GiB free]
416452
```
417453

418-
1. Expand the desired logical volume (lv) by the desired amount, which does not 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.
454+
1. Expand the LV by the required amount, which does not 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.
419455

420456
```bash
421457
[root@rhel-lvm ~]# lvresize -r -L +10G /dev/mapper/rootvg-rootlv
@@ -439,11 +475,7 @@ To increase the OS disk size in SUSE 12 SP4, SUSE SLES 12 for SAP, SUSE SLES 15,
439475
data blocks changed from 524288 to 3145728
440476
```
441477

442-
1. The `lvresize` command automatically calls the appropriate resize command for the filesystem in the LV. Verify whether **/dev/mapper/rootvg-rootlv**, which is mounted on **/**, has an increased file system size by using this command:
443-
444-
```shell
445-
[root@rhel-lvm ~]# df -Th /
446-
```
478+
1. The `lvresize` command automatically calls the appropriate resize command for the filesystem in the LV. Verify whether **/dev/mapper/rootvg-rootlv**, which is mounted on **/**, has an increased file system size by using the `df -Th` command:
447479

448480
Example output:
449481

0 commit comments

Comments
 (0)