I currently have 4 ext4 disks in my PC. Together they have about 4TB of space available. I want to store a 3 TB image just for a day. Is it possible to create a temporary virtual fs across the available space of the disks.
It is possible for me to move the files around to get the space on a single drive. I'm just wondering if there is a current solution for something like this.
Best Answer
Yes, it is possible with
dmsetup
.Prepare empty files
This example gives
800 GiB
,1200 GiB
,1100 GiB
and200 GiB
in four files –3300 GiB
in total.Prepare loop devices
Check with
sudo losetup -a
which loop devices are associated with your files. My example assumes they are/dev/loop0
,/dev/loop1
,/dev/loop2
and/dev/loop3
respectively.Create logical device
EDIT: see Xen2050's answer. It gives a simpler way from this point.
My original, more complex way is as follows:
First you have to know how large your files are in
512 B
unit. In my example these numbers are800*1024*1024*2
,1200*1024*1024*2
,1100*1024*1024*2
and200*1024*1024*2
; i.e.1677721600
,2516582400
,2306867200
and419430400
.You will also need the sum of the first...
zero numbers (trivial):
0
,one number (trivial):
1677721600
,two numbers:
1677721600 + 2516582400 = 4194304000
,three numbers:
1677721600 + 2516582400 + 2306867200 = 6501171200
.I hope i did my math right. :)
Invoke:
Now give a proper table (map):
(Every line starts with a computed sum followed by computed size.)
Press Ctrl+D to finish.
Create filesystem
Mount
Note that there is less than
3300 GiB
of free space onmy_device
because of the filesystem needs. Adjust the sizes of your files beforehand, depending on available free space on your partitions and your image size.When your job is over:
Revert