top of page
Writer's pictureMukesh Chanderia

Linux Commands Part 16 - PARTITION PART 1

Updated: Aug 21, 2021

[root@localhost ~]# fdisk /dev/sda3


Command (m for help): m


Generic

d delete a partition

F list free unpartitioned space

l list known partition types

n add a new partition

p print the partition table

t change a partition type

v verify the partition table

i print information about a partition


Misc

m print this menu

x extra functionality (experts only)


Script

I load disk layout from sfdisk script file

O dump disk layout to sfdisk script file


Save & Exit

w write table to disk and exit

q quit without saving changes


Now Let's Create partition


Command (m for help): n

Partition type

p primary (0 primary, 0 extended, 4 free)

e extended (container for logical partitions)

Select (default p):


Using default response p.

Partition number (1-4, default 1):

First sector (2048-2147483647, default 2048):

Last sector, +sectors or +size{K,M,G,T,P} (2048-2147483647, default 2147483647): +1G


Note : If last sector is selected default then all available space will be used.


Created a new partition 1 of type 'Linux' and of size 1 GiB.


Command (m for help): p (to Print)

Disk /dev/sdc: 1 TiB, 1099511627776 bytes, 2147483648 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: 0xb6158727


Device Boot Start End Sectors Size Id Type

/dev/sdc1 2048 2099199 2097152 1G 83 Linux


Command (m for help): n

Partition type

p primary (1 primary, 0 extended, 3 free)

e extended (container for logical partitions)

Select (default p):


Using default response p.

Partition number (2-4, default 2):

First sector (2099200-2147483647, default 2099200):

Last sector, +sectors or +size{K,M,G,T,P} (2099200-2147483647, default 2147483647): +2G


Created a new partition 2 of type 'Linux' and of size 2 GiB


Command (m for help): n

Partition type

p primary (2 primary, 0 extended, 2 free)

e extended (container for logical partitions)

Select (default p):


Using default response p

Partition number (3,4, default 3): -⇾ Here we are creating 3rd Primary Partition

First sector (6293504-2147483647, default 6293504):

Last sector, +sectors or +size{K,M,G,T,P} (6293504-2147483647, default 2147483647): +3G


Created a new partition 3 of type 'Linux' and of size 3 GiB.


Command (m for help): p

Disk /dev/sdc: 1 TiB, 1099511627776 bytes, 2147483648 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: 0xb6158727


Device Boot Start End Sectors Size Id Type

/dev/sdc1 2048 2099199 2097152 1G 83 Linux

/dev/sdc2 2099200 6293503 4194304 2G 83 Linux

/dev/sdc3 6293504 12584959 6291456 3G 83 Linux


Command (m for help): n

Partition type

p primary (3 primary, 0 extended, 1 free)

e extended (container for logical partitions)


Select (default e): -⇾ On Fourth time the default partition is extended


Using default response e.

Selected partition 4

First sector (12584960-2147483647, default 12584960):

Last sector, +sectors or +size{K,M,G,T,P} (12584960-2147483647, default 2147483647):


Created a new partition 4 of type 'Extended' and of size 1018 GiB.


Command (m for help): p

Disk /dev/sdc: 1 TiB, 1099511627776 bytes, 2147483648 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: 0xb6158727


Device Boot Start End Sectors Size Id Type

/dev/sdc1 2048 2099199 2097152 1G 83 Linux

/dev/sdc2 2099200 6293503 4194304 2G 83 Linux

/dev/sdc3 6293504 12584959 6291456 3G 83 Linux

/dev/sdc4 12584960 2147483647 2134898688 1018G 5 Extended


Command (m for help): n

All primary partitions are in use.

Adding logical partition 5

First sector (12587008-2147483647, default 12587008):

Last sector, +sectors or +size{K,M,G,T,P} (12587008-2147483647, default 2147483647): +6G


Created a new partition 5 of type 'Linux' and of size 6 GiB.


Command (m for help): p

Disk /dev/sdc: 1 TiB, 1099511627776 bytes, 2147483648 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: 0xb6158727


Device Boot Start End Sectors Size Id Type

/dev/sdc1 2048 2099199 2097152 1G 83 Linux

/dev/sdc2 2099200 6293503 4194304 2G 83 Linux

/dev/sdc3 6293504 12584959 6291456 3G 83 Linux

/dev/sdc4 12584960 2147483647 2134898688 1018G 5 Extended

/dev/sdc5 12587008 25169919 12582912 6G 83 Linux




Command (m for help): p

Disk /dev/sdc: 1 TiB, 1099511627776 bytes, 2147483648 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: 0xb6158727


Device Boot Start End Sectors Size Id Type

/dev/sdc1 2048 2099199 2097152 1G 83 Linux

/dev/sdc2 2099200 6293503 4194304 2G 83 Linux

/dev/sdc3 6293504 12584959 6291456 3G 83 Linux

/dev/sdc4 12584960 2147483647 2134898688 1018G 5 Extended

/dev/sdc5 12587008 25169919 12582912 6G 83 Linux

/dev/sdc6 25171968 44046335 18874368 9G 83 Linux

/dev/sdc7 44048384 69214207 25165824 12G 83 Linux


Command (m for help): m


Help:


DOS (MBR)

a toggle a bootable flag

b edit nested BSD disklabel

c toggle the dos compatibility flag


Generic

d delete a partition

F list free unpartitioned space

l list known partition types

n add a new partition

p print the partition table

t change a partition type

v verify the partition table

i print information about a partition


Misc

m print this menu

u change display/entry units

x extra functionality (experts only)


Script

I load disk layout from sfdisk script file

O dump disk layout to sfdisk script file


Save & Exit

w write table to disk and exit

q quit without saving changes



Command (m for help): w

The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.


[root@RedHat adminji]# partprobe (to update kernal all disk partision )

[root@RedHat adminji]# partprobe /dev/sdc (To update specific hard disk)

6 views0 comments

Comments


bottom of page