fdisk -l shows 16 ram disks /dev/ram0 ... /ram15

Ever since I upgraded to 15.10, fdisk -l reports 16 ram disks (/dev/ram0 ... /dev/ram15). I'm a bit unsure what those are needed for. Is it safe to delete them? If not, how can I get rid of that fdisk output?


Solution 1:

This is perfectly normal on Linux systems. It's kind of a preparatory action for the case that the RAM disks should be required. Each of them has a size of 64 MiB, a very low value. If necessary, the size will be increased automatically.

Why suddenly 16 RAM disks are available in Wily, can be explained only with difficulty.

I have tested the default RAM disks on:

  • CentOS 7 – No RAM disks
  • Fedora 23 – No RAM disks
  • Ubuntu 14.04 – No RAM disks
  • Raspbian Jessie – 16 RAM disks (4MiB)

Source

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/initrd.txt). 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.

Solution 2:

No idea why fdisk is suddenly reporting /dev/ram.

You can however tell fdisk to only report specific devices.

fdisk -l /dev/sd*

Will list real drives.

Alternatively you could also use parted and lsblk.

Parted output for one drive here.

Model: ATA Samsung SSD 840 (scsi)
Disk /dev/sda: 120GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system  Flags
 1      2096kB  120GB   120GB   extended               boot
 7      2097kB  26.2GB  26.2GB  logical   ext4
 5      26.2GB  36.7GB  10.5GB  logical   ext4
 6      36.7GB  47.2GB  10.5GB  logical   ext4

Corresponding lsblk output

    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 111.8G  0 disk 
├─sda1   8:1    0     1K  0 part 
├─sda5   8:5    0   9.8G  0 part /mnt/Links
├─sda6   8:6    0   9.8G  0 part 
└─sda7   8:7    0  24.4G  0 part /

Solution 3:

I know this thread is old, but I came across it only recently. After installing Slackware 14.2 I got the same 16 RAM disks in the output of fdisk -l. I investigated a little further and found that in the 'util-linux' package, which fdisk (among others) is part of, the selcetion of what fdisk considers as block device changed substantially. In the util-linux package version 2.21 this decision is based on the reported disk geometry while in the current version 2.72 the output of /proc/partitions is parsed. According to my searches on the internet the ramdisks have been there in Linux since kernel 2.4, fdisk did just not show them. Since I am annoyed by the listing of many "disks", which are no real disks, I made a patch for fdisk:

    diff -Nur util-linux-2.27.1_ori/disk-utils/fdisk-list.c util-linux-2.27.1_fdisk-no-ram-disks/disk-utils/fdisk-list.c
--- util-linux-2.27.1_ori/disk-utils/fdisk-list.c   2015-10-06 08:59:51.572589724 +0200
+++ util-linux-2.27.1_fdisk-no-ram-disks/disk-utils/fdisk-list.c    2016-08-16 15:55:14.840952091 +0200
@@ -312,6 +312,10 @@
        if (devno <= 0)
            continue;

+       /* dont list RAM disks */
+       if (strstr(line, "ram") && devno >= 256)
+           continue;
+
        if (sysfs_devno_is_lvm_private(devno) ||
            sysfs_devno_is_wholedisk(devno) <= 0)
            continue;

Maybe this helps some others...