文件系统初始化分为两个阶段,时间点如下
1. start_kernel -> kernel_init
2. kernel_init -> ...
且我们讨论的时候,以 无 init_xxx 技术的启动流程为准
一二阶段概览
start_kernel
vfs_caches_init_early
vfs_caches_init
mnt_init
init_rootfs
初始化 is_tmpfs
init_mount_tree
kernel_init
prepare_namespace
mount_root
devtmpfs_mount
init_mount(".", "/", NULL, MS_MOVE, NULL);
init_chroot(".");
init_post
run_init_process(execute_command)
[第二阶段]
mount_root
create_dev("/dev/root", ROOT_DEV);
mount_block_root("/dev/root", root_mountflags);
"挂载"本质上是什么
关键字:
挂载点
挂载物
挂载过程:
将挂载物 挂载 到 挂载点上
关键字解读:
挂载点 对于 ubuntu 上的用户来说 是 目录(/mnt),对于内存来说是 struct dentry
挂载物 对于 ubuntu 上的用户来说 是 分区(/dev/sdb1),对于内存来说是 struct mount(之前版本为struct vfsmount)
挂载过程:
每进行一次mount ,内存中就会 新建一个挂载物(struct mount)
在内存中 目录 用 struct dentry 表示,注意 struct dentry 在另一个挂载物中
挂载是 将 struct dentry(挂载点) 与 struct mount(挂载物) 建立联系
struct mount(挂载物) 的 mnt 成员值 为 struct dentry(挂载点)的地址
struct mount(挂载物) 的 mnt_mounts 成员值 为 struct dentry(挂载点)所在的挂载物(另一个struct mount)的地址
struct mount(挂载物) 的 mnt_parent 成员值 为 struct dentry(挂载点)所在的挂载物(另一个struct mount)的地址
struct dentry(挂载点)所在的挂载物(另一个struct mount)的mnt_child成员值 为 当前struct mount(挂载物)的地址
- 挂载物
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/178f231db445e239d70f8771434112d9.png)
- 挂载点
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/3c8e984c89582ff5296b60371fa6fb56.png)
- 挂载物挂载到挂载点时的状态
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/c6ca0c042b4a9c8e6ebbab674cb3dfeb.png)