• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Linux » How To Get Total Inodes and Increase Disk Inode Number in Linux

How To Get Total Inodes and Increase Disk Inode Number in Linux

sammbysamm
October 20, 2023
Inodes and Increase Disk Inode Number

How To Get Total Inodes and Increase Disk Inode Number in Linux

Share on FacebookShare on LinkedinShare on Whatsapp

Introduction

In the realm of Linux systems, understanding and managing inodes play a crucial role in maintaining efficient file storage and system performance. Inodes are data structures that store metadata about files on a filesystem. This comprehensive guide will walk you through the process of How To Get Total Inodes and Increase Disk Inode Number in Linux, explaining their significance, and guiding you through increasing the number of inodes on a disk when needed.

Table of Contents

  • Introduction
  • Understanding Inodes and Their Importance
  • Calculating Total Inodes on a Disk
    • How to Get Total Inodes of Root Partition
    • Increase Inode Number
      • Creating a New File System
      • Mounting the New File System
      • Moving the Existing Files
      • Updating the File System Table
    • Alternative Methods Increase Inode
    • Considerations
  • Conclusion

Understanding Inodes and Their Importance

In a Linux filesystem, each inode corresponds to a single file or directory. When you create a new file or directory, the system also creates an inode to store its metadata. In essence, inodes act as a reference point to the data stored on the disk. This metadata includes details like permissions, ownership, timestamps, and pointers to the actual data blocks on the disk.

OTHER POSTS

A Simple Guide: How To Manage Groups on Linux

How To Manage Log Files Using Logrotate In Linux

The Easy Ways to Check File Size in Linux

Inodes play a vital role in maintaining file system integrity and organization. They allow the operating system to keep track of files, their attributes, and their physical location on the disk. However, the filesystem has a finite number of inodes available, and this number becomes determined during filesystem creation.

Calculating Total Inodes on a Disk

To calculate the total number of inodes available on a disk, use the following formula:

Total Inodes = Total Disk Blocks × Inodes per Block

Filesystem creation usually determines the inodes per block. Common values are 128, 256, or 1024. To check the total number of inodes on a Linux filesystem, you can use the df command with the -i option. Open a terminal and enter the following command:

df -i

How to Get Total Inodes of Root Partition

One possible way a filesystem can run out of space is by using up all the inodes. This can happen even when there is enough free space on disk; consumption of all inodes in the filesystem can block the creation of new files. Besides, it can result in a sudden stop of the system.

To get the number of inodes of files in a directory, for example, the root directory, open a terminal window and run the following ls command, where the -l option means long listing format, -a means all files and -i mean to print the index number of each file.

[samm@linux ~]$ ls -lai /

total 28
      128 dr-xr-xr-x.  19 root  root   247 Jul 25 22:23 .
      128 dr-xr-xr-x.  19 root  root   247 Jul 25 22:23 ..
100687509 dr-xr-xr-x.   2 root  root     6 May 16  2022 afs
   162206 lrwxrwxrwx.   1 root  root     7 May 16  2022 bin -> usr/bin
      128 dr-xr-xr-x.   5 root  root  4096 Jul  1 05:22 boot
      128 drwxr-xr-x.   3 minio minio   24 Jul 25 23:24 data
        1 drwxr-xr-x.  21 root  root  3340 Jul 25 22:37 dev
 67155073 drwxr-xr-x. 115 root  root  8192 Jul 30 16:27 etc
 67222701 drwxr-xr-x.   5 root  root    46 Jul 28 18:14 home
   162212 lrwxrwxrwx.   1 root  root     7 May 16  2022 lib -> usr/lib
   162213 lrwxrwxrwx.   1 root  root     9 May 16  2022 lib64 -> usr/lib64
100687514 drwxr-xr-x.   2 root  root     6 May 16  2022 media
   162214 drwxr-xr-x.   2 root  root     6 May 16  2022 mnt
 33675293 drwxr-xr-x.   6 root  root    83 Jul 28 02:16 opt
        1 dr-xr-xr-x. 209 root  root     0 Jun 16 04:41 proc
 33554562 dr-xr-x---.   4 root  root  4096 Jul 28 18:38 root
        1 drwxr-xr-x.  33 root  root   980 Jul 28 16:38 run
   162215 lrwxrwxrwx.   1 root  root     8 May 16  2022 sbin -> usr/sbin
 67222702 drwxr-xr-x.   2 root  root     6 May 16  2022 srv
        1 dr-xr-xr-x.  13 root  root     0 Jun 16 04:41 sys
 33554561 drwxrwxrwt.   9 root  root  4096 Jul 30 16:27 tmp
      140 drwxr-xr-x.  13 root  root   155 Jul 28 19:59 usr
 67155078 drwxr-xr-x.  21 root  root  4096 Jul 21 15:01 var

To get the total number of inodes, run the following du command.

[samm@linux ~]$ sudo du --inode /

.....
14	/home/ansible
4	/home/sammy
21440	/home
1	/media
1	/mnt
2	/opt/app-sammlinux
3	/opt/remi/libzip/lib64
.......
9	/opt/remi/libmemcached-awesome/lib64
15	/opt/remi/libmemcached-awesome
25	/opt/remi
4	/opt/ansible-project
1	/opt/containerd/bin
1	/opt/containerd/lib
3	/opt/containerd
35	/opt
269643	/

List statistics about inode usage in the root partition, use the df commands as follows :

[samm@linux ~]$ sudo df -i /
Filesystem            Inodes  IUsed    IFree IUse% Mounted on
/dev/mapper/rl-root 23615488 138973 23476515    1% /

[samm@linux ~]$ sudo df -ih /
Filesystem          Inodes IUsed IFree IUse% Mounted on
/dev/mapper/rl-root    23M  136K   23M    1% /

The -h flag allows for showing information in a human-readable format.

Increase Inode Number

To increase the disk inode number, you’ll need to create a new file system with a higher inode count and then move the existing files to the new file system. This process can be time-consuming and may require additional disk space, so it’s important to plan accordingly.

Creating a New File System

To create a new file system with a higher inode count, you can use the mkfs command. For example, to create a new ext4 file system with 10 million inodes, you can run following command

[samm@linux ~]$ sudo mkfs.ext4 -i 10000000 /dev/sdb1

In this example, the new file system will be created on the device /dev/sdb1. The -t option specifies the file system type, and the -N option sets the number of inodes.

You may also issue the following command from terminal using -T flag to configure how your filesystem handles large files.

[samm@linux ~]$ sudo mkfs.ext4 -T largefile /dev/sdb1
OR
[samm@linux ~]$ sudo mkfs.ext4 -T largefile4 /dev/sdb1

In the above code we use largefile and largefile4 settings that stores 1 inode per 1Mb and 4Mb respectively.

If you want to check the number of inodes available and used you can do so with the following command.

[samm@linux ~]$ df -iT

Filesystem               Type       Inodes  IUsed    IFree IUse% Mounted on
devtmpfs                 devtmpfs   463401    415   462986    1% /dev
tmpfs                    tmpfs      468702      1   468701    1% /dev/shm
tmpfs                    tmpfs      819200    660   818540    1% /run
/dev/mapper/rl-root      xfs      23615488 138973 23476515    1% /
/dev/sda1                xfs        524288    365   523923    1% /boot
/dev/mapper/storage-data xfs      10483712     22 10483690    1% /data
tmpfs                    tmpfs       93740     21    93719    1% /run/user/1101

Mounting the New File System

Once you create the new file system, you can use the mount command to attach it to a directory. For example, to mount the new file system to the /mnt/data directory, you can run following command

[samm@linux ~]$ sudo mount /dev/sdb1 /mnt/data

Moving the Existing Files

