Linux ramdisk block device

Using the RAM disk block device with LinuxВ¶

1) OverviewВ¶

The RAM disk driver is a way to use main system memory as a block device. It is required for initrd, an initial filesystem used if you need to load modules in order to access the root filesystem (see Documentation/admin-guide/initrd.rst). It can also be used for a temporary filesystem for crypto work, since the contents are erased on reboot.

The RAM disk dynamically grows as more space is required. It does this by using RAM from the buffer cache. The driver marks the buffers it is using as dirty so that the VM subsystem does not try to reclaim them later.

The RAM disk supports up to 16 RAM disks by default, and can be reconfigured to support an unlimited number of RAM disks (at your own risk). Just change the configuration symbol BLK_DEV_RAM_COUNT in the Block drivers config menu and (re)build the kernel.

To use RAM disk support with your system, run ‘./MAKEDEV ram’ from the /dev directory. RAM disks are all major number 1, and start with minor number 0 for /dev/ram0, etc. If used, modern kernels use /dev/ram0 for an initrd.

The new RAM disk also has the ability to load compressed RAM disk images, allowing one to squeeze more programs onto an average installation or rescue floppy disk.

2) ParametersВ¶

2a) Kernel Command Line Parameters

This parameter tells the RAM disk driver to set up RAM disks of N k size. The default is 4096 (4 MB).

2b) Module parameters

3) Using «rdev -r»В¶

The usage of the word (two bytes) that «rdev -r» sets in the kernel image is as follows. The low 11 bits (0 -> 10) specify an offset (in 1 k blocks) of up to 2 MB (2^11) of where to find the RAM disk (this used to be the size). Bit 14 indicates that a RAM disk is to be loaded, and bit 15 indicates whether a prompt/wait sequence is to be given before trying to read the RAM disk. Since the RAM disk dynamically grows as data is being written into it, a size field is not required. Bits 11 to 13 are not currently used and may as well be zero. These numbers are no magical secrets, as seen below:

Consider a typical two floppy disk setup, where you will have the kernel on disk one, and have already put a RAM disk image onto disk #2.

Hence you want to set bits 0 to 13 as 0, meaning that your RAM disk starts at an offset of 0 kB from the beginning of the floppy. The command line equivalent is: «ramdisk_start=0»

You want bit 14 as one, indicating that a RAM disk is to be loaded. The command line equivalent is: «load_ramdisk=1»

You want bit 15 as one, indicating that you want a prompt/keypress sequence so that you have a chance to switch floppy disks. The command line equivalent is: «prompt_ramdisk=1»

Putting that together gives 2^15 + 2^14 + 0 = 49152 for an rdev word. So to create disk one of the set, you would do:

If you make a boot disk that has LILO, then for the above, you would use:

Источник

Using the RAM disk block device with LinuxВ¶

1) OverviewВ¶

The RAM disk driver is a way to use main system memory as a block device. It is required for initrd, an initial filesystem used if you need to load modules in order to access the root filesystem (see Documentation/admin-guide/initrd.rst). It can also be used for a temporary filesystem for crypto work, since the contents are erased on reboot.

The RAM disk dynamically grows as more space is required. It does this by using RAM from the buffer cache. The driver marks the buffers it is using as dirty so that the VM subsystem does not try to reclaim them later.

Читайте также:  Линукс с рабочим столом windows

The RAM disk supports up to 16 RAM disks by default, and can be reconfigured to support an unlimited number of RAM disks (at your own risk). Just change the configuration symbol BLK_DEV_RAM_COUNT in the Block drivers config menu and (re)build the kernel.

To use RAM disk support with your system, run ‘./MAKEDEV ram’ from the /dev directory. RAM disks are all major number 1, and start with minor number 0 for /dev/ram0, etc. If used, modern kernels use /dev/ram0 for an initrd.

The new RAM disk also has the ability to load compressed RAM disk images, allowing one to squeeze more programs onto an average installation or rescue floppy disk.

2) ParametersВ¶

2a) Kernel Command Line Parameters

This parameter tells the RAM disk driver to set up RAM disks of N k size. The default is 4096 (4 MB).

2b) Module parameters

3) Using “rdev -r”¶

The usage of the word (two bytes) that “rdev -r” sets in the kernel image is as follows. The low 11 bits (0 -> 10) specify an offset (in 1 k blocks) of up to 2 MB (2^11) of where to find the RAM disk (this used to be the size). Bit 14 indicates that a RAM disk is to be loaded, and bit 15 indicates whether a prompt/wait sequence is to be given before trying to read the RAM disk. Since the RAM disk dynamically grows as data is being written into it, a size field is not required. Bits 11 to 13 are not currently used and may as well be zero. These numbers are no magical secrets, as seen below:

Consider a typical two floppy disk setup, where you will have the kernel on disk one, and have already put a RAM disk image onto disk #2.

