How to Create Virtual Block Devices

3

1

I want to create multiple virtual block devices like /dev/sda and then use them to create an md device for test purpose. I have mounted my root filesystem on /dev/sda1 and don't have extra space to create new physical partitions. Therefore, I am looking for a way to temporary allocate small portion of my free space to these virtual block devices.

Can I use dmsetup or other utilities to create these virtual block devices ?

ARH

Posted 2014-11-07T19:02:59.857

Reputation: 133

Answers

4

A better solution would be to set up a virtual machine and test in a VM, but this can be done without using a VM.

What you need to do is create a loopback device.

  • Create a 100MB file: dd if=/dev/zero of=loopback_file1 bs=1M count=100
  • Assign that file as a loopback device: losetup /dev/loop0 loopback_file1.

From then on the block device /dev/loop0 will appear like a drive, and the contents will go to the loopback_file1 file. You can then test your mdadm commands against that device.

Links:

Zoredache

Posted 2014-11-07T19:02:59.857

Reputation: 18 453