11
$ df /tmp
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/root      480589544 42607368 413546516  10% /

$ ls /dev/root
ls: cannot access /dev/root: No such file or directory

I wanted to check if my default Debian installation places /tmp in RAM or on the disk, but now am completely confused. Why would a non-existing device be reported as a filesystem type? What doe "mounted on /" mean?

Here is the output of mount:

/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=811520k,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=1013960,mode=755)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=1623020k)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
none_debugfs on /sys/kernel/debug type debugfs (rw,relatime)
cgroup on /sys/fs/cgroup type tmpfs (rw,relatime,size=12k)
cgmfs on /run/cgmanager/fs type tmpfs (rw,relatime,size=100k,mode=755)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/run/cgmanager/agents/cgm-release-agent.systemd,name=systemd)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=811520k,mode=700,uid=1000,gid=1000)
3
  • 2
    The output seems very spartan. Would you please post the output of the mount command? – Rui F Ribeiro Jan 19 '16 at 14:40
  • 1
    /tmp is a mount point. The question you mean to ask is "What partition/device is mounted on /tmp?" – William Pursell Nov 8 '18 at 18:15
  • And phrasing it that way (I think) clarifies your confusion. /dev/root is the device mounted at the root of the filesystem (/) – William Pursell Nov 8 '18 at 18:17
10

If the output is as above, it's on the hard disk. You can get /dev/root by looking at the kernel commandline:

$ cat /proc/cmdline | grep root
BOOT_IMAGE=/boot/vmlinuz-3.19.0-32-generic root=UUID=0cde5cf9-b15d-4369-b3b1-4405204fd9ff ro

So /dev/root is equivalent to the partition with the UUID printed above; your's will differ. To look this UUID up, use

$ sudo blkid
/dev/sda1: UUID="0cde5cf9-b15d-4369-b3b1-4405204fd9ff" TYPE="ext4" 
/dev/sda5: UUID="37bc6a9c-a27f-43dc-a485-5fb1830e1e42" TYPE="swap" 
/dev/sdb1: UUID="177c3cec-5612-44a7-9716-4dcba27c69f9" TYPE="ext4" 

As you can see, the matching partition is /dev/sda1. So your /tmp is on the hard disk. Another giveaway in the output of df is the mountpoint /. If you mounted /tmp in the RAM, you'd instead get

$ df /tmp
Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs            3640904    20   3640884   1% /tmp
9

The output of df /tmp gives the answer: the “Mounted on” column lists /, so /tmp is part of the filesystem that's mounted on /, i.e. the root filesystem. It is not a separate filesystem.

To be more accurate, you should run df /tmp/: if /tmp is a symbolic link, then df /tmp lists information about the location of the symbolic link, whereas df /tmp/ lists information about the target directory.

The mention of /dev/root in the device column is due to its being listed in /etc/mtab. You can find the real device by looking in /proc/mounts with </proc/mounts awk '$2 == "/" {print $1}' or findmnt /.

1
  • +1 for df /tmp and findmnt /. – akhan Feb 20 '18 at 19:21
0

df /path/to/target shows which filesystem contains the folder target, bytes total, bytes used, percentage available and the mount point.

In the example documented in this question, the folder /tmp/ is located within the filesystem labeled root, which is on the block device /dev/sda1.

mount | grep target will show any filesystems containing the name target as listed in /etc/mtab. If the target folder is not a separate filesystem, mount will not directly give you accurate information.

However, to know what device contains /tmp/, use df to get the filesystem name, (/dev/root), and the mount point, (/), and then search the output of mount to find the device or mount point and determine what block device holds that filesystem.

It is important to distinguish between device and filesystem because there is not always a 1:1 correlation. The block device can be partitioned and each partition will have a filesystem. Each partition can have a different type of filesystem. Each partition its own unique name and UUID and can have aliases.

-2

To check this, mount is more appropriate. You can try it, and grep its output on 'tmp'

Ex:

$  mount | grep tmp
tmpfs on /dev/shm type tmpfs ...

Here it says that my partition /dev/shm is mounted with tmpfs (temporary file storage, i.e. in RAM). If your partition isn't mounted with tmpfs then it's not in volatile memory.

3
  • I was expecting to see tmpfs on /tmp. – Vorac Jan 19 '16 at 15:44
  • On the contrary, df gives the information directly, whereas mount | grep does not give the information reliably (it would miss cases where /tmp is a symbolic link, and it wouldn't work for something like /var/tmp since either /var or /var/tmp could be a mount point). – Gilles 'SO- stop being evil' Jan 19 '16 at 22:08
  • mount basically prints the contents of the mtab file (/etc/mtab). This shows only mounted filesystems. If the target folder is not a separate filesystem, you will not find it using mount. However, if you use df /path/to/target, it will positively tell you which block device contains the target folder, and where that device is mounted. You can then use mount or other tools to determine what type of filesystem it is and other information. In OP's example, your suggestion will not show where the /tmp/ folder is mounted, since his /tmp/ is not a separate filesystem, but part of /. – Xalorous Nov 8 '18 at 15:44

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.