Hence you want to set bits 0 to 13 as 0, meaning that your RAM disk starts at an offset of 0 kB from the beginning of the floppy. The command line equivalent is: “ramdisk_start=0”

You want bit 14 as one, indicating that a RAM disk is to be loaded. The command line equivalent is: “load_ramdisk=1”

You want bit 15 as one, indicating that you want a prompt/keypress sequence so that you have a chance to switch floppy disks. The command line equivalent is: “prompt_ramdisk=1”

Putting that together gives 2^15 + 2^14 + 0 = 49152 for an rdev word. So to create disk one of the set, you would do:

If you make a boot disk that has LILO, then for the above, you would use:

Источник

Using the RAM disk block device with LinuxВ¶

1) OverviewВ¶

The RAM disk driver is a way to use main system memory as a block device. It is required for initrd, an initial filesystem used if you need to load modules in order to access the root filesystem (see Using the initial RAM disk (initrd) ). It can also be used for a temporary filesystem for crypto work, since the contents are erased on reboot.

The RAM disk dynamically grows as more space is required. It does this by using RAM from the buffer cache. The driver marks the buffers it is using as dirty so that the VM subsystem does not try to reclaim them later.

The RAM disk supports up to 16 RAM disks by default, and can be reconfigured to support an unlimited number of RAM disks (at your own risk). Just change the configuration symbol BLK_DEV_RAM_COUNT in the Block drivers config menu and (re)build the kernel.

To use RAM disk support with your system, run ‘./MAKEDEV ram’ from the /dev directory. RAM disks are all major number 1, and start with minor number 0 for /dev/ram0, etc. If used, modern kernels use /dev/ram0 for an initrd.

The new RAM disk also has the ability to load compressed RAM disk images, allowing one to squeeze more programs onto an average installation or rescue floppy disk.

2) ParametersВ¶

2a) Kernel Command Line Parameters

This parameter tells the RAM disk driver to set up RAM disks of N k size. The default is 4096 (4 MB).

2b) Module parameters

3) Using “rdev”¶

“rdev” is an obsolete, deprecated, antiquated utility that could be used to set the boot device in a Linux kernel image.

Instead of using rdev, just place the boot device information on the kernel command line and pass it to the kernel from the bootloader.

You can also pass arguments to the kernel by setting FDARGS in arch/x86/boot/Makefile and specify in initrd image by setting FDINITRD in arch/x86/boot/Makefile.

Читайте также:  Windows 2003 логи rdp

Some of the kernel command line boot options that may apply here are:

If you make a boot disk that has LILO, then for the above, you would use:

4) An Example of Creating a Compressed RAM DiskВ¶

To create a RAM disk image, you will need a spare block device to construct it on. This can be the RAM disk device itself, or an unused disk partition (such as an unmounted swap partition). For this example, we will use the RAM disk device, “/dev/ram0”.

Note: This technique should not be done on a machine with less than 8 MB of RAM. If using a spare disk partition instead of /dev/ram0, then this restriction does not apply.

Decide on the RAM disk size that you want. Say 2 MB for this example. Create it by writing to the RAM disk device. (This step is not currently required, but may be in the future.) It is wise to zero out the area (esp. for disks) so that maximal compression is achieved for the unused blocks of the image that you are about to create:

Make a filesystem on it. Say ext2fs for this example:

