Splits directory into multiple with equal size for ISO burning purpose

Sometime it is necessary to convert a directory with many multiple files (which are all smaller than a certain medium, eg. DVD) and “splits” it into “volumes,” looking for the optimal order to get the best space/medium-number efficiency.

ADVERTISEMENTS

For example, I have /data/network/mp3 directory size as follows:

$ du -ch


….
1.2 GB size

Now I would like to burn all these files on 700MB CD. Since size is 1.2 GB, I need to split it into two ISO files. Therefore, I need to take help of dirsplit command as follows.

1) Create list of files

$ cd /data/network/mp3
$ dirsplit -s 700M -e2 /data/network/mp3
$ ls vol*

Output:

vol_1.list
vol_2.list

Above dirsplit command created two mkisofs catalogs to burn all music (mp3) to 700M CDRs, keep single files in each dir together.

Where,

  • -s 700M : 700M CDR size
  • -e N : Special exploration modes, used with directory argument

As you see, it created two files vol_1.list vol_2.list. Now use these files to create two ISO images that can opened on both windows and Linux computer:

$ mkisofs -o vol1.iso -D -r –joliet-long -graft-points -path-list vol_1.list
$ mkisofs -o vol2.iso -D -r –joliet-long -graft-points -path-list vol_2.list
$ ls -l *.iso

Output:

-rw-r--r-- 1 vivek vivek 663M 2006-03-05 05:18 vol1.iso
-rw-r--r-- 1 vivek vivek 510M 2006-03-05 05:19 vol2.iso

Now ISO images are ready and you can burn them using cdrecord or other GUI tools.
Write an ISO (happ.iso) to CD i.e. burn an image:

$ cdrecord -v -dev=ATA:1,0,0 speed=8 vo1.iso
$ cdrecord -v -dev=ATA:1,0,0 speed=8 vo2.iso

dirsplit can ignore some junk files i.e. it can filter file list. For example, don’t include other directory while creating split:

$ dirsplit -s 700M -e2 -f ‘!other’ -e2 /data/network/mp3

(Check out all of our posts on Linux)

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
4 comments… add one
  • smoke Apr 12, 2007 @ 20:44

    is there such tool for win32? (must be cli driven)

  • freeloadr Feb 11, 2010 @ 16:40

    This is part of the genisoimage package on Ubuntu.

  • Joaquin Apr 19, 2012 @ 19:34

    Great! Thanks was very usefull.

  • Ben Oct 29, 2015 @ 14:51

    Even now this is really handy. I just had to return 30GB of data to someone over a bunch of DVDs.

    One thing I will say, you need to drop the ‘e2’ if one directory exceeds the max size limit you set.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.