1

If a picture is worth a thousand words, here is 2K:

enter image description here

The top is gparted and the bottom is the terminal.


gparted lists partitions in sector order:

  • p1, p2, p3, p4, p11, p5, p8, p6, p7

The terminal lists partitions in lsblk order (using the alias lsdrv):

  • p11, p7, p5, p3, p1, p8, p6, p4, p2

There are partitions deleted in preparation of Ubuntu 24.04 install:

  • p9, p10

It's noteworthy that partition p11 used to be p9 with the flags hidden, diag but after copy & paste the flags were changed to msftdata. I haven't booted Windows 10 in years so I may never know if this will be a problem...

Some say fdisk may solve the problem and renumber the partitions in order, but I haven't found a definitive answer. How can partitions be renumbered in the order of:

  • p1, p2, p3, p4, p5, p6, p7, p8 and p9?
4
  • I take it this SuperUser answer is the fdisk solution that doesn’t do what you need? 🤔
    – matigo
    Commented May 28 at 9:25
  • 1
    @matigo I had tried that SuperUser answer before posting my question but it told me device not found which led me to believe nvme devices weren't supported. However I must have spelled the device wrong because it works now. I'll delete my question later today after you read the comment. Thanks. Commented May 28 at 11:11
  • 1
    Generally renumbering is a bad idea. Any place still using device like /dev/sdX or /dev/nvme0nXpY will then be wrong. You can use gdisk. rodsbooks.com/gdisk/walkthrough.html I would make sure to have really good backups including a backup of the current partition table just in case sudo sfdisk -d /dev/sda > PT_sda. And same for nmve drive's partitions.
    – oldfred
    Commented May 28 at 14:04
  • @oldfred Great advice as always. Long ago I used to always buy new SSD's, PCMIA's, NVMe's and SDRAM cards so I had learned to always use the mount name. In etc/fstab it's by UUID of course so that is the only thing I would have to change to point to the mount name. I'll rescind my idea of deleting this question because your excellent comment will go into the dust-bin. I'll post an answer of what I did to solve the problem and add your caution to backup and recommendation for gdisk by Rod Smith. Commented May 28 at 22:25

1 Answer 1

1

This is a duplicate question for Stack Exchange because the solution is posted on Super User: How to renumber a partition?. I'll use artistic license and post an answer here in Ask Ubuntu and expand with additional details.

Firstly, please follow the comment by Old Fred to backup your current partition information:

  • sudo sfdisk -d /dev/sda > PT_sda

The fdisk program was used to renumber the partitions:

enter image description here

As per Old Fred's comment above you can also use gdisk: A gdisk Walkthrough


The lsblk command messes up the sort order in the first place. See: How to change lsblk sort order?. Following the link gives "nice" results (IMO):

$ lsdrv | sblk

NAME        FSTYPE   LABEL            MOUNTPOINT                      SIZE MODEL
nvme0n1                                                               477G Samsung SSD 960 PRO 512GB               
├─nvme0n1p1 ntfs                                                      450M 
├─nvme0n1p2 vfat                      /boot/efi                        99M 
├─nvme0n1p3                                                            16M 
├─nvme0n1p4 ntfs     NVMe_Win10       /mnt/c                        265.5G 
├─nvme0n1p5 ntfs                                                      859M 
├─nvme0n1p6 ntfs     Shared_WSL+Linux /mnt/e                            9G 
├─nvme0n1p7 ext4     Ubuntu 24.04                                   115.8G 
├─nvme0n1p8 ext4     New_Ubuntu_16.04 /                              45.1G 
└─nvme0n1p9 ext4     Old_Ubuntu_16.04 /mnt/old                       23.1G 
sdb                                                                  15.4M                 
└─sdb1      vfat                                                     15.4M 
mmcblk0                                                             119.1G 
└─mmcblk0p1 vfat     SANDISK128       /media/rick/SANDISK128        119.1G 
sr0                                                                  1024M DVD+/-RW DW316  
sda                                                                 931.5G HGST HTS721010A9
├─sda1      vfat     ESP                                              500M 
├─sda2                                                                128M 
├─sda3      ntfs     HGST_Win10       /mnt/d                          919G 
├─sda4      ntfs     WINRETOOLS                                       450M 
└─sda5      ntfs     Image                                           11.4G 

You must log in to answer this question.

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