~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/admin-guide/blockdev/ramdisk.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/admin-guide/blockdev/ramdisk.rst (Version linux-6.12-rc7) and /Documentation/admin-guide/blockdev/ramdisk.rst (Version linux-5.13.19)


  1 ==========================================          1 ==========================================
  2 Using the RAM disk block device with Linux          2 Using the RAM disk block device with Linux
  3 ==========================================          3 ==========================================
  4                                                     4 
  5 .. Contents:                                        5 .. Contents:
  6                                                     6 
  7         1) Overview                                 7         1) Overview
  8         2) Kernel Command Line Parameters           8         2) Kernel Command Line Parameters
  9         3) Using "rdev"                             9         3) Using "rdev"
 10         4) An Example of Creating a Compressed     10         4) An Example of Creating a Compressed RAM Disk
 11                                                    11 
 12                                                    12 
 13 1) Overview                                        13 1) Overview
 14 -----------                                        14 -----------
 15                                                    15 
 16 The RAM disk driver is a way to use main syste     16 The RAM disk driver is a way to use main system memory as a block device.  It
 17 is required for initrd, an initial filesystem      17 is required for initrd, an initial filesystem used if you need to load modules
 18 in order to access the root filesystem (see Do     18 in order to access the root filesystem (see Documentation/admin-guide/initrd.rst).  It can
 19 also be used for a temporary filesystem for cr     19 also be used for a temporary filesystem for crypto work, since the contents
 20 are erased on reboot.                              20 are erased on reboot.
 21                                                    21 
 22 The RAM disk dynamically grows as more space i     22 The RAM disk dynamically grows as more space is required. It does this by using
 23 RAM from the buffer cache. The driver marks th     23 RAM from the buffer cache. The driver marks the buffers it is using as dirty
 24 so that the VM subsystem does not try to recla     24 so that the VM subsystem does not try to reclaim them later.
 25                                                    25 
 26 The RAM disk supports up to 16 RAM disks by de     26 The RAM disk supports up to 16 RAM disks by default, and can be reconfigured
 27 to support an unlimited number of RAM disks (a     27 to support an unlimited number of RAM disks (at your own risk).  Just change
 28 the configuration symbol BLK_DEV_RAM_COUNT in      28 the configuration symbol BLK_DEV_RAM_COUNT in the Block drivers config menu
 29 and (re)build the kernel.                          29 and (re)build the kernel.
 30                                                    30 
 31 To use RAM disk support with your system, run      31 To use RAM disk support with your system, run './MAKEDEV ram' from the /dev
 32 directory.  RAM disks are all major number 1,      32 directory.  RAM disks are all major number 1, and start with minor number 0
 33 for /dev/ram0, etc.  If used, modern kernels u     33 for /dev/ram0, etc.  If used, modern kernels use /dev/ram0 for an initrd.
 34                                                    34 
 35 The new RAM disk also has the ability to load      35 The new RAM disk also has the ability to load compressed RAM disk images,
 36 allowing one to squeeze more programs onto an      36 allowing one to squeeze more programs onto an average installation or
 37 rescue floppy disk.                                37 rescue floppy disk.
 38                                                    38 
 39                                                    39 
 40 2) Parameters                                      40 2) Parameters
 41 ---------------------------------                  41 ---------------------------------
 42                                                    42 
 43 2a) Kernel Command Line Parameters                 43 2a) Kernel Command Line Parameters
 44                                                    44 
 45         ramdisk_size=N                             45         ramdisk_size=N
 46                 Size of the ramdisk.               46                 Size of the ramdisk.
 47                                                    47 
 48 This parameter tells the RAM disk driver to se     48 This parameter tells the RAM disk driver to set up RAM disks of N k size.  The
 49 default is 4096 (4 MB).                            49 default is 4096 (4 MB).
 50                                                    50 
 51 2b) Module parameters                              51 2b) Module parameters
 52                                                    52 
 53         rd_nr                                      53         rd_nr
 54                 /dev/ramX devices created.         54                 /dev/ramX devices created.
 55                                                    55 
 56         max_part                                   56         max_part
 57                 Maximum partition number.          57                 Maximum partition number.
 58                                                    58 
 59         rd_size                                    59         rd_size
 60                 See ramdisk_size.                  60                 See ramdisk_size.
 61                                                    61 
 62 3) Using "rdev"                                    62 3) Using "rdev"
 63 ---------------                                    63 ---------------
 64                                                    64 
 65 "rdev" is an obsolete, deprecated, antiquated      65 "rdev" is an obsolete, deprecated, antiquated utility that could be used
 66 to set the boot device in a Linux kernel image     66 to set the boot device in a Linux kernel image.
 67                                                    67 
 68 Instead of using rdev, just place the boot dev     68 Instead of using rdev, just place the boot device information on the
 69 kernel command line and pass it to the kernel      69 kernel command line and pass it to the kernel from the bootloader.
 70                                                    70 
 71 You can also pass arguments to the kernel by s     71 You can also pass arguments to the kernel by setting FDARGS in
 72 arch/x86/boot/Makefile and specify in initrd i     72 arch/x86/boot/Makefile and specify in initrd image by setting FDINITRD in
 73 arch/x86/boot/Makefile.                            73 arch/x86/boot/Makefile.
 74                                                    74 
 75 Some of the kernel command line boot options t     75 Some of the kernel command line boot options that may apply here are::
 76                                                    76 
 77   ramdisk_start=N                                  77   ramdisk_start=N
 78   ramdisk_size=M                                   78   ramdisk_size=M
 79                                                    79 
 80 If you make a boot disk that has LILO, then fo     80 If you make a boot disk that has LILO, then for the above, you would use::
 81                                                    81 
 82         append = "ramdisk_start=N ramdisk_size     82         append = "ramdisk_start=N ramdisk_size=M"
 83                                                    83 
 84 4) An Example of Creating a Compressed RAM Dis     84 4) An Example of Creating a Compressed RAM Disk
 85 ----------------------------------------------     85 -----------------------------------------------
 86                                                    86 
 87 To create a RAM disk image, you will need a sp     87 To create a RAM disk image, you will need a spare block device to
 88 construct it on. This can be the RAM disk devi     88 construct it on. This can be the RAM disk device itself, or an
 89 unused disk partition (such as an unmounted sw     89 unused disk partition (such as an unmounted swap partition). For this
 90 example, we will use the RAM disk device, "/de     90 example, we will use the RAM disk device, "/dev/ram0".
 91                                                    91 
 92 Note: This technique should not be done on a m     92 Note: This technique should not be done on a machine with less than 8 MB
 93 of RAM. If using a spare disk partition instea     93 of RAM. If using a spare disk partition instead of /dev/ram0, then this
 94 restriction does not apply.                        94 restriction does not apply.
 95                                                    95 
 96 a) Decide on the RAM disk size that you want.      96 a) Decide on the RAM disk size that you want. Say 2 MB for this example.
 97    Create it by writing to the RAM disk device     97    Create it by writing to the RAM disk device. (This step is not currently
 98    required, but may be in the future.) It is      98    required, but may be in the future.) It is wise to zero out the
 99    area (esp. for disks) so that maximal compr     99    area (esp. for disks) so that maximal compression is achieved for
