Linux下使用mke2fsk格式化分区的方法

运维 系统运维
上一篇,我们在Linux下用fdisk实现了硬盘的分区,在硬盘分区后,硬盘没有被格式化,因此,分区尚不能使用。在这个阶段,如果我们尝试去查看硬盘信息的话,系统将会给出以下的错误信息说明有效的超级块(superblock)不存在:

 上一篇,我们在Linux下用fdisk实现了硬盘的分区,在硬盘分区后,硬盘没有被格式化,因此,分区尚不能使用。在这个阶段,如果我们尝试去查看硬盘信息的话,系统将会给出以下的错误信息说明有效的超级块(superblock)不存在:

# tune2fs -l /dev/sda1 
tune2fs 1.35 (28-Feb-2004) 
tune2fs: Bad magic number in super-block while trying to open /dev/sda1 
Couldn't find valid filesystem superblock.

可以使用mke2fs来格式化硬盘。

# mke2fs /dev/sda1

你也可以在mke2fs中使用如下参数 :

1) -m 0 : reserved-blocks-percentage –这个用来指示文件系统保留给根用户的块的比例。默认情况下是5%。在下面的例子中,它设置为0 。 
2) -b 4096 : block-size specified in bytes. 有效值为每个块 1024,2048 或 4096 字节。

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# mke2fs -m 0 -b 4096 /dev/sda1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
205344 inodes, 70069497 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=71303168
2139 block groups
32768 blocks per group, 32768 fragments per group
96 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.

 

以上命令会创建一个ext2的文件系统。如果想创建ext3文件系统则用如下命令:

# mkfs.ext3 /dev/sda1 
# mke2fs –j /dev/sda1

这样,我们就在Linux下用mke2fsk完成了格式化。

【编辑推荐】

  1. 如何在RHEL5.7下搭建和配置DHCP服务器
  2. Linux服务器的16个监控命令
  3. 服务器性能指标:拨开服务器评测体系迷雾
责任编辑:赵宁宁
相关推荐

2009-08-17 08:35:22

Linux挂载分区表fstab

2013-07-02 10:25:03

LinuxUSB设备

2014-08-07 11:26:04

linuxfdiskpartprobe

2010-02-03 15:07:15

2010-05-28 18:23:27

Linux分区工具

2018-12-03 09:10:07

Linux驱动器命令

2009-05-19 14:34:52

Oraclehash优化

2010-08-02 16:15:20

ibmdwLinux

2010-08-05 11:03:55

创建分区文件系统

2019-09-18 10:22:13

操作系统LinuxCentOSMac

2019-05-17 13:20:57

Black格式化工具Python

2022-06-26 08:39:19

Spring容器字段格式化

2009-07-30 16:40:03

C#日期格式化

2021-07-26 14:34:02

springboot 时间格式化项目

2022-09-05 08:06:36

SpringBoot时间格式化

2022-08-01 21:38:25

Linux fmt命令

2023-03-21 07:39:51

CentOS挂载硬盘

2009-03-06 16:21:59

LinuxTestdisk修复软件

2009-12-25 09:54:56

linuxfdisk

2020-09-02 07:19:41

printf 格式化输出Unix
点赞
收藏

51CTO技术栈公众号