Mount it, copy the files you want to it (eg: /etc/* /dev/* …) and unmount it again.

Compress the contents of the RAM disk. The level of compression will be approximately 50% of the space used by the files. Unused space on the RAM disk will compress to almost nothing:

Put the kernel onto the floppy:

Put the RAM disk image onto the floppy, after the kernel. Use an offset that is slightly larger than the kernel, so that you can put another (possibly larger) kernel onto the same floppy later without overlapping the RAM disk image. An offset of 400 kB for kernels about 350 kB in size would be reasonable. Make sure offset+size of ram_image.gz is not larger than the total space on your floppy (usually 1440 kB):

Make sure that you have already specified the boot information in FDARGS and FDINITRD or that you use a bootloader to pass kernel command line boot options to the kernel.

That is it. You now have your boot/root compressed RAM disk floppy. Some users may wish to combine steps (d) and (f) by using a pipe.

Источник

Using the RAM disk block device with LinuxВ¶

1) OverviewВ¶

The RAM disk driver is a way to use main system memory as a block device. It is required for initrd, an initial filesystem used if you need to load modules in order to access the root filesystem (see Documentation/admin-guide/initrd.rst). It can also be used for a temporary filesystem for crypto work, since the contents are erased on reboot.

The RAM disk dynamically grows as more space is required. It does this by using RAM from the buffer cache. The driver marks the buffers it is using as dirty so that the VM subsystem does not try to reclaim them later.

The RAM disk supports up to 16 RAM disks by default, and can be reconfigured to support an unlimited number of RAM disks (at your own risk). Just change the configuration symbol BLK_DEV_RAM_COUNT in the Block drivers config menu and (re)build the kernel.

To use RAM disk support with your system, run ‘./MAKEDEV ram’ from the /dev directory. RAM disks are all major number 1, and start with minor number 0 for /dev/ram0, etc. If used, modern kernels use /dev/ram0 for an initrd.

The new RAM disk also has the ability to load compressed RAM disk images, allowing one to squeeze more programs onto an average installation or rescue floppy disk.

2) ParametersВ¶

2a) Kernel Command Line Parameters

This parameter tells the RAM disk driver to set up RAM disks of N k size. The default is 4096 (4 MB).

2b) Module parameters

3) Using “rdev -r”¶

The usage of the word (two bytes) that “rdev -r” sets in the kernel image is as follows. The low 11 bits (0 -> 10) specify an offset (in 1 k blocks) of up to 2 MB (2^11) of where to find the RAM disk (this used to be the size). Bit 14 indicates that a RAM disk is to be loaded, and bit 15 indicates whether a prompt/wait sequence is to be given before trying to read the RAM disk. Since the RAM disk dynamically grows as data is being written into it, a size field is not required. Bits 11 to 13 are not currently used and may as well be zero. These numbers are no magical secrets, as seen below:

Читайте также:  Vmware tools для astra linux

Consider a typical two floppy disk setup, where you will have the kernel on disk one, and have already put a RAM disk image onto disk #2.

Hence you want to set bits 0 to 13 as 0, meaning that your RAM disk starts at an offset of 0 kB from the beginning of the floppy. The command line equivalent is: “ramdisk_start=0”

You want bit 14 as one, indicating that a RAM disk is to be loaded. The command line equivalent is: “load_ramdisk=1”

You want bit 15 as one, indicating that you want a prompt/keypress sequence so that you have a chance to switch floppy disks. The command line equivalent is: “prompt_ramdisk=1”

Putting that together gives 2^15 + 2^14 + 0 = 49152 for an rdev word. So to create disk one of the set, you would do:

If you make a boot disk that has LILO, then for the above, you would use:

Источник

Using the RAM disk block device with LinuxВ¶

1) OverviewВ¶

The RAM disk driver is a way to use main system memory as a block device. It is required for initrd, an initial filesystem used if you need to load modules in order to access the root filesystem (see Documentation/admin-guide/initrd.rst). It can also be used for a temporary filesystem for crypto work, since the contents are erased on reboot.

The RAM disk dynamically grows as more space is required. It does this by using RAM from the buffer cache. The driver marks the buffers it is using as dirty so that the VM subsystem does not try to reclaim them later.

The RAM disk supports up to 16 RAM disks by default, and can be reconfigured to support an unlimited number of RAM disks (at your own risk). Just change the configuration symbol BLK_DEV_RAM_COUNT in the Block drivers config menu and (re)build the kernel.

To use RAM disk support with your system, run ‘./MAKEDEV ram’ from the /dev directory. RAM disks are all major number 1, and start with minor number 0 for /dev/ram0, etc. If used, modern kernels use /dev/ram0 for an initrd.

The new RAM disk also has the ability to load compressed RAM disk images, allowing one to squeeze more programs onto an average installation or rescue floppy disk.

2) ParametersВ¶

2a) Kernel Command Line Parameters

This parameter tells the RAM disk driver to set up RAM disks of N k size. The default is 4096 (4 MB).

2b) Module parameters

3) Using “rdev -r”¶

The usage of the word (two bytes) that “rdev -r” sets in the kernel image is as follows. The low 11 bits (0 -> 10) specify an offset (in 1 k blocks) of up to 2 MB (2^11) of where to find the RAM disk (this used to be the size). Bit 14 indicates that a RAM disk is to be loaded, and bit 15 indicates whether a prompt/wait sequence is to be given before trying to read the RAM disk. Since the RAM disk dynamically grows as data is being written into it, a size field is not required. Bits 11 to 13 are not currently used and may as well be zero. These numbers are no magical secrets, as seen below:

Consider a typical two floppy disk setup, where you will have the kernel on disk one, and have already put a RAM disk image onto disk #2.

Hence you want to set bits 0 to 13 as 0, meaning that your RAM disk starts at an offset of 0 kB from the beginning of the floppy. The command line equivalent is: “ramdisk_start=0”

You want bit 14 as one, indicating that a RAM disk is to be loaded. The command line equivalent is: “load_ramdisk=1”

You want bit 15 as one, indicating that you want a prompt/keypress sequence so that you have a chance to switch floppy disks. The command line equivalent is: “prompt_ramdisk=1”

Putting that together gives 2^15 + 2^14 + 0 = 49152 for an rdev word. So to create disk one of the set, you would do:

If you make a boot disk that has LILO, then for the above, you would use:

Источник

Оцените статью