'sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget&/translations/zh_CN/admin-guide/initrdmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/zh_TW/admin-guide/initrdmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/it_IT/admin-guide/initrdmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/ja_JP/admin-guide/initrdmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/ko_KR/admin-guide/initrdmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget&/translations/sp_SP/admin-guide/initrdmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h#Using the initial RAM disk (initrd)h]h#Using the initial RAM disk (initrd)}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh@/var/lib/git/docbuild/linux/Documentation/admin-guide/initrd.rsthKubh paragraph)}(heWritten 1996,2000 by Werner Almesberger and Hans Lermen h](h)Written 1996,2000 by Werner Almesberger <}(hhhhhNhNubh reference)}(hwerner.almesberger@epfl.chh]hwerner.almesberger@epfl.ch}(hhhhhNhNubah}(h]h ]h"]h$]h&]refuri!mailto:werner.almesberger@epfl.chuh1hhhubh> and Hans Lermen <}(hhhhhNhNubh)}(hlermen@fgan.deh]hlermen@fgan.de}(hhhhhNhNubah}(h]h ]h"]h$]h&]refurimailto:lermen@fgan.deuh1hhhubh>}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXKinitrd provides the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root file system and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root (from initrd) is then moved to a directory and can be subsequently unmounted.h]hXKinitrd provides the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root file system and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root (from initrd) is then moved to a directory and can be subsequently unmounted.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hinitrd is mainly designed to allow system startup to occur in two phases, where the kernel comes up with a minimum set of compiled-in drivers, and where additional modules are loaded from initrd.h]hinitrd is mainly designed to allow system startup to occur in two phases, where the kernel comes up with a minimum set of compiled-in drivers, and where additional modules are loaded from initrd.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hThis document gives a brief overview of the use of initrd. A more detailed discussion of the boot process can be found in [#f1]_.h](hzThis document gives a brief overview of the use of initrd. A more detailed discussion of the boot process can be found in }(hj hhhNhNubhfootnote_reference)}(h[#f1]_h]h1}(hjhhhNhNubah}(h]id1ah ]h"]h$]h&]autoKrefidf1docnameadmin-guide/initrduh1jhj resolvedKubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(h Operationh]h Operation}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj6hhhhhKubh)}(h9When using initrd, the system typically boots as follows:h]h9When using initrd, the system typically boots as follows:}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj6hhubh block_quote)}(hXL1) the boot loader loads the kernel and the initial RAM disk 2) the kernel converts initrd into a "normal" RAM disk and frees the memory used by initrd 3) if the root device is not ``/dev/ram0``, the old (deprecated) change_root procedure is followed. see the "Obsolete root change mechanism" section below. 4) root device is mounted. if it is ``/dev/ram0``, the initrd image is then mounted as root 5) /sbin/init is executed (this can be any valid executable, including shell scripts; it is run with uid 0 and can do basically everything init can do). 6) init mounts the "real" root file system 7) init places the root file system at the root directory using the pivot_root system call 8) init execs the ``/sbin/init`` on the new root filesystem, performing the usual boot sequence 9) the initrd file system is removed h]henumerated_list)}(hhh](h list_item)}(h9the boot loader loads the kernel and the initial RAM diskh]h)}(hjdh]h9the boot loader loads the kernel and the initial RAM disk}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjbubah}(h]h ]h"]h$]h&]uh1j`hj]ubja)}(hWthe kernel converts initrd into a "normal" RAM disk and frees the memory used by initrdh]h)}(hWthe kernel converts initrd into a "normal" RAM disk and frees the memory used by initrdh]h[the kernel converts initrd into a “normal” RAM disk and frees the memory used by initrd}(hj}hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjyubah}(h]h ]h"]h$]h&]uh1j`hj]ubja)}(hif the root device is not ``/dev/ram0``, the old (deprecated) change_root procedure is followed. see the "Obsolete root change mechanism" section below.h]h)}(hif the root device is not ``/dev/ram0``, the old (deprecated) change_root procedure is followed. see the "Obsolete root change mechanism" section below.h](hif the root device is not }(hjhhhNhNubhliteral)}(h ``/dev/ram0``h]h /dev/ram0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhu, the old (deprecated) change_root procedure is followed. see the “Obsolete root change mechanism” section below.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j`hj]ubja)}(hXroot device is mounted. if it is ``/dev/ram0``, the initrd image is then mounted as rooth]h)}(hXroot device is mounted. if it is ``/dev/ram0``, the initrd image is then mounted as rooth](h!root device is mounted. if it is }(hjhhhNhNubj)}(h ``/dev/ram0``h]h /dev/ram0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh*, the initrd image is then mounted as root}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK!hjubah}(h]h ]h"]h$]h&]uh1j`hj]ubja)}(h/sbin/init is executed (this can be any valid executable, including shell scripts; it is run with uid 0 and can do basically everything init can do).h]h)}(h/sbin/init is executed (this can be any valid executable, including shell scripts; it is run with uid 0 and can do basically everything init can do).h]h/sbin/init is executed (this can be any valid executable, including shell scripts; it is run with uid 0 and can do basically everything init can do).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK#hjubah}(h]h ]h"]h$]h&]uh1j`hj]ubja)}(h'init mounts the "real" root file systemh]h)}(hjh]h+init mounts the “real” root file system}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK&hjubah}(h]h ]h"]h$]h&]uh1j`hj]ubja)}(hWinit places the root file system at the root directory using the pivot_root system callh]h)}(hWinit places the root file system at the root directory using the pivot_root system callh]hWinit places the root file system at the root directory using the pivot_root system call}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK'hjubah}(h]h ]h"]h$]h&]uh1j`hj]ubja)}(h\init execs the ``/sbin/init`` on the new root filesystem, performing the usual boot sequenceh]h)}(h\init execs the ``/sbin/init`` on the new root filesystem, performing the usual boot sequenceh](hinit execs the }(hj2hhhNhNubj)}(h``/sbin/init``h]h /sbin/init}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj2ubh? on the new root filesystem, performing the usual boot sequence}(hj2hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK)hj.ubah}(h]h ]h"]h$]h&]uh1j`hj]ubja)}(h"the initrd file system is removed h]h)}(h!the initrd file system is removedh]h!the initrd file system is removed}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK+hjXubah}(h]h ]h"]h$]h&]uh1j`hj]ubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix)uh1j[hjWubah}(h]h ]h"]h$]h&]uh1jUhhhKhj6hhubh)}(hNote that changing the root directory does not involve unmounting it. It is therefore possible to leave processes running on initrd during that procedure. Also note that file systems mounted under initrd continue to be accessible.h]hNote that changing the root directory does not involve unmounting it. It is therefore possible to leave processes running on initrd during that procedure. Also note that file systems mounted under initrd continue to be accessible.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hj6hhubeh}(h] operationah ]h"] operationah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hBoot command-line optionsh]hBoot command-line options}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK4ubh)}(h'initrd adds the following new options::h]h&initrd adds the following new options:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hjhhubh literal_block)}(hXHinitrd= (e.g. LOADLIN) Loads the specified file as the initial RAM disk. When using LILO, you have to specify the RAM disk image file in /etc/lilo.conf, using the INITRD configuration variable. noinitrd initrd data is preserved but it is not converted to a RAM disk and the "normal" root file system is mounted. initrd data can be read from /dev/initrd. Note that the data in initrd can have any structure in this case and doesn't necessarily have to be a file system image. This option is used mainly for debugging. Note: /dev/initrd is read-only and it can only be used once. As soon as the last process has closed it, all data is freed and /dev/initrd can't be opened anymore. root=/dev/ram0 initrd is mounted as root, and the normal boot procedure is followed, with the RAM disk mounted as root.h]hXHinitrd= (e.g. LOADLIN) Loads the specified file as the initial RAM disk. When using LILO, you have to specify the RAM disk image file in /etc/lilo.conf, using the INITRD configuration variable. noinitrd initrd data is preserved but it is not converted to a RAM disk and the "normal" root file system is mounted. initrd data can be read from /dev/initrd. Note that the data in initrd can have any structure in this case and doesn't necessarily have to be a file system image. This option is used mainly for debugging. Note: /dev/initrd is read-only and it can only be used once. As soon as the last process has closed it, all data is freed and /dev/initrd can't be opened anymore. root=/dev/ram0 initrd is mounted as root, and the normal boot procedure is followed, with the RAM disk mounted as root.}hjsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhK8hjhhubeh}(h]boot-command-line-optionsah ]h"]boot command-line optionsah$]h&]uh1hhhhhhhhK4ubh)}(hhh](h)}(hCompressed cpio imagesh]hCompressed cpio images}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKPubh)}(hX8Recent kernels have support for populating a ramdisk from a compressed cpio archive. On such systems, the creation of a ramdisk image doesn't need to involve special block devices or loopbacks; you merely create a directory on disk with the desired initrd content, cd to that directory, and run (as an example)::h]hX9Recent kernels have support for populating a ramdisk from a compressed cpio archive. On such systems, the creation of a ramdisk image doesn’t need to involve special block devices or loopbacks; you merely create a directory on disk with the desired initrd content, cd to that directory, and run (as an example):}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKRhjhhubj)}(hCfind . | cpio --quiet -H newc -o | gzip -9 -n > /boot/imagefile.imgh]hCfind . | cpio --quiet -H newc -o | gzip -9 -n > /boot/imagefile.img}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKXhjhhubh)}(hDExamining the contents of an existing image file is just as simple::h]hCExamining the contents of an existing image file is just as simple:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKZhjhhubj)}(hWmkdir /tmp/imagefile cd /tmp/imagefile gzip -cd /boot/imagefile.img | cpio -imd --quieth]hWmkdir /tmp/imagefile cd /tmp/imagefile gzip -cd /boot/imagefile.img | cpio -imd --quiet}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhK\hjhhubeh}(h]compressed-cpio-imagesah ]h"]compressed cpio imagesah$]h&]uh1hhhhhhhhKPubh)}(hhh](h)}(h Installationh]h Installation}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj!hhhhhKaubh)}(hhFirst, a directory for the initrd file system has to be created on the "normal" root file system, e.g.::h]hkFirst, a directory for the initrd file system has to be created on the “normal” root file system, e.g.:}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchj!hhubj)}(h# mkdir /initrdh]h# mkdir /initrd}hj@sbah}(h]h ]h"]h$]h&]jjuh1jhhhKfhj!hhubh)}(h]The name is not relevant. More details can be found on the :manpage:`pivot_root(2)` man page.h](h;The name is not relevant. More details can be found on the }(hjNhhhNhNubhmanpage)}(h:manpage:`pivot_root(2)`h]h pivot_root(2)}(hjXhhhNhNubah}(h]h ]jVah"]h$]h&]jjpath pivot_root(2)page pivot_rootsection2uh1jVhjNubh man page.}(hjNhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhj!hhubh)}(hIf the root file system is created during the boot procedure (i.e. if you're building an install floppy), the root file system creation procedure should create the ``/initrd`` directory.h](hIf the root file system is created during the boot procedure (i.e. if you’re building an install floppy), the root file system creation procedure should create the }(hjvhhhNhNubj)}(h ``/initrd``h]h/initrd}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjvubh directory.}(hjvhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKkhj!hhubh)}(hwIf initrd will not be mounted in some cases, its content is still accessible if the following device has been created::h]hvIf initrd will not be mounted in some cases, its content is still accessible if the following device has been created:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKohj!hhubj)}(h3# mknod /dev/initrd b 1 250 # chmod 400 /dev/initrdh]h3# mknod /dev/initrd b 1 250 # chmod 400 /dev/initrd}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKrhj!hhubh)}(hSecond, the kernel has to be compiled with RAM disk support and with support for the initial RAM disk enabled. Also, at least all components needed to execute programs from initrd (e.g. executable format and file system) must be compiled into the kernel.h]hSecond, the kernel has to be compiled with RAM disk support and with support for the initial RAM disk enabled. Also, at least all components needed to execute programs from initrd (e.g. executable format and file system) must be compiled into the kernel.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKuhj!hhubh)}(hXThird, you have to create the RAM disk image. This is done by creating a file system on a block device, copying files to it as needed, and then copying the content of the block device to the initrd file. With recent kernels, at least three types of devices are suitable for that:h]hXThird, you have to create the RAM disk image. This is done by creating a file system on a block device, copying files to it as needed, and then copying the content of the block device to the initrd file. With recent kernels, at least three types of devices are suitable for that:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhj!hhubjV)}(h- a floppy disk (works everywhere but it's painfully slow) - a RAM disk (fast, but allocates physical memory) - a loopback device (the most elegant solution) h]h bullet_list)}(hhh](ja)}(h8a floppy disk (works everywhere but it's painfully slow)h]h)}(hjh]h:a floppy disk (works everywhere but it’s painfully slow)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(h0a RAM disk (fast, but allocates physical memory)h]h)}(hjh]h0a RAM disk (fast, but allocates physical memory)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(h.a loopback device (the most elegant solution) h]h)}(h-a loopback device (the most elegant solution)h]h-a loopback device (the most elegant solution)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j`hjubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jUhhhKhj!hhubh)}(h*We'll describe the loopback device method:h]h,We’ll describe the loopback device method:}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubjV)}(hX 1) make sure loopback block devices are configured into the kernel 2) create an empty file system of the appropriate size, e.g.:: # dd if=/dev/zero of=initrd bs=300k count=1 # mke2fs -F -m0 initrd (if space is critical, you may want to use the Minix FS instead of Ext2) 3) mount the file system, e.g.:: # mount -t ext2 -o loop initrd /mnt 4) create the console device:: # mkdir /mnt/dev # mknod /mnt/dev/console c 5 1 5) copy all the files that are needed to properly use the initrd environment. Don't forget the most important file, ``/sbin/init`` .. note:: ``/sbin/init`` permissions must include "x" (execute). 6) correct operation the initrd environment can frequently be tested even without rebooting with the command:: # chroot /mnt /sbin/init This is of course limited to initrds that do not interfere with the general system state (e.g. by reconfiguring network interfaces, overwriting mounted devices, trying to start already running demons, etc. Note however that it is usually possible to use pivot_root in such a chroot'ed initrd environment.) 7) unmount the file system:: # umount /mnt 8) the initrd is now in the file "initrd". Optionally, it can now be compressed:: # gzip -9 initrd h]j\)}(hhh](ja)}(h?make sure loopback block devices are configured into the kernelh]h)}(hjBh]h?make sure loopback block devices are configured into the kernel}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj@ubah}(h]h ]h"]h$]h&]uh1j`hj=ubja)}(hcreate an empty file system of the appropriate size, e.g.:: # dd if=/dev/zero of=initrd bs=300k count=1 # mke2fs -F -m0 initrd (if space is critical, you may want to use the Minix FS instead of Ext2)h](h)}(h;create an empty file system of the appropriate size, e.g.::h]h:create an empty file system of the appropriate size, e.g.:}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjWubj)}(hB# dd if=/dev/zero of=initrd bs=300k count=1 # mke2fs -F -m0 initrdh]hB# dd if=/dev/zero of=initrd bs=300k count=1 # mke2fs -F -m0 initrd}hjisbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjWubh)}(hH(if space is critical, you may want to use the Minix FS instead of Ext2)h]hH(if space is critical, you may want to use the Minix FS instead of Ext2)}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjWubeh}(h]h ]h"]h$]h&]uh1j`hj=ubja)}(hGmount the file system, e.g.:: # mount -t ext2 -o loop initrd /mnt h](h)}(hmount the file system, e.g.::h]hmount the file system, e.g.:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(h## mount -t ext2 -o loop initrd /mnth]h## mount -t ext2 -o loop initrd /mnt}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1j`hj=ubja)}(hMcreate the console device:: # mkdir /mnt/dev # mknod /mnt/dev/console c 5 1 h](h)}(hcreate the console device::h]hcreate the console device:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(h/# mkdir /mnt/dev # mknod /mnt/dev/console c 5 1h]h/# mkdir /mnt/dev # mknod /mnt/dev/console c 5 1}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1j`hj=ubja)}(hcopy all the files that are needed to properly use the initrd environment. Don't forget the most important file, ``/sbin/init`` .. note:: ``/sbin/init`` permissions must include "x" (execute). h](h)}(hcopy all the files that are needed to properly use the initrd environment. Don't forget the most important file, ``/sbin/init``h](hscopy all the files that are needed to properly use the initrd environment. Don’t forget the most important file, }(hjhhhNhNubj)}(h``/sbin/init``h]h /sbin/init}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubhnote)}(h6``/sbin/init`` permissions must include "x" (execute).h]h)}(hjh](j)}(h``/sbin/init``h]h /sbin/init}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh, permissions must include “x” (execute).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j`hj=ubja)}(hXcorrect operation the initrd environment can frequently be tested even without rebooting with the command:: # chroot /mnt /sbin/init This is of course limited to initrds that do not interfere with the general system state (e.g. by reconfiguring network interfaces, overwriting mounted devices, trying to start already running demons, etc. Note however that it is usually possible to use pivot_root in such a chroot'ed initrd environment.)h](h)}(hkcorrect operation the initrd environment can frequently be tested even without rebooting with the command::h]hjcorrect operation the initrd environment can frequently be tested even without rebooting with the command:}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$ubj)}(h# chroot /mnt /sbin/inith]h# chroot /mnt /sbin/init}hj6sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj$ubh)}(hX1This is of course limited to initrds that do not interfere with the general system state (e.g. by reconfiguring network interfaces, overwriting mounted devices, trying to start already running demons, etc. Note however that it is usually possible to use pivot_root in such a chroot'ed initrd environment.)h]hX3This is of course limited to initrds that do not interfere with the general system state (e.g. by reconfiguring network interfaces, overwriting mounted devices, trying to start already running demons, etc. Note however that it is usually possible to use pivot_root in such a chroot’ed initrd environment.)}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj$ubeh}(h]h ]h"]h$]h&]uh1j`hj=ubja)}(h-unmount the file system:: # umount /mnt h](h)}(hunmount the file system::h]hunmount the file system:}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjXubj)}(h # umount /mnth]h # umount /mnt}hjjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjXubeh}(h]h ]h"]h$]h&]uh1j`hj=ubja)}(hethe initrd is now in the file "initrd". Optionally, it can now be compressed:: # gzip -9 initrd h](h)}(hNthe initrd is now in the file "initrd". Optionally, it can now be compressed::h]hQthe initrd is now in the file “initrd”. Optionally, it can now be compressed:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj~ubj)}(h# gzip -9 initrdh]h# gzip -9 initrd}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj~ubeh}(h]h ]h"]h$]h&]uh1j`hj=ubeh}(h]h ]h"]h$]h&]jvjwjxhjyjzuh1j[hj9ubah}(h]h ]h"]h$]h&]uh1jUhhhKhj!hhubh)}(hFor experimenting with initrd, you may want to take a rescue floppy and only add a symbolic link from ``/sbin/init`` to ``/bin/sh``. Alternatively, you can try the experimental newlib environment [#f2]_ to create a small initrd.h](hfFor experimenting with initrd, you may want to take a rescue floppy and only add a symbolic link from }(hjhhhNhNubj)}(h``/sbin/init``h]h /sbin/init}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh to }(hjhhhNhNubj)}(h ``/bin/sh``h]h/bin/sh}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubhA. Alternatively, you can try the experimental newlib environment }(hjhhhNhNubj)}(h[#f2]_h]h2}(hjhhhNhNubah}(h]id2ah ]h"]h$]h&]j&Kj'f2j)j*uh1jhjj+Kubh to create a small initrd.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubh)}(hFinally, you have to boot the kernel and load initrd. Almost all Linux boot loaders support initrd. Since the boot process is still compatible with an older mechanism, the following boot command line parameters have to be given::h]hFinally, you have to boot the kernel and load initrd. Almost all Linux boot loaders support initrd. Since the boot process is still compatible with an older mechanism, the following boot command line parameters have to be given:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubj)}(hroot=/dev/ram0 rwh]hroot=/dev/ram0 rw}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj!hhubh)}(h<(rw is only necessary if writing to the initrd file system.)h]h<(rw is only necessary if writing to the initrd file system.)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubh)}(h"With LOADLIN, you simply execute::h]h!With LOADLIN, you simply execute:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubj)}(h$LOADLIN initrd=h]h$LOADLIN initrd=}hj.sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj!hhubh)}(he.g.::h]he.g.:}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubj)}(hDLOADLIN C:\LINUX\BZIMAGE initrd=C:\LINUX\INITRD.GZ root=/dev/ram0 rwh]hDLOADLIN C:\LINUX\BZIMAGE initrd=C:\LINUX\INITRD.GZ root=/dev/ram0 rw}hjJsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj!hhubh)}(hWith LILO, you add the option ``INITRD=`` to either the global section or to the section of the respective kernel in ``/etc/lilo.conf``, and pass the options using APPEND, e.g.::h](hWith LILO, you add the option }(hjXhhhNhNubj)}(h``INITRD=``h]h INITRD=}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjXubhL to either the global section or to the section of the respective kernel in }(hjXhhhNhNubj)}(h``/etc/lilo.conf``h]h/etc/lilo.conf}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjXubh*, and pass the options using APPEND, e.g.:}(hjXhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubj)}(hJimage = /bzImage initrd = /boot/initrd.gz append = "root=/dev/ram0 rw"h]hJimage = /bzImage initrd = /boot/initrd.gz append = "root=/dev/ram0 rw"}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj!hhubh)}(hand run ``/sbin/lilo``h](hand run }(hjhhhNhNubj)}(h``/sbin/lilo``h]h /sbin/lilo}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubh)}(hEFor other boot loaders, please refer to the respective documentation.h]hEFor other boot loaders, please refer to the respective documentation.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubh)}(h(Now you can boot and enjoy using initrd.h]h(Now you can boot and enjoy using initrd.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj!hhubeh}(h] installationah ]h"] installationah$]h&]uh1hhhhhhhhKaubh)}(hhh](h)}(hChanging the root deviceh]hChanging the root device}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hWhen finished with its duties, init typically changes the root device and proceeds with starting the Linux system on the "real" root device.h]hWhen finished with its duties, init typically changes the root device and proceeds with starting the Linux system on the “real” root device.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubhdefinition_list)}(hhh]hdefinition_list_item)}(hThe procedure involves the following steps: - mounting the new root file system - turning it into the root file system - removing all accesses to the old (initrd) root file system - unmounting the initrd file system and de-allocating the RAM disk h](hterm)}(h+The procedure involves the following steps:h]h+The procedure involves the following steps:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubh definition)}(hhh]j)}(hhh](ja)}(h!mounting the new root file systemh]h)}(hjh]h!mounting the new root file system}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(h$turning it into the root file systemh]h)}(hj3h]h$turning it into the root file system}(hj5hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj1ubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(h:removing all accesses to the old (initrd) root file systemh]h)}(hjJh]h:removing all accesses to the old (initrd) root file system}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjHubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(hAunmounting the initrd file system and de-allocating the RAM disk h]h)}(h@unmounting the initrd file system and de-allocating the RAM diskh]h@unmounting the initrd file system and de-allocating the RAM disk}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj_ubah}(h]h ]h"]h$]h&]uh1j`hjubeh}(h]h ]h"]h$]h&]j#j$uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhNhNubh)}(hwMounting the new root file system is easy: it just needs to be mounted on a directory under the current root. Example::h]hvMounting the new root file system is easy: it just needs to be mounted on a directory under the current root. Example:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h3# mkdir /new-root # mount -o ro /dev/hda1 /new-rooth]h3# mkdir /new-root # mount -o ro /dev/hda1 /new-root}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubh)}(hXThe root change is accomplished with the pivot_root system call, which is also available via the ``pivot_root`` utility (see :manpage:`pivot_root(8)` man page; ``pivot_root`` is distributed with util-linux version 2.10h or higher [#f3]_). ``pivot_root`` moves the current root to a directory under the new root, and puts the new root at its place. The directory for the old root must exist before calling ``pivot_root``. Example::h](haThe root change is accomplished with the pivot_root system call, which is also available via the }(hjhhhNhNubj)}(h``pivot_root``h]h pivot_root}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh utility (see }(hjhhhNhNubjW)}(h:manpage:`pivot_root(8)`h]h pivot_root(8)}(hjhhhNhNubah}(h]h ]jVah"]h$]h&]jjjf pivot_root(8)jh pivot_rootjj8uh1jVhjubh man page; }(hjhhhNhNubj)}(h``pivot_root``h]h pivot_root}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh8 is distributed with util-linux version 2.10h or higher }(hjhhhNhNubj)}(h[#f3]_h]h3}(hjhhhNhNubah}(h]id3ah ]h"]h$]h&]j&Kj'f3j)j*uh1jhjj+Kubh). }(hjhhhNhNubj)}(h``pivot_root``h]h pivot_root}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh moves the current root to a directory under the new root, and puts the new root at its place. The directory for the old root must exist before calling }(hjhhhNhNubj)}(h``pivot_root``h]h pivot_root}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh . Example:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h3# cd /new-root # mkdir initrd # pivot_root . initrdh]h3# cd /new-root # mkdir initrd # pivot_root . initrd}hj*sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubh)}(hNow, the init process may still access the old root via its executable, shared libraries, standard input/output/error, and its current root directory. All these references are dropped by the following command::h]hNow, the init process may still access the old root via its executable, shared libraries, standard input/output/error, and its current root directory. All these references are dropped by the following command:}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h;# exec chroot . what-follows dev/console 2>&1h]h;# exec chroot . what-follows dev/console 2>&1}hjFsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjhhubh)}(hWhere what-follows is a program under the new root, e.g. ``/sbin/init`` If the new root file system will be used with udev and has no valid ``/dev`` directory, udev must be initialized before invoking chroot in order to provide ``/dev/console``.h](h9Where what-follows is a program under the new root, e.g. }(hjThhhNhNubj)}(h``/sbin/init``h]h /sbin/init}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjTubhE If the new root file system will be used with udev and has no valid }(hjThhhNhNubj)}(h``/dev``h]h/dev}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjTubhP directory, udev must be initialized before invoking chroot in order to provide }(hjThhhNhNubj)}(h``/dev/console``h]h /dev/console}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjTubh.}(hjThhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hNote: implementation details of pivot_root may change with time. In order to ensure compatibility, the following points should be observed:h]hNote: implementation details of pivot_root may change with time. In order to ensure compatibility, the following points should be observed:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjV)}(hX- before calling pivot_root, the current directory of the invoking process should point to the new root directory - use . as the first argument, and the _relative_ path of the directory for the old root as the second argument - a chroot program must be available under the old and the new root - chroot to the new root afterwards - use relative paths for dev/console in the exec command h]j)}(hhh](ja)}(hobefore calling pivot_root, the current directory of the invoking process should point to the new root directoryh]h)}(hobefore calling pivot_root, the current directory of the invoking process should point to the new root directoryh]hobefore calling pivot_root, the current directory of the invoking process should point to the new root directory}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(hmuse . as the first argument, and the _relative_ path of the directory for the old root as the second argumenth]h)}(hmuse . as the first argument, and the _relative_ path of the directory for the old root as the second argumenth]hmuse . as the first argument, and the _relative_ path of the directory for the old root as the second argument}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(hAa chroot program must be available under the old and the new rooth]h)}(hjh]hAa chroot program must be available under the old and the new root}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(h!chroot to the new root afterwardsh]h)}(hjh]h!chroot to the new root afterwards}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j`hjubja)}(h7use relative paths for dev/console in the exec command h]h)}(h6use relative paths for dev/console in the exec commandh]h6use relative paths for dev/console in the exec command}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j`hjubeh}(h]h ]h"]h$]h&]j#j$uh1jhhhKhjubah}(h]h ]h"]h$]h&]uh1jUhhhKhjhhubh)}(hXNow, the initrd can be unmounted and the memory allocated by the RAM disk can be freed::h]hWNow, the initrd can be unmounted and the memory allocated by the RAM disk can be freed:}(hj/ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubj)}(h1# umount /initrd # blockdev --flushbufs /dev/ram0h]h1# umount /initrd # blockdev --flushbufs /dev/ram0}hj= sbah}(h]h ]h"]h$]h&]jjuh1jhhhM hjhhubh)}(hrIt is also possible to use initrd with an NFS-mounted root, see the :manpage:`pivot_root(8)` man page for details.h](hDIt is also possible to use initrd with an NFS-mounted root, see the }(hjK hhhNhNubjW)}(h:manpage:`pivot_root(8)`h]h pivot_root(8)}(hjS hhhNhNubah}(h]h ]jVah"]h$]h&]jjjf pivot_root(8)jh pivot_rootjjjuh1jVhjK ubh man page for details.}(hjK hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM hjhhubeh}(h]changing-the-root-deviceah ]h"]changing the root deviceah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hUsage scenariosh]hUsage scenarios}(hjx hhhNhNubah}(h]h ]h"]h$]h&]uh1hhju hhhhhMubh)}(hThe main motivation for implementing initrd was to allow for modular kernel configuration at system installation. The procedure would work as follows:h]hThe main motivation for implementing initrd was to allow for modular kernel configuration at system installation. The procedure would work as follows:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhju hhubjV)}(hX[1) system boots from floppy or other media with a minimal kernel (e.g. support for RAM disks, initrd, a.out, and the Ext2 FS) and loads initrd 2) ``/sbin/init`` determines what is needed to (1) mount the "real" root FS (i.e. device type, device drivers, file system) and (2) the distribution media (e.g. CD-ROM, network, tape, ...). This can be done by asking the user, by auto-probing, or by using a hybrid approach. 3) ``/sbin/init`` loads the necessary kernel modules 4) ``/sbin/init`` creates and populates the root file system (this doesn't have to be a very usable system yet) 5) ``/sbin/init`` invokes ``pivot_root`` to change the root file system and execs - via chroot - a program that continues the installation 6) the boot loader is installed 7) the boot loader is configured to load an initrd with the set of modules that was used to bring up the system (e.g. ``/initrd`` can be modified, then unmounted, and finally, the image is written from ``/dev/ram0`` or ``/dev/rd/0`` to a file) 8) now the system is bootable and additional installation tasks can be performed h]j\)}(hhh](ja)}(hsystem boots from floppy or other media with a minimal kernel (e.g. support for RAM disks, initrd, a.out, and the Ext2 FS) and loads initrdh]h)}(hsystem boots from floppy or other media with a minimal kernel (e.g. support for RAM disks, initrd, a.out, and the Ext2 FS) and loads initrdh]hsystem boots from floppy or other media with a minimal kernel (e.g. support for RAM disks, initrd, a.out, and the Ext2 FS) and loads initrd}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j`hj ubja)}(hX``/sbin/init`` determines what is needed to (1) mount the "real" root FS (i.e. device type, device drivers, file system) and (2) the distribution media (e.g. CD-ROM, network, tape, ...). This can be done by asking the user, by auto-probing, or by using a hybrid approach.h]h)}(hX``/sbin/init`` determines what is needed to (1) mount the "real" root FS (i.e. device type, device drivers, file system) and (2) the distribution media (e.g. CD-ROM, network, tape, ...). This can be done by asking the user, by auto-probing, or by using a hybrid approach.h](j)}(h``/sbin/init``h]h /sbin/init}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubhX determines what is needed to (1) mount the “real” root FS (i.e. device type, device drivers, file system) and (2) the distribution media (e.g. CD-ROM, network, tape, ...). This can be done by asking the user, by auto-probing, or by using a hybrid approach.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j`hj ubja)}(h1``/sbin/init`` loads the necessary kernel modulesh]h)}(hj h](j)}(h``/sbin/init``h]h /sbin/init}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh# loads the necessary kernel modules}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1j`hj ubja)}(hl``/sbin/init`` creates and populates the root file system (this doesn't have to be a very usable system yet)h]h)}(hl``/sbin/init`` creates and populates the root file system (this doesn't have to be a very usable system yet)h](j)}(h``/sbin/init``h]h /sbin/init}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh` creates and populates the root file system (this doesn’t have to be a very usable system yet)}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM hj ubah}(h]h ]h"]h$]h&]uh1j`hj ubja)}(h``/sbin/init`` invokes ``pivot_root`` to change the root file system and execs - via chroot - a program that continues the installationh]h)}(h``/sbin/init`` invokes ``pivot_root`` to change the root file system and execs - via chroot - a program that continues the installationh](j)}(h``/sbin/init``h]h /sbin/init}(hj, hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj( ubh invokes }(hj( hhhNhNubj)}(h``pivot_root``h]h pivot_root}(hj> hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj( ubhb to change the root file system and execs - via chroot - a program that continues the installation}(hj( hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM"hj$ ubah}(h]h ]h"]h$]h&]uh1j`hj ubja)}(hthe boot loader is installedh]h)}(hj^ h]hthe boot loader is installed}(hj` hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM$hj\ ubah}(h]h ]h"]h$]h&]uh1j`hj ubja)}(hthe boot loader is configured to load an initrd with the set of modules that was used to bring up the system (e.g. ``/initrd`` can be modified, then unmounted, and finally, the image is written from ``/dev/ram0`` or ``/dev/rd/0`` to a file)h]h)}(hthe boot loader is configured to load an initrd with the set of modules that was used to bring up the system (e.g. ``/initrd`` can be modified, then unmounted, and finally, the image is written from ``/dev/ram0`` or ``/dev/rd/0`` to a file)h](hsthe boot loader is configured to load an initrd with the set of modules that was used to bring up the system (e.g. }(hjw hhhNhNubj)}(h ``/initrd``h]h/initrd}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjw ubhI can be modified, then unmounted, and finally, the image is written from }(hjw hhhNhNubj)}(h ``/dev/ram0``h]h /dev/ram0}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjw ubh or }(hjw hhhNhNubj)}(h ``/dev/rd/0``h]h /dev/rd/0}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjw ubh to a file)}(hjw hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM%hjs ubah}(h]h ]h"]h$]h&]uh1j`hj ubja)}(hNnow the system is bootable and additional installation tasks can be performed h]h)}(hMnow the system is bootable and additional installation tasks can be performedh]hMnow the system is bootable and additional installation tasks can be performed}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM)hj ubah}(h]h ]h"]h$]h&]uh1j`hj ubeh}(h]h ]h"]h$]h&]jvjwjxhjyjzuh1j[hj ubah}(h]h ]h"]h$]h&]uh1jUhhhMhju hhubh)}(hThe key role of initrd here is to re-use the configuration data during normal system operation without requiring the use of a bloated "generic" kernel or re-compiling or re-linking the kernel.h]hThe key role of initrd here is to re-use the configuration data during normal system operation without requiring the use of a bloated “generic” kernel or re-compiling or re-linking the kernel.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM,hju hhubh)}(hXA second scenario is for installations where Linux runs on systems with different hardware configurations in a single administrative domain. In such cases, it is desirable to generate only a small set of kernels (ideally only one) and to keep the system-specific part of configuration information as small as possible. In this case, a common initrd could be generated with all the necessary modules. Then, only ``/sbin/init`` or a file read by it would have to be different.h](hXA second scenario is for installations where Linux runs on systems with different hardware configurations in a single administrative domain. In such cases, it is desirable to generate only a small set of kernels (ideally only one) and to keep the system-specific part of configuration information as small as possible. In this case, a common initrd could be generated with all the necessary modules. Then, only }(hj hhhNhNubj)}(h``/sbin/init``h]h /sbin/init}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh1 or a file read by it would have to be different.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM0hju hhubh)}(hX2A third scenario is more convenient recovery disks, because information like the location of the root FS partition doesn't have to be provided at boot time, but the system loaded from initrd can invoke a user-friendly dialog and it can also perform some sanity checks (or even some form of auto-detection).h]hX4A third scenario is more convenient recovery disks, because information like the location of the root FS partition doesn’t have to be provided at boot time, but the system loaded from initrd can invoke a user-friendly dialog and it can also perform some sanity checks (or even some form of auto-detection).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM8hju hhubh)}(hX'Last not least, CD-ROM distributors may use it for better installation from CD, e.g. by using a boot floppy and bootstrapping a bigger RAM disk via initrd from CD; or by booting via a loader like ``LOADLIN`` or directly from the CD-ROM, and loading the RAM disk from CD without need of floppies.h](hLast not least, CD-ROM distributors may use it for better installation from CD, e.g. by using a boot floppy and bootstrapping a bigger RAM disk via initrd from CD; or by booting via a loader like }(hj! hhhNhNubj)}(h ``LOADLIN``h]hLOADLIN}(hj) hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj! ubhX or directly from the CD-ROM, and loading the RAM disk from CD without need of floppies.}(hj! hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM>hju hhubeh}(h]usage-scenariosah ]h"]usage scenariosah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hObsolete root change mechanismh]hObsolete root change mechanism}(hjL hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjI hhhhhMFubh)}(hThe following mechanism was used before the introduction of pivot_root. Current kernels still support it, but you should _not_ rely on its continued availability.h]hThe following mechanism was used before the introduction of pivot_root. Current kernels still support it, but you should _not_ rely on its continued availability.}(hjZ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMHhjI hhubh)}(hXOIt works by mounting the "real" root device (i.e. the one set with rdev in the kernel image or with root=... at the boot command line) as the root file system when linuxrc exits. The initrd file system is then unmounted, or, if it is still busy, moved to a directory ``/initrd``, if such a directory exists on the new root file system.h](hXIt works by mounting the “real” root device (i.e. the one set with rdev in the kernel image or with root=... at the boot command line) as the root file system when linuxrc exits. The initrd file system is then unmounted, or, if it is still busy, moved to a directory }(hjh hhhNhNubj)}(h ``/initrd``h]h/initrd}(hjp hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjh ubh9, if such a directory exists on the new root file system.}(hjh hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMLhjI hhubh)}(hIn order to use this mechanism, you do not have to specify the boot command options root, init, or rw. (If specified, they will affect the real root file system, not the initrd environment.)h]hIn order to use this mechanism, you do not have to specify the boot command options root, init, or rw. (If specified, they will affect the real root file system, not the initrd environment.)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMRhjI hhubh)}(hIf /proc is mounted, the "real" root device can be changed from within linuxrc by writing the number of the new root FS device to the special file /proc/sys/kernel/real-root-dev, e.g.::h]hIf /proc is mounted, the “real” root device can be changed from within linuxrc by writing the number of the new root FS device to the special file /proc/sys/kernel/real-root-dev, e.g.:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMVhjI hhubj)}(h,# echo 0x301 >/proc/sys/kernel/real-root-devh]h,# echo 0x301 >/proc/sys/kernel/real-root-dev}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhMZhjI hhubh)}(hJNote that the mechanism is incompatible with NFS and similar file systems.h]hJNote that the mechanism is incompatible with NFS and similar file systems.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM\hjI hhubh)}(hThis old, deprecated mechanism is commonly called ``change_root``, while the new, supported mechanism is called ``pivot_root``.h](h2This old, deprecated mechanism is commonly called }(hj hhhNhNubj)}(h``change_root``h]h change_root}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh/, while the new, supported mechanism is called }(hj hhhNhNubj)}(h``pivot_root``h]h pivot_root}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM_hjI hhubeh}(h]obsolete-root-change-mechanismah ]h"]obsolete root change mechanismah$]h&]uh1hhhhhhhhMFubh)}(hhh](h)}(h*Mixed change_root and pivot_root mechanismh]h*Mixed change_root and pivot_root mechanism}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMdubh)}(hIn case you did not want to use ``root=/dev/ram0`` to trigger the pivot_root mechanism, you may create both ``/linuxrc`` and ``/sbin/init`` in your initrd image.h](h In case you did not want to use }(hj hhhNhNubj)}(h``root=/dev/ram0``h]hroot=/dev/ram0}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh: to trigger the pivot_root mechanism, you may create both }(hj hhhNhNubj)}(h ``/linuxrc``h]h/linuxrc}(hj% hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh and }(hj hhhNhNubj)}(h``/sbin/init``h]h /sbin/init}(hj7 hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubh in your initrd image.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMfhj hhubh)}(h/``/linuxrc`` would contain only the following::h](j)}(h ``/linuxrc``h]h/linuxrc}(hjS hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjO ubh" would contain only the following:}(hjO hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMjhj hhubj)}(hb#! /bin/sh mount -n -t proc proc /proc echo 0x0100 >/proc/sys/kernel/real-root-dev umount -n /proch]hb#! /bin/sh mount -n -t proc proc /proc echo 0x0100 >/proc/sys/kernel/real-root-dev umount -n /proc}hjk sbah}(h]h ]h"]h$]h&]jjuh1jhhhMlhj hhubh)}(hX"Once linuxrc exited, the kernel would mount again your initrd as root, this time executing ``/sbin/init``. Again, it would be the duty of this init to build the right environment (maybe using the ``root= device`` passed on the cmdline) before the final execution of the real ``/sbin/init``.h](h[Once linuxrc exited, the kernel would mount again your initrd as root, this time executing }(hjy hhhNhNubj)}(h``/sbin/init``h]h /sbin/init}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjy ubh[. Again, it would be the duty of this init to build the right environment (maybe using the }(hjy hhhNhNubj)}(h``root= device``h]h root= device}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjy ubh? passed on the cmdline) before the final execution of the real }(hjy hhhNhNubj)}(h``/sbin/init``h]h /sbin/init}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjy ubh.}(hjy hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMqhj hhubeh}(h]*mixed-change-root-and-pivot-root-mechanismah ]h"]*mixed change_root and pivot_root mechanismah$]h&]uh1hhhhhhhhMdubh)}(hhh](h)}(h Resourcesh]h Resources}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMxubhfootnote)}(htAlmesberger, Werner; "Booting Linux: The History and the Future" https://www.almesberger.net/cv/papers/ols2k-9.ps.gzh](hlabel)}(hhh]h1}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j hj hhhNhNubh)}(htAlmesberger, Werner; "Booting Linux: The History and the Future" https://www.almesberger.net/cv/papers/ols2k-9.ps.gzh](hEAlmesberger, Werner; “Booting Linux: The History and the Future” }(hj hhhNhNubh)}(h3https://www.almesberger.net/cv/papers/ols2k-9.ps.gzh]h3https://www.almesberger.net/cv/papers/ols2k-9.ps.gz}(hj hhhNhNubah}(h]h ]h"]h$]h&]refurij uh1hhj ubeh}(h]h ]h"]h$]h&]uh1hhhhMzhj ubeh}(h]j(ah ]h"]f1ah$]h&]j!aj&Kj)j*uh1j hhhMzhj hhubj )}(hUnewlib package (experimental), with initrd example https://www.sourceware.org/newlib/h](j )}(hhh]h2}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j hj hhhNhNubh)}(hUnewlib package (experimental), with initrd example https://www.sourceware.org/newlib/h](h3newlib package (experimental), with initrd example }(hj hhhNhNubh)}(h"https://www.sourceware.org/newlib/h]h"https://www.sourceware.org/newlib/}(hj( hhhNhNubah}(h]h ]h"]h$]h&]refurij* uh1hhj ubeh}(h]h ]h"]h$]h&]uh1hhhhM|hj ubeh}(h]jah ]h"]f2ah$]h&]jaj&Kj)j*uh1j hhhM|hj hhubj )}(h`util-linux: Miscellaneous utilities for Linux https://www.kernel.org/pub/linux/utils/util-linux/h](j )}(hhh]h3}(hjH hhhNhNubah}(h]h ]h"]h$]h&]uh1j hjD hhhNhNubh)}(h`util-linux: Miscellaneous utilities for Linux https://www.kernel.org/pub/linux/utils/util-linux/h](h.util-linux: Miscellaneous utilities for Linux }(hjU hhhNhNubh)}(h2https://www.kernel.org/pub/linux/utils/util-linux/h]h2https://www.kernel.org/pub/linux/utils/util-linux/}(hj] hhhNhNubah}(h]h ]h"]h$]h&]refurij_ uh1hhjU ubeh}(h]h ]h"]h$]h&]uh1hhhhM~hjD ubeh}(h]jah ]h"]f3ah$]h&]jaj&Kj)j*uh1j hhhM~hj hhubeh}(h] resourcesah ]h"] resourcesah$]h&]uh1hhhhhhhhMxubeh}(h]!using-the-initial-ram-disk-initrdah ]h"]#using the initial ram disk (initrd)ah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}(f1]jaf2]jaf3]jaurefids}(j(]jaj]jaj]jaunameids}(j j jjjjjjjjjr jo jF jC j j j j j~ j{ j j(jA jjv ju nametypes}(j jjjjjr jF j j j~ j jA jv uh}(j hj!jjj6jjjjjj!jjjo jjjjC ju j jI j j j{ j j(j jj jjD u footnote_refs}(j ]jaj ]jaj ]jau citation_refs} autofootnotes](j j jD eautofootnote_refs](jjjesymbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}j KsRparse_messages]transform_messages] transformerN include_log] decorationNhhub.