100    the unused blocks of the image that you are    100    the unused blocks of the image that you are about to create::
101                                                   101 
102         dd if=/dev/zero of=/dev/ram0 bs=1k cou    102         dd if=/dev/zero of=/dev/ram0 bs=1k count=2048
103                                                   103 
104 b) Make a filesystem on it. Say ext2fs for thi    104 b) Make a filesystem on it. Say ext2fs for this example::
105                                                   105 
106         mke2fs -vm0 /dev/ram0 2048                106         mke2fs -vm0 /dev/ram0 2048
107                                                   107 
108 c) Mount it, copy the files you want to it (eg    108 c) Mount it, copy the files you want to it (eg: /etc/* /dev/* ...)
109    and unmount it again.                          109    and unmount it again.
110                                                   110 
111 d) Compress the contents of the RAM disk. The     111 d) Compress the contents of the RAM disk. The level of compression
112    will be approximately 50% of the space used    112    will be approximately 50% of the space used by the files. Unused
113    space on the RAM disk will compress to almo    113    space on the RAM disk will compress to almost nothing::
114                                                   114 
115         dd if=/dev/ram0 bs=1k count=2048 | gzi    115         dd if=/dev/ram0 bs=1k count=2048 | gzip -v9 > /tmp/ram_image.gz
116                                                   116 
117 e) Put the kernel onto the floppy::               117 e) Put the kernel onto the floppy::
118                                                   118 
119         dd if=zImage of=/dev/fd0 bs=1k            119         dd if=zImage of=/dev/fd0 bs=1k
120                                                   120 
121 f) Put the RAM disk image onto the floppy, aft    121 f) Put the RAM disk image onto the floppy, after the kernel. Use an offset
122    that is slightly larger than the kernel, so    122    that is slightly larger than the kernel, so that you can put another
123    (possibly larger) kernel onto the same flop    123    (possibly larger) kernel onto the same floppy later without overlapping
124    the RAM disk image. An offset of 400 kB for    124    the RAM disk image. An offset of 400 kB for kernels about 350 kB in
125    size would be reasonable. Make sure offset+    125    size would be reasonable. Make sure offset+size of ram_image.gz is
126    not larger than the total space on your flo    126    not larger than the total space on your floppy (usually 1440 kB)::
127                                                   127 
128         dd if=/tmp/ram_image.gz of=/dev/fd0 bs    128         dd if=/tmp/ram_image.gz of=/dev/fd0 bs=1k seek=400
129                                                   129 
130 g) Make sure that you have already specified t    130 g) Make sure that you have already specified the boot information in
131    FDARGS and FDINITRD or that you use a bootl    131    FDARGS and FDINITRD or that you use a bootloader to pass kernel
132    command line boot options to the kernel.       132    command line boot options to the kernel.
133                                                   133 
134 That is it. You now have your boot/root compre    134 That is it. You now have your boot/root compressed RAM disk floppy. Some
135 users may wish to combine steps (d) and (f) by    135 users may wish to combine steps (d) and (f) by using a pipe.
136                                                   136 
137                                                   137 
138                                                   138                                                 Paul Gortmaker 12/95
139                                                   139 
140 Changelog:                                        140 Changelog:
141 ----------                                        141 ----------
142                                                   142 
143 SEPT-2020 :                                       143 SEPT-2020 :
144                                                   144 
145                 Removed usage of "rdev"           145                 Removed usage of "rdev"
146                                                   146 
147 10-22-04 :                                        147 10-22-04 :
148                 Updated to reflect changes in     148                 Updated to reflect changes in command line options, remove
149                 obsolete references, general c    149                 obsolete references, general cleanup.
150                 James Nelson (james4765@gmail.    150                 James Nelson (james4765@gmail.com)
151                                                   151 
152 12-95 :                                           152 12-95 :
153                 Original Document                 153                 Original Document
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php