You are on page 1of 8

PARTITION

In linux there are 4 different kind of partition we can create.


1. Standard partition:
a. Primary partition: used to store data and install os.
b. Extended partition: is is a container for the logical partition.
we cannot directly store data inside it we need create logical
partition and then we can store data.
c. Logical partition: it is used to store data only. It can only be
created inside a extended partition. It is used only in mbr
technology.
2. Lvm: logical volume manager. In standard partition we cannot increase or
decrease the partition size easily. So lvm gives us the feature to
resize our volume as per our need very easily.
3.stratis: it is a advanced storage system. Used to optimize storage. It is
also called as dynamic storage system.
4. Vdo: virtual data optimizer. It also do storage optimization. It helps us
not to save any data replication.

Technology to create a partition:


There are basically two different kind of technology for creating a partition. It is also called
as partitioning style.
1. MBR: master boot record.
a. MBR is a old technology.
b. MBR can only format a partition with max size 2tb.
c. If we use MBR technology then only 4 primary partition we can create.
d. To overcome the problem of very less primary partition creating. mbr gives us a
option to create more than 4 primary partition. How? 3primary+1extended(11logical) we can
create. In mbr max 15 partition we can create.
e. Name of partition is already reserved in MBR. Vda-vdd is reserved for primary and
extended. If we create a logical partition their name will be starting from vde-vdp
f. Fdisk, parted is the tool to create a MBR partition.
2. GPT: guid partition table.
a. GPT is an advanced technology.
b. Where GPT has no limit for formatting a partition.
c. If we use GPT then max 128 primary partition we can create.
d. As it is letting us to create 128 primary partitions, we don't need to use logical or
extended partition.
e. Gdisk,fdisk and parted all tool can create gpt partition but specifically, gdisk is
created for making gpt partition.
When we purchase a new hard drive it is called as block device. It is like A raw space. We
can not store data inside it. For storing data we need to First format the hard drive. What is
formatting? Formatting means all part of our hard drive will be now recognized with a no.
When we format then in our hard drive track and sector is created.
Mbr: 512byte
It is also called as 1st boot sector. Another name is index. This 512 byte
Is divided into 3 things.
1. Pti(64byte): partition table information 64/4=16byte for each primary
Partition
2. Ipl(446byte): initial program loader. It is program for booing process.
4. Mn(2byte): magic no. Used to generate unique id for track sector and Block.
In mbr 4p, 3p+[1e(200gb)11logical partition can be created]
In total max 15 partition can be created
3p+1e(11l)=15
there are three types of standard partition in linux.
1. primary partition-- used to store os and data
2. extended partition (its a container for logical partition)
3. logical partition. -- used to store only data.
there are two types of partition technology (partition style).
GPT (GUID PARTITION TABLE) AND MBR (MASTER BOOT RECORD)
difference between gpt and mbr:
1. mbr can format a partition with less than 2TB IN size. so, max a partition size can never
exceed 2TB limit. for gpt there are no limit of a partition size.
2. in mbr there is no index replication but in gpt index is replicated in different areas.
3. mbr can create max 4 primary partition. or 3p+1E(11L)=15 max partition is possible in
mbr. but in gpt the max no of primary partition is 128.
note: normally we work always with mbr. but its better to work with gpt partition.
command to create a partion:
1. fdisk -- primarily it creates mbr partition but it's capable to create gpt partition.
2. gdisk -- only can create a gpt partition.
3. parted -- it can create both mbr and gpt.
mbr is having 512 byte 1st boot sector or index.
1. PTI(partition table information)
the size of pti is 64byte(4x16=64) 16 byte index is for each primary partition.
2. IPL(initial program loader) it stores the bootable information.
size of ipl is 446byte
3. MN(MAGIC NUMBER) used to provide unique id to each sector and tracks.
size of mn is 2 byte.
ext2,ext3,ext4 xfs vfat/fat32 ntfs-3g package | ntfs fat fat32
the temporary mount point info in stored inside /etc/mtab
if we mount any device temporary then after reboot the mount point will be removed.
so, again we need to mount manually.
to mount a device permanently we need to update information inside /etc/fstab file.
so, even after reboot our mountpoint will be available.

steps to create a partition:


fdisk /dev/sdb -- select your hard drive
create a primary partition
save and quit
partprobe
mkfs.xfs /dev/sdb1 -- to format
blkid -- to check uuid of formatted /dev/sdb1
mkdir /mountpoint -- create a dir where you will mount it.
vim /etc/fstab
device mountpoint filesystem defaults fsck(file system check) backup
mount -a -- to update the entry on fstab file in df -h command and to check syntax of fstab
file.

Linux File Systems: Ext2 vs Ext3 vs Ext4 vs Xfs


Ext2
Ext2 stands for second extended file system.

