I have a disk with two partitions: sda1 and sda2. I would like change the number of sda1 to sda2 and sda2 to sda1.
It's possible but I don't remember the procedure. i.e. My first partition will be sda2 and the second sda1, so I need to specify a manual order, not an automatic ordering like in fdisk -> x -> f.
How can I change the order? Links to manuals or tutorials are also welcome.
Thanks.
The reason: I have an application that needs to read data from sda1 but the data is in sda2. Changing the partition table is the fastest fix for this issue. The system isn't critical but I don't want to keep the system halted for too much time.
Update: the fdisk version of OpenBSD includes this functionality.
Best Answer
FYI, it is a bad idea and you can lose everything. If you still want to do it, here are the steps:
Use the
sfdisk
tool: First, make a backup of the partition table usingThen go for it:
You will see something like this
Now it is asking you to give the new details for the 'sda1' partition. So you have to give the numbers of sda2 here. So, I put '6 1012' here and press Enter:
Now check if the numbers printed after you pressed Enter are exactly the same as those printed earlier for sda2. If it is okay, continue with giving the new numbers for sda2:
This time it was enough to enter "0" in my case - but you have to make sure the numbers aren't messed up in yours.
Next, continue with the other partitions in the same manner. If you already reached the end of the disk, pressing Enter is enough. Finally, check again that all the numbers are okay and save the partition table (or not). If you messed something up, have a look at
man sfdisk
and the descriptions of '-d', '-O' and '-I' options.Notice also, that once you've made the crazy changes, you might need to run 'sync' so that the partitions are re-read before you try to mount them.