From owner-freebsd-questions@freebsd.org Sat Jan 20 13:58:25 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 469C0ED277D for ; Sat, 20 Jan 2018 13:58:25 +0000 (UTC) (envelope-from martymac@freebsd.org) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:c:538::198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 156F97AE4C for ; Sat, 20 Jan 2018 13:58:25 +0000 (UTC) (envelope-from martymac@freebsd.org) X-Originating-IP: 78.248.30.101 Received: from home.martymac.org (sse35-1-78-248-30-101.fbx.proxad.net [78.248.30.101]) (Authenticated sender: ganael.laplanche@martymac.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 601B9FB89F; Sat, 20 Jan 2018 14:58:21 +0100 (CET) From: Ganael Laplanche To: freebsd-questions@freebsd.org, rfg@tristatelogic.com Cc: Paul Mather Subject: Re: Splitting up sets of files for archiving (e.g. to tape, optical media) Date: Sat, 20 Jan 2018 14:58:14 +0100 Message-ID: <2532800.haqQPGL0BO@home.martymac.org> User-Agent: KMail/4.14.10 (FreeBSD/11.1-RELEASE-p4; KDE/4.14.30; amd64; ; ) In-Reply-To: <2456E55A-D14F-41ED-B8DD-9633BD73ACF1@gromit.dlib.vt.edu> References: <2456E55A-D14F-41ED-B8DD-9633BD73ACF1@gromit.dlib.vt.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jan 2018 13:58:25 -0000 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 http://www.martymac.org | http://contribs.martymac.org FreeBSD: martymac , http://www.FreeBSD.org