Linux 代码分析,为什么parted不能建立 ext3,ext4,xfs文件系统
1 环境
- Red Hat Enterprise Linux 6
- parted-2.1-29.el6.x86_64
2 问题
- 我们可以通过 parted mkfs 来直接建立文件系统,可以支持的系统为
ext2,fat16,fat32,linux-swap; 但是我们为什么不能建立ext3,ext4,xfs呢 ?
3 执行的流程简介
- 当
mkfs partition fs-type参数被使用的时候,函数do_mkpartfs会被调用 - 然后
do_mkpartfs调用ped_file_system_create函数来建立文件系统 - 之后,对应文件系统的函数
create会被调用
4. 函数 create 具体实现
NULL 代表其回调函数并没被实现
41 具体的实现状态
ext2文件系统, 其中create是有实现的1
2
3
4
5
6static PedFileSystemOps _ext2_ops = {
probe: _ext2_probe,
......
create: _ext2_create,
......
};fat16文件系统, 其中create是有实现的1
2
3
4
5
6static PedFileSystemOps fat16_ops = {
probe: fat_probe_fat16,
......
create: fat_create_fat16,
......
};fat32文件系统, 其中create是有实现的1
2
3
4
5
6static PedFileSystemOps fat32_ops = {
probe: fat_probe_fat32,
......
create: fat_create_fat32,
......
};linux-swap文件系统, 其中create是有实现的1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18static PedFileSystemOps _swap_v0_ops = {
probe: _swap_v0_probe,
.......
create: swap_create,
......
};
static PedFileSystemOps _swap_v1_ops = {
probe: _swap_v1_probe,
.......
create: swap_create,
......
};
static PedFileSystemOps _swap_swsusp_ops = {
probe: _swap_swsusp_probe,
.......
create: swap_create,
......
};-
xfs文件系统,我们看到,其中的实现是 NULL1
2
3
4
5
6static PedFileSystemOps xfs_ops = {
probe: xfs_probe,
......
create: NULL,
......
}; ext3文件系统,我们看到,其中的实现是 NULL1
2
3
4
5
6static PedFileSystemOps _ext3_ops = {
probe: _ext3_probe,
......
create: NULL,
......
};ext4文件系统,我们看到,其中的实现是 NULL1
2
3
4
5
6static PedFileSystemOps _ext4_ops = {
probe: _ext4_probe,
......
create: NULL,
......
};附录: 来自代码中的描述,所以后续创建文件系统还是建议使用其对应工具。
1
NOTE: `parted` file system manipulation code is not as robust as what you'll find in dedicated, file-system-specific packages like e2fsprogs. We recommend you use only to manipulate partition tables, whenever possible. Support for performing most operations on most types of file systems will be removed in an upcoming release.