Skip to content

Commit d4df07a

Browse files
authored
Merge pull request #71947 from pagienge/patch-6
Update resize-os-disk-gpt-partition.md
2 parents f99670d + 7d4b059 commit d4df07a

File tree

1 file changed

+82
-90
lines changed

1 file changed

+82
-90
lines changed

articles/virtual-machines/linux/resize-os-disk-gpt-partition.md

Lines changed: 82 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -395,131 +395,123 @@ When the VM has restarted, complete these steps:
395395
> [!NOTE]
396396
> To use the same procedure to resize any other logical volume, change the LV name in step 12.
397397
398+
398399
### RHEL RAW
399-
>[!NOTE]
400-
>Always take a snapshot of the VM before increasing OS disk size.
401400

402401
To increase the size of the OS disk in an RHEL RAW partition:
403402

404403
1. Stop the VM.
405404
1. Increase the size of the OS disk from the portal.
406405
1. Start the VM.
407406

408-
When the VM has restarted, perform the following steps:
407+
When the VM has restarted, complete these steps:
409408

410409
1. Access your VM as a **root** user by using the following command:
411-
412-
```
413-
sudo su
414-
```
415410

416-
1. Install the **gptfdisk** package, which is required to increase the size of the OS disk.
417-
418-
```
419-
yum install gdisk -y
411+
```bash
412+
[root@dd-rhel7vm ~]# sudo -i
420413
```
421414

422-
1. To see all the sectors available on the disk, run the following command:
423-
```
424-
gdisk -l /dev/sda
425-
```
426-
427-
1. You will see the details informing the partition type. Ensure it is GPT. Identify the root partition. Do not change or delete the boot partition (BIOS boot partition) and the system partition ('EFI System Partition')
428-
429-
1. Use the following command to start the partitioning for the first time.
430-
```
431-
gdisk /dev/sda
432-
```
415+
1. When the VM has restarted, complete the following step:
433416

434-
1. Now you will see a message asking for the next command ('Command: ? for help').
417+
- 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.
435418

436-
```
437-
w
419+
```bash
420+
[root@dd-rhel7vm ~]# yum install cloud-utils-growpart gdisk
438421
```
439422

