0

Is it possible to combine 2 disk and 1 RAID array into 1 single logical volume in Ubuntu 18.04?

I am planning to set up a PostgreSQL database on this machine and think it is better to let it store data in 1 single volume than to span across multiple volumes (which I believe require manual config like creating multiple tablespaces).

My system is currently configured to have

  1. /dev/sda5: 2 TB Drive (containing Ubuntu 18.04)
  2. /dev/sdb: 2 TB Drive (Empty)
  3. /dev/md0: RAID-10 Array (2 TB Usable, Software RAID using mdadm, empty)

Thank you!

Nyxynyx
  • 1,459
  • 11
  • 39
  • 49

2 Answers2

6

Short answer: yes, you can do that via LVM, but don't do that. Simply install PostgreSQL on the current RAID1 array.

Long answer: LVM has the concept of linear concatenation of multiple physical volume to create a single logical volume. However, in this case a single failed physical disks will destroy your volume, leading to unrecoverable and complete data loss. Moreover, in you case sda5 is not empty, and this poses additional complexity.

You could work around that, and create a second RAID1 array between sda and sdb, then concatenate the two RAID arrays in a single logical volume. Alternatively, you could rely on LVM own RAID management (--type raid1) but, again, this is a quite complex setup starting from your current configuration.

I suggest to skip this complexity and to simply use /dev/md0 to store your PostgreSQL database: 2 TB is quite a lot of space for many databases and, if they really are not enough, you probably need to start from scratch with a more sensible setup.

shodanshok
  • 47,711
  • 7
  • 111
  • 180
1

As it is usually the case with any striping RAID's levels the more disks RAID contains the better it handles workload. I'd suggest hence expanding RAID10 over all of the disks — and then you can combine remainder of 2 bigger disks into another RAID (RAID1 specifically) which can be used for system partition and other stuff that doesn't have high performance requirements.

poige
  • 9,448
  • 2
  • 25
  • 52
  • My current RAID-10 array `/dev/md0` consists of four 1TB disks. Is it possible to expand this RAID-10 array over the 2TB disk `/dev/sdb`, since there will be an odd number of drives and the drive sizes are no longer all the same. – Nyxynyx Jan 27 '20 at 14:21
  • Linux Software RAID supports odd number of disks for RAID10, and you’d of course better use only a fraction of bigger disk (IOW “partition”), using the rest for RAID1. Also I’d recommend rebuilding RAID10 with use of all disks, totalling to 6 instead of 5, in similar manner. – poige Jan 27 '20 at 14:32
  • Thanks. If my OS is on one of the drives `/dev/sda`, can it be used in the new RAID10 array? – Nyxynyx Jan 27 '20 at 14:38
  • Or are you suggesting that the drive `/dev/sda` containing the OS be partitioned, for example, into two 1TB partitions. Then create the new RAID10 to include 1TB partition from `/dev/sda`, 2 TB from `/dev/sdb`, and 4x1TB from the initial RAID10 `/dev/md0`? Giving about 3.75 TB of usable space? The OS will remain on the 1TB partition which does not belong to any RAID array. – Nyxynyx Jan 27 '20 at 14:38
  • I explained it in the answer. Partition bigger disks so that you can use part of them both in R10 on 6 disks and R1 on 2. GRUB supports booting from R1 as well. Of course it’s better to use LVM-2 on top of those RAIDs for flexibility but it’s up to you. – poige Jan 27 '20 at 15:48