Splitting up sets of files for archiving (e.g. to tape, optical media)

Ganael Laplanche martymac at freebsd.org
Sat Jan 20 13:58:25 UTC 2018


On Friday 19 January 2018 09:37:55 Paul Mather wrote:

Hi Ronald, Paul,

> Have you looked at fpart (https://github.com/martymac/fpart)?  It looks to
> me like it is applicable to your problem (which sounds to me like a variant
> of the bin packing problem).  The fpart README even lists packing music
> files onto fixed-size DVD media as one of its examples, which sounds close
> to the archiving scenario you give above.  Plus, it claims to be developed
> on FreeBSD.

Yes, fpart should do exactly what you want : it can create "partitions" (bags) 
of a maximum size and spread files amongst them, trying to minimize space loss.

The following example creates partitions of 150 MiB from /usr/src :

$ fpart -s $((150 * 1024 * 1024)) /usr/src >/dev/null
Part #0: size = 0, 0 file(s)
Part #1: size = 157286400, 18268 file(s)
Part #2: size = 157286400, 8144 file(s)
Part #3: size = 157286400, 5700 file(s)
Part #4: size = 157286400, 10075 file(s)
Part #5: size = 157286400, 9823 file(s)
Part #6: size = 157286399, 10482 file(s)
Part #7: size = 157286400, 9967 file(s)
Part #8: size = 157286399, 9899 file(s)
Part #9: size = 157286399, 11237 file(s)
Part #10: size = 157286399, 9860 file(s)
Part #11: size = 157286400, 5634 file(s)
Part #12: size = 157286399, 9026 file(s)
Part #13: size = 157286399, 9396 file(s)
Part #14: size = 133225448, 10583 file(s)

(the first partition, partition 0, is a special one and designed to host files 
bigger than the maximum size specified)

Fpart is available in sysutils/fpart. Don't hesitate if you have any questions 
regarding that tool. I'll be happy to help :)

Best regards,

-- 
Ganael LAPLANCHE <ganael.laplanche at martymac.org>
http://www.martymac.org | http://contribs.martymac.org
FreeBSD: martymac <martymac at FreeBSD.org>, http://www.FreeBSD.org


More information about the freebsd-questions mailing list