To hide a device or volume on Linux after mounting, you can use the following steps:
- Identify the device or volume you want to hide by using the lsblk or fdisk command. For example, let's say the device is /dev/sdb1.
- Unmount the device or volume if it is currently mounted. You can use the umount command followed by the device path. For example:
sudo umount /dev/sdb1
- Create a new directory to act as a mount point for the device. For example:
sudo mkdir /mnt/hidden
- Move the mount point directory to a hidden location. This can be done by renaming it or moving it inside a hidden directory. For example, you can move it to /mnt/.hidden/:
sudo mv /mnt/hidden /mnt/.hidden/
- Mount the device or volume to the new hidden mount point:
sudo mount /dev/sdb1 /mnt/.hidden/hidden
- Update the /etc/fstab file to make the mount permanent. Add an entry at the end of the file to mount the device or volume to the hidden mount point. For example:
/dev/sdb1 /mnt/.hidden/hidden ext4 defaults 0 0
- Save the file and exit.
After completing these steps, the device or volume will be mounted to the hidden mount point, making it inaccessible through the usual mount point. It will remain hidden until you manually mount it or update the
/etc/fstab file to mount it elsewhere.