How to regenerate /etc/mtab file on Linux

Last updated on June 9, 2020 by Dan Nanni

Question: I accidentally messed up (or removed) /etc/mtab file. How can I recreate the original /etc/mtab file which reflects the current mount information?

In case /etc/mtab file is removed or corrupted by accident, and you want to recover the original /etc/mtab file, you can use /proc/mounts, which shows an up-to-date list of all mounts currently used by Linux system.

To reset /etc/mtab file to reflect the current mount information, run the following command.

$ sudo sh -c 'grep -v rootfs /proc/mounts > /etc/mtab'

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean