accessing files under a mount point (getting at the files that have been obscured by another filesystem mounted on top of them)

This has come up 3 times in the last few days so I thought I'd share it. The situation is that there are files at /var/spool/mqueue that are part of the /var filesystem. But there is also another filesystem mounted at /var/spool/mqueue with it's own files. You want to access the files under the mount but you can't. So, there are two ways around this (in this instance).

Option 1

Mount /var somewhere else, get the mount device for /var
[me@host ~] $ mount |grep "/var " |sed -e 's/\(.*\) on \/var type.*/\1/'
/dev/mapper/vg_root/lv_var
[me@host ~] $ sudo mkdir /mnt/var
[me@host ~] $ sudo mount /dev/mapper/vg_root/lv_var /mnt/var

The files that were mounted on top of will be accessible again, yay (pretty darn simple no), just don't get confused cause now they'll be in /mnt/var/spool

Option 2

Use a bind mount to mount /var/spool somewhere else, don't need to figure out the device this way...

[me@host ~] $ sudo mkdir /mnt/spool
[me@host ~] $ sudo mount -t bind -o bind /var/spool /mnt/spool

I prefer this method, the bind mount is also a good clue to the next admin that something funky is going on here...

About the Author...

Slides from LISA 2019 Linux systems troubleshooting #LISA2019 https://t.co/D4dMKflK6R Tue Oct 29 05:59:30 +0000 2019

https://t.co/AGeihMALAv configuring grub2 with EFI Fri Sep 13 05:20:01 +0000 2019

I published a Thing on @thingiverse! https://t.co/IYpRyEb7Hz #thingalert Tue Jul 23 19:27:57 +0000 2019

Nokogiri install on MacOSX https://t.co/v3An0miW9L Fri Jul 12 15:06:49 +0000 2019

HTML email with plain mailer plugin on Jenkins https://t.co/Z6FSDMDjy8 Thu Jul 11 21:07:25 +0000 2019