PDA

View Full Version : using regular files as raid devices?



Jeff Sadowski
14th September 2006, 03:00 AM
Can you use regular files as raid devices and how would I go about it.
Is there some way to do it maybe with loop back support?
Reason being that i need to backup my linux files to a windows machine.
windows does not support all the filesystem attributes i need for a proper backup
so what i thought about doing is this: Create a bunch of gig size files in windows then use a raid of lvm to make those files into a mount place and wala I could mount it normally and backup to it with rsync even. Then when windows reads the files they will be normal files to it.

Jeff Sadowski
14th September 2006, 03:32 AM
found it
I did this to test my method
dd if=/dev/zero of=/tmp/loop0 bs=1M count=10
cp /tmp/loop0 /tmp/loop1
cp /tmp/loop0 /tmp/loop2
cp /tmp/loop0 /tmp/loop3
cp /tmp/loop0 /tmp/loop4
cp /tmp/loop0 /tmp/loop5

losetup /dev/loop0 /tmp/loop0
losetup /dev/loop1 /tmp/loop1
losetup /dev/loop2 /tmp/loop2
losetup /dev/loop3 /tmp/loop3
losetup /dev/loop4 /tmp/loop4
losetup /dev/loop5 /tmp/loop5

pvcreate /dev/loop0
pvcreate /dev/loop1
pvcreate /dev/loop2
pvcreate /dev/loop3
pvcreate /dev/loop4
pvcreate /dev/loop5

vgcreate my_volume_group /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 /dev/loop4 /dev/loop5
lvcreate -L48M -nmy_logical_volume my_volume_group
mke2fs /dev/my_volume_group/my_logical_volume

and now i can mount it

Jeff Sadowski
14th September 2006, 03:39 AM
now I have to figure out how to close them down to umount and remount them without loosing data

Jeff Sadowski
14th September 2006, 04:03 AM
and this is how I use it now
unmount it then

vgchange -an my_volume_group
losetup -d /dev/loop0
losetup -d /dev/loop1
losetup -d /dev/loop2
losetup -d /dev/loop3
losetup -d /dev/loop4
losetup -d /dev/loop5

and when I want to use it again

losetup /dev/loop0 /tmp/loop0
losetup /dev/loop1 /tmp/loop1
losetup /dev/loop2 /tmp/loop2
losetup /dev/loop3 /tmp/loop3
losetup /dev/loop4 /tmp/loop4
losetup /dev/loop5 /tmp/loop5

vgscan
vgchange -ay my_volume_group

and mount it again.
this is a perfect work around adding more should be pretty easy also I might run out of loopback devices but I know how to fix that.

Jeff Sadowski
14th September 2006, 04:07 AM
now its just a matter of placing the /tmp/loop* files in a smb mounted directory.