This shows you the differences between two versions of the page.
ep:labs:03:contents:tasks:ex5 [2020/07/30 20:47] gheorghe.petre2608 [06. [30p] RAM disk] |
ep:labs:03:contents:tasks:ex5 [2022/10/24 00:11] (current) andrei.mirciu [03. [30p] RAM disk] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== 06. [30p] RAM disk === | + | ==== 03. [30p] RAM disk ==== |
- | Linux allows you to use part of your RAM as a block device, viewing it as a hard disk partition. The advantage of using a RAM disk is the extremely low latency (even when compared to SSDs). The disadvantage is that all contents will be lost after a reboot. | + | Linux allows you to use part of your RAM as a block device, viewing it as a hard disk partition. The advantage of using a RAM disk is the **extremely low latency** (even when compared to SSDs). The disadvantage is that all contents will be lost after a reboot. |
<note tip> | <note tip> | ||
There are two main types of RAM disks: | There are two main types of RAM disks: | ||
Line 9: | Line 9: | ||
=== [15p] Task A - Create RAM Disk === | === [15p] Task A - Create RAM Disk === | ||
- | Before getting started, let's find out the file system that our root partition uses. Run the following command (T = print file system type, h = human readable): | + | Before getting started, let's find out the file system that our root partition uses. Run the following command (T - print file system type, h - human readable): |
<code bash> | <code bash> | ||
$ df -Th | $ df -Th | ||
+ | </code> | ||
+ | The result should look like this: | ||
+ | <code> | ||
+ | Filesystem Type Size Used Avail Use% Mounted on | ||
+ | udev devtmpfs 1.1G 0 1.1G 0% /dev | ||
+ | tmpfs tmpfs 214M 3.8M 210M 2% /run | ||
+ | /dev/sda1 ext4 218G 4.1G 202G 2% / <- root partition | ||
+ | tmpfs tmpfs 1.1G 252K 1.1G 1% /dev/shm | ||
+ | tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock | ||
+ | tmpfs tmpfs 1.1G 0 1.1G 0% /sys/fs/cgroup | ||
+ | /dev/sda2 ext4 923M 73M 787M 9% /boot | ||
+ | /dev/sda4 ext4 266G 62M 253G 1% /home | ||
</code> | </code> | ||
- | We will assume that the file system is **ext4**. If it's not, just use what you have in what follows: | + | From the results, we will assume in the following commands that the file system is **ext4**. If it's not your case, just replace with what you have: |
<code bash> | <code bash> | ||
Line 22: | Line 34: | ||
</code> | </code> | ||
+ | <note> | ||
If you want the RAM disk to persist after a reboot, you can add the following line to ///etc/fstab//. Remember that its contents will still be lost. | If you want the RAM disk to persist after a reboot, you can add the following line to ///etc/fstab//. Remember that its contents will still be lost. | ||
Line 27: | Line 40: | ||
tmpfs /mnt/ramdisk tmpfs rw,nodev,nosuid,size=1G 0 0 | tmpfs /mnt/ramdisk tmpfs rw,nodev,nosuid,size=1G 0 0 | ||
</code> | </code> | ||
+ | </note> | ||
That's it. We just created a 1Gb **tmpfs** ramdisk with an **ext4** file system and mounted it at ///mnt/ramdisk//. Use **df** again to check this yourself. | That's it. We just created a 1Gb **tmpfs** ramdisk with an **ext4** file system and mounted it at ///mnt/ramdisk//. Use **df** again to check this yourself. | ||
Line 42: | Line 56: | ||
Look at the elapsed time and average transfer speed. What conclusion can you draw? | Look at the elapsed time and average transfer speed. What conclusion can you draw? | ||
+ | |||
+ | :!: Put one screenshot with the tmpfs partition in df output and one screenshot of both pv commands and write your conclusion. | ||
+ |