Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to recreate a feature of Mac OS X called sparse bundles (disk images made out of smaller files, making them easy to backup after a small change). For that I'm looking for a way to 'virtually' create a single file made by concatenation of smaller ones (big.file shouldn't use all this space, just link to .files):

4096 0.file
4096 1.file
4096 2.file
4096 3.file
4096 4.file
20480 big.file

so that I'd be able to mount big.file using loop device, format as btrfs and upon writing to this disk, data should be written only to certain .files, allowing me to backup easily.

Any suggestions how I could accomplish that? Perhaps something FUSE-related?

share|improve this question
2  
Have you considered LVM snapshots? –  jordanm Dec 29 '12 at 0:33
    
@jordanm: how would LVM snapshots help my problem? –  anon94943 Dec 29 '12 at 12:29
1  
Backup after small changes? Just snapshot, and then make an incremental backup out of it. –  jordanm Dec 29 '12 at 17:51
    
There are sparse files under GNU/linux, although I wonder to which extent to the GNU tools support these, and how does mount deal with those. –  njsg Dec 29 '12 at 21:18
add comment

1 Answer 1

up vote 2 down vote accepted

One way to do this would be to make each file an LVM physical volume, and join those physical volumes in a volume group and make an LVM logical volume using that space. But it's cumbersome: you need to associate the file with a loop device.

dd if=/dev/zero of=0.file bs=1024k count=4
losetup /dev/loop0 0.file
pvcreate /dev/loop0
# … repeat for all parts …
vgcreate -s 1m foo /dev/loop0 /dev/loop1 …
lvcreate -l 19 -n big foo
mkfs.btrfs /dev/mapper/foo-big

Reassembling the parts is not likely to be directly supported by your boot scripts, so you'd have to code quite a few things manually.

I don't see the point: how does splitting files facilitate backups? Many changes are likely to be spread over the whole volume (for example, several parts will contain copies of the superblock). You won't gain much by only backing up the parts that have changed: you'll need to look further inside the parts anyway.

If you want to make incremental backups, make them at the filesystem level.

If you want to make full backups of the whole image but ignore empty space, make sure to create a sparse file, use backup tools that manipulate sparse files efficiently, and periodically fill the empty space in the filesystem with zeroes and sparsify it.

share|improve this answer
    
Unfortunately, that won't do because of the limit of loop devices you can create (can't make more than 9999 I believe). I'd need to create much more - I'm interested in making something like 300 GB image made out of 4MB parts. Is there a way of attaching multiple files to one loop device? –  anon94943 Dec 30 '12 at 18:10
    
@anon94943 A loop device corresponds to one file. If you want a device that maps to the concatenation of several files, I think you'd have to code it up. But again, I don't see the point. –  Gilles Dec 30 '12 at 18:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.