1FPART(1)                  BSD General Commands Manual                 FPART(1)
2

NAME

4     fpart — Sort and pack files into partitions
5

SYNOPSIS

7     fpart [-h] [-V] -n num | -f files | -s size [-i infile] [-a] [-o outfile]
8           [-0] [-e] [-v] [-l] [-b] [-y pattern] [-Y pattern] [-x pattern]
9           [-X pattern] [-z] [-zz] [-zzz] [-Z] [-d depth] [-D] [-E] [-L] [-S]
10           [-w cmd] [-W cmd] [-p num] [-q num] [-r num] [FILE or DIR...]
11

DESCRIPTION

13     The fpart utility helps you sort file trees and pack them into bags
14     (called "partitions").
15

GENERAL OPTIONS

17     -h      Print help
18
19     -V      Print version
20

PARTITION CONTROL

22     -n num  Create exactly num partitions and try to generate partitions with
23             the same size and number of files.  This option cannot be used in
24             conjunction with -f, -s or -L.
25
26     -f files
27             Create partitions containing at most files files or directories.
28             This option can be used in conjunction with -s and -L.
29
30     -s size
31             Create partitions with a maximum size of size bytes.  With this
32             option, a special partition 0 may be used to handle files that do
33             not fit in a regular partition, given the provided size limit.
34             This option can be used in conjunction with -f and -L.  You can
35             use a human-friendly unit suffix here (k, m, g, t, p).
36

INPUT CONTROL

38     -i infile
39             Read file list from infile.  If infile is “-”, then list is read
40             from stdin.
41
42     -a      Input contains arbitrary values; just sort them (do not crawl
43             filesystem).  Input must follow the “size(blank)path” scheme.
44             This option is incompatible with crawling-related options.
45

OUTPUT CONTROL

47     -o outfile
48             Output partitions' contents to outfile template.  Multiple files
49             will be generated given that template.  Each outfile will get
50             partition number as a suffix.  If outfile is “-”, then partitions
51             will be printed to stdout, with partition number used as a prefix
52             (so you can grep partitions you are interested in, or do whatever
53             you want).
54
55     -0      End filenames with a null (’\0’) character when using option -o.
56
57     -e      When adding directories (see DIRECTORY HANDLING ), add an ending
58             “/” to each directory entry.
59
60     -v      Verbose mode (may be specified more than once).
61

FILESYSTEM CRAWLING CONTROL

63     -l      Follow symbolic links (default: do not follow).
64
65     -b      Do not cross filesystem boundaries (default: cross).
66
67     -y pattern
68             Include files or directories matching pattern only (and discard
69             all other files).  This option may be specified several times.
70             Pattern may be a leaf (file or directory) name or a specific
71             path.  Shell pattern matching characters (“[”, “]”, “*”, “?”) may
72             be used.  Include patterns are ignored when computing size of di‐
73             rectories.
74
75     -Y pattern
76             Same as -y but case insensitive.  This option may not be avail‐
77             able on your platform (at least FreeBSD and GNU/Linux support it,
78             Solaris does not).
79
80     -x pattern
81             Exclude files or directories matching pattern.  This option can
82             be used in conjunction with -y and -Y.  In this case, exclusion
83             is performed after.  This option may be specified several times.
84             Pattern may be a leaf (file or directory) name or a specific
85             path.  Shell pattern matching characters (“[”, “]”, “*”, “?”) may
86             be used.  Exclude patterns also apply when computing size of di‐
87             rectories.
88
89     -X pattern
90             Same as -x but case insensitive.  This option may not be avail‐
91             able on your platform (at least FreeBSD and GNU/Linux support it,
92             Solaris does not).
93

DIRECTORY HANDLING

95     -z      Pack empty directories.  By default, fpart will pack files only
96             (except when using the -d or -D options).  This option can be
97             useful for tools such as rsync(1) to be able to recreate a full
98             file tree when used with fpart (e.g. using rsync's --files-from
99             option).  See the -zz option to also pack un-readable directo‐
100             ries.
101
102     -zz     Treat un-readable or erroneous (partly-read) directories as
103             empty, causing them to be packed anyway.  Partly-read (non-empty)
104             directories can end up being packed while some of their children
105             have already been packed.
106
107     -zzz    Pack all directories (as empty).  Useful when 3rd party tools
108             need directory entries to update them (e.g. cpio or tar).
109
110     -Z      Pack un-readable/erroneous directories in dedicated partitions.
111             This option helps isolating erroneous parts of a filesystem.
112             Used in conjuction with FPART_PARTERRNO variable, hooks can try
113             to handle or work around the error.  Requires live mode (option
114             -L) and option -zz (- or -zzz)
115
116     -d depth
117             After a certain depth, pack directories instead of files (direc‐
118             tories themselves will be added to partitions, instead of their
119             content).  You can force a specific file to be packed anyway by
120             listing it on the command line explicitly.
121
122     -D      Implies -z.  Pack leaf directories: if a directory contains files
123             only, it will be packed as a single entry.  You can force a spe‐
124             cific file to be packed anyway by listing it on the command line
125             explicitly.
126
127     -E      Implies -D.  Pack directories only (work on a per-directory ba‐
128             sis): in that mode, no file will be packed.  Instead, each direc‐
129             tory will be packed as a single entry with a size being the sum
130             of all top-level files' sizes.  You can force a specific file to
131             be packed anyway by listing it on the command line explicitly.
132

