“Sometimes all bad things will happen at the same time” – I remembered this quote on a night when my client identified a bug on her e-commerce website and wanted me to fix it immediately. It was only at that moment, I realized that I had been locked out of the server due to hosts.allow
settings. I have been using hosts.allow
on the CentOS server to allow SSH login only from specific IP addresses. But on a bad day, a major network migration in my office resulted in the change of IP address of my machine, which didn’t go well with hosts.allow
settings. Oops! SSH: Connection refused. However, I need to find a way to login to the server and fix the issue as soon as possible.
Well, a quick heads-up – the error – “mount unknown filesystem type ‘lvm2_member’” is unrelated to the SSH lock-out. It was an error that occurred while I tried mounting the partition that contains hosts.allow
file in system rescue mode. Here’s how the error panned out. Since I was locked out of the server, I needed to boot the server in the system rescue mode, mount the desired partition & remove the entries in hosts.allow
& hosts.deny
files. The error occurred while mounting the partition.
Error: mount unknown filesystem type ‘lvm2_member’
Once the system is booted into system rescue mode, I need to mount the hard disk partition that contains the hosts.allow
file and remove the entries to allow access to all (without restricting IP addresses).
The below command is used to list the hard disk partitions.
# fdisk -l
Mount the desired partition, and in my case, it is /dev/sda3.
# mkdir /mnt/disk # mount /dev/sda3 /mnt/disk
But the above command ended up with an error:
unknown filesystem type 'lvm2_member'
Well, I resolved the issue by executing the below command:
# mount /dev/mapper/vg-root /mnt/disk
But you might think what the above command is all about. Here’s the explanation.
Since I need to edit hosts.allow & hosts.deny
files that are located under the /etc/
folder of the physical hard disk partition (/dev/sda3
), I tried mounting the same. However, the system rescue toolkit was not configured to automatically recognize & mount LVM (Logical Volume managed by LVM). Here /dev/sda3
is a standard disk partition, i.e., a physical section of the hard disk. But /dev/mapper/vg-root
is a logical volume that’s created on top of the physical partition /dev/sda3
.
To list the logical volumes in CentOS, execute any of the below commands.
#lvs #lvdisplay #lvscan
Hence, by mounting the logical volume (/dev/mapper/vg-root
), I have bypassed mounting the physical device which seems to be the limitation of the system rescue toolkit.
Note: In vg-root
, vg
is the logical volume name (it could be different on your system) & root
refers to the partition inside the logical volume.
All is well now!