It was introduced in 1993. Developed by Rémy Card.

This was developed to overcome the limitation of the original ext file system.

Ext2 does not have journaling feature.

On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of
journaling.

Maximum individual file size can be from 16 GB to 2 TB

Overall ext2 file system size can be from 2 TB to 32 TB

Ext3
Ext3 stands for third extended file system.

It was introduced in 2001. Developed by Stephen Tweedie.

Starting from Linux Kernel 2.4.15 ext3 was available.

The main benefit of ext3 is that it allows journaling.

Journaling has a dedicated area in the file system, where all the changes are tracked. When the
system crashes, the possibility of file system corruption is less because of journaling.

Maximum individual file size can be from 16 GB to 2 TB

Overall ext3 file system size can be from 2 TB to 32 TB

There are three types of journaling available in ext3 file system.

Journal – Metadata and content are saved in the journal.

Ordered – Only metadata is saved in the journal. Metadata are journaled only after writing the
content to disk. This is the default.

Writeback – Only metadata is saved in the journal. Metadata might be journaled either before or
after the content is written to the disk.
You can convert a ext2 file system to ext3 file system directly (without backup/restore).

Ext4
Ext4 stands for fourth extended file system.

It was introduced in 2008.

Starting from Linux Kernel 2.6.19 ext4 was available.

Supports huge individual file size and overall file system size.

Maximum individual file size can be from 16 GB to 16 TB

Overall maximum ext4 file system size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB = 1024 TB
(terabyte).

Directory can contain a maximum of 64,000 subdirectories (as opposed to 32,000 in ext3)

You can also mount an existing ext3 fs as ext4 fs (without having to upgrade it).

Several other new features are introduced in ext4: multiblock allocation, delayed allocation, journal
checksum. fast fsck, etc. All you need to know is that these new features have improved the
performance and reliability of the filesystem when compared to ext3.

In ext4, you also have the option of turning the journaling feature “off”.

XFS:
As mentioned it supports metadata journaling, which facilitates quicker crash recovery.

Tightly integrated backup and restore utilities

Online defragmentation and growth: This filesystem can be defragmented and enlarged
while mounted and active.

Comprehensive diagnostics capabilities

Scalable and fast repair utilities. XFS scales to exabytes more than 500TB

Optimizations for streaming video workloads

B-tree indexing for scalability of free space management

Ability to support a large number of concurrent operations

Extensive run-time metadata consistency checking

Sophisticated metadata read-ahead algorithms


Delayed, Extent-based allocation

Dynamically allocated inodes

Extended attributes (xattr): This allows the system to associate several additional
name/value pairs per file. It is enabled by default.

Compared to Ext4, XFS has a relatively poor performance for single threaded, metadata-
intensive workloads. This includes workload that creates or deletes large numbers of small
files in a single thread.

Quota journaling: This avoids the need for lengthy quota consistency checks after a crash.

LVM
logical volume manager is a advanced level of storage which can help us for creting flexible
partition.
what we require to create a lvm?
you need either a whole hard drive or a standard partition. the standard partition can be mbr
or gpt. if we are using gpt best way to create lvm is using primary partition. but we can also
create by using logical parition.
in linux there is two kind of partition.
1. standard(primary,extended and logical)
2. advanced storage(ceph,lvm,stratis,vdo)
how to create a lvm partition?
step1: create a primary partition.
note: after creating don't do any kind of formatting or mounting.
step2: create pv(physical volume)
step3: create vg(volume group)
step4: create lv(logical volume)
step5: format the newly created lv.
step6: create mount point and mount it permanently.

pv(physical volume): it is a backend of a logical volume. the standard


primary partition we created it need to be initiated as a physical
volume for creating the lvm.
#pvcreate /dev/sdb1
how to check pv volume?
#pvs --> for small details.
#pvdisplay --> for all details of pv.

vg(volume group): it is a combination/group of small chunks. when we


create a vg then the whole space of pv is broken into small small
pieces. by default each chunk size is 4MB.
if i am having 100MB pv and we create vg there we will get 100/4=25
chunks.
how to check total no of chunks?
#vgdisplay --all details
#vgs- for small details.
when we create a vg we must give a name to it and if we want we can
change the size of the each chunks.
note: we can decrease the size of the chunks but cannot increase.

lv(logical volume): it is the end result we want. this is the device


where we will store our data. it is created by taking some chunks from the vg.
how to check the size of the lvm ?
#lvdisplay --for long details
#lvs -- for small details.

we can easily change the name of vg and lv:


#vgrename --for changing the vg name
#lvrename --for changing the lv name

to change the size of each chunks:


#vgchange

#to remove any kind of volume:


#pvremove -- for removing pv
#vgremove --for removing vg
#lvremove -- for removing lv.

You might also like