Page 1 of 1

iso remaster to CD size (shrink)

Posted: Mon Feb 17, 2014 8:18 am
by ChrisPZV
Hi forum,

there's the need for me to have a CD (not DVD) with LMDE, because of non PAE CPU support. Since there's no CD image download anymore I tried myself with the help of this forum and several other sources to shrink the iso file.
At the moment I've no luck to get it shrinked to the estimated size inspite of purging more than 650MB from the linuxmint-201303-mate-dvd-32bit.iso.
After all processing I get about 1.04GB.
here is my script that does the work:

Code: Select all

#!/bin/bash

iso="linuxmint-201303-mate-dvd-32bit"

if [ "$UID" -ne "0" ]
then
echo "This script will only work when run by "root"."
exit 1
fi

# not everyone will have squash tools, install them if not found
if [ ! `which unsquashfs` ]
then
aptitude install squashfs-tools
fi

# not everyone will have genisoimage, install it if not found
if [ ! `which mkisofs` ]
then
aptitude install genisoimage
fi

START=$(date +%s)

mkdir iso
mount $iso.iso iso/ -o loop

cp -R iso/ image/

echo "Decompressing SquashFS..."
cp iso/casper/filesystem.squashfs ./
unsquashfs filesystem.squashfs

echo "Setting up Live CD chroot..."
mkdir -p squashfs-root/etc/
touch squashfs-root/etc/resolv.conf
echo "nameserver 208.67.220.220" >> squashfs-root/etc/resolv.conf
echo "nameserver 208.67.222.222" >> squashfs-root/etc/resolv.conf
echo "nameserver 4.2.2.4" >> squashfs-root/etc/resolv.conf
echo "nameserver 4.2.2.5" >> squashfs-root/etc/resolv.conf
cp /etc/hosts squashfs-root/etc/
cp /etc/apt/sources.list squashfs-root/etc/apt/sources.list

mount --bind /dev/ squashfs-root/dev

chroot squashfs-root/ mount -t proc none /proc
chroot squashfs-root/ mount -t sysfs none /sys
chroot squashfs-root/ mount -t devpts none /dev/pts
export HOME=/root
export LC_ALL=C

echo "Refreshing and Upgrading Packages"
chroot squashfs-root/ apt-get update
chroot squashfs-root/ apt-get -y purge libreoffice-core gimp-data thunderbird freepats pidgin-data openjdk-6-jre-headless w32codecs mint-x-icons python-qt4 build-essential evolution-data-server-common thunderbird-l10n-en-us