440-
1. You will receive a warning stating "Warning! Secondary header is placed too early on the disk! Do you want to
441-
correct this problem? (Y/N):". You have to press 'Y'
423+
1. Use the **lsblk -f** command to verify the partition and filesystem type holding the root (**/**) partition:
442424

443-
```
444-
Y
425+
```bash
426+
[root@vm-dd-cent7 ~]# lsblk -f
427+
NAME FSTYPE LABEL UUID MOUNTPOINT
428+
sda
429+
├─sda1 xfs 2a7bb59d-6a71-4841-a3c6-cba23413a5d2 /boot
430+
├─sda2 xfs 148be922-e3ec-43b5-8705-69786b522b05 /
431+
├─sda14
432+
└─sda15 vfat 788D-DC65 /boot/efi
433+
sdb
434+
└─sdb1 ext4 923f51ff-acbd-4b91-b01b-c56140920098 /mnt/resource
445435
```
446436

447-
1. You should see a message informing that final checks are complete and asking for confirmation. Press 'Y'
437+
1. For verification, start by listing the partition table of the sda disk with **gdisk**. In this example, we see a 48-GB disk with partition 2 at 29.0 GiB. The disk was expanded from 30 GB to 48 GB in the Azure portal.
448438

449-
```
450-
Y
451-
```
452-
453-
1. Check if everything happened correctly using partprobe command
439+
```bash
440+
[root@vm-dd-cent7 ~]# gdisk -l /dev/sda
441+
GPT fdisk (gdisk) version 0.8.10
454442

455-
```
456-
partprobe
457-
```
443+
Partition table scan:
444+
MBR: protective
445+
BSD: not present
446+
APM: not present
447+
GPT: present
458448

459-
1. The above steps have ensured that the secondary GPT header is placed at the end. The next step is to start the process of resizing by using the gdisk tool again. Use the following command.
449+
Found valid GPT with protective MBR; using GPT.
450+
Disk /dev/sda: 100663296 sectors, 48.0 GiB
451+
Logical sector size: 512 bytes
452+
Disk identifier (GUID): 78CDF84D-9C8E-4B9F-8978-8C496A1BEC83
453+
Partition table holds up to 128 entries
454+
First usable sector is 34, last usable sector is 62914526
455+
Partitions will be aligned on 2048-sector boundaries
456+
Total free space is 6076 sectors (3.0 MiB)
460457

458+
Number Start (sector) End (sector) Size Code Name
459+
1 1026048 2050047 500.0 MiB 0700
460+
2 2050048 62912511 29.0 GiB 0700
461+
14 2048 10239 4.0 MiB EF02
462+
15 10240 1024000 495.0 MiB EF00 EFI System Partition
461463
```
462-
gdisk /dev/sda
463-
```
464-
1. In the command menu, press 'p' to see list of partition. Identify the root partition (In the steps, sda2 is considered as the root partition) and the boot partition (In the steps, sda3 is considered as the boot partition)
465464

466-
```
467-
p
468-
```
469-
![Root Partition and Boot Partition](./media/resize-os-disk-rhelraw/resize-os-disk-rhelraw1.png)
465+
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.
470466

471-
1. Press 'd' to delete the partition and select the partition number assigned to boot (in this example it is '3')
472-
```
473-
d
474-
3
475-
```
476-
1. Press 'd' to delete the partition and select the partition number assigned to boot (in this example it is '2')
477-
```
478-
d
479-
2
467+
```bash
468+
[root@vm-dd-cent7 ~]# growpart /dev/sda 2
469+
CHANGED: partition=2 start=2050048 old: size=60862464 end=62912512 new: size=98613214 end=100663262
480470
```
481-
![Delete Root Partition and Boot Partition](./media/resize-os-disk-rhelraw/resize-os-disk-rhelraw2.png)
482471

483-
1. To recreate root partition with increased size, Press 'n', enter the partition number you deleted previously for root('2' for this example) and choose the First Sector as 'Default Value', Last Sector as 'Last sector value - boot size sector' ('4096 in this case' corresponding to 2MB boot) and Hex Code as '8300'
484-
```
485-
n
486-
2
487-
(Enter default)
488-
(Calculateed value of Last sector value - 4096)
489-
8300
490-
```
491-
1. To recreate boot partition, Press 'n', enter the partition number you deleted previously for boot('3' for this example) and choose the First Sector as 'Default Value', Last Sector as 'Default value' and Hex Code as 'EF02'
492-
```
493-
n
494-
3
495-
(Enter default)
496-
(Enter default)
497-
EF02
498-
```
472+
1. Now print the new partition table with **gdisk** again. Notice that partition 2 has expanded to 47.0 GiB:
499473

500-
1. Write the changes with the 'w' command and press 'Y' to confirm
501-
```
502-
w
503-
Y
504-
```
505-
1. Run command 'partprobe' to check for disk stability
506-
```
507-
partprobe
508-
```
509-
1. Reboot the VM and the root partition size would have been increased
510-
```
511-
reboot
512-
```
474+
```bash
475+
[root@vm-dd-cent7 ~]# gdisk -l /dev/sda
476+
GPT fdisk (gdisk) version 0.8.10
513477

514-
![New Root Partition and Boot Partition](./media/resize-os-disk-rhelraw/resize-os-disk-rhelraw3.png)
478+
Partition table scan:
479+
MBR: protective
480+
BSD: not present
481+
APM: not present
482+
GPT: present
515483

516-
1. Run the xfs_growfs command on the partition to resize it
517-
```
518-
xfs_growfs /dev/sda2
484+
Found valid GPT with protective MBR; using GPT.
485+
Disk /dev/sda: 100663296 sectors, 48.0 GiB
486+
Logical sector size: 512 bytes
487+
Disk identifier (GUID): 78CDF84D-9C8E-4B9F-8978-8C496A1BEC83
488+
Partition table holds up to 128 entries
489+
First usable sector is 34, last usable sector is 100663262
490+
Partitions will be aligned on 2048-sector boundaries
491+
Total free space is 4062 sectors (2.0 MiB)
492+
493+
Number Start (sector) End (sector) Size Code Name
494+
1 1026048 2050047 500.0 MiB 0700
495+
2 2050048 100663261 47.0 GiB 0700
496+
14 2048 10239 4.0 MiB EF02
497+
15 10240 1024000 495.0 MiB EF00 EFI System Partition
519498
```
520499

521-
![XFS Grow FS](./media/resize-os-disk-rhelraw/resize-os-disk-rhelraw4.png)
500+
1. Expand the filesystem on the partition with **xfs_growfs**, which is appropriate for a standard marketplace-generated RedHat system:
522501

502+
```bash
503+
[root@vm-dd-cent7 ~]# xfs_growfs /
504+
meta-data=/dev/sda2 isize=512 agcount=4, agsize=1901952 blks
505+
= sectsz=4096 attr=2, projid32bit=1
506+
= crc=1 finobt=0 spinodes=0
507+
data = bsize=4096 blocks=7607808, imaxpct=25
508+
= sunit=0 swidth=0 blks
509+
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
510+
log =internal bsize=4096 blocks=3714, version=2
511+
= sectsz=4096 sunit=1 blks, lazy-count=1
512+
realtime =none extsz=4096 blocks=0, rtextents=0
513+
data blocks changed from 7607808 to 12326651
514+
```
523515

524516
1. Verify the new size is reflected by using the **df** command:
525517

0 commit comments

Comments
 (0)