4

I have tried to sort my partitions to change the order, but when I try to use s command of gdisk, this warning appears:

You may need to edit /etc/fstab and/or your boot loader configuration!

And it doesn't let me use the command. What can I do to sort the partitions? (I can't use fdisk).

Thank you!

GAD3R
  • 3,702
  • 2
  • 18
  • 32
fnicolas
  • 41
  • 1
  • 3

2 Answers2

7

Use the s command in gdisk.

The warning doesn't prevent you from using the command. It's just a warning. If you use s and then p, you'll probably find that the partitions are, indeed, sorted and ready to be written.

Note that the "Sort" command only does what it says – sorts the partition table entries in ascending order, to match the actual disk layout. It doesn't let you move the GPT entries manually (use "Expert" → "Transpose" for that), and it does not move the actual partition contents.

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
  • 2
    Absolutely correct. I'd like to add that the warning is a bit of overabundance of caution. In the Old Days, `/etc/fstab` and boot loader configurations referred to partitions by device filename, like `/dev/sda4`. If you sort the entries, those may change, and therefore require edits to `/etc/fstab` and boot loader configuration files. Today, filesystems are usually identified by UUID values, which will not change because of a `gdisk` sort operation. Still, the old method can be used, and occasionally is. – Rod Smith May 04 '16 at 13:15
  • AFAIK, some other things (e.g. the UEFI boot entries, and apparently the Windows BCD thing) still refer to disk UUID + partition index as well? (I remember having temporarily broken Windows on my dualboot system by deleting a preceding Linux partition…) – u1686_grawity May 04 '16 at 13:20
  • That may well be. I'm not too familiar with Windows' BCD, so I can't comment on it. EFI boot entries normally refer to files on the [EFI System Partition (ESP),](http://en.wikipedia.org/wiki/EFI_System_partition) which is usually the first or second partition, in part to minimize the risk of problems arising by it being renumbered. Still, if the ESP *is* a later-numbered partition (which is legal, even if it's unusual), problems might arise if it were to be renumbered. I can't say I've experimented with such changes, so I don't know firsthand what would actually happen. – Rod Smith May 05 '16 at 12:54
  • Right, seems like I was mistaken about EFI boot entries – checking mine now I can see the ESP's UUID, not the disk UUID. – u1686_grawity May 06 '16 at 04:31
2

Slightly easier, from the command prompt:

sgdisk --sort <device>

sgdisk is included in the gdisk package on CentOS 6 and 7

lickdragon
  • 21
  • 2