A: Preface Some time ago, when compiling the kernel, it was found that rootfs could not be mounted. The same root option sets the old version of the image. In order to completely solve this problem. I studied the rootfs mounting process. The summary is as follows, I hope to give some help to this confused knowledge. Second: the type of rootfs In general, rootfs is divided into two types: virtual rootfs and real rootfs. Now the trend of the kernel is to put more functions into the user space. To keep the kernel lean. Virtual rootfs is also a common method used by various Linux distribution vendors. A part of the initialization work can be done in the virtual rootfs. Then switch to the real file system. During the development of the virtual rootfs. There are also the following versions: initramfs: Initramfs is a technology introduced in kernel 2.5. In fact, its meaning is: attach a cpio package to the kernel image. This cpio package contains a small file system when the kernel starts. The kernel unpacks the cpio package and releases the file system contained in it into rootfs. A portion of the initialization code in the kernel is placed in the file system and executed as a user-level process. This has the obvious benefit of streamlining the kernel's initialization code and making the kernel's initialization process easier to customize. The rootfs in this way are .cpio-initrd contained in the kernel image: rootfs in cpio format
image-initrd: the traditional format rootfs for the production of these two virtual file systems, please refer to it yourself. Other information three: the rootfs file system mount process The rootfs mentioned here is different from the rootfs analyzed above. This refers to the root node when the system is initialized. That is, the node. It is its rootfs file system in memory. This part has been previously analyzed in << linux boot process analysis>> and file system. Repeat again for the sake of knowledge. Start_kernel()àmnt_init():void __init mnt_init(void)
{…………init_rootfs();init_mount_tree();}Init_rootfs has the following code: int __init init_rootfs(void)
{int err;err = bdi_init(&ramfs_backing_dev_info);
if (err)return err;err = register_filesystem(&rootfs_fs_type);if (err)bdi_destroy(&ramfs_backing_dev_info );return err;} This function is very simple. The file system registered with rootfs.init_mount_tree() is as follows: static void __init init_mount_tree(void)
{struct vfsmount *mnt;struct mnt_namespace *ns;struct path root;mnt = do_kern_mount("rootfs" , 0, "rootfs", NULL);
if (IS_ERR(mnt))panic("Can't create rootfs");
ns = kmalloc(sizeof(*ns ), GFP_KERNEL); if (!ns)panic("Can't allocate initial namespace");
atomic_set(&ns->count, 1);INIT_LIST_HEAD(&ns-> List);init_waitqueue_head(&ns->poll);ns->event = 0;list_add(&mnt->mnt_list, &ns->list);
ns-> ;root = mnt;mnt->mnt_ns=ns;init_task.nsproxy->mnt_ns=ns;get_mnt_ns(ns);root.mnt=ns->root;root.dentry=ns->root-> Mnt_root;set_fs_pwd(current->fs, &root);set_fs_root(current->fs, &root);} Here, the rootfs file system is mounted. Its mount point defaults to ”/”. The last switch to the root directory and current directory is ”/”. This is the origin of the root directory. But here is just initialization. After the specific file system is mounted, the root directory is generally switched to a specific file system. Therefore, after the system is started, you can't see the mount information of rootfs with the mount command. 4. The mount directory of the virtual file system has been mounted, and the specific file system can be mounted. In start_kernel()à Rest_init()àkernel_init():static int __init kernel_init(void * unused)
{…………do_basic_setup();if (!ramdisk_execute_command)
ramdisk_execute_command = "/init";
if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
ramdisk_execute_command = NULL;
prepare_namespace() ;}/** Ok, we have completed the initial bootup, and
* we're essentially up and running. Get rid of the
* initmem segments and start the user-mode stuff ..
*/init_post();return 0;}do_basic_setup() is a very important function, and all modules compiled directly in the kernel are started by it. The code snippet is as follows: static void __init do_basic_setup(void)
{/* drivers will send hotplug events */init_workqueues();usermodehelper_init();driver_init();init_irq_proc();do_initcalls();}Do_initcalls( ) is used to start all functions in the __initcall_start and __initcall_end sections, and modules that are statically compiled into the kernel will also place their entries in this interval. The initialization functions associated with the root file system are referenced by rootfs_initcall(). Notice the following initialization function: rootfs_initcall(populate_rootfs); that is, populate_rootfs will be called for initialization when the system is initialized. The code is as follows: static int __init populate_rootfs(void)
{char *err = unpack_to_rootfs(__initramfs_start,__initramfs_end - __initramfs_start, 0); if (err)panic(err);if (initrd_start) {#ifdef CONFIG_BLK_DEV_RAM< Br>
int fd;printk(KERN_INFO "checking if image is initramfs...");
err = unpack_to_rootfs((char *)initrd_start,
We use this program and output to analyze the usage and characteristics of waitpid. We set waitpid t
I am getting error in make posix, prompt: make: cc: Command not found make: *** [posix] Error 127 so
For systems on the Internet, it is important to be clear about the situation: the network is not se
GRUB is the default bootloader for most Linux systems. You can choose to enter different operating s
Xen's rapid deployment basics tutorial
How to configure telnet service under RedHat linux
View file call status under Linux system Shell command
Ssh certificate authentication landing implementation tutorial
How Linux can modify the system's service start and stop
Linux system command make, clean usage explain
Liunx scheduled backup mysql task implementation code
Configuration Management for Users and Groups under Linux Operating System
Find the file content find+grep
How to modify the Win7 family group password
Linux uses mkisofs to make boot images
SP2 Chinese official version installation settings graphic guide
Win7 system installed .net framework4.0 after the blue screen solution
XP: Learn to use the script to restore the system's user password.
How to establish wifi sharing in the win10 system campus network
What should I do if I open the group policy after Win10 10240 upgrades the 10565 system?
The magical use of letters and character keys in smart ABC
Under Windows8 system, how to uninstall the program
Win7 right click on the desktop menu without administrator options how to add it to