How to mount two hard drives in Linux to the same directory?

In a Linux system, you can mount two hard drives to the same directory using LVM (Logical Volume Management).

The following are the specific steps:

  1. Show block devices.
  2. List all the partitions on the system.
  3. initialize a physical volume
pvcreate /dev/sdb
pvcreate /dev/sdc
  1. create a volume group
vgcreate myvg /dev/sdb /dev/sdc
  1. create a logical volume
lvcreate -L 100G -n mylv myvg
  1. Create a new file system
mkfs.ext4 /dev/myvg/mylv
  1. Create a directory for mounting the logical volume, for example:
mkdir /mnt/mylv
  1. To climb or scale a mountain.
mount /dev/myvg/mylv /mnt/mylv
  1. The file named /etc/fstab
/dev/myvg/mylv /mnt/mylv ext4 defaults 0 0

After completing the above steps, both hard drives will be mounted in the same directory and can be used together.

bannerAds