What directories on my Ubuntu computer aren't actually on my hard drive? I am making a personal backup software, and some of the directories are not "real" Which directories aren't actually on my hard drive?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
To list all mounted file systems and their mount point directories that are virtual i.e. not backed by a physical disk storage, you can parse the output of the
For simplicity, I'm only filtering out all mounts corresponding to devices starting with
/dev/mmcblk, which should cover most hard disk partitions and removable media. This is not perfect, because you might possibly have devices that show up differently which would then not get filtered out, but as you later still see what was mounted in the output, I prefer false positive results here over false negatives. If you notice you need to add something, simply add it to the regular expression pattern of the first
grep command, inside the
(...) brackets and separated from the other filtered line beginnings with a
mount | grep -vE '^(/dev/sd|/dev/mmcblk)' | grep -oE '\S+ on \S+' | sort -k3 | column -t
This will result in a list of mounts, like that one on my example machine:
$ mount | grep -vE '^(/dev/sd|/dev/mmcblk)' | grep -oE '\S+ on \S+' | sort -k3 | column -t udev on /dev hugetlbfs on /dev/hugepages mqueue on /dev/mqueue devpts on /dev/pts tmpfs on /dev/shm proc on /proc binfmt_misc on /proc/sys/fs/binfmt_misc systemd-1 on /proc/sys/fs/binfmt_misc tmpfs on /run cgmfs on /run/cgmanager/fs hugetlbfs-kvm on /run/hugepages/kvm tmpfs on /run/lock tmpfs on /run/user/1000 gvfsd-fuse on /run/user/1000/gvfs sysfs on /sys efivarfs on /sys/firmware/efi/efivars tmpfs on /sys/fs/cgroup cgroup on /sys/fs/cgroup/blkio cgroup on /sys/fs/cgroup/cpu,cpuacct cgroup on /sys/fs/cgroup/cpuset cgroup on /sys/fs/cgroup/devices cgroup on /sys/fs/cgroup/freezer cgroup on /sys/fs/cgroup/hugetlb cgroup on /sys/fs/cgroup/memory cgroup on /sys/fs/cgroup/net_cls,net_prio cgroup on /sys/fs/cgroup/perf_event cgroup on /sys/fs/cgroup/pids cgroup on /sys/fs/cgroup/systemd fusectl on /sys/fs/fuse/connections pstore on /sys/fs/pstore debugfs on /sys/kernel/debug securityfs on /sys/kernel/security none on /tmp
This listing should show all paths on the right where you have a virtual file system mounted and the corresponding type of file system on the left. As mentioned above, due to filtering
/dev/sd* only, there might be some false positive results in the list.
So from that list we can conclude that
/tmp are purely virtual. Note that while the first four directories are virtual on all Ubuntu installations,
/tmp is normally stored on he hard disk unless you manually make it a tmpfs like I did. It should never be included into a backup anyway though.
If you want a way to reduce that list of paths and filter out all those which are only subdirectories of already mentioned paths (like e.g.
/dev/pts can be omitted because
/dev is already listed), look at Having a list of paths, how can I filter out subdirectories of previously mentioned paths?
This really depends on how you are going to restore your system. If you will rebuild then you only need the configuration/data files for your services (eg: /etc, /opt, /var, /home)
If you are after a full system restore, then it you could omit /proc, /boot & /dev. Then you can install the minimum OS from your boot media and then restore your system via your backup.