实验一:inode耗尽导致磁盘故障

该实验详细记录了如何通过创建大量文件导致EXT4文件系统的inode耗尽,进而演示了当inode耗尽时,尽管磁盘空间充足,但仍无法创建新文件的问题。解决方案包括编写脚本来批量删除文件,以释放inode。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

实验一:inode耗尽导致磁盘故障


实验步骤

  1. 新建一个约32MB大小的EXT4文件系统
    • 分区
    • 格式化
    • 挂载
    • 查看inode信息
  2. 编写一个测试程序,耗尽所有可用的inode
  3. 测试创建新文件
  4. 解决inode耗尽故障

实验过程

1.新建一个32M的EXT4的文件系统

分区

[root@Daring jason]# fdisk /dev/sde

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (787-2610, default 787): 
Using default value 787
Last cylinder, +cylinders or +size{K,M,G} (787-2610, default 2610): +32M

Command (m for help): p

Disk /dev/sde: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe4b1d138

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1         262     2104483+  fd  Linux raid autodetect
/dev/sde2             263         524     2104515   fd  Linux raid autodetect
/dev/sde3             525         786     2104515   fd  Linux raid autodetect
/dev/sde4             787         791       40162+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@Daring jason]# partprobe /dev/sde  //探测新分的分区
sde   sde1  sde2  sde3  sde4             //探测到新的分区
[root@Daring jason]# partprobe /dev/sde

格式化成ext4

[root@Daring jason]# mkfs.ext4 /dev/sde4
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
10040 inodes, 40160 blocks
2008 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=41156608
5 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks: 
    8193, 24577

Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值