Disk Partitioning in Linux

v Step by Step partition [Standard]:

Ü Add and check HD

Add RAW hard disk [10G]

[root@node1 ~]# lsblk /dev/sdc

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sdc    8:32   0  10G  0 disk

[root@node1 ~]# fdisk -l

Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 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

Ü Check all option

[root@node1 ~]# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0xef5a5055.

Command (m for help): m

Command action

   d   delete a partition
   n   add a new partition
   p   print the partition table
   q   quit without saving changes
   t   change a partition's system id
   w   write table to disk and exit

Ü Create partition

---By default disklabel - DOS

[root@node1 ~]# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x199a0abb.

Command (m for help): n

Partition type:

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

   e   extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

First sector (2048-20971519, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +200M

Partition 1 of type Linux and of size 200 MiB is set

Command (m for help): p

Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos

Disk identifier: 0x199a0abb

Device Boot        Start         End           Blocks   Id  System

/dev/sdc1            2048      411647      204800   83  Linux

Ü Type change (FileSystem)

ID (83) means linux native filesystem (vfat/extx/xfs)
ID (85) means linux swap filesystem
ID (8E) means linux lvm filesystem

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): L

Hex code (type L to list all codes): 83

Changed type of partition 'Linux' to 'Linux'

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

Ü Check

[root@node1 ~]# blkid /dev/sdc1

/dev/sdb1: UUID="16e5da81-1045-476b-b836-a42450dcd5a3"

Ü Format and apply file system

[root@node1 ~]# mkfs.xfs /dev/sdc1

meta-data=/dev/sdc1              isize=256    agcount=4, agsize=12800 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=0        finobt=0, sparse=0, rmapbt=0

         =                       reflink=0

data     =                       bsize=4096   blocks=51200, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0, ftype=1

log      =internal log           bsize=4096   blocks=853, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

Ü Check

[root@local ~]# blkid /dev/sdc1

/dev/sdb1: UUID="16e5da81-1045-476b-b836-a42450dcd5a3" TYPE="xfs"

Ü Mount - Optional

[root@local ~]# mount /dev/sdc1 /Data

Ü Permanent Mount

vim /etc/fstab

/dev/sdc1        /Data    xfs  defaults 0 0

UUID=24e57c60-8437-41c2-b38b-2644c501c532  /Data xfs defaults  0 0

mount –av

 

v Step by Step partition [SWAP]:

Ü Add and check HD

Add RAW hard disk [10G]

[root@node1 ~]# lsblk /dev/sdc

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sdc    8:32   0  10G  0 disk

[root@node1 ~]# fdisk -l

Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 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

Ü Check all option

[root@node1 ~]# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0xef5a5055.

Command (m for help): m

Command action

   d   delete a partition
   n   add a new partition
   p   print the partition table
   q   quit without saving changes
   t   change a partition's system id
   w   write table to disk and exit

Ü Create partition

----By default disklabel - DOS

[root@node1 ~]# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x199a0abb.

Command (m for help): n

Partition type:

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

   e   extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

First sector (2048-20971519, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +200M

Partition 1 of type Linux and of size 200 MiB is set

Command (m for help): p

Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos

Disk identifier: 0x199a0abb

Device Boot        Start         End           Blocks   Id  System

/dev/sdc2            2048      411647      204800   83  Linux

Ü Type change (FileSystem)

ID (83) means linux native filesystem (vfat/extx/xfs)
ID (85) means linux swap filesystem
ID (8E) means linux lvm filesystem

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): L

Hex code (type L to list all codes): 85

Changed type of partition 'swap' to 'swap'

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

Ü Check

[root@node1 ~]# blkid /dev/sdc2

/dev/sdb1: UUID="16e5da81-1045-476b-b836-a42450dcd5a3"

Format and apply swap file system

[root@node1 ~]# mkswap /dev/sdc2

meta-data=/dev/sdc1              isize=256    agcount=4, agsize=12800 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=0        finobt=0, sparse=0, rmapbt=0

         =                       reflink=0

data     =                       bsize=4096   blocks=51200, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0, ftype=1

log      =internal log           bsize=4096   blocks=853, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

Ü Check

[root@local ~]# blkid /dev/sdc2

/dev/sdc2: UUID="16e5da81-1045-476b-b836-a42450dcd5a3" TYPE="swap"

Ü Mount - Optional

[root@local ~]# swapon /dev/sdc2

Ü Permanent Mount

vim /etc/fstab

/dev/sdc1        none    swap  defaults 0 0

UUID=24e57c60-8437-41c2-b38b-2641c532  none swap defaults 0 0

mount –av


Previous Post Next Post

نموذج الاتصال