LIVE MODE

134     -L      Live mode (default: disabled).  When using this mode, partitions
135             will be generated while crawling filesystem.  This option saves
136             time and memory but will never produce special partition 0 (see
137             options -s and -S ).  As a consequence, it will generate parti‐
138             tions slightly larger than the size specified with option -s.
139             This option can be used in conjunction with options -f and -s,
140             but not with option -n.
141
142     -S      Skip big files (default: disabled).  In live mode, no special
143             partition 0 can be produced and big files are added to the cur‐
144             rent partition as they are found while crawling the filesystem.
145             That can lead to huge partitions.  That option makes fpart skip
146             files bigger than the specified maximum partition size (option -s
147             ) and print them to stdout (even when using option -o ) as be‐
148             longing to a pseudo-partition S (as in 'S'kipped).  It allows a
149             consumer to handle them immediately through a separate process
150             (no fpart hook will be executed for skipped files).  That option
151             can only be used in Live mode (option -L ), when a maximum parti‐
152             tion size has been given (option -s ).
153
154     -w cmd  When using live mode, execute cmd when starting a new partition
155             (before having opened next output file, if any).  cmd is run in a
156             specific environment that provides several variables describing
157             the state of the program: FPART_HOOKTYPE ("pre-part" or "post-
158             part"), FPART_PARTFILENAME (current partition's output file
159             name), FPART_PARTNUMBER (current partition number),
160             FPART_PARTSIZE (current partition size), FPART_PARTNUMFILES (num‐
161             ber of files in current partition), FPART_PARTERRNO (0 if every
162             single partition's entry has been read without error, else last
163             erroneous entry's errno.  For error detection to work properly,
164             you may need to rebuild fpart using embedded fts library, depend‐
165             ing on the version shipped with your OS), FPART_PID (PID of
166             fpart).  Note that variables may or may not be defined, depending
167             on requested options and current partition's state when the hook
168             is triggered.  Also, note that hooks are executed in a synchro‐
169             nous way while crawling filesystem, so 1) avoid executing com‐
170             mands that take a long time to return as it slows down filesystem
171             crawling and 2) do not presume cwd (PWD) is the one fpart has
172             been started in, as it is regularly changed to speed up crawling
173             (use absolute paths within hooks).
174
175     -W cmd  Same as -w, but executes cmd when finishing a partition (after
176             having closed last output file, if any).
177

SIZE HANDLING

179     -p num  Preload each partition with num bytes.  You can use a human-
180             friendly unit suffix here (k, m, g, t, p).
181
182     -q num  Overload each file size with num bytes.  You can use a human-
183             friendly unit suffix here (k, m, g, t, p).
184
185     -r num  Round each file size up to next num bytes multiple.  This option
186             can be used in conjunction with overloading, which is done *be‐
187             fore* rounding.  You can use a human-friendly unit suffix here
188             (k, m, g, t, p).
189

EXAMPLES

191     Here are some examples:
192
193     fpart -n 3 -o var-parts /var
194             Produce 3 partitions, with (hopefully) the same size and number
195             of files.  Three files: var-parts.1, var-parts.2 and var-parts.3
196             are generated as output.
197
198     fpart -s 4724464025 -o music-parts /path/to/music ./*.mp3
199             Produce partitions of 4.4 GB, containing music files from
200             /path/to/music as well as MP3 files from current directory; with
201             such a partition size, each partition content will be ready to be
202             burnt to a DVD.  Files music-parts.0 to music-parts.n, are gener‐
203             ated as output.
204
205     find /usr ! -type d | fpart -f 10000 -i - /home | grep '^1 '
206             Produce partitions containing 10000 files each by examining /usr
207             first and then /home and display only partition 1 on stdout.
208
209     du * | fpart -n 2 -a
210             Produce two partitions by using du(1) output.  Fpart will not ex‐
211             amine the file system but instead use arbitrary values printed by
212             du(1) and sort them.
213

SEE ALSO

215     du(1), find(1), fpsync(1), grep(1), rsync(1)
216

AUTHOR, AVAILABILITY

218     Fpart has been written by Ganaël LAPLANCHE and is available under the BSD
219     license on http://contribs.martymac.org
220

BUGS

222     No bug known (yet).
223
224BSD                            November 18, 2011                           BSD
Impressum