Linux. Inode. Hints

Материал из Wiki
Перейти к навигации Перейти к поиску



Links

https://losst.pro/chto-takoe-inode

Посмотреть кол-во inode

df -i

Изменить количество inode при форматировании

Вы не можете изменить количество Inode для существующей файловой системы, зато можете указать для новой с помощью опции -N.

Например:

mkfs -t ext4 -N 3000000 /dev/nvme0n1p5

Показать номер inode файла/директории

Директория в ФС ext - это особый тип файла

У директории, как и у файла есть номер inode

ls -i ./file.txt

ls -id ./directory

У корневой директории номер inode - "2"

ls -id /

2 /

Посмотреть информацию об inode с номером "2"

debugfs Работает только с ФС ext*

debugfs 1.42.9 (4-Feb-2014)

debugfs:  stat <2>

Имена файлов и директорий внутри этой директории хранятся в блоках данных, на который ссылается inode директории

...
Inode: 2   Type: directory    Mode:  0755   Flags: 0x80000
Generation: 0    Version: 0x00000000:0000003e
User:     0   Group:     0   Size: 4096
File ACL: 0    Directory ACL: 0
Links: 9   Blockcount: 8
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x5be96164:af6dd6bc -- Mon Nov 12 14:17:56 2018
 atime: 0x5e205209:c091e918 -- Thu Jan 16 15:07:37 2020
 mtime: 0x5be96164:af6dd6bc -- Mon Nov 12 14:17:56 2018
crtime: 0x558d36ca:00000000 -- Fri Jun 26 14:26:02 2015
Size of extra inode fields: 28
EXTENTS:
(0):9249
...

Посмотреть список директорий внутри директории, на который ссылается inode

debugfs /dev/sdb1

debugfs: block_dump 9249

debugfs: ls -l <2>

Посмотреть содержимое файла в блоке данных, на который ссылается inode

debugfs /dev/sdb1

debugfs: block_dump 6596316

Установить количество inode при форматировании файловой системы

When creating an ext4 file system, you can specify the usage type:

mkfs.ext4 -T usage-type /dev/something

The available usage types are listed in /etc/mke2fs.conf. The main difference between usage types is the inode ratio. The lower the inode ratio, the more you can create files in your file system.

The usage type in mke2fs.conf which allocates the highest number of inodes in the file system is "news". With this usage type on a 1 TB hard drive, ext4 creates 244 million inodes.

tune2fs -l /dev/sdb1 | grep -i "inode count"

Inode count:              244219904

sgdisk --print /dev/sdb

Disk /dev/sdb: 1953525168 sectors, 931.5 GiB

This means that it would require more than 4 TB to create an ext4 file system with "-Tnews" that could possibly hold 1 billion inodes.