You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/resize-os-disk-gpt-partition.md
+82-90Lines changed: 82 additions & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -395,131 +395,123 @@ When the VM has restarted, complete these steps:
395
395
> [!NOTE]
396
396
> To use the same procedure to resize any other logical volume, change the LV name in step 12.
397
397
398
+
398
399
### RHEL RAW
399
-
>[!NOTE]
400
-
>Always take a snapshot of the VM before increasing OS disk size.
401
400
402
401
To increase the size of the OS disk in an RHEL RAW partition:
403
402
404
403
1. Stop the VM.
405
404
1. Increase the size of the OS disk from the portal.
406
405
1. Start the VM.
407
406
408
-
When the VM has restarted, perform the following steps:
407
+
When the VM has restarted, complete these steps:
409
408
410
409
1. Access your VM as a **root** user by using the following command:
411
-
412
-
```
413
-
sudo su
414
-
```
415
410
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
420
413
```
421
414
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:
433
416
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.
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.
448
438
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
454
442
455
-
```
456
-
partprobe
457
-
```
443
+
Partition table scan:
444
+
MBR: protective
445
+
BSD: not present
446
+
APM: not present
447
+
GPT: present
458
448
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)
460
457
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
461
463
```
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)
465
464
466
-
```
467
-
p
468
-
```
469
-

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.
470
466
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')

482
471
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:
499
473
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
513
477
514
-

478
+
Partition table scan:
479
+
MBR: protective
480
+
BSD: not present
481
+
APM: not present
482
+
GPT: present
515
483
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
0 commit comments