Master The Skills Of Linux File System And Be Successful
Linux file system is a method to partition the Hard Disk drive into multiple partitions. Partitions are used to store the data by making Linux File System in it. Basically Linux File systems are two types as shown below
Linux File System
Local File Systems are used to format partitions into usable without making file system in partitions we can’t store data. Just making the partitions will turn them as RAW. Partitions are used to organize users data on a Hard Disk.
When you make an Extended File System it will create an different types off blocks to segregate data store
- Master Blocks / Boot Blocks
- Super Blocks
- Inode Blocks
- Data Blocks
Master Blocks / Boot Blocks : Only boot partitions contain master blocks data. Remaining partitions master blocks are empty.
Super Blocks : Just like an index to the book and it works holds to the information as follows
- Utilized inode numbers
- Free inode numbers
- Utilized data blocks
- Free data blocks
Inode table (index table) which holds all the information about files/directories like permissions, owner, group name, size and time stamps.
- 4096 bytes default block size
- 15 data blocks = inode
If data size is more than 100MB block size is 4096bytes. If data size is less than 100MB block size is 1024bytes.
Data block storage of files
Below is the File System comparison in brief
File System |
Max File Size |
Max Partition Size |
Journal-ling |
Notes |
Fat16 |
2 GB |
2 GB |
No |
Legacy |
Fat32 |
4 GB |
8 TB |
No |
Legacy |
NTFS |
2 TB |
256 TB |
Yes |
(For Windows Compatibility) NTFS-3g is installed by default in Ubuntu, allowing Read/Write support |
ext2 |
2 TB |
32 TB |
No |
Legacy |
ext3 |
2 TB |
32 TB |
Yes |
Standard linux filesystem for many years. Best choice for super-standard installation. |
ext4 |
16 TB |
1 EB |
Yes |
Modern iteration of ext3. Best choice for new installations where super-standard isn’t necessary |
reiserFS |
8 TB |
16 TB |
Yes |
No longer well-maintained |
JFS |
4PB |
32PB |
Yes (metadata) |
Created by IBM – Not well maintained |
XFS |
8 EB |
8 EB |
Yes (metadata) |
Created by SGI. Best choice for a mix of stability and advanced journaling |
GB= Gigabyte (1024 MB) TB = Terabyte (1024 GB) PB = Petabyte (1024 TB) EB = Exabyte (1024 PB) |
How the Partitions take place
Always partitions can be four at any point of time
Primary =3 and Extended =1 OR Primary=4
if you create an partition, numbers will be assigned as mentioned below
All primary partitions will directly assign 1 – 4 numbers, whereas 3 primary 1 extended will create like below. Extended partition number 4 just created we can’t make any file system on that.
To Create partitions we have to use fdisk utility
[root@Techtutorials ~]# 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. Command (m for help): n All primary partitions are in use Adding logical partition 6 First sector (825344-10485759, default 825344):↵ Using default value 825344 Last sector, +sectors or +size{K,M,G} (825344-10485759, default 10485759): +100M Partition 6 of type Linux and of size 100 MiB is set Command (m for help): p Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 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: 0xead8a888 Device Boot Start End Blocks Id System /dev/sdc1 2048 206847 102400 83 Linux /dev/sdc2 206848 411647 102400 83 Linux /dev/sdc3 411648 616447 102400 83 Linux /dev/sdc4 616448 10485759 4934656 5 Extended /dev/sdc5 618496 823295 102400 83 Linux /dev/sdc6 825344 1030143 102400 83 Linux Command (m for help): wq The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
by default when you create an extended partition it will not update kernel to update kernel we have to execute below command
# partprobe /dev/sdc
[root@Techtutorials ~]# mkfs.ext4 /dev/sdc1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25688 inodes, 102400 blocks
5120 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33685504
13 block groups
8192 blocks per group, 8192 fragments per group
1976 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
Mount partition
Partition has been formatted with EXT4, to mount it permanently we have to add an entry in /etc/fstab file.
[root@Techtutorials ~]# mkdir /data [root@Techtutorials ~]# vi /etc/fstab [root@Techtutorials ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Wed Jun 22 11:14:58 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/rhel-root / xfs defaults 0 0 UUID=5b0f4ed0-592e-4114-9a8e-10a7b99d2cd3 /boot xfs defaults 0 0 /dev/mapper/rhel-swap swap swap defaults 0 0 /dev/sdc1 /data ext4 defaults 0 0 [root@Techtutorials ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 18G 3.3G 15G 19% / devtmpfs 1.2G 0 1.2G 0% /dev tmpfs 1.2G 80K 1.2G 1% /dev/shm tmpfs 1.2G 8.9M 1.2G 1% /run tmpfs 1.2G 0 1.2G 0% /sys/fs/cgroup /dev/sda1 497M 124M 373M 25% /boot [root@Techtutorials ~]# mount -a [root@Techtutorials ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 18G 3.3G 15G 19% / devtmpfs 1.2G 0 1.2G 0% /dev tmpfs 1.2G 80K 1.2G 1% /dev/shm tmpfs 1.2G 8.9M 1.2G 1% /run tmpfs 1.2G 0 1.2G 0% /sys/fs/cgroup /dev/sda1 497M 124M 373M 25% /boot /dev/sdc1 93M 1.6M 85M 2% /data
To mount partition temporarily we have to use below command mount and unmount partition using umount
[root@Techtutorials ~]# mount /dev/sdc1 /data [root@Techtutorials ~]# df -h /data Filesystem Size Used Avail Use% Mounted on /dev/sdc1 93M 1.6M 85M 2% /data [root@Techtutorials ~]# umount /data
To Delete Partition follow below steps
- unmount file system
- Remove entry from fstab file
- delete partition
- Update kernel
[root@Techtutorials ~]# umount /data [root@Techtutorials ~]# vi /etc/fstab [root@Techtutorials ~]# mount -a [root@Techtutorials ~]# cat /etc/fstab |grep /dev/sdc ##/dev/sdc1 /data ext4 defaults 0 0 [root@Techtutorials ~]# 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. Command (m for help): d Partition number (1-6, default 6): 1 Partition 1 is deleted Command (m for help): p Disk /dev/sdc: 5368 MB, 5368709120 bytes, 10485760 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: 0xead8a888 Device Boot Start End Blocks Id System /dev/sdc2 206848 411647 102400 83 Linux /dev/sdc3 411648 616447 102400 83 Linux /dev/sdc4 616448 10485759 4934656 5 Extended /dev/sdc5 618496 823295 102400 83 Linux /dev/sdc6 825344 1030143 102400 83 Linux Command (m for help): wq The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@Techtutorials ~]# partprobe /dev/sdc
Conclusion
Standard partition can be created using fdisk utility. Standard Linux File system can’t be increased/decreased which is not flexible for production environment.
That’s it about Linux File System
Related Articles
Thanks for your wonderful Support and Encouragement