chroot squashfs-root/ aptitude purge ~c
chroot squashfs-root/ aptitude unmarkauto ~M
chroot squashfs-root/ apt-get clean
chroot squashfs-root/ aptitude autoclean
chroot squashfs-root/ rm -rf /var/cache/debconf/*.dat-old
chroot squashfs-root/ rm -rf /var/lib/aptitude/*.old
chroot squashfs-root/ rm -rf /var/lib/dpkg/*-old
chroot squashfs-root/ rm -rf /var/cache/apt/*.bin


#cleanup chroot
echo "Cleaning up chroot..."
chroot squashfs-root/ rm -rf /tmp/*
chroot squashfs-root/ rm -f /etc/resolv.conf
chroot squashfs-root/ umount -l -f /proc
chroot squashfs-root/ umount -l -f /sys
chroot squashfs-root/ umount /dev/pts
umount squashfs-root/dev

chroot squashfs-root/ dpkg-query -W --showformat='${Package} ${Version}\n' > image/casper/filesystem.manifest 
    
echo "Removing old SquashFS filesystem..."
rm image/casper/filesystem.squashfs

echo "Creating new SquashFS filesystem..."
mksquashfs squashfs-root image/casper/filesystem.squashfs -comp xz

echo "Finding and creating MD5 hash sums of files in image..."
cd image
find . -type f -print0 | xargs -0 md5sum > md5sum.txt
cd ..

echo "Creating new image..."
mkisofs -r -V "${iso}" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o "${iso}_remaster.iso" image/

# Make sure that mkisofs succeeded before we try moving or renaming
# any images.
if [ $? != "0" ]
then
echo "mkisofs failed with error code: $?"
exit
fi

#cleanup working directory

echo "Cleaning up working directory..."
umount iso/

rm -rf squashfs-root
rm -rf image
rm -rf iso
rm -f filesystem.squashfs
rm -f umr-livecd.sums

echo "Getting MD5 and SHA1 sum of image..."
echo "MD5: " > umr-livecd.sums
md5sum $iso.iso >> umr-livecd.sums
echo "SHA1: " >> umr-livecd.sums
sha1sum $iso.iso >> umr-livecd.sums

END=$(date +%s)

echo "Done at `date`. The whole process took $(($END - $START)) seconds!"
What I don't understand: Why do the purges not free the calculated space on squashfs/iso-file?
Could anybody point me where to make efficient changes to the script, to get it done properly?

Thanks in advance!

kind regards
Christian

[edit]Oops! Sorry, I've read it right after posting the message: "Do not start a support topic here please."[/edit]

Re: iso remaster to CD size (shrink)

Posted: Mon Feb 17, 2014 8:37 am
by xenopeek
ChrisPZV wrote:there's the need for me to have a CD (not DVD) with LMDE
Why? If it's because you don't have DVD drive... There are many ways to install LMDE that don't require you to have a DVD drive (or be able to boot from USB), and don't require you to mess with the ISO.

Re: iso remaster to CD size (shrink)

Posted: Mon Feb 17, 2014 8:49 am
by ChrisPZV
Hm... I thought I did enough to avoid that question...
Yes, all the horrible parameters came together: An old IBM ThinkPad R40 (2722), with updated BIOS, CD-RW-Drive, not able to boot USB thumb drive. This R40 can't even boot the DVD on an external DVD-RW-drive (CDs are bootet from that drive).

Re: iso remaster to CD size (shrink)

Posted: Mon Feb 17, 2014 8:56 am
by wayne128
ChrisPZV wrote:Hm... I thought I did enough to avoid that question...
Yes, all the horrible parameters came together: An old IBM ThinkPad R40 (2722), with updated BIOS, CD-RW-Drive, not able to boot USB thumb drive. This R40 can't even boot the DVD on an external DVD-RW-drive (CDs are bootet from that drive).

There is another way too.

No need DVD/CD
No need USB

all you need is a working OS, WinXP/vista/7 or Linux

Says you are with WinXP...

Download unetbootin, windows version
Download Linux iso

Run Unetbootin
select Linux iso
select HARDDISK!!!, this will frugal install into WinXP,

Reboot, select the line 'unetbootin'.. it should boot and run Linux in Live mode..

Hope it works for you

Re: iso remaster to CD size (shrink)

Posted: Mon Feb 17, 2014 9:21 am
by xenopeek
Right, well the alternative I was thinking about is as follows:
- Write the LMDE ISO to a USB stick, using appropriate tool.
- Write the Plop Boot Manager to a CD and boot from that; Plop allows you to then boot from the USB stick, even if your computer's BIOS doesn't support that :wink:

You can find Plop here: http://www.plop.at/en/bootmanagers.html

Also note that at this moment you are strongly discouraged to download and install LMDE. Wait till the new ISO is available. It's currently in testing, you can follow progress here. The release candidate should hopefully be out later this month, with the final release somewhere early next month.

Re: iso remaster to CD size (shrink)

Posted: Mon Feb 17, 2014 9:45 am
by ChrisPZV
@wayne128: I'm on Linux for years now... What is WinXP? ;-)

xenopeek wrote:Also note that at this moment you are strongly discouraged to download and install LMDE. Wait till the new ISO is available. It's currently in testing, you can follow progress here. The release candidate should hopefully be out later this month, with the final release somewhere early next month.
Got it, just used that image for testing purposes. I just wan't to be prepared when the latest image is ready for download. :-)
xenopeek wrote:Right, well the alternative I was thinking about is as follows:
- Write the LMDE ISO to a USB stick, using appropriate tool.
- Write the Plop Boot Manager to a CD and boot from that; Plop allows you to then boot from the USB stick, even if your computer's BIOS doesn't support that :wink:

You can find Plop here: http://www.plop.at/en/bootmanagers.html
Yes, using Super Grub Disk was what I considered instead of shrinking the iso. But that's what I wouldn't call a nifty solution. ;-)

Re: iso remaster to CD size (shrink)

Posted: Mon Feb 17, 2014 10:52 am
by The_Raven
Another way is to install over network with PXE. But this way needs a lot of config (DHCP-Server, NFS/Samba-Server, TFTP-Server and PXE-Config).