How to Create Virtual Block Devices
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 ?
You can create a loopback device to a file and do it that way
# create a 100M file in /opt dd if=/dev/zero of=/opt/dev0-backstore bs=1M count=100 # create the loopback block device # where 7 is the major number of loop device driver, grep loop /proc/devices mknod /dev/fake-dev0 b 7 200 losetup /dev/fake-dev0 /opt/dev0-backstore
Make a little script to automate this and done.