0

I've been struggling to get this right and tried plenty of tutorials with no luck.

I have a Centos 7 installed as a guest on Hyper-V and need to expand the disk space on centos root partition. I've already extended VHDX in Hyper-V. I've been following this tutorial but it doesn't increase the logical volume. Below is the output of the disk structure.

[root@atlassian-01 ~]# lsblk;pvs;vgs;lvs;df -h;fdisk -l /dev/sda
NAME                          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                             8:0    0  150G  0 disk
├─sda1                          8:1    0  200M  0 part /boot/efi
├─sda2                          8:2    0    1G  0 part /boot
└─sda3                          8:3    0 28.8G  0 part
  ├─centos_atlassian--01-root 253:0    0 25.8G  0 lvm  /
  └─centos_atlassian--01-swap 253:1    0    3G  0 lvm  [SWAP]
sr0                            11:0    1 1024M  0 rom
  PV         VG                  Fmt  Attr PSize  PFree
  /dev/sda3  centos_atlassian-01 lvm2 a--  28.80g    0
  VG                  #PV #LV #SN Attr   VSize  VFree
  centos_atlassian-01   1   2   0 wz--n- 28.80g    0
  LV   VG                  Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos_atlassian-01 -wi-ao---- 25.80g
  swap centos_atlassian-01 -wi-ao----  3.00g
Filesystem                             Size  Used Avail Use% Mounted on
/dev/mapper/centos_atlassian--01-root   26G   26G   17M 100% /
devtmpfs                               3.8G     0  3.8G   0% /dev
tmpfs                                  3.9G  8.0K  3.9G   1% /dev/shm
tmpfs                                  3.9G  8.3M  3.8G   1% /run
tmpfs                                  3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda2                             1014M  134M  881M  14% /boot
/dev/sda1                              200M  9.8M  191M   5% /boot/efi
tmpfs                                  780M     0  780M   0% /run/user/0

Disk /dev/sda: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1    62914559    31457279+  ee  GPT
Partition 1 does not start on physical sector boundary.

What is the proper way to allocate more space to centos_atlassian--01-root?

Best regards, Jacek

Jacek Michalski
  • 11
  • 1
  • 1
  • 2
  • 1
    You haven't resized your `sda3` partition. You may use [this SO answer](https://unix.stackexchange.com/a/320454) to do that, or just create a new partition. After creating/extending your LVM partition(s), you may then do the usual `pvcreate` + `vgextend` (only if you created a new partition), `lvextend`, and `xfs_growfs` or `resize2fs`. – mforsetti Jul 12 '18 at 15:23
  • Yeah, but when I execute fdisk -l /dev/sda I have listed only /dev/sda1 partition. Should I delete it and extend it? There is no /dev/sda3 i fdisk. What am I doing wrong? – Jacek Michalski Jul 12 '18 at 18:20
  • You don't do anything wrong. Your version of `fdisk` is old, and does not support non-aligned partition boundary, therefore the error `Partition 1 does not start on physical sector boundary.`; your `lsblk` shows otherwise. Do not delete anything. Check if your `fdisk` version is >= 1.2.3 [1](https://www.seagate.com/as/en/tech-insights/advanced-format-4k-sector-hard-drives-master-ti/). – mforsetti Jul 13 '18 at 07:19
  • My fdisk version is 2.23.2 – Jacek Michalski Jul 13 '18 at 07:39
  • Can't test this right now so probably snapshot your VM and try using `fdisk` to add new partition. – mforsetti Jul 13 '18 at 07:47

1 Answers1

1

Ok, I've figured it out. You can't use fdisk on GPT partition. Instead you need to use gdisk.

I have followed this article and everything works like a charm.

I hope that it will help someone :-)

Jacek Michalski
  • 11
  • 1
  • 1
  • 2