Wise people learn when they can; fools learn when they must - Arthur Wellesley

Thursday, 2 March 2017

SOLARIS BASICS-P4


SOLARIS BASICS-P4


FILE SYSTEM

In UNIX everything is file, if you find something which is not file then it must be a process.

So what is file system…?

Let’s consider a disk is divided into 4 partitions. And now we have to put data on them. Is it possible…?


Yes as well as No… why yes and why no…?

If there are only partitions then we cannot access the slices for writing.
If there are FS created on partitions then we can access and write data.



There is one box (HDD) with 4 partitions in that box. 

There are 4 file systems (FS-1/FS-2/FS-3/FS-4) created on each partitions. Each FS contains files and directories.
Directories are also files but acts in different way, a dir contain files and subdirectories.

Now what is the definition for a FS…?

File system is a logical collection of files and directories on a disk.

Wait…wait… we know that directory is also a file then why directories are mentioned separately…?

Nice catch, let’s make it more precise.

A File System is a logical collection of files on a partition or disk.


FILE SYSTEM PARAMETERS:

1.  LOGICAL BLOCK SIZE
2.  FRAGMENT SIZE
3.  MIN FREE SPACE
4.  NO OF INODES AND BYTES PER INODE

LOGICAL BLOCK SIZE:

Grrrr… we already studied about BLOCK SIZE, now what is this…?

Well, Size of blocks that are used to read/write files by kernel.
Logical Block Size if different from Phy Block Size, previously we had learned about Phy Block Size.
Phy Block Size is of 512 bytes of Fixed length, and it is used by disk controller for R/W.
Whereas size of Logical Blocks can be altered while creating FS only.

By default the size of logical Block is 8192 Bytes (8KB) for UFS.

If I know that a particular FS having maximum large files then I can assign a larger block size to increase efficiency.

Let’s make Phy & Logical blocks simpler,

Basically it is the way to reach at some place on disk,

Same Disk => Same Location => Same Path => Same destination

Ohhhooo… if everything is same then why 2 names and 2 sizes LLL

It is why because Phy Blocks are for Disk Controllers (say DC), the DC recognizes same place by Phy Block of 512 bytes and the same place is recognized by Kernel in logical Blocks with 8192 bytes.
So how they understand the 512/8192…?



FRAGMENT SIZE:

Kernel do its R/W operation in respect of Logical Blocks and Logical blocks is of size 8KB. Let’s the data is of 2kb, 3kb, 4kb, 5kb, 6kb again 2kb, 3kb, 4kb, 5kb, 6kb. Hence kernel starts writing these in Logical blocks.



Each block is of 8Kb, whereas data written is much smaller than the actual size of Block size.
What does it mean…?

Simple, just wastage of precious space.

To overcome this issue, FRAGMENTATION of data is used.
Each block can be divided in to One-Two-Four or Eight fragments, resulting fragment size of 1KB to 8KB.
For larger files, first block is assigned. If still data left then further accommodated in Fragments of next block.
If data is small then directly Fragments are assigned.

MIN FREE SPACE:
% of total disk space held in reserve or hidden from users.
“tunefs” command is used to identify as well as redefine the min free space.

bash-3.2# fstyp -v /dev/dsk/c1t0d0s3 |grep -i min
minfree 10%     maxbpg  2048    optim   time

bash-3.2# tunefs -m 2 /dev/dsk/c1t0d0s3
minimum percentage of free space changes from 10% to 2%

NO OF INODES AND BYTES PER INODE:

We already know that what Inode is and what it contains. Now concentrate on requirement of Inodes.

·         No of bytes/inode reflects the capacity of Inodes in FS.
·         One Inode for each file
·         Total size of FS divided by the no of bytes/inode to get the exact no of Inodes.
·         No of Inodes are directly proportional to the No of files to be created.

Let’s a FS is of 100MB (104857600 Bytes) and allocated Bytes/inode is 2048 Bytes.

No of Inodes => 104857600 / 2048 => 51200 Inodes
No of Inodes => 102400 KB / 2 KB => 51200 Inodes

According to this scenario we can create 51200 files in 100MB slice, what if I increase the size of Bytes/Inode, like
102400 KB / 10240 Kb => 10 Inodes

Now we can create only 10 Files, doesn’t matter if the 10 files are of 1KB each.

It’s always better to have Max possible No of Inodes for a FS.

FILE SYSTEM SIZE
NO OF BYTES/INODE
Less than equal to 1GB
2048
Less than 2GB
4096
Less than 3GB
6144
3GB to 1TB
8192
>1TB
1048576





No comments:

Post a Comment