Introduction
In this article, we will discuss how to create a virtual block device using multiple discs, known as Synchronized Disc Operations. This technique allows utilities to group multiple discs, creating a single virtual block device whose interactions apply to all members of the group. However, it is important to note that this is not a RAID mirror, as the data is not duplicated across the discs.
Background
In many computing environments, it is necessary to combine multiple physical discs into a single logical unit. This can be done for a variety of reasons, such as increasing storage capacity, improving performance, or providing redundancy. One way to achieve this is through the use of a virtual block device, which presents a single logical device to the operating system, while actually representing multiple physical discs.
Creating a Virtual Block Device with Multiple Discs
To create a virtual block device with multiple discs, you will need to use a utility that supports this feature. One such utility is the Linux mdadm tool, which can be used to manage multiple discs as a single logical unit.
Step 1: Identify the Discs
The first step in creating a virtual block device is to identify the discs that you want to include in the group. You can use the lsblk command to list all of the block devices on your system, including physical discs and partitions.
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 4.6M 1 loop /snap/canonical-livepatch/95
loop1 7:1 0 89.1M 1 loop /snap/core/9066
loop2 7:2 0 4.3M 1 loop /snap/canonical-livepatch/98
loop3 7:3 0 34.3M 1 loop /snap/gnome-3-28-1804/110
...
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 16G 0 part [SWAP]
└─sda3 8:3 0 914.9G 0 part /
sdb 8:16 0 931.5G 0 disk
└─sdb1 8:17 0 931.5G 0 part
sdc 8:32 0 931.5G 0 disk
└─sdc1 8:33 0 931.5G 0 part
sdd 8:48 0 931.5G 0 disk
└─sdd1 8:49 0 931.5G 0 part
In this example, we have four 931.5GB discs (/dev/sda, /dev/sdb, /dev/sdc, and /dev/sdd). We will use these discs to create our virtual block device.
Step 2: Create the Virtual Block Device
Once you have identified the discs that you want to include in the virtual block device, you can use the mdadm command to create the device. The basic syntax for creating a virtual block device with mdadm is as follows:
mdadm --create /dev/mdX --level=linear --raid-devices=N /dev/sd[a-z]
Where /dev/mdX is the name of the virtual block device, N is the number of physical discs in the group, and /dev/sd[a-z] is a list of the physical discs.
In our example, we will create a virtual block device called /dev/md0 using all four of our 931.5GB discs:
$ sudo mdadm --create /dev/md0 --level=linear --raid-devices=4 /dev/sda /dev/sdb /dev/sdc /dev/sdd
mdadm: array /dev/md0 started.
This will create a new virtual block device called /dev/md0, which represents the combined capacity of all four physical discs.
Step 3: Format the Virtual Block Device
Once you have created the virtual block device, you will need to format it using a file system. You can use the mkfs command to format the device with a file system such as ext4:
$ sudo mkfs.ext4 /dev/md0
mke2fs 1.44.1 (24-Mar-2018)
Discarding device blocks: done
Creating filesystem with 2344389248 4k blocks and 586048000 inodes
Filesystem UUID: 7e8f