How do I view my partitions if they are primary or secondary in Linux CentOS? I tried df -T
but it does not show if partitions are primary or secondary.
-
Why are you still using msdos labels? – stark Jun 16 '18 at 21:10
-
no such thing as secondary, you mean primary or logical within an extended. – barlop Aug 23 '19 at 13:35
6 Answers
Use this command: sudo parted /dev/sda
followed by print
. It outputs:
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA WDC WD10JPVX-60J (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 525MB 524MB primary ntfs
2 525MB 132GB 131GB primary ntfs boot
3 132GB 461GB 329GB primary ntfs
4 461GB 966GB 505GB extended lba
6 461GB 566GB 105GB logical ext4
5 566GB 896GB 330GB logical ntfs
7 896GB 966GB 70.0GB logical ext4
You can check if the partition is primary or extended from this. Hope this helps!
- 171
- 1
- 4
-
1To me it doesn't show the column "Type". Maybe it's because I'm using a SSD? – Rodrigo Jul 29 '20 at 04:41
-
1@Rodrigo To me it doesn't show the column "Type". Even though I'm using a HDD! – Porcupine Feb 01 '21 at 08:49
Try fdisk -l
and df -T
and align the devices fdisk reports to the devices df reports. A standard MBR disk can contain only 4 primary partitions or 3 primary and 1 extended. If you have partitions numbered >= 5 they are logical partitions (with the extended partition hosting them being always number 4 i.e. /dev/sda4).
- 659
- 3
- 8
-
Your information is wrong, the extended partition is always numbered less than 5, but it doesn't have to be 4. You can also have primary partitions after extended partition. – Jimmy Mar 02 '14 at 15:31
Use "fdisk -l
", but look at the "Start"/"End" sectors instead of sdan numbers. If there is any overlap between Devices, there are extended/logical partitions.
Here is an abstraction for MBR scheme. Be aware the sda2 starts from 1001470 and ends at 1000214527, covering the following 4 partitions range. It's identified as Extended partition and sda5 ~ sda8 are logical partitions.
$ sudo fdisk -l
Disk /dev/sda: 477 GiB, 512110190592 bytes, 1000215216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x000e5c64
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 1000214527 999213058 476.5G 5 Extended
/dev/sda5 1001472 40060927 39059456 18.6G 83 Linux
/dev/sda6 40062976 79122431 39059456 18.6G 83 Linux
/dev/sda7 79124480 977559551 898435072 428.4G 83 Linux
/dev/sda8 977561600 1000214527 22652928 10.8G 82 Linux swap / Solaris
...
Here is an example of GPT partition scheme. There are all Primary partitions. No Extended partition.
$ sudo fdisk -l
Disk /dev/sda: 477 GiB, 512110190592 bytes, 1000215216 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
Disklabel type: gpt
Disk identifier: 079BF6C7-D69B-4188-B3AD-8BFE39D0F289
Device Start End Sectors Size Type
/dev/sda1 2048 616447 614400 300M Windows recovery environment
/dev/sda2 616448 1638399 1021952 499M EFI System
/dev/sda3 1638400 1900543 262144 128M Microsoft reserved
/dev/sda4 1900544 206700543 204800000 97.7G Microsoft basic data
/dev/sda5 206700544 956700671 750000128 357.6G Linux filesystem
/dev/sda6 956700672 957700095 999424 488M Linux filesystem
/dev/sda7 957700096 1000214527 42514432 20.3G Linux swap
...
These are from Ubuntu machines.
- 11
- 3
-
You are right, but if the extended partition does not include other partitions, you won't see the difference in its span compared to a primary partition. – Yaroslav Nikitenko Oct 22 '17 at 15:21
-
Right, that's a valid case. In the fdisk -l output Id/Type fields also give good hints. https://en.wikipedia.org/wiki/Partition_type – ywu Nov 09 '18 at 16:00
What are the names of the partitions? primary partitions are numbered 1 to 4, for example: sda1, hdb2, etc...
Whereas logical partitions are numbered 5 and above.
The primary extended partition is always numbered 4.
- 731
- 6
- 16
-
Your information is wrong, the extended partition is always numbered less than 5, but it doesn't have to be 4. You can also have primary partitions after extended partition. – Jimmy Mar 02 '14 at 15:31
cat /proc/partitions
You'll get something like this:
major minor #blocks name
8 0 488386584 sda
8 1 52436128 sda1
8 2 1 sda2
8 5 2104483 sda5
8 6 20972826 sda6
8 7 52436128 sda7
8 8 360434308 sda8
179 0 3979776 mmcblk0
179 1 3975680 mmcblk0p1
- If the partition number (
minor
) is between 1 and 4, it is either primary or extended. The extended one will have1
in the#blocks
column (above, it'ssda2
). - If the partition number is 5 or higher, it is logical.
- 140
- 5