1

I have a CentOS server on VMware that has, among others, a disk of 1.5TB, with a single xfs partition using the whole disk. This disk/partition is running out of space, so I need to increase its size to 2.5TB.

So I increased the size on VMware and tried to delete and add the partition, which failed. Of course, the original partition is MBR and the new one must be GPT, but when trying to remove/add the partition, the conversion fails. I've found the original partition is at sector 128 and the new one tries to start at sector 2048, which I tried to modify, but I couldn't (I guess because GPT needs more space than MBR?).

Then I come with the idea of moving the original partition so it starts at sector 2048, convert the partition to GPT, then increase the size of the partition.

Does it make sense? Is that possible? Specially the first part of moving the partition. Thanks!

Update For formatting reasons, here's the output of the suggested command: parted /dev/disk unit s print free

Disk /dev/sdb: 5368709120s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Numero  Inicio       Fin          Tamaño       Typo     Sistema de ficheros  Banderas
        63s          127s         65s                   Free Space
 1      128s         3259013119s  3259012992s  primary  xfs
        3259013120s  5368709119s  2109696000s           Free Space
6
  • Can you show output of parted /dev/disk unit s print free or similar? Which bootloader are you using, you might also need an additional partition for that. Sep 2, 2021 at 8:24
  • I've updated the question with the output of the command. About the bootloader, why would I need that in a disk added just for data? There's no SO here.
    – curropar
    Sep 2, 2021 at 9:04
  • 1
    OK, so it's just a data disk, that's much simpler then. Sep 2, 2021 at 9:11
  • Sorry, last line of the output was not updated, coming from an old copy/paste. It's updated now.
    – curropar
    Sep 2, 2021 at 9:16
  • With any major change like this, you need good backup. Does gdisk work better? Converting to or from GPT - must have good backups. rodsbooks.com/gdisk/mbr2gpt.html
    – oldfred
    Sep 2, 2021 at 14:59

1 Answer 1

1

So you have one msdos partition that starts at sector 128.

This is uncommon since the standard would be MiB alignment, starting at sector 2048 (for 512 byte logical sector size).

With GPT, you can still use the start sector 128, that isn't a problem:

# parted /dev/loop0 unit s print free
Model: Loopback device (loopback)
Disk /dev/loop0: 3259017216s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start  End          Size         File system  Name  Flags
        34s    127s         94s          Free Space
 1      128s   3259017182s  3259017055s

However, parted will complain to you when you create it:

# parted /dev/loop0
(parted) mklabel gpt
(parted) mkpart                                                           
Partition name?  []?                                                      
File system type?  [ext2]?                                                
Start? 128s                                                               
End? 100%                                                                 
Warning: The resulting partition is not properly aligned for best performance:
128s % 2048s != 0s
Ignore/Cancel? Ignore                                                     

If you do not care about MiB alignment (and since your data is already there, you have no choice, anyway) you can just ignore this warning. A start sector of 128 would still be 4K aligned (64K aligned), so that would be fine too.

GPT also stores a backup at the end of disk, so the end sector can sometimes be the issue. However you're lucky and you have 4096 free sectors at the end of your disk, so there is no issue in your case. Otherwise you'd have to grow the disk first before converting to GPT.

If you want to achieve MiB alignment, you'd have to shift all data. The safest way to do so (if you have enough space) would be to just copy it over to a new disk entirely. Relocating data in place can be risky.

6
  • Thanks! Will try and come back. Just out of curiosity, as I've no choice, as you said: what does it means not having MiB in terms of performance? FYI, this disk contains images to deploy to new computers, so just huge files accessed with not many accesses.
    – curropar
    Sep 2, 2021 at 9:36
  • Chances are you won't be seeing any difference in performance. For many devices, simple 4K alignment is enough (and filesystems don't do MiB alignment internally anyway). The MiB alignment is mainly because its easier to handle (for humans) and it's future-proof as some devices already use larger than 4K pages. Sep 2, 2021 at 9:53
  • So warnings everywhere, one saying the data will be destroyed (messages are in Spanish, I'm translating them, so they might not be with the same wording as in English): (parted) mklabel gpt Warning: The partition(s) in /dev/sdb are being used. Descartar/Ignore/Cancelar/Cancel? I warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue? Sí/Yes/No?
    – curropar
    Sep 2, 2021 at 10:22
  • parted does not know what you're up to, basically you are wiping your partition table and re-creating them by hand. If you don't do this correctly, the data will no longer be accessible. You can use other tools instead if it makes you feel better. Sep 3, 2021 at 6:55
  • 1
    Sorry for the late answer, but the data on the disk wasn't mine, and I wasn't responsible of move it. So, it has worked out flawless. I just needed to resize the filesystem after the partition was on GPT format, and now it's 2.5TB. Thanks!!
    – curropar
    Oct 7, 2021 at 11:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .