Need I change the device sda2 into sda5?

Asked by MadhuSoodanan

I am with Ubuntu14.04 LTS. After deleting sda2 extended & sda5 Linux swap (as a part of increasing swap area), sda5 swap area changed to sda2.

madhu@madhu-desktop:~$ swapon -s
Filename Type Size Used Priority
/dev/sda2 partition 3787772 0 -1
----------------------------------------------------------------------------------------------------------------------

Here the priority is -1. How can I change this sda2 to sda5 ?

---------------------------------------------------------------------------------------------------------------------
madhu@madhu-desktop:~$ sudo fdisk -l
[sudo] password for madhu:

Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders, total 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bd4e8

   Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1242060799 621029376 83 Linux
/dev/sda2 1242060800 1249636351 3787776 82 Linux swap / Solaris
madhu@madhu-desktop:~$

If I change sda2 , Which one should I use? Live CD or Gparted or Terminal command? I tried using the first two. But I couldn't.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
Best Manfred Hampl (m-hampl) said :
#1

Why do you see a need to change sda2 into sda5?

For a correct understanding of device naming you have to know some details of partitioning:
The first partitioning schemes could only work with a maximum of four partitions per disk, numbered 1 to 4 (those nowadays are usually called primary partitions).
To raise that limit, the concept of extended partitions was created. One of these possible four entries was used not as a partition, but for some kind of table of contents for more partitions. This extended partition information table then uses one of the number 1 to 4, and all the partitions whose information is stored there, then get numbered 5 and higher.

As far as I can see from your previous question documents, you had a hard disk partitioned with a primary partition sda1, and an entry for extended partitions. There was only one extended partition called sda5.

Now you have resized and reworked your partitions, with sda1 being the same primary partition as before (just shrunk), and instead of an external partition that contains only one partition (was sda5), now there is just a second primary partition sda2 as swap.

The system does not care much what the numbers of the partition are. So I do not see any advantage of re-restructuring your partition layout to get back an extended partition with the swap partition inside.

And the priority -1 does not matter either. If you have only one single swap area, its priority is irrelevant. Only if you have more than one swap file, the system uses the one with higher priority first.

Revision history for this message
MadhuSoodanan (mt-madhu) said :
#2

Whenever I searched I could see sda2 for extended partition; and it was not for Linux. So I wished to change it sda2 into sda5. I realize it was my ignorance. Manfred Hampl, Thank you very much for finding the root cause of my problem and for solving it with a very good explanation.

Revision history for this message
MadhuSoodanan (mt-madhu) said :
#3

Thanks Manfred Hampl, that solved my question.