r
Storage wise Two types of Partition
·
Standard Partition
· LVM
· LVM
r
Partitioning
·
RAW Hard-Disk
· Existing Hard-Disk
· Existing Hard-Disk
r
Types of Partition
·
Primary
o Extended
§ Logical
o Extended
§ Logical
r
Partition Scheme/Identifier
·
MS-DOS [MBR]
o In MS-DOS [MBR] maximum 4 Primary Partitions
· GPT [GUID Partition Table]
o Can be created Total 128 Primary Partitions
o In MS-DOS [MBR] maximum 4 Primary Partitions
· GPT [GUID Partition Table]
o Can be created Total 128 Primary Partitions
r
Verify - Disk using
·
lsblk [Information
will collect from OS]
· fdisk -l [Information will collect from Hard-Disk]
· fdisk -l [Information will collect from Hard-Disk]
r
Create Partition - using
·
fdisk
· gdisk
· parted
· gparted
· cfdisk
· gdisk
· parted
· gparted
· cfdisk
r
DOS (MBR)
·
d delete
a partition
· n add a new partition
· p print the partition table
· t change a partition type
· v verify the partition table
· w write table to disk and exit
· q quit without saving changes
· g create a new empty GPT partition table
· create a new empty DOS partition table
· n add a new partition
· p print the partition table
· t change a partition type
· v verify the partition table
· w write table to disk and exit
· q quit without saving changes
· g create a new empty GPT partition table
· create a new empty DOS partition table
r
Update partition table using partprobe
·
partprobe
· partprobe /dev/vdb
· partprobe /dev/vdb
r
Verify using
·
lsblk
· lsblk /dev/vdb
Partition:
/dev/vdb1
· lsblk /dev/vdb
r
Create FileSystem using
·
mkfs for
vfat/ext2/ext4/xfs
o mkfs.xfs /dev/vdb1
o mkfs.xfs /dev/vdb1
mkfs -t vfat /dev/vdb1
· mkswap for swap
o mkswap /dev/vdb2
· mkswap for swap
o mkswap /dev/vdb2
r
Verify using blkid command
·
blkid /dev/vdb1
r
On-Demand mount
#Create
mount point using mkdir
#Mount using mount command
· mount /dev/vdb1 /data
· mount <partid> /data
· mount <UUID> /data
#Mount using mount command
· mount /dev/vdb1 /data
· mount <partid> /data
· mount <UUID> /data
r
Verify
·
df -hT
· df -hT /data
· df -hT /data
r
Permanent Mount
·
Add entry to /etc/fstab
o /dev/vdb1 /data ext4
defaults 0 0
v Procedure
to be followed for Standard Partition
Step 01: Physical or Virtual disk attach on Linux
server
[root@SysAdmin ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
sdb 8:16 0 5G 0 disk
sr0 11:0 1 1024M 0 rom
Step 02: Create Partition
[root@SysAdmin ~]# fdisk
/dev/sdb
Welcome to fdisk (util-linux 2.37.4).
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.
Created a new DOS disklabel with disk identifier 0x71729618.
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VBOX HARDDISK
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: dos
Disk identifier: 0x71729618
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-10485759, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759): +2G
Created a new partition 1 of type 'Linux' and of size 2
GiB.
Partition #1 contains a xfs signature.
Do you want to remove the signature? [Y]es/[N]o: Y
The signature will be removed by a write command.
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VBOX HARDDISK
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: dos
Disk identifier: 0x71729618
Device Boot
Start End Sectors Size Id Type
/dev/sdb1 2048 4196351 4194304 2G 83 Linux
Filesystem/RAID signature on partition 1 will be wiped.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Step 03: Change type of partition
[root@SysAdmin ~]# fdisk
/dev/sdb
Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): t
Partition number (1,2, default 2):
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): 82/swap
Changed type of partition 'Linux' to 'Linux swap /
Solaris'.
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VBOX HARDDISK
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: dos
Disk identifier: 0x71729618
Device
Boot Start End Sectors Size Id Type
/dev/sdb1 2048 4196351 4194304 2G 83 Linux
/dev/sdb2 4196352 10485759 6289408 3G 82 Linux swap / Solaris
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 100G 0 disk
sdb 8:16 0 5G 0 disk
sr0 11:0 1 1024M 0 rom
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.
Created a new DOS disklabel with disk identifier 0x71729618.
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VBOX HARDDISK
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: dos
Disk identifier: 0x71729618
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-10485759, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759): +2G
Partition #1 contains a xfs signature.
Do you want to remove the signature? [Y]es/[N]o: Y
The signature will be removed by a write command.
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VBOX HARDDISK
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: dos
Disk identifier: 0x71729618
/dev/sdb1 2048 4196351 4194304 2G 83 Linux
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Partition number (1,2, default 2):
linux - 83
swap - 82
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Disk model: VBOX HARDDISK
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: dos
Disk identifier: 0x71729618
/dev/sdb1 2048 4196351 4194304 2G 83 Linux
/dev/sdb2 4196352 10485759 6289408 3G 82 Linux swap / Solaris
Step 04: Formatting the partition / Apply filesystem
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=16384, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Setting up swapspace version 1, size = 3 GiB (3220172800 bytes)
no label, UUID=8ece08f9-21ba-404d-96ec-4ee99ddee21d
[root@SysAdmin ~]# swapon /dev/sdb2
/dev/sdb2 swap swap defaults 0 0
Tags
RHCSA