{"id":2511,"date":"2015-01-28T12:56:46","date_gmt":"2015-01-28T17:56:46","guid":{"rendered":"http:\/\/antipaucity.com\/?p=2511"},"modified":"2015-01-28T12:56:46","modified_gmt":"2015-01-28T17:56:46","slug":"merging-centos-iso-images","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=2511","title":{"rendered":"merging centos iso images"},"content":{"rendered":"<p>Thanks to @<a href=\"http:\/\/unix.stackexchange.com\/users\/27643\/anon\">Anon<\/a>\u00a0on <a href=\"http:\/\/unix.stackexchange.com\">Unix.SE<\/a> for the pointer on how to do this. And to @<a href=\"http:\/\/unix.stackexchange.com\/users\/56093\/andy\">Andy<\/a>&#8216;s comment on @<a href=\"http:\/\/unix.stackexchange.com\/users\/3852\/mmckinst\">mmckinst<\/a>&#8216;s <a href=\"http:\/\/unix.stackexchange.com\/a\/63745\/6388\">answer<\/a>\u00a0for the warning about additional packages you may need.<\/p>\n<p>As my three readers <a href=\"http:\/\/antipaucity.com\/2014\/05\/22\/soup-to-nuts-mirroring-of-centos\/#.VMkgaV54q_Q\">know<\/a>, I run a {{CentOS}}\u00a0<a href=\"http:\/\/centos.datente.com\">mirror<\/a>. One of the idiosyncrasies of CentOS, like its upstream {{RHEL}}, is that DVD ISOs aren&#8217;t\u00a0<em>always<\/em> just one image &#8211; for example, the <a href=\"http:\/\/centos.datente.com\/media\/6.6\/isos\/x86_64\">6.6 x64<\/a>\u00a0image comes on two ISOs. I suppose this has something to do with the &#8220;normal&#8221; or &#8220;simple&#8221; <a href=\"http:\/\/en.wikipedia.org\/wiki\/DVD#Capacity\">capacity<\/a>\u00a0of a DVD disc, but it&#8217;s annoying.<\/p>\n<p>Enter the mkdvdiso.sh script (original found <a href=\"http:\/\/wiki.centos.org\/TipsAndTricks\/CDtoDVDMedia\">here<\/a>) from Chris Kloiber &amp; Phil Schaffner.<\/p>\n<p>The process I used to combine these two ISOs into one is as follows:<br \/>\n<code>yum install isomd5sum createrepo mkisofs<br \/>\nmkdvdiso.sh \/full\/path\/to\/original\/isos \/full\/path\/to\/destination.iso<\/code><\/p>\n<p>For posterity, and in case the CentOS <a href=\"http:\/\/wiki.centos.org\">wiki<\/a> dies, below is the mkdvdiso.sh script:<\/p>\n<pre>#!\/bin\/bash\n\n# by Chris Kloiber <ckloiber @redhat.com>\n# Mods under CentOS by Phil Schaffner <pschaff2 @verizon.net>\n\n# A quick hack that will create a bootable DVD iso of a Red Hat Linux\n# Distribution. Feed it either a directory containing the downloaded\n# iso files of a distribution, or point it at a directory containing\n# the \"RedHat\", \"isolinux\", and \"images\" directories.\n\n# This version only works with \"isolinux\" based Red Hat Linux versions.\n\n# Lots of disk space required to work, 3X the distribution size at least.\n\n# GPL version 2 applies. No warranties, yadda, yadda. Have fun.\n\n# Modified to add sanity checks and fix CentOS4 syntax errors\n\n# TODO:\n#   Add checks for available disk space on devices holding output and\n#       temp files.\n#   Add optional 3rd parameter to specify location of temp directory.\n#   Create .discinfo if not present.\n\nOS_VER=\\\n$((test -e \/etc\/fedora-release && rpm -qf \/etc\/fedora-release --qf \"FC%{VERSION}\") \\\n|| (test -e \/etc\/redhat-release && rpm -qf \/etc\/redhat-release --qf \"EL%{VERSION}\") \\\n|| echo OS_unknown)\n\ncase \"$OS_VER\" in\n  EL[45]*|FC?)\n        IMPLANT=\/usr\/lib\/anaconda-runtime\/implantisomd5\n        if [ ! -f $IMPLANT ]; then\n            echo \"Error: $IMPLANT Not Found!\"\n            echo \"Please install anaconda-runtime and try again.\"\n            exit 1\n        fi\n        ;;\n  EL6*|FC1?)\n        IMPLANT=\/usr\/bin\/implantisomd5\n        if [ ! -f $IMPLANT ]; then\n            echo \"Error: $IMPLANT Not Found!\"\n            echo \"Please install isomd5sum and try again.\"\n            exit 1\n        fi\n        ;;\n  OS_unknown)\n        echo \"Unknown OS.\"\n        exit 1\n        ;;\n  *)\n        echo \"Fix this script for $OS_VER\"\n        exit 1\nesac\n\nif [ $# -lt 2 ]; then\n        echo \"Usage: `basename $0` source \/destination\/DVD.iso\"\n        echo \"\"\n        echo \"        The 'source' can be either a directory containing a single\"\n        echo \"        set of isos, or an exploded tree like an ftp site.\"\n        exit 1\nfi\n\nDVD_DIR=`dirname $2`\nDVD_FILE=`basename $2`\n\necho \"DVD directory is $DVD_DIR\"\necho \"ISO file is $DVD_FILE\"\n\nif [ \"$DVD_DIR\" = \".\" ]; then\n    echo \"Destinaton Directory $DVD_DIR does not exist\"\n    exit 1\nelse\n    if [ ! -d \"\/$DVD_DIR\" ]; then\n        echo \"Destinaton Directory $DVD_DIR must be an absolute path\"\n        exit 1\n    else\n        if [ \"$DVD_FILE\" = \"\" ] || [ -d \"$DVD_DIR\/$DVD_FILE\" ]; then\n            echo \"Null ISO file name.\"\n            exit 1\n        fi\n    fi\nfi\n\nwhich mkisofs >&\/dev\/null\nif [ \"$?\" != 0 ]; then\n    echo \"mkisofs Not Found\"\n    echo \"yum install mkisofs\"\nfi\n\nwhich createrepo >&\/dev\/null\nif [ \"$?\" != 0 ]; then\n    echo \"createrepo Not Found\"\n    echo \"yum install createrepo\"\nfi\n\nif [ -f $2 ]; then\n    echo \"DVD ISO destination $2 already exists. Remove first to recreate.\"\n    exit 1\nfi\n\n# Make sure there is enough free space to hold the DVD image on the filesystem\n# where the home directory resides, otherwise change ~\/mkrhdvd to point to\n# a filesystem with sufficient free space.\n\ncleanup() {\n    [ ${LOOP:=\/tmp\/loop} = \"\/\" ] && echo \"LOOP mount point = \\\/, dying!\" && exit\n    [ -d $LOOP ] && rm -rf $LOOP \n    [ ${DVD:=~\/mkrhdvd} = \"\/\" ] && echo \"DVD data location is \\\/, dying!\" && exit\n    [ -d $DVD ] && rm -rf $DVD \n}\n\ncleanup\nmkdir -p $LOOP\nmkdir -p $DVD\n\nls $1\/*.iso &>\/dev\/null\nif [ \"$?\" = 0 ]; then\n\n    echo \"Found ISO CD images...\"\n\n    CDS=`expr 0`\n    DISKS=\"1\"\n\n    [ -w \/ ] || {   # Very portable, but perhaps not perfect, test for superuser.\n        echo \"Only 'root' may use this script for loopback mounts\" 1>&2\n        exit 1\n    }\n\n    for f in `ls $1\/*.iso`; do\n        mount -o loop $f $LOOP\n        cp -av $LOOP\/* $DVD\n        if [ -f $LOOP\/.discinfo ]; then\n            cp -av $LOOP\/.discinfo $DVD\n            CDS=`expr $CDS + 1`\n            if [ $CDS != 1 ] ; then\n                DISKS=`echo ${DISKS},${CDS}`\n            fi\n        fi\n        umount $LOOP\n    done\nelse\n    if [ -f $1\/isolinux\/isolinux.bin ]; then\n\n        echo \"Found FTP-like tree...\"\n\n        if [ -e $1\/.discinfo ]; then\n            cp -av $1\/.discinfo $DVD\n        else\n# How does one construct a legal .discinfo file if none is found?\n            echo \"Error: No .discinfo file found in $1\"\n            cleanup\n            exit 1\n        fi\n        cp -av $1\/* $DVD\n    else\n        echo \"Error: No CD images nor FTP-like tree found in $1\"\n        cleanup\n        exit 1\n    fi\nfi\n\nif [ -e $DVD\/.discinfo ]; then\n    awk '{ if ( NR == 4 ) { print disks } else { print ; } }' disks=\"ALL\" $DVD\/.discinfo > $DVD\/.discinfo.new\n    mv $DVD\/.discinfo.new $DVD\/.discinfo\nelse\n    echo  \"Error: No .discinfo file found in $DVD\"\n    cleanup\n    exit 1\nfi\n\nrm -rf $DVD\/isolinux\/boot.cat\nfind $DVD -name TRANS.TBL | xargs rm -f\n\ncd $DVD\ncreaterepo -g repodata\/comps.xml .\/\nmkisofs -J -R -v -T -o $2 -b isolinux\/isolinux.bin -c isolinux\/boot.cat -no-emul-boot -boot-load-size 8 -boot-info-table $DVD\nif [ \"$?\" = 0 ]; then\n\n    echo \"\"\n    echo \"Image complete, create md5sum...\"\n\n#  $IMPLANT --force $2\n# Don't like forced mediacheck? Try this instead.\n    $IMPLANT --supported-iso --force $2\n\n    echo \"Start cleanup...\"\n\n    cleanup\n\n    echo \"\"\n    echo \"Process Complete!\"\n    echo \"Wrote DVD ISO image to $DVD_DIR\/$DVD_FILE\"\n    echo \"\"\nelse\n    echo \"ERROR: Image creation failed, start cleanup...\"\n\n    cleanup\n\n    echo \"\"\n    echo \"Failed to create ISO image $DVD_DIR\/$DVD_FILE\"\n    echo \"\"\nfi\n<\/pschaff2><\/ckloiber><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Thanks to @Anon\u00a0on Unix.SE for the pointer on how to do this. And to @Andy&#8216;s comment on @mmckinst&#8216;s answer\u00a0for the warning about additional packages you may need. As my three readers know, I run a {{CentOS}}\u00a0mirror. One of the idiosyncrasies of CentOS, like its upstream {{RHEL}}, is that DVD ISOs aren&#8217;t\u00a0always just one image &#8211; &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=2511\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">merging centos iso images<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[9,41,45],"tags":[166,390,421,450,637],"keyring_services":[],"class_list":["post-2511","post","type-post","status-publish","format-standard","hentry","category-cool","category-technical","category-tutorial","tag-centos","tag-how-to","tag-iso","tag-linux","tag-rhel"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/2511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2511"}],"version-history":[{"count":0,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/2511\/revisions"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2511"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=2511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}