I needed to add extra 2.5TB to the existing 400GB disk (sda) on my system. I added new virtual disks with 2.5TB (sdb), proceeded to create the partition table with fdisk.

Used pvcreate /dev/sdb1, to create the physical volume, then extended the volume group and finally extended the logical volume.

At the end I used the xfs_grow2fs for the filesystem to recognize. Only until then I realized that I only got 2TB out of the 2.5TB on the new disk due to MBR limitation.

Can I convert this drive to GPT without affecting sda? Will this movement affect the filesystem due to xfs_grow2fs being used? The worst case scenario would be having .5TB missing.

Using CentOS 7.

lsblk command output

fd0                    2:0    1     4K  0 disk 
sda                    8:0    0   420G  0 disk 
├─sda1                 8:1    0   500M  0 part /boot
└─sda2                 8:2    0 419.5G  0 part 
  ├─centos_sftp-root 253:0    0    15G  0 lvm  /
  ├─centos_sftp-swap 253:1    0     2G  0 lvm  [SWAP]
  └─centos_sftp-home 253:2    0   2.4T  0 lvm  /home
sdb                    8:16   0   2.5T  0 disk 
└─sdb1                 8:17   0     2T  0 part 
  └─centos_sftp-home 253:2    0   2.4T  0 lvm  /home
sr0                   11:0    1  1024M  0 rom  

lvs command

  LV   VG          Attr       LSize  Pool Origin Data%  Meta%  Move Log 
Cpy%Sync Convert
  home centos_sftp -wi-ao----  2.39t                                                    
  root centos_sftp -wi-ao---- 15.00g                                                    
  swap centos_sftp -wi-ao----  2.00g      

df command

Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/centos_sftp-root   15G  2.7G   13G  18% /
devtmpfs                      2.9G     0  2.9G   0% /dev
tmpfs                         2.9G     0  2.9G   0% /dev/shm
tmpfs                         2.9G  8.6M  2.9G   1% /run
tmpfs                         2.9G     0  2.9G   0% /sys/fs/cgroup
/dev/mapper/centos_sftp-home  2.4T  103G  2.3T   5% /home
/dev/sda1                     497M  171M  326M  35% /boot
tmpfs                         581M     0  581M   0% /run/user/1000
tmpfs                         581M     0  581M   0% /run/user/0

I used xfs_growfs to extend home to use the additional 2.5TB but only got 2TB from the new disk due to MBR limits.

output of fdisk -l /dev/sdb

Disk /dev/sdb: 2748.8 GB, 2748779069440 bytes, 5368709120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x3633c5d9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048  4294967294  2147482623+  8e  Linux LVM
  • I'm confused. If you ran pvcreate sdb then there's neither a MBR nor a GPT on sdb. If the XFS filesystem is on a logical volume, then there's no MBR that impacts it in any way. What makes you think that your problem is related to MBR partitions? Post the output of lsblk, lvs and df. Also tell us exactly how you called xfs_grow2fs and copy-paste the output. – Gilles May 9 '18 at 21:59
  • Output is available. – Dagonar May 9 '18 at 22:09
  • 1
    I see. You evidently didn't run pvcreate sdb, but pvcreate /dev/sdb1. Please copy-paste the actual commands you ran, otherwise it's hard to help you. It's also confusing that you refer to 2TB as the filesystem size, but you have a 2.4TB filesystem, your problem is the size of the partition /dev/sdb1 which doesn't span the whole disk unlike what you intended. And now post the output of fdisk -l /dev/sdb. – Gilles May 9 '18 at 22:24
  • I followed the commands listed on this tutorial. The only thing changing is the names of the groups displayed. – Dagonar May 9 '18 at 22:36
  • WARNING: The size of this disk is 2.7 TB (2748779069440 bytes). DOS partition table format can not be used on drives for volumes larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID partition table format (GPT). This is what makes me think I need to change sdb to GPT. – Dagonar May 9 '18 at 22:38

The MBR partition /dev/sdb1 starts at the offset 1MB. This is good, because the first GPT partition would also start at the offset 1MB.

So delete the current partition with fdisk and use g to create a new GPT partition. Choose type LVM for this partition. Make sure that the new partition starts at the same offset as the old one, before you use the w command. Otherwise you will lose all your data.

You can now use the full extent of the 2.5TB instead of the 2TB limit on MBR. Write the changes on disk and reboot. Use fdisk -l to check that changes on sdb are okay. Now we read 2.5TB available. Time to resize the volume groups and physical volumes.

Use pvresize /dev/sdb1 to resize to the new additional space appropriately. Afterwards use lvresize to resize the logical volume group. And finally xfs_growfs to increase the filesystem. Use df to confirm the changes at the end.

For this last part you may refer to this article.

  • 2
    This worked, not because the new disk contains no data, but because the GPT partition you created started at the same offset as the original MBR partition. – Gilles May 10 '18 at 9:59
  • 1
    @sourcejedi The reason it worked is that the procedure actually doesn't overwrite anything in sdb except the partition table. Crucially, the content of the partition wasn't modified. – Gilles May 10 '18 at 10:03
  • @Gilles I have edited for an amusing typo, and to be even more explicit about the safe sequence, and changed my downvote to upvote :). – sourcejedi May 10 '18 at 10:26
  • @Gilles I reverted "Reboot the machine if you feel like it but you shouldn't need to." See unix.stackexchange.com/questions/441789/… – sourcejedi May 10 '18 at 10:28
  • @sourcejedi I think partprobe works in this case on modern systems, but better safe than sorry. – Gilles May 10 '18 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.