FPART(1)
π¦ fpart(1) β sort & pack files into partitions π¦
okay bestie, welcome to FPART(1), General Commands Manual edition π this is the girl who sorts your file trees and packs them into lil bags. let's go.
β¨ NAME β¨
fpart β sort and pack files into partitions π
β¨ SYNOPSIS β¨
fpart [-h] [-V] -n num | -f files | -s size [-i infile] [-a]
[-o outfile] [-0] [-e] [-P] [-v] [-l] [-b] [-y pattern]
[-Y pattern] [-x pattern] [-X pattern] [-z] [-zz] [-zzz] [-Z]
[-d depth] [-D] [-E] [-L] [-S] [-w cmd] [-W cmd] [-R cmd] [-p num]
[-q num] [-r num] [FILE or DIR...]
β¨ DESCRIPTION β¨
The fpart utility helps you sort file trees and pack them into bags β which we're calling "partitions" πβ¨ that's the whole vibe. it takes your messy pile of files and gives it structure. iconic behavior honestly.
β¨ GENERAL OPTIONS β¨
-h,--helpβ print help π«Ά she'll tell you what's up.-V,--versionβ print version π show me the number.
β¨ PARTITION CONTROL β¨
-n num,--parts numβ create exactlynumpartitions, and try to make them all the same size and hold the same number of files. balance is the moment β¨. this option cannot be used together with-f,-sor-L. no cap.-f files,--files filesβ create partitions holding at mostfilesfiles or directories. this one can be used with-sand-Lπ«Ά.-s size,--size sizeβ create partitions with a max size ofsizebytes. when you use this, a special partition 0 may show up to handle files that just do not fit in a regular partition given your size limit (main character exception energy, we respect it). this can be used with-fand-L. also bestie you can use a human-friendly unit suffix here βk,m,g,t,pπ.
β¨ INPUT CONTROL β¨
-i infileβ read the file list frominfile. ifinfileisβ-β, then the list gets read from stdin π₯.-a,--arbitraryβ the input contains arbitrary values, so we just sort them (no filesystem crawling, we're staying in). the input has to follow theβsize(blank)pathβscheme. this option is incompatible with crawling-related options β οΈ.
β¨ OUTPUT CONTROL β¨
-o outfileβ output partitions' contents to theoutfiletemplate. multiple files will get generated from that template. eachoutfilegets the partition number as a suffix π’. ifoutfileisβ-β, then partitions get printed to stdout, with the partition number used as a prefix (so you cangrepthe partitions you care about, or do literally whatever you want π ).-0β end filenames with a null (β\0β) character when you're using option-oπ«§.-eβ when adding directories (peep βDIRECTORY HANDLINGβ), add a trailingβ/βto each directory entry π.-Pβ add parent directories when closing partitions. this can be used together with-zzzto produce partitions that can be synchronized in parallel with tools likecpio(1),pax(1)ortar(1)β¨. adding parent directories at the end of each partition makes sure modification times get reapplied to directories, no matter what order the partitions get processed in. directories added that way are 0-sized and are not subject to partition counters (for example, a file limit given with option-fwill be exceeded bynparent directories). also, they are not subject to inclusion/exclusion options (-y,-Y,-x,-X), and they always have a trailingβ/βeven if option-ehasn't been used (this simplifies symlinks handling, because we always want to add targets here, never the links themselves). heads up: this option may lead to creating duplicate directory entries when the next partition begins with a directory entry that was already added as a parent when closing the previous partition π. only intermediate partitions get parent directories added β not the very last one, which gets its parents through option-zzzwhenfts(3)crawling finishes. requires live mode (option-L) π.-v,--verboseβ verbose mode (may be specified more than once) π£οΈ say it louder.
β¨ FILESYSTEM CRAWLING CONTROL β¨
-lβ follow symbolic links (default: do not follow) π.-bβ do not cross filesystem boundaries (default: cross) π§.-y pattern,--include patternβ include files or directories matchingpatternonly (and discard all other files). this option may be specified several times.patternmay be a leaf (file or directory) name or a specific path. shell pattern matching characters (β[β,β]β,β*β,β?β) may be used. include patterns are ignored when computing the size of directories π.-Y patternβ same as-ybut case insensitive. this option may not be available on your platform (at least FreeBSD and GNU/Linux support it, Solaris does not) β οΈ.-x pattern,--exclude patternβ exclude files or directories matchingpattern. this can be used together with-yand-Yβ in that case, exclusion is performed after. this option may be specified several times.patternmay be a leaf (file or directory) name or a specific path. shell pattern matching characters (β[β,β]β,β*β,β?β) may be used. exclude patterns also apply when computing the size of directories π«.-X patternβ same as-xbut case insensitive. this option may not be available on your platform (at least FreeBSD and GNU/Linux support it, Solaris does not) β οΈ.
β¨ DIRECTORY HANDLING β¨
-zβ pack empty directories. by default,fpartwill pack files only (except when using the-dor-Doptions). this is useful for tools likersync(1)so they can recreate a full file tree when used withfpart(e.g. using rsync's--files-fromoption) ποΈ. peep-zzif you also want to pack un-readable directories.-zzβ treat un-readable or erroneous (partly-read) directories as empty, which causes them to get packed anyway. note that partly-read (non-empty) directories can end up being packed while some of their children have already been packed π¬.-zzzβ pack all directories (as empty). useful when 3rd party tools need directory entries so they can update them (e.g.cpio(1),pax(1)ortar(1)) π.-Zβ pack un-readable/erroneous directories in dedicated partitions. this helps isolate erroneous parts of a filesystem π§―. used together with theFPART_PARTERRNOvariable, hooks can try to handle or work around the error. requires live mode (option-L) and option-zz(-or-zzz) π.-d depthβ after a certain depth, pack directories instead of files (the directories themselves get added to partitions, instead of their content) π³οΈ. you can force a specific file to be packed anyway by listing it on the command line explicitly π .-D,--leaf-dirsβ implies-z. pack leaf directories: if a directory contains files only, it gets packed as a single entry π. you can force a specific file to be packed anyway by listing it on the command line explicitly π .-E,--dirs-onlyβ implies-D. pack directories only (work on a per-directory basis): in that mode, no file gets packed. instead, each directory gets packed as a single entry, with a size that is the sum of all top-level files' sizes πβ¨. you can force a specific file to be packed anyway by listing it on the command line explicitly π .
β¨ LIVE MODE β¨
-L,--liveβ live mode (default: disabled). when you use this, partitions get generated while crawling the filesystem π₯. this saves time and memory, but it will never produce special partition 0 (see options-sand-S). as a consequence, it will generate partitions slightly larger than the size specified with option-s. this can be used with options-fand-s, but not with option-nβ οΈ.-Sβ skip big files (default: disabled). in live mode, no special partition 0 can be produced, and big files get added to the current partition as they're found while crawling the filesystem β which can lead to huge partitions π. this option makesfpartskip files bigger than the specified maximum partition size (option-s) and print them to stdout (even when using option-o) as belonging to a pseudo-partitionS(as in'S'kipped). it lets a consumer handle them immediately through a separate process (nofparthook will be executed for skipped files). this option can only be used in Live mode (option-L), when a maximum partition size has been given (option-s) π.-w cmd,--pre-part-cmd cmdβ when using live mode, executecmdwhen starting a new partition (before having opened the next output file, if any) π¬.cmdruns in a specific environment that provides several variables describing the state of the program:FPART_HOOKTYPE("pre-part","post-part"or"post-run"),FPART_PARTFILENAME(current partition's output file name),FPART_PARTNUMBER(current partition number),FPART_PARTSIZE(current partition's size),FPART_TOTALSIZE(total partitions' size),FPART_PARTNUMFILES(number of files packed in current partition),FPART_TOTALNUMFILES(total number of files packed so far),FPART_PARTERRNO(0 if every single partition's entry has been read without error, else last erroneous entry'serrno. For error detection to work properly, you may need to rebuildfpartusing embeddedfts(3)library, depending on the version shipped with your OS),FPART_PID(PID offpart),FPART_TOTALNUMPARTS(total number of partitions generated so far). variables may or may not be defined, depending on requested options and the current partition's state when the hook is triggered π€·. hooks are executed in a synchronous way while crawling the filesystem, so: 1) avoid executing commands that take a long time to return, because it slows down filesystem crawling, and 2) do not presume cwd (PWD) is the onefparthas been started in, as it is regularly changed to speed up crawling (i.e. use absolute paths within hooks) π«Ά. size-related variables are affected by preloading, overloading and rounding options.-W cmd,--post-part-cmd cmdβ same as-w, but executescmdwhen finishing a partition (after having closed the last output file, if any) π.-R cmd,--post-run-cmd cmdβ same as-wand-W, but executescmdjust once before exiting π. note that only theFPART_TOTALSIZEandFPART_TOTALNUMFILESenvironment variables are available in post-run hooks π.
β¨ SIZE HANDLING β¨
okay bestie this is where you get to β¨control the numbersβ¨ β all three of these take a num and all three let you use a human-friendly unit suffix (k, m, g, t, p) π
-pnum β preload each partition with num bytes. Like, give it a lil head start π«Ά. You can use a human-friendly unit suffix here (k,m,g,t,p).-qnum β overload each file size with num bytes. You can use a human-friendly unit suffix here (k,m,g,t,p).-rnum β round each file size up to the next num bytes multiple π₯. This one can be used in conjunction with overloading, and here's the tea: overloading is done before rounding. You can use a human-friendly unit suffix here (k,m,g,t,p).
π EXAMPLES π
here are some examples, and honestly they ate:
fpart -n 3 -o var-parts /var
Produce 3 partitions, with (hopefully) the same size and number of files. Three files: var-parts.1, var-parts.2 and var-parts.3 are generated as output. so clean β¨
fpart -s 4724464025 -o music-parts /path/to/music ./*.mp3
Produce partitions of 4.4 GB, containing music files from /path/to/music as well as MP3 files from current directory; with such a partition size, each partition content will be ready to be burnt to a DVD πΏ. Files music-parts.0 to music-parts.n, are generated as output. (yes bestie, .0 β it starts at zero, that's just how it is π)
find /usr ! -type d | fpart -f 10000 -i - /home | grep '^1 '
Produce partitions containing 10000 files each by examining /usr first and then /home and display only partition 1 on stdout. the pipeline is giving main character energy fr fr π₯
du * | fpart -n 2 -a
Produce two partitions by using du(1) output. Fpart will not examine the file system but instead use arbitrary values printed by du(1) and sort them. no filesystem crawling, we're just trusting the vibes (the du vibes, specifically) π
π SEE ALSO π
du(1), find(1), fpsync(1), grep(1), rsync(1)
like, go read those too, they're the friend group π«Ά
π AUTHOR, AVAILABILITY π
Fpart has been written by GanaΓ«l LAPLANCHE and is available under the BSD license on http://contribs.martymac.org β icon, legend, the moment π
π BUGS π
No bug known (yet). yet. not me side-eyeing this line ππ
okay bestie that's the whole page, you're officially an fpart girlie now πβ¨ This was the Debian build of FPART(1), dated November 18, 2011 β yeah she's a 2011 baby, vintage, lowkey iconic for it π. go partition something. slay. periodt. π¦
π¦ where this page comes from
- debian trixie: fpart 1.7.0-1 Β· BSD-2-Clause
- fedora 43: fpart 1.7.0-2.fc43 Β· BSD-2-Clause AND BSD-3-Clause
- fedora 44: fpart 1.7.0-3.fc44 Β· BSD-2-Clause AND BSD-3-Clause
- nixos 26.05: fpart 1.7.0
- ubuntu questing: fpart 1.7.0-1
- ubuntu resolute: fpart 1.7.0-1build1 Β· BSD-2-Clause
- ubuntu stonking: fpart 1.7.0-1build1 Β· BSD-2-Clause
- Copyright (c) 2011-2025 Ganael LAPLANCHE <ganael.laplanche@martymac.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms