Recently, we have to perform a test to restore a file by mistake using the rm command in the ext4 file system. We need to format a hard disk into the ext4 file system, and the result returns an error:
[Root @ server ~] # Mkfs. ext4/dev/sdb1
-Bash: mkfs. ext4: command not foundI didn't load the ext4 module on the system before, and I was prompted that I didn't have this command, so I would like to configure it first (kernel version: 2.6.18-194. el5 ).
PS: CentOS 5.x contains the ext4 module, but it is not loaded. You need to manually add the module to the system.
[Root @ server ~] # Cd/lib/modules/2.6.18-194. el5/kernel/fs/ext4/
[Root @ server ext4] # ll
Total 288
-Rwxr -- r -- 1 root 285684 2010-04-03 ext4.koAfter finding the module, run the modprobe command to add it:
[Root @ server ext4] # modprobe ext4
// Note: Only the module name can be written, but not ext4.ko.After the ext4 module is added, use lsmod to view it:
[Root @ server ext4] # lsmod | grep ext4
Ext4 243693 0
Jbd2 58329 1 ext4
Crc16 6209 1 ext4Install the e4fsprogs software (otherwise, the error-bash: mkfs. ext4: command not found will still occur)
[Root @ server ext4] # yum-y installe4fsprogsFormat the hard disk again:
[Root @ server ext4] # cd ~
[Root @ server ~] # Mkfs. ext4/dev/sdb1
Mke4fs 1.41.12 (17-May-2010)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
Stride = 0 blocks, Stripe width = 0 blocks
655360 inodes, 2620595 blocks
131029 blocks (5.00%) reserved for the super user
First data block = 0
Maximum filesystem blocks = 2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229 376, 294912,819 200, 884736,160 5632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune4fs-c or-I to override.
The system prompts that the formatting is successful. Attach a new disk and view the file system format:
[Root @ server ~] # Mkdir/mnt/test
[Root @ server ~] # Mount/dev/sdb1/mnt/test/
[Root @ server ~] # Df-Th
File System Type capacity available in use % mount point
/Dev/sda2 ext3 20G 2.9G 16G 17%/
/Dev/sda1 ext3 122 M 12 M 104 M 10%/boot
Tmpfs 95 M 0 95 M 0%/dev/shm
/Dev/sdb1 ext4 9.9G 151 M 9.2G 2%/mnt/testFinally, configure to automatically mount the new disk (sdb1) at startup ):
[Root @ server ~] # Vi/etc/fstab
LABEL = // ext3 defaults 1 1
LABEL =/boot ext3 defaults 1 2
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
LABEL = SWAP-sda3 swap defaults 0 0
/Dev/sdb1/mnt/test ext4 defaults 0 0