Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Jan 2018 14:58:14 +0100
From:      Ganael Laplanche <martymac@freebsd.org>
To:        freebsd-questions@freebsd.org, rfg@tristatelogic.com
Cc:        Paul Mather <freebsd-lists@gromit.dlib.vt.edu>
Subject:   Re: Splitting up sets of files for archiving (e.g. to tape, optical media)
Message-ID:  <2532800.haqQPGL0BO@home.martymac.org>
In-Reply-To: <2456E55A-D14F-41ED-B8DD-9633BD73ACF1@gromit.dlib.vt.edu>
References:  <mailman.2518.1516348796.70356.freebsd-questions@freebsd.org> <2456E55A-D14F-41ED-B8DD-9633BD73ACF1@gromit.dlib.vt.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
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@martymac.org>
http://www.martymac.org | http://contribs.martymac.org
FreeBSD: martymac <martymac@FreeBSD.org>, http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2532800.haqQPGL0BO>