Sometimes (usually after some repartitioning operations) disk partitions can get into the wrong order (e. g., "
sdb1 sdb7 sdb2 sdb5 sdb4 sdb3", as you can see it in
lsblk / fdisk / Parted / GParted etc.).
Usually it's harmless, but anyway can be easily fixed in Linux with a
fdisk
utility (from the
util-linux package): just start
fdisk
with a HDD device as an argument (e. g.:
fdisk /dev/sdb
), then sequentially press
'x',
'f' and
'w' keys, and finally reboot your system (for the changes to take effect).
Be careful:
- you can do this from a some sort of Live CD / Live USB environment;
please don't try this on a running production system;
- partition numbers get changed, and some OS's (and especially OS bootloaders) sometimes don't like this;
- the partition table can get corrupted — make backups prior to any experiments.
Here is a sample output log:
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.21.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): x
Expert command (m for help): m
Command action
b move beginning of data in a partition
c change number of cylinders
d print the raw data in the partition table
e list extended partitions
f fix partition order
g create an IRIX (SGI) partition table
h change number of heads
i change the disk identifier
m print this menu
p print the partition table
q quit without saving changes
r return to main menu
s change number of sectors/track
v verify the partition table
w write table to disk and exit
Expert command (m for help): f
Done.
Expert command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
---
Last updated: 2014-06-17