With the new file system mounted, you can now move the existing files to the new location. One way to do this is to use the rsync command, which can copy files and directories while preserving ownership, permissions, and other attributes. For example, to copy all files and directories from the /data directory to the new location, you can run following command

[samm@linux ~]$ sudo rsync -a /data/ /mnt/data/

The -a option activates archive mode, which preserves all attributes of the files and directories being copied.

Updating the File System Table

After copying the files to the new file system, the next step involves updating the file system table. This action is necessary to guarantee the automatic mounting of the new file system during boot time. To do this, you can edit the /etc/fstab file and add an entry for the new file system. For example :

[samm@linux ~]$ sudo vi /etc/fstab

/dev/sdb1   /mnt/data   ext4   defaults   0   2In this example, the first column specifies the device, the second column specifies the mount point, the third column specifies the file system type, the fourth column specifies the mount options (in this case, the defaults), and the last two columns specify the dump and fsck order.

Alternative Methods Increase Inode

In addition to creating a new file system with a higher inode count, you can also employ several alternative methods to increase the disk inode number in Linux. These include :

  • Resize the existing file system − If unused space exists on the disk, you should consider resizing the existing file system to potentially increase the inode count. You can achieve this task by utilizing tools such as resize2fs or xfs_growfs. However, this method can be risky and may result in data loss or corruption if not done correctly.
  • Use a file system with a higher default inode count − Some file systems, such as xfs, have a higher default inode count than others, such as ext4. Using a file system with a higher default inode count can help avoid the need to increase the inode count manually.
  • Use a different file system type − Different file system types have different limits on the number of inodes they can support. For example, btrfs and ReiserFS have much higher inode limits than ext4. Using a different file system type may be a viable option if the current file system is limiting performance due to its inode count.

Considerations

When you increase the disk inode number, you should take several considerations into account. First, it’s important to ensure that the file system type supports the desired number of inodes. Some file systems, such as ext2 and ext3, have a fixed inode count that cannot be changed without reformatting the disk. In contrast, ext4 and xfs file systems allow for dynamic inode allocation, which makes it easier to increase the inode count without reformatting.

Secondly, increasing the inode count can impact disk space usage. Each inode carries overhead, and this can accumulate when generating a significant number of inodes. As a result, it becomes crucial to assess the quantity of files and directories that will reside on the disk.

Conclusion

Get Total Inodes and Increase Disk Inode Number in Linux can help prevent performance issues and ensure that the file system can accommodate a large number of files and directories. However, it’s important to carefully plan and execute the process, as it can be time-consuming and may require additional disk space. By following the steps outlined in this article, you can safely and effectively increase the disk inode number in Linux.

Also Read Our Other Guides :

  • How To Create Multiboot USB with Ventoy in Linux
  • How To Use Rsync to Sync Local and Remote Directories in Linux
  • How To Create and Use Swap File on Linux System
  • How To Install and Use Linux Screen with Commands
  • The 40 Most-Used Linux Commands You Should Know
  • 6 Methods To Search For Files By Name In Linux
  • How To Install and Config Git on Ubuntu 22.04

Finally, now you have learned How To Get Total Inodes and Increase Disk Inode Number in Linux.

Tags: DiskHDDInodesLinuxStorageSwap

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install Composer in Ubuntu 22.04: A Comprehensive Guide

Next Post

How To Secure Nginx with Let’s Encrypt on Rocky Linux 9

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Manage Groups on Linux
Linux

A Simple Guide: How To Manage Groups on Linux

November 12, 2023
Logrotate In Linux
Linux

How To Manage Log Files Using Logrotate In Linux

November 10, 2023
Check File Size in Linux
Linux

The Easy Ways to Check File Size in Linux

November 10, 2023
Linux server security system administrators
Linux

Best Practices Linux Server Security for System Administrator

November 10, 2023
Load More
Next Post
Nginx with Let's Encrypt on Rocky Linux

How To Secure Nginx with Let's Encrypt on Rocky Linux 9

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.