Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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