{
    "content": [
        {
            "type": "text",
            "text": "# INITRD (man)\n\n## NAME\n\ninitrd - boot loader initialized RAM disk\n\n## DESCRIPTION\n\nThe special file /dev/initrd is a read-only block device.  This device is a RAM disk that  is\ninitialized  (e.g., loaded) by the boot loader before the kernel is started.  The kernel then\ncan use /dev/initrd's contents for a two-phase system boot-up.\n\n## Sections\n\n- **NAME**\n- **CONFIGURATION**\n- **DESCRIPTION** (5 subsections)\n- **FILES**\n- **NOTES**\n- **SEE ALSO**\n- **COLOPHON**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "INITRD",
        "section": "",
        "mode": "man",
        "summary": "initrd - boot loader initialized RAM disk",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "chown",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/chown/1/json"
            },
            {
                "name": "mknod",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/mknod/1/json"
            },
            {
                "name": "ram",
                "section": "4",
                "url": "https://www.chedong.com/phpMan.php/man/ram/4/json"
            },
            {
                "name": "freeramdisk",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/freeramdisk/8/json"
            },
            {
                "name": "rdev",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/rdev/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "CONFIGURATION",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 10,
                "subsections": [
                    {
                        "name": "Boot-up operation",
                        "lines": 32
                    },
                    {
                        "name": "Options",
                        "lines": 9
                    },
                    {
                        "name": "noinitrd",
                        "lines": 13
                    },
                    {
                        "name": "Changing the normal root filesystem",
                        "lines": 35
                    },
                    {
                        "name": "Usage",
                        "lines": 52
                    }
                ]
            },
            {
                "name": "FILES",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "COLOPHON",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "initrd - boot loader initialized RAM disk\n",
                "subsections": []
            },
            "CONFIGURATION": {
                "content": "/dev/initrd  is a read-only block device assigned major number 1 and minor number 250.  Typi‐\ncally /dev/initrd is owned by root:disk with mode 0400 (read access by root  only).   If  the\nLinux  system does not have /dev/initrd already created, it can be created with the following\ncommands:\n\nmknod -m 400 /dev/initrd b 1 250\nchown root:disk /dev/initrd\n\nAlso, support for both \"RAM disk\" and \"Initial RAM disk\" (e.g., CONFIGBLKDEVRAM=y and CON‐‐\nFIGBLKDEVINITRD=y)  must  be  compiled  directly into the Linux kernel to use /dev/initrd.\nWhen using /dev/initrd, the RAM disk driver cannot be loaded as a module.\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The special file /dev/initrd is a read-only block device.  This device is a RAM disk that  is\ninitialized  (e.g., loaded) by the boot loader before the kernel is started.  The kernel then\ncan use /dev/initrd's contents for a two-phase system boot-up.\n\nIn the first boot-up phase, the kernel starts up and mounts an initial root  filesystem  from\nthe  contents  of /dev/initrd (e.g., RAM disk initialized by the boot loader).  In the second\nphase, additional drivers or other modules are loaded from the  initial  root  device's  con‐\ntents.   After  loading  the additional modules, a new root filesystem (i.e., the normal root\nfilesystem) is mounted from a different device.\n",
                "subsections": [
                    {
                        "name": "Boot-up operation",
                        "content": "When booting up with initrd, the system boots as follows:\n\n1. The boot loader loads the kernel program and /dev/initrd's contents into memory.\n\n2. On kernel startup, the kernel uncompresses and copies the contents of the device /dev/ini‐\ntrd onto device /dev/ram0 and then frees the memory used by /dev/initrd.\n\n3. The kernel then read-write mounts the device /dev/ram0 as the initial root filesystem.\n\n4. If  the  indicated  normal  root  filesystem  is  also  the initial root filesystem (e.g.,\n/dev/ram0) then the kernel skips to the last step for the usual boot sequence.\n\n5. If the executable file /linuxrc is present in the initial root filesystem, /linuxrc is ex‐\necuted with UID 0.  (The file /linuxrc must have executable permission.  The file /linuxrc\ncan be any valid executable, including a shell script.)\n\n6. If /linuxrc is not executed or when /linuxrc terminates, the  normal  root  filesystem  is\nmounted.   (If /linuxrc exits with any filesystems mounted on the initial root filesystem,\nthen the behavior of the kernel is UNSPECIFIED.  See the NOTES  section  for  the  current\nkernel behavior.)\n\n7. If  the normal root filesystem has a directory /initrd, the device /dev/ram0 is moved from\n/ to /initrd.  Otherwise, if the directory /initrd does not exist, the device /dev/ram0 is\nunmounted.   (When  moved from / to /initrd, /dev/ram0 is not unmounted and therefore pro‐\ncesses can remain running from /dev/ram0.  If directory /initrd does not exist on the nor‐\nmal  root  filesystem and any processes remain running from /dev/ram0 when /linuxrc exits,\nthe behavior of the kernel is UNSPECIFIED.  See the NOTES section for the  current  kernel\nbehavior.)\n\n8. The  usual  boot sequence (e.g., invocation of /sbin/init) is performed on the normal root\nfilesystem.\n"
                    },
                    {
                        "name": "Options",
                        "content": "The following boot loader options, when used with initrd, affect the kernel's boot-up  opera‐\ntion:\n\ninitrd=filename\nSpecifies the file to load as the contents of /dev/initrd.  For LOADLIN this is a com‐\nmand-line option.  For LILO you have to use this command  in  the  LILO  configuration\nfile  /etc/lilo.config.   The  filename specified with this option will typically be a\ngzipped filesystem image.\n"
                    },
                    {
                        "name": "noinitrd",
                        "content": "This boot option disables the two-phase boot-up operation.  The  kernel  performs  the\nusual boot sequence as if /dev/initrd was not initialized.  With this option, any con‐\ntents of /dev/initrd loaded into memory by the boot  loader  contents  are  preserved.\nThis option permits the contents of /dev/initrd to be any data and need not be limited\nto a filesystem image.  However, device /dev/initrd is read-only and can be read  only\none time after system startup.\n\nroot=device-name\nSpecifies  the device to be used as the normal root filesystem.  For LOADLIN this is a\ncommand-line option.  For LILO this is a boot time option or can be used as an  option\nline  in  the  LILO configuration file /etc/lilo.config.  The device specified by this\noption must be a mountable device having a suitable root filesystem.\n"
                    },
                    {
                        "name": "Changing the normal root filesystem",
                        "content": "By default, the kernel's settings (e.g., set in the kernel file with rdev(8) or compiled into\nthe  kernel file), or the boot loader option setting is used for the normal root filesystems.\nFor an NFS-mounted normal root filesystem, one has to use the nfsrootname and  nfsrootad‐‐\ndrs  boot options to give the NFS settings.  For more information on NFS-mounted root see the\nkernel   documentation   file   Documentation/filesystems/nfs/nfsroot.txt   (or    Documenta‐\ntion/filesystems/nfsroot.txt  before Linux 2.6.33).  For more information on setting the root\nfilesystem see also the LILO and LOADLIN documentation.\n\nIt is also possible for the /linuxrc executable to change the normal root device.  For  /lin‐\nuxrc to change the normal root device, /proc must be mounted.  After mounting /proc, /linuxrc\nchanges the normal root device by writing into the proc files /proc/sys/kernel/real-root-dev,\n/proc/sys/kernel/nfs-root-name, and /proc/sys/kernel/nfs-root-addrs.  For a physical root de‐\nvice, the root device is changed by having /linuxrc write the new root filesystem device num‐\nber  into  /proc/sys/kernel/real-root-dev.   For  an  NFS root filesystem, the root device is\nchanged by having /linuxrc write the NFS setting  into  files  /proc/sys/kernel/nfs-root-name\nand  /proc/sys/kernel/nfs-root-addrs  and then writing 0xff (e.g., the pseudo-NFS-device num‐\nber) into file /proc/sys/kernel/real-root-dev.  For example, the following shell command line\nwould change the normal root device to /dev/hdb1:\n\necho 0x365 >/proc/sys/kernel/real-root-dev\n\nFor  an NFS example, the following shell command lines would change the normal root device to\nthe NFS directory /var/nfsroot on a local networked NFS server with IP number 193.8.232.7 for\na system with IP number 193.8.232.2 and named \"idefix\":\n\necho /var/nfsroot >/proc/sys/kernel/nfs-root-name\necho 193.8.232.2:193.8.232.7::255.255.255.0:idefix \\\n>/proc/sys/kernel/nfs-root-addrs\necho 255 >/proc/sys/kernel/real-root-dev\n\nNote:  The  use  of /proc/sys/kernel/real-root-dev to change the root filesystem is obsolete.\nSee the Linux kernel source file Documentation/admin-guide/initrd.rst (or  Documentation/ini‐\ntrd.txt  before Linux 4.10) as well as pivotroot(2) and pivotroot(8) for information on the\nmodern method of changing the root filesystem.\n"
                    },
                    {
                        "name": "Usage",
                        "content": "The main motivation for implementing initrd was to allow for modular kernel configuration  at\nsystem installation.\n\nA possible system installation scenario is as follows:\n\n1. The  loader  program boots from floppy or other media with a minimal kernel (e.g., support\nfor /dev/ram, /dev/initrd, and the ext2 filesystem) and loads /dev/initrd with  a  gzipped\nversion of the initial filesystem.\n\n2. The  executable /linuxrc determines what is needed to (1) mount the normal root filesystem\n(i.e., device type, device drivers, filesystem) and (2) the distribution media (e.g.,  CD-\nROM, network, tape, ...).  This can be done by asking the user, by auto-probing, or by us‐\ning a hybrid approach.\n\n3. The executable /linuxrc loads the necessary modules from the initial root filesystem.\n\n4. The executable /linuxrc creates and populates the root filesystem.   (At  this  stage  the\nnormal root filesystem does not have to be a completed system yet.)\n\n5. The  executable  /linuxrc  sets /proc/sys/kernel/real-root-dev, unmounts /proc, the normal\nroot filesystem and any other filesystems it has mounted, and then terminates.\n\n6. The kernel then mounts the normal root filesystem.\n\n7. Now that the filesystem is accessible and intact, the boot loader can be installed.\n\n8. The boot loader is configured to load into /dev/initrd a filesystem with the set  of  mod‐\nules  that was used to bring up the system.  (e.g., device /dev/ram0 can be modified, then\nunmounted, and finally, the image is written from /dev/ram0 to a file.)\n\n9. The system is now bootable and additional installation tasks can be performed.\n\nThe key role of /dev/initrd in the above is to reuse the  configuration  data  during  normal\nsystem  operation  without requiring initial kernel selection, a large generic kernel or, re‐\ncompiling the kernel.\n\nA second scenario is for installations where Linux runs on systems  with  different  hardware\nconfigurations in a single administrative network.  In such cases, it may be desirable to use\nonly a small set of kernels (ideally only one) and to keep the system-specific part  of  con‐\nfiguration  information  as  small  as possible.  In this case, create a common file with all\nneeded modules.  Then, only the /linuxrc file or a file executed by /linuxrc would be differ‐\nent.\n\nA third scenario is more convenient recovery disks.  Because information like the location of\nthe root filesystem partition is not needed at boot time, the system loaded from  /dev/initrd\ncan use a dialog and/or auto-detection followed by a possible sanity check.\n\nLast  but  not least, Linux distributions on CD-ROM may use initrd for easy installation from\nthe CD-ROM.  The distribution can use LOADLIN to directly load /dev/initrd from CD-ROM  with‐\nout  the  need  of any floppies.  The distribution could also use a LILO boot floppy and then\nbootstrap a bigger RAM disk via /dev/initrd from the CD-ROM.\n"
                    }
                ]
            },
            "FILES": {
                "content": "/dev/initrd\n/dev/ram0\n/linuxrc\n/initrd\n",
                "subsections": []
            },
            "NOTES": {
                "content": "1. With the current kernel, any filesystems that remain mounted when /dev/ram0 is moved  from\n/  to  /initrd  continue  to be accessible.  However, the /proc/mounts entries are not up‐\ndated.\n\n2. With the current kernel, if directory /initrd does not exist, then /dev/ram0 will  not  be\nfully  unmounted  if /dev/ram0 is used by any process or has any filesystem mounted on it.\nIf /dev/ram0 is not fully unmounted, then /dev/ram0 will remain in memory.\n\n3. Users of /dev/initrd should not depend on the behavior given in the above notes.  The  be‐\nhavior may change in future versions of the Linux kernel.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "chown(1), mknod(1), ram(4), freeramdisk(8), rdev(8)\n\nDocumentation/admin-guide/initrd.rst  (or  Documentation/initrd.txt before Linux 4.10) in the\nLinux kernel source tree, the LILO documentation, the  LOADLIN  documentation,  the  SYSLINUX\ndocumentation\n",
                "subsections": []
            },
            "COLOPHON": {
                "content": "This  page  is  part  of  release  5.10 of the Linux man-pages project.  A description of the\nproject, information about reporting bugs, and the latest version of this page, can be  found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2019-03-06                                    INITRD(4)",
                "subsections": []
            }
        }
    }
}