1

To create a ramdisk (Ubuntu 18.04), I issued "sudo mkdir /mnt/ramdisk" at the Putty terminal prompt. Then I issued "mount | tail -n 1" and it returned:

tmpfs on /run/user/1000 type tmpfs  (rw,nosuid,nodev,relatime,size=100912k,mode=700,uid=1000,gid=1000)

Now to unmount I issued "sudo umount /mnt/ramdisk/" but it said not found. So instead I issued "sudo umount /run/user/1000/" (part of the return from the mount command). Then, to be sure it's gone, I issued "mount | tail -n 1" and it returned:

tmpfs on /run/user/0 type  tmpfs(rw,nosuid,nodev,relatime,size=100912k,mode=700)

So I issued "sudo umount /run/user/0/"

Finally it's gone.

My questions are:

  1. When I mount a ramdisk at /mnt/ramdisk, how do I know where the ramdisk will actually be mounted so I can unmount it? This was done at the Linux command line, but if I did it with system() in a C program, how can I get the actual mount point to unmount it?

  2. When I unmounted /run/user/1000/ why did it end up at /run/user/0/?

  3. Why didn't it just go to /mnt/ramdisk?

Thanks.

0

1 Answer 1

2

The ramdisk created by the system at /run/user/1000 is for system processes and I would create a new, dedicated one if you wish to use it for your own purposes.

sudo mkdir /mnt/ramdisk will create a folder called ramdisk in the folder /mnt but not a ram disk.

If you wish to mount a RAM disk to the /mnt/ramdisk folder, usable by the user you log in as, enter the following (one time use):

mount -o size=4G,uid=1000 -t tmpfs tmpfs /mnt/ramdisk

(replace "4G" with the required size)

If it should be created at each boot, edit /etc/fstab as root (e.g. by sudo nano /etc/fstab) and add a line like this

none /mnt/ramdisk tmpfs size=4G,uid=1000 0 0

Then during each boot a new, empty ram disk will be mounted at /mnt/ramdisk for files discarded during shutdown.

4
  • Should I assume it will be found at /run/user/1000? Or does that vary?
    – RTC222
    Aug 1, 2020 at 23:29
  • No, I will add more info.
    – Ned64
    Aug 1, 2020 at 23:31
  • Thanks for the extra info. Where does "uid-1000" come from?
    – RTC222
    Aug 1, 2020 at 23:34
  • 2
    Each Linux user has a numerical ID as well as a user name. Perhaps you log in as "john" but internally there is a number behind it. I use numerical IDs here because I do not know your username but could derive your ID from your question. The first Linux user (person) normally has the user ID (UID) 1000.
    – Ned64
    Aug 1, 2020 at 23:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .