I am using Arch Linux and want to mount my two disks, /dev/nbd1 and /dev/nbd2, at the same mount point.
I created the mount at /share/data and added the following to /etc/fstab:
/dev/vg_data/volume /share/data ext4 defaults 0 1
Where vg_data is an LVM volume group.
I can mount it manually without a problem using mount /dev/vg_data/volume /share/data, but once I reboot the server it boots into emergency mode with the following output:
What is wrong?
I followed instructions from here: https://askubuntu.com/questions/7002/how-to-set-up-multiple-hard-drives-as-one-volume
UPDATE:
I just removed the entry from /etc/fstab and rebooted the server. As expected, the server booted normally, BUT /dev/vg_data no longer existed?
I don't know what is going on.
UPDATE 2:
This is what I did (copied from link):
I started with a disk that I did not have anything on it that I needed.
First you need to create a partition as Linux LVM. You can use fdisk to do this. You can see all the drives Ubuntu sees and how they are listed by running: sudo fdisk -l.
The first line in each section should give you enough information to identify your drive. It will look like:
Disk /dev/sda: 500.1 GB, 500107862016 bytes
The part that matters is /dev/sda. Now run: sudo fdisk /dev/sda. You will see:
Command (m for help):
Type p to list the partitions on your drive. You need to delete the partitions that you want to make part of the LVM. So type d to delete. If the drive only has one partition it will remove it (well flag it for removal, it does not happen until we tell it to do it). Otherwise I think (mine only had one) it asks you to enter the number of the one you want to delete.
Now you need to create the new partition. Type n for new. It asks whether extended or primary. Type p for primary. It asks for partition number, type 1. For first cylinder and last cylinder just leave them blank to use the defaults.
Now you need to set it to Linux LVM. Type t. It asks for a hex code, use 8e for the Linux LVM. You should see something like:
Changed system type of partition 1 to 8e (Linux LVM)
Finally type w to write out the changes to the disk.
Now we need to install LVM so run
sudo apt-get install lvm2to install it.I am going be honest and say I am not sure what this step does but the other directions said to do
modprobe dm-modto load the LVM Module. I did not get any errors so I figure it worked.We need to edit the
/etc/modulesfile so this module loads on boot. Dosudo nano /etc/modulesto open it up to edit. Adddm-modto the list of items.We also want to edit the lvm configuration to update the filter so it does not take to long to scan (I think that is why anyway). So do
sudo nano -w /etc/lvm/lvm.confand change the line with:
filter = [ "a/.*/" ]
to be:
filter = [ "a|/dev/hd[ab]|", "r/.*/" ]
Now we need to set up the first LVM. Do
sudo vgscan. You should see something like:Reading all physical volumes. This may take a while... No volume groups found
Just in case there are any volume groups already set up run sudo vgchange -a y to make them available.
- Now run
sudo pvcreate /dev/sda1to set up the partition. - Now run
sudo vgcreate media /dev/sda1replacing media with the name you want the partition to be labeled as. - Now run
sudo lvcreate -l100%FREE -nvolume mediareplacingvolumewith the name you want it to be called. This will use all the free space available in the partition. - Now we need to format the volume so for ext4 you would do
sudo mke2fs -t ext4 /dev/media/volume. - Make the directory you want to mount the volume at. I did
sudo mkdir /mnt/media. - Mount the volume by doing
sudo mount /dev/media/volume /mnt/media. Now this is only for this session. When you reboot it will not be remounted automatically. To do that we need to edit/etc/fstabfile. To do this addsudo nano /etc/fstaband add the line:
/dev/media/volume /mnt/media ext4 defaults 0 1
At this point you could start adding files to the disk, so if you need to clear other disks you want to add you could copy them on here.
Adding another drive to your volume
Follow the steps in the first bullet again but for the new drive. Now if the drive name is
/dev/sdb1then dosudo vgextend media /dev/sdb1to add it to the volume.Now we need to unmount the volume. To do this do sudo umount /dev/media/volume.
Now you can see the stats on your volume now by running
sudo vgdisplay. The important part isFree PE / Size. You need to know how much space you can add to the volume for the next step.So if you had 150 Gb of space you would do
sudo lvextend -L+150G /dev/media/volume.Now run
sudo e2fsck -f /dev/media/volumeto check the filesystem.Now run
sudo resize2fs /dev/media/volumeto resize everything.You can run the stats again and verify that
Free PE / Sizehas dropped to what you expect.Remount the volume by doing
sudo mount /dev/media/volume /mnt/mediaRinse and repeat for any other drives.
