15

I have Arch Linux running on my Raspberry Pi 2.

Right after install, I ran lsblk, fdisk and df commands (unfortunately I did not save the output) but I had one disk, which is the SD card and two partitions on it. Then, I upgraded the system with pacman -Syu, installed sudo and configured ssh. Now, when I run fdisk it shows I have 16 RAM disks in memory with parameters:

Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors 

Units: sectors of 1 * 512 = 512 bytes 

Sector size (logical/physical): 512 bytes / 4096 bytes 

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

and all kinds of file systems mounted at various mount points (while I personally created only /dev/root and /dev/boot):

Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.8G  1.1G  557M  67% /
devtmpfs        458M     0  458M   0% /dev
tmpfs           462M     0  462M   0% /dev/shm
tmpfs           462M  328K  462M   1% /run
tmpfs           462M     0  462M   0% /sys/fs/cgroup
tmpfs           462M     0  462M   0% /tmp
/dev/mmcblk0p1  100M   18M   83M  18% /boot
tmpfs            93M     0   93M   0% /run/user/1000

So my question is: What are all these RAM disks and why they are in my system, since I definitely did not create them and what are those file systems mounted?

Edit:

cat /proc/partitions output:

major minor  #blocks  name

   1        0       4096 ram0
   1        1       4096 ram1
   1        2       4096 ram2
   1        3       4096 ram3
   1        4       4096 ram4
   1        5       4096 ram5
   1        6       4096 ram6
   1        7       4096 ram7
   1        8       4096 ram8
   1        9       4096 ram9
   1       10       4096 ram10
   1       11       4096 ram11
   1       12       4096 ram12
   1       13       4096 ram13
   1       14       4096 ram14
   1       15       4096 ram15
 179        0   31472640 mmcblk0
 179        1     102400 mmcblk0p1
 179        2    1853439 mmcblk0p2
  • 1
    I found this related question. That question does not have any great answers either, but one comment suggests that /proc/partitions may be of relevance. You should include the output of cat /proc/partitions in your question. – kasperd Mar 27 '16 at 17:26
  • You won't necessarily find any answers on a Raspberry Pi specific site to general Linux questions. A quick Google finds answers. – joan Mar 28 '16 at 9:34
  • 1
    @joan Oh, i did extensive googling, but i could not find a clear and concise answer, just bits and pieces. – RusI Mar 29 '16 at 12:27
  • 1. Those RAM disks have to enabled before compiling the kernel. 2. They should not actually use any RAM before mounting a FS on them. – flakeshake Mar 30 '16 at 12:31
  • The reason for allocating these RAM disks remains a mystery then... it would seem that the reason would have to be: 1) save writes to the SD card, and/or 2) improve performance by reducing disk i/o latency.But nobody (credible) has gone on record with such a statement. – Seamus May 14 '18 at 20:38
4

Firstly, RAM disks are not the same thing as tmpfs.

There are many directories on your root drive that are used to store temporary files. These folders tend to have a lot of reading and writing going on as applications create, modify then delete the files during the course of their execution.

On a mechanical hard-drive where the number of read/write cycles don't matter, this is perfectly fine. However, on the Raspberry Pi, where the main storage backend is an SD Card where there is a limited number of read/write cycles, having so much I/O going on can prematurely wear the card out.

Since we don't need to persist the files in those temporary directories over a reboot, many distros attempt to reduce the wear and tear on the storage device by storing the high-traffic temporary files in RAM. Tmpfs is used since its a filesystem that uses RAM as its storage backend. This is why you see so many directories mounted as tmpfs.

RAM disks are completely unrelated to this. They are block devices that are backed by RAM whereas tmpfs is a filesystem backed by RAM. RAM disks are raw block devices similar to /dev/sda etc... You can make a filesystem on top of a RAM disk by running mkfs /dev/ram just as you would on a normal hard drive block device.

I believe the number of RAM disks that are available to use is controlled by a kernel config option. Rest assured that they do not actually take up space until you use/write to them.

7

That is nothing unusual.

RAM discs are commonly used for temporary file systems.

My Debian laptop

Filesystem      Size  Used Avail Use% Mounted on
udev            1.5G     0  1.5G   0% /dev
tmpfs           301M   32M  269M  11% /run
/dev/sda2        47G   31G   14G  71% /
tmpfs           1.5G  1.7M  1.5G   1% /dev/shm
tmpfs           5.0M  8.0K  5.0M   1% /run/lock
tmpfs           1.5G     0  1.5G   0% /sys/fs/cgroup
tmpfs           1.5G   69M  1.5G   5% /tmp
/dev/sda4       386G  344G   23G  94% /home
tmpfs           301M   12K  301M   1% /run/user/114
tmpfs           301M   76K  301M   1% /run/user/1000

My Raspbian Pi Zero

Filesystem                     Size  Used Avail Use% Mounted on
/dev/root                      7.2G  3.8G  3.1G  56% /
devtmpfs                       214M     0  214M   0% /dev
tmpfs                          218M     0  218M   0% /dev/shm
tmpfs                          218M   17M  202M   8% /run
tmpfs                          5.0M  4.0K  5.0M   1% /run/lock
tmpfs                          218M     0  218M   0% /sys/fs/cgroup
/dev/mmcblk0p1                  56M   20M   37M  36% /boot
tmpfs                          100M  4.0K  100M   1% /ram
tmpfs                           44M     0   44M   0% /run/user/109
mercury.lan:/home/common/code  386G  344G   23G  94% /code
tmpfs                           44M     0   44M   0% /run/user/1000
  • 3
    You are not answering the question. The question is why /dev/ram15 (and presumably 0-14 as well) show up in the output from fdisk. Your answer is only mentioning tmpfs which is entirely unrelated to /dev/ram*. – kasperd Mar 27 '16 at 17:01
  • 1
    I do not doubt your statements but i'm really interested in why these changes took place in my system. While i'm just studying Linux and i specifically chose Arch as being "hardcore" so to speak where you have to tell the OS explicitly what you want it to do, and now i've got system creating disks and file systems and mounting them all over the place on its own - so who is in control here? – RusI Mar 27 '16 at 17:43
2

Short answer: it is just a fdisk peculiarity on latest versions. Alternatively you could also use parted and lsblk.

Extracted from this thread at AskUbuntu:

On later versions of fdisk the selection of what the program considers as block device changed substantially. In the util-linux package, which fdisk (among others) is part of, version 2.21 this decision is based on the reported disk geometry while in the (as for May 2017) current version 2.72.1 the output of /proc/partitions is parsed

And:

The ram-disks have been in the kernel for a long time, it is the behavior of fdisk that changed.

More details and several workarounds (if those ram disks on screen annoys you) on the above mentioned thread.

  • "More details and several workarounds" ??? where ??? – ZEE Apr 2 at 15:36
  • @Zee , look at the referred thread on AskUbuntu. They even list some patches for fdisk original source. – Sopalajo de Arrierez Apr 3 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.