How to reduce the size of Debian Live image

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

How to reduce the size of Debian Live image

#1 Post by saintless »

This method describes how to slim down debian live squeeze from working image by removing files and applications.
I've done this only once and I can't tell all the steps I had to take to reduce the size at maximum. It took me over a week with different results and upgrading from already finished squash file. But the main concept is this one and with testing and adding advices from other people it could be improved.

Important information : Use only ext partition. vfat can't manage some linux file permissions and will cause errors.

In this example I will use the smallest debian-live-6.0.0-i386-standard.iso from here:
http://live.debian.net/files/oldstable/ ... so-hybrid/

Download and extract the live folder on /mnt/sda1 for example. If you can do it from puppy it will be great.
http://postimg.org/image/7zx9a64jn/
Unsquash filesystem.squashfs.

Code: Select all

unsquashfs -d /mnt/sda1/deb-6 /mnt/sda1/live/filesystem.squashfs
Now you have the content extracted in /mnt/sda1/deb-6 folder.
Add this sources to /mnt/sda1/deb-6/etc/apt/sources.list

Code: Select all

deb http://backports.debian.org/debian-backports squeeze-backports main
Create file /mnt/sda1/deb-6/etc/apt/apt.conf with this content inside:

Code: Select all

APT::Install-Recommends "false"; APT::Install-Suggests "false"; 
This way apt-get will install only the base packages.
Create folder /mnt/sda1/slim-boot and copy /mnt/sda1/deb-6/boot and /mnt/sda1/deb-6/dev folders + initrd.img and vmlinuz links as shown on the picture:
http://postimg.org/image/4b4w7i8qb/
You can remove one of the kernels as the example on the picture or not. It does not matter on this point. Just be sure to choose which kernel will be booted. It is 686 for me.

Now create squashfs from /mnt/sda1/slim-boot:

Code: Select all

mksquashfs /mnt/sda1/slim-boot /mnt/sda1/live/01-slim-boot.squashfs
You will need this slim-boot squash file only for boot. At the end it will be deleted.
I guess it is possible to include only /dev folder in 01-slim-boot.squashfs and the result will be the same.
Latest test shows this slim-boot squash file can be empty.
Next step is to create live-rw save file. 1Gb is enough. I remember I had some issues if live-rw is placed in sda1. To play safe put it on another partition. sda2 for example.

Code: Select all

dd if=/dev/zero of=/mnt/sda2/live-rw bs=1M count=1000
mkfs.ext2 /mnt/sda2/live-rw
Mount live-rw to /mnt/cdrom for example. I presume the optical drive is empty:

Code: Select all

mount -o loop /mnt/sda2/live-rw /mnt/cdrom
Copy from terminal all files from /mnt/sda1/deb-6 to /mnt/cdrom

Code: Select all

cp -frp /mnt/sda1/deb-6/* /mnt/cdrom
Unmount live-rw:

Code: Select all

umount /media/cdrom
Now you have all the content of filesystem.squashfs inside live-rw file.
It is time to remove filesystem.squashfs from /mnt/sda1/live
We already have in there 01-slim-boot.squashfs + vmlinuz and initrd.img. Now is time to reboot and enter the debian live system.
Use this grub legacy code (for kernel 686 in my example):

Code: Select all

title Debian-live
root=(hd0,0)
kernel /live/vmlinuz boot=live config persistent swapon quickreboot noprompt noautologin
initrd /live/initrd.img
boot
If all went well you will get to debian login prompt. Login as user with password live
Then create root password:

Code: Select all

sudo passwd root
Type and confirm the password.

Code: Select all

sudo login
Login as root and run:

Code: Select all

apt-get update
Install dialog with:

Code: Select all

apt-get install dialog
================================

If you are not going to change the kernel with 3.2.0-0.bpo.4-rt-686-pae don't read this section.

Code: Select all

apt-cache search linux-image-3
Choose the kernel you prefer or thisone:

Code: Select all

apt-get -t squeeze-backports install linux-image-3.2.0-0.bpo.4-rt-pae firmware-linux-free
I had a breaking here because of low ram issue while depmod. If it happen type:

Code: Select all

dpkg --configure -a
It will finish the process.

Code: Select all

cd /boot
ls
Now create initrd.img for the newer kernel:

Code: Select all

mkinitramfs -o initrd-3.2.0-0.bpo.4-rt-pae.img 3.2.0-0.bpo.4-rt-pae
Then copy the vmlinuz and initrd to live folder and rename them to initrd.img and vmlinuz after removing the oldonce.
You might also have to create link from /boot/initrd.img to / if it is broken but it does not matter since we will remove /boot folder at the end.
If everything went well after reboot you will have new kernel. Type to confirm:

Code: Select all

uname -r
Then remove the older kernels with:

Code: Select all

apt-get purge linux-image-2.6.32-5-486
apt-get purge linux-image-2.6.32-5-686

Code: Select all

apt-get autoremove
--======================================
Last edited by saintless on Sat 24 Jun 2017, 11:56, edited 30 times in total.

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

Removing packages

#2 Post by saintless »

You can see list of installed packages here or in /live folder:
http://live.debian.net/files/oldstable/ ... o.packages
It is only a list with no description. The better place to choose what to remove is /var/lib/dpkg Check out available or status files. You will have information what is the priority of every package - essential, extra, etc. Be careful not to change anything in dpkg folder.
You can open this available on another computer or make a smaller list with packages to remove, place somewhere and open it from time to time with nano while removing packages.
By the way I prefer to replace nano with e3. If you do this after opening file with e3 the exit is (hold CRL and press one by another K and X).
Start removing packages with:

Code: Select all

apt-get purge package-name
apt-get autoremove
If you try to remove essential package or dependency you will get a message to confirm with:

Code: Select all

Yes, do as I say!
Don't do it! I did it ones and it was a bad idea. I ended up with broken apt-get and had to start all over again.
When you finish and don't think you can remove more it is time to install:

Code: Select all

apt-get install squashfs-tools
And if you like you can do now distro upgrade to the newest packages:

Code: Select all

apt-get dist-upgrade
It will not take much extra space.
Make sure squashfs-tools supports xz compression:

Code: Select all

mksquashfs --h
You should see xz and -Xdict-size options in the output.
Just in case something is installed run:

Code: Select all

apt-get clean
to make sure /var/cache/apt/archives is empty.
Now is time to squash back live-rw

Code: Select all

mksquashfs /live/cow /live/image/live/new.squashfs
You don't need to use maximum compression yet because we have more cleaning to do from GUI.
All your changes are saved now in /mnt/sda1/live/new.squashfs (assuming we use puppy). The path to this place from debian live is different as you see from mksquashfs command: /live/image/live/new.squashfs
You can use safer approach here by mounting live-rw from puppy and copying from command line the content in another folder.
Now before reboot unsquash new.squashfs with this command:

Code: Select all

unsquashfs -d /live/image/new-sfs /live/image/live/new.squashfs
We have the content of new.squashfs in /live/image/new-sfs (or /mnt/sda1/new-sfs from puppy).
Reboot the computer and go back to puppy.
Last edited by saintless on Sat 07 Dec 2013, 09:23, edited 7 times in total.

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

Last cleaning of files

#3 Post by saintless »

The last cleaning we do from GUI.
Open /mnt/sda1/new-sfs folder and start removing this list of files and folders (lets pretend new-sfs is the top of a partition):

/.wh..wh.orph
/.wh..wh.plnk
/.wh..wh.aufs
+ any file starting with .wh here
from folder /etc remove:
fstab, mtab, group- , gshadow- , passwd- ,
open resolv.conf to clean your dns servers and save it. You can also remove it. It will be recreated on boot.
From /etc/udev/rules.d remove:
70-persistent-cd.rules, 70-persistent-net.rules
Check out /etc/network/interfaces If it has some of yours network settins remove them. The file should look like this:

Code: Select all

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp
You can also remove it. It will be recreated on boot.
Check out live, media, mnt, tmp folders. They have to be empty.
From /root remove:
.xsession-errors, .bash_history
Remove everything from /var/cache/apt/archives
From /var/cache/apt/ remove:
pkgcache.bin and rcpkgcache.bin
They will be created again after apt-get update command.
From /var/lib/apt/lists and /var/lib/apt/lists/partial remove the files bigger than 1 Mb. You will see file over 30Mb there. I think you can delete all but the rest is too small to deal with it. The files wil be created again after apt-get update command.

Replase the content of:
/usr/share/doc
/usr/share/man
/usr/share/info
with zerosize files with the same names.
This is great idea from JBV included in a special script for FoxyRoxyLinux.
It can be edited a little to do the same for the files in any folder.
It also searches in all folders for empty .wh files and removes them.
This is part of his script I use for this purpose.
By the way if you have time take a look what can be done with scripts in debian-live system:
http://foxyroxylinux.com/viewtopic.php?f=2&t=108
http://foxyroxylinux.com/viewforum.php? ... ede21d6573

Code: Select all

#!/bin/bash
#edited part of 95-clean script created by JBV for foxyroxylinux.com

zerosize() {
  find $* | while read file; do
    echo -n "."
    rm -f $file
    touch $file
  done
}

    zerosize /live/image/02/usr/share/doc -type f -size +1c
    zerosize /live/image/02/usr/share/doc -type l

    zerosize /live/image/02/usr/share/man -type f -size +1c
    zerosize /live/image/02/usr/share/man -type l


    zerosize /live/image/02/usr/share/info -type f -size +1c
    zerosize /live/image/02/usr/share/info -type l

    find /live/image/02 -name '.wh*' -delete

chown -R man:root /live/image/02/usr/share/man
Replace /live/image/02 with the path you use for new-sfs folder.

Now go back to the top and move /boot folder and /vmlinuz and /initrd.img links to another folder. Create squashfs with them in case you need them for upgrading the kernel and removing the older one from the system. initrd.img is already compressed file and you will save at least 15 Mb compressed space as a result. The system will boot without them and missing /boot does not cause any errors as far as the test shows to the moment.
You can load /boot as a squash at any time and any order. It will not break dpkg database and new installed packages.

The last thing is to compress back new-sfs into squash file.
This command gives me best xz compression results to the moment:

Code: Select all

mksquashfs /live/image/new-sfs /live/image/01-filesystem.squashfs -b 1048576 -comp xz -Xbcj x86
Place 01-filesystem.squashfs in /live folder, remove slim-boot.squashfs and reboot.

So, this is all from me to the moment. If something is not clear just ask questions. If I remeber or discover something new it will be added as new post. Happy slimming down live systems :)
Last edited by saintless on Fri 24 Jan 2014, 17:16, edited 2 times in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#4 Post by sunburnt »

I looked at the Foxy Roxy site, a NAS unit huh? I thought about making one, but now you can buy a NAS box with no-HDs for about $100 U.S.
So with a pair of 3 GB HDs it comes to about $300 U.S. It`s much smaller and it uses less power with less heat than a PC.

Wow... This code you`ve got looks like it could be wizard scripted pretty easy. There`s decisions to be made (guis) and automating of the process of course.

I need to clarify the sequence of work and start making scripts for each stage. I also need to refresh my knowledge of dpkg, apt-get, and the other pkg. man.s.
My interest is using the pkg. man. to build AppDir pkgs., not to install apps. The O.S. only uses AppDir pkgs, no legacy apps, no sfs, so no union needed.
This simplifies the O.S., and finally gets rid of the multitude of union problems. I`ve thought about this for years now and this looks like the chance to do it.

# What do you think about scripting a wizard for this build setup.?
.

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#5 Post by saintless »

sunburnt wrote:# What do you think about scripting a wizard for this build setup.?
.
It will be nice. By the way JBV made this code much more complicated and polished. It displays messages and gives options to say yes or no. It is only small rough edited part from his script which I use to clean quick before squashing back.
He is doing miracles with FoxyRoxy. It has a script for adding or removing packages in the main squash file and rebuild it again. He solved also the the problem with breaking dpkg database if you load extra squash files in not correct order. He created orphan squash files which can be removed or added to the system while updating dpkg database at the same time. And much much more. I'm inside this process and I still don't get all he does with this distro.

Cheers, Toni

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#6 Post by sunburnt »

I`ll look closer at the Foxy site to see what I can get from it, scripts, etc.

If there`s any help you need, guis, scripts, etc., let me know and I`ll focus on it.

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#7 Post by saintless »

sunburnt wrote:If there`s any help you need, guis, scripts, etc., let me know and I`ll focus on it.
Thanks, Sunburnt,

I will ask you for help when my head starts to hurt too much from banging the desk :)
Today I made my first trial slimming down wheezy. There is hope to get some acceptable size for core and to add more information in this thread.

Cheers, Toni

go2null
Posts: 11
Joined: Mon 24 Oct 2011, 02:04

Debian Live Web Builder

#8 Post by go2null »

@saintless: Have you tried using the Debian Live Web Builder (Manual)?

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

Re: Debian Live Web Builder

#9 Post by saintless »

go2null wrote:@saintless: Have you tried using the Debian Live Web Builder (Manual)?
No, but I will try it. Thanks.

BTW I know Sickgut used this method. I'm not sure what exactly was the process after building it but he ended up with 55 Mb squash file without xorg. Light-Debian was made the way described here and the result is the same size + newer bigger kernel, xorg, xfe, web browser.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#10 Post by sunburnt »

Wow... Looked at the Debian Live site and it`s typical of them. What a mass of info.
But as much as there is, it doesn`t clarify much. Takes a Deb. install to make a Live.
There is an online builder, it`s a possibility, but again it`s not real clear how to use it.
Very comprehensive, does distro, arch, media, and a bunch of other stuff too.
Might be a good way to go, but it`s gonna be a large learning curve for sure.

Saintless; I`m thinking we can add to your Squeeze the Deb-Live build setup with apt-get.

Code: Select all

# apt-get install live-build
Then we can all feed info to each other as we go. My slow web won`t allow big iso files.
I`m reading the starting examples and tutorials, and it`s simple to get a Lxde or Xfce iso.
http://live-systems.org/manual/current/ ... l#examples
In this tutorial, we will create an image suitable for use as a web browser utility, serving as an introduction to customizing live system images.
783

$ mkdir tutorial2
$ cd tutorial2
$ echo "task-lxde-desktop iceweasel" >> config/package-lists/my.list.chroot

784

Our choice of LXDE for this example reflects our desire to provide a minimal desktop environment, since the focus of the image is the single use we have in mind, the web browser. We could go even further and provide a default configuration for the web browser in config/includes.chroot/etc/iceweasel/profile/, or additional support packages for viewing various kinds of web content, but we leave this as an exercise for the reader.
785

Build the image, again as superuser, keeping a log as in Tutorial 1:
786

# lb build 2>&1 | tee build.log

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#11 Post by saintless »

sunburnt wrote:Saintless; I`m thinking we can add to your Squeeze the Deb-Live build setup with apt-get.

Code: Select all

# apt-get install live-build
Hi, Sunburnt,
included in the wheezy version for now. No problem to add it in squeeze. No problem to remove it if we want later.
Working on wheezy today.

Cheers, Toni

go2null
Posts: 11
Joined: Mon 24 Oct 2011, 02:04

#12 Post by go2null »

sunburnt wrote:Wow... Looked at the Debian Live site and it`s typical of them. What a mass of info.
But as much as there is, it doesn`t clarify much. Takes a Deb. install to make a Live.
There is an online builder, it`s a possibility, but again it`s not real clear how to use it.
Very comprehensive, does distro, arch, media, and a bunch of other stuff too.
Might be a good way to go, but it`s gonna be a large learning curve for sure.
I know :-) That's why it's still on my TODO list.

emil
Posts: 633
Joined: Tue 10 Nov 2009, 08:36
Location: Austria
Contact:

Automatization and package handling

#13 Post by emil »

Hi,

saintless wrote (in debin light wheezy thread):
The biggest problem for me is to automate the process for every user this way - install package --> clean it the best way to be small and working --> make sfs from it --> rebuild it in the main squashfs as an option --> do not brake dpkg database (most important). If we can do this to be executed with script without need from user confirmation it will be very good solution. Then anyone can create sfs files with one or multiple programs he/she needs.
as saintless mentioned I hope some steps forward are achieved with some sort of automatization and standartisation of the tools used to produce small images and handle packages. At the moment I see 3 main areas:

1) building and stripping the base image
2) use of squashfs (sfs) modules
3) user generated deb packages (conversion of pet to deb)

Currently manual cleaning and modifying is used to prepare a working system. I would call it "hacking the sfs". This approach may be faster and easier for the moment, but in the long term I would prefer a customized buildscript, which should be more maintainable and would reduce future tedious work. The debian live build system allows for extended customisation (e.g. "hooks"). There are very interesting examples of projects which use the live-build tools, and I wonder if anybody here is still using it to get small base image:

example1 (crunchbang-debianlive): http://crunchbang.org/forums/viewtopic.php?id=4753 (build script, interesting because it uses openbox)
example2 (sage debian live): http://sagedebianlive.metelu.net/ - (look under Source Code/Browse files: config.sh, build.sh)
example3 (minimal debian live, example from manual): http://live.debian.net/manual/current/h ... n.html#831

The minimal example Nr. 3 contains discussion of a minimization tool "stripping.hook" /written by the live-tools author D. Baumann).
There are others or similar:
95-snap.sh (FoxyRoxy) "zerosizes" files to avoid package errors.
Iguleder's package tools have the strippkg and mkpkg scripts.
Last but not least, new2dir from Puppy.

For me it seems that the stripping/splitting of the base image should be automated (to the greatest extend) with the same algorithms as the stripping of further packages or squashfs files.

I wrote this mainly for me as a a reminder to links for a starting point.
kind regards
emil

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#14 Post by saintless »

Hi, Emil,

Thank you for the links. I will check them all when I have some spare time to do it.
JBV created most of the scripts we need in FoxyRoxyLinux but the cleaning process could be improved in order to make the sfs file smaller as we can.
I will not be able to create professional made script but I think I can create a script with simple commands in order to be executed automatic (as example of my point of view what is the best) and then someone maybe will make something better from it.

Cheers, Toni

emil
Posts: 633
Joined: Tue 10 Nov 2009, 08:36
Location: Austria
Contact:

#15 Post by emil »

Hi Toni,
I think in the spirit of this forum everybody should work on the projects he likes and do it in a way which he feels works best for him. So don't feel obligation to produce such scripts yourself, you already do a lot.
cheers

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#16 Post by saintless »

Similar to Debian experimenting with Linux Mint 17 (Ubuntu based) after reading Mintpup thread from wanderer.
The result is much smaller base without xorg and autologin as root (multiuser function is still available and functional). The point to remove safe all possible packages is to start fresh system build without installing recommended packages.
Started with frugal install on sda1 having /casper directory with initrd.lz, vmlinuz and filesystem.squashfs (1,3 Gb).
Second ext3 partition with label casper-rw used for saving the changes.
Grub menu list boot code:

Code: Select all

title Linux Mint
root (hd0,0)
kernel /casper/vmlinuz boot=casper ignore_uuid persistent
initrd /casper/initrd.lz
After booting as live user mint exit to console by pressing Ctrl+Alt+F1
Create root password and login as root:

Code: Select all

sudo passwd root #type new root password.
sudo login #login as root
Removing the packages - more or less complete list of purge commands using the package list information in /var/lib/dpkg/info and status.
Avoid removing package if you need to confirm with "Yes, do as I say!" or you will end up with broken system.

Code: Select all

apt-get purge acl
apt-get purge aptitude accountsservice sane* cups* gnome* man-db bamfdaemon desktop-file-utils mime-support
apt-get purge hicolor* doc-base
apt-get purge java* libreoffice* libqt* gir1.2*
apt-get purge shared-mime* fontconfi*
apt-get purge xserver*
apt-get purge virtualbox*
apt-get purge cron* anacro*
apt-get purge xfce*
apt-get purge mint*
apt-get purge compiz*
apt-get purge apt-transport-https aptdaemon-data dictionaries* espeak* evince* friendly* gnome* gstreamer* grub* policykit* libicu* libllvm*
apt-get purge wayland*
apt-get purge jack*
apt-get purge pulseaudio*
apt-get purge libgl1*
apt-get purge gvfs* totem* mplay* vlc* system*
apt-get purge java* language* libreoff* firefox* cups* python*
apt-get purge apt-xapian-index
rm -fr ./apt-xapian-index
apt-get purge liblangtag-common mtools mtr-tiny syslinux-legacy libgcr-3-common avahi-autoipd syslinux-common
apt-get purge libdirac-encoder0
apt-get purge kpartx hexchat-common libtext-wrapi18n-perl fonts-freefont-ttf hwdata
apt-get purge fonts*
apt-get purge hddtemp memtest86+ libsocket6-perl libmtp-common fonts*
apt-get purge ndiswrapper-common
apt-get purge fonts-tlwg-typo ecryptfs-utils libclass-accessor-perl p11-kit telnet gpgv libzvbi-common gettext-base
apt-get purge ecryptfs-utils libclass-accessor-perl p11-kit telnet gettext-base
apt-get purge archdetect-deb sound-theme-freedesktop localechooser-data libgdbm3 libavcodec54 libsox-fmt-alsa
apt-get purge libwildmidi-config locate libgtop2-common ubiquity-ubuntu-artwork cpp-4.8 user-setup
apt-get purge libgeoip1 dnsutils libgssapi-krb5-2 qtcore4-l10n mscompress libv4l-0 liblivemedia23
apt-get purge tcl8.6 wamerican ubiquity-casper libpeas-common libavc1394-0 libgpg-error0
apt-get purge libdbusmenu-glib4 tumbler-common libwebkitgtk-3.0-common iw libxapian22
apt-get purge install-info libgtksourceview-3.0-common libcrack2 ssl-cert dctrl-tools liba52-0.7.4
apt-get purge openssl libcloog-isl4 lvm2
apt-get purge libutempter0 libexo-helpers sgml-base libopenal-data manpages-dev
apt-get purge libbonobo2-common transmission-common pidgin-data usb-modeswitch libxcb-icccm4 libwnck-3-common gconf2-common
apt-get purge libsnmp-base gawk linux-libc-dev libthai-data
apt-get purge libcap2-bin libdrm-radeon1 libmx-common libwebkitgtk-1.0-common libburn4 os-prober libapt-inst1.5 gsfonts fonts*
apt-get purge libpwquality-common manpages ed libck-connector0 gimp-data poppler-data xfdesktop4-data fortunes-husse lockfile-progs
apt-get purge xfce*
apt-get purge rdate libwacom-common libpulsedsp libjpeg-turbo-progs liblvm2app2.2 genisoimage hdparm
apt-get purge tcpdump libsecret-common libpulse0 lshw libbasicusageenvironment0 guile-2.0-libs watershed
apt-get purge radeontool samba-common libproxy-tools uuid-runtime libpaper-utils uno-libs3
apt-get purge libnm-gtk-common libexo-common plymouth-theme-ubuntu-text rtkit x11-common wireless-regdb xdg-utils libgs9-common
apt-get purge plymouth-theme-ubuntu-text rtkit x11-common wireless-regdb xdg-utils libgs9-common libnl-genl-3-200
apt-get purge libnm-gtk-common libexo-common plymouth-theme-ubuntu-text rtkit libgs9-common
apt-get purge wireless-regdb
apt-get purge xdg-utils
apt-get purge xdg*
apt-get purge samba*
apt-get purge gnome*
apt-get purge systemd*
apt-get purge codec*
apt-get autoremove
apt-get purge xserv*
apt-get purge mplayer*
apt-get purge totem*
apt-get purge vlc*
apt-get purge xfce4*
apt-get purge jfsutils kbd krb5-locales libavahi-core7:i386 libavahi-common3:i386
apt-get purge libbonoboui2-common libcgmanager0:i386
apt-get purge libclucene-contribs1:i386 libclucene-contribs1:i386 libcolamd2.8.0:i386 libcrystalhd3:i386 libdc1394-22:i386
apt-get purge libboost-iostreams1.54.0:i386
apt-get purge libdevmapper-event1.02.1:i386 libdjvulibre21:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdvdread4:i386
apt-get purge libmpeg2encpp-2.1-0 libmpfr4:i386 libmpg123-0:i386 libnetfilter-conntrack3:i386
apt-get purge libopencore-amrnb0:i386 libroken18-heimdal:i386 libschroedinger-1.0-0:i386 libwavpack1:i386 libx11-xcb1:i386
apt-get purge linux-headers-3.13.0-37 linux-sound-base mlocate
apt-get purge openjdk-7-jre-lib p11-kit-modules:i386 plymouth qtchooser thunar-data toshset
apt-get purge openjdk-7-jre-lib p11-kit-modules:i386 qtchooser thunar-data toshset
apt-get purge usb-modeswitch-data vbetool wodim x11-common xbitmaps xkb-data
apt-get autoremove
apt-get -f install
apt-get install squashfs-tools ntfs-3g
To autologin as root you need to change one line after extracting initrd.lz in /etc/casper.conf (the file is inside initrd.lz).
It is best to do this first in different linux and then reboot with the modded initrd.lz after creating the root password.
You need to install first p7zip-full (for example in Debian based system using apt-get):

Code: Select all

apt-get install p7zip-full
Then copy initrd.lz in /casper/init/ and create subfolder (/casper/init/1 for example). Change to /casper/init/1:

Code: Select all

cd /path-to/casper/init/1 #note you should have initrd.lz inside /path-to/casper/init
7z e -so ../initrd.lz | cpio -id
initrd.lz is extracted inside /path-to/casper/init/1

Open /path-to/casper/init/1/etc/casper.conf with text editor and change:

Code: Select all

export USERNAME="mint"
to:

Code: Select all

export USERNAME="root"
and rebuild the initrd.lz (using xz compression):

Code: Select all

cd /path-to/casper/init/1
find . -print | cpio -o -H newc 2>/dev/null | xz -f --extreme --check=crc32 > ../initrd-casper.xz
Rename the original initrd.lz and use initrd-casper.xz instead (rename it to initrd.lz if you like to use the same boot code example above).
Boot the system and you should autologin as root to console (using the same persistent casper-rw partition after removing the packages) with working wired internet connection (for wireless you will have to try to find some solution using command line only).
Now it is time to remaster the system using DebianDog cli script modded to work with Linux Mint (it creates zero-size files in /usr/share/doc, info and man but you can remove this part if you like to keep them):

Code: Select all

#!/bin/bash

# Edited for command line only tool from original RemasterDog, remaster script for DebianDog by Fred (fredx181)

echo "Run this scripts as root or using sudo."
echo "Open the script with text editor if you like to change the working directory drive DEST="
echo "It is set to use the boot partition mounted as /cdrom. It will be remounted in RW mode."
echo "The script will start copying files in 60 seconds. There will be prompt to create squashfs module."
sleep 60

[ "`whoami`" != "root" ] && exec gsu ${0}

DEST="/cdrom"
mount -o remount,rw $DEST
wait

mkdir $DEST/work-dir
echo -n "Copying files in $DEST/work-dir... Please, wait..."
rsync -a / $DEST/work-dir/ --exclude=/{cdrom,mnt,proc,sys,media,run,tmp,rofs,lost+found}

mkdir -p $DEST/work-dir/{proc,run,mnt,media,sys,tmp}
chmod a=rwx,o+t $DEST/work-dir/tmp
echo ""

echo -n "Cleaning..."
rm -f $DEST/work-dir/var/lib/alsa/asound.state
rm -f $DEST/work-dir/root/.bash_history
rm -f $DEST/work-dir/root/.xsession-errors
rm -rf $DEST/work-dir/root/.cache
rm -rf $DEST/work-dir/root/.thumbnails
rm -f $DEST/work-dir/etc/blkid-cache
rm -f $DEST/work-dir/etc/resolv.conf
rm -rf $DEST/work-dir/etc/udev/rules.d/70-persistent*
rm -f $DEST/work-dir/var/lib/dhcp/dhclient.eth0.leases
rm -f $DEST/work-dir/var/lib/dhcpcd/*.lease
rm -fr $DEST/work-dir/var/lib/aptitude/*
echo ""

ls $DEST/work-dir/var/lib/apt/lists | grep -v "lock" | grep -v "partial" | xargs -i rm $DEST/work-dir/var/lib/apt/lists/{} ;

ls $DEST/work-dir/var/cache/apt/archives | grep -v "lock" | grep -v "partial" | xargs -i rm $DEST/work-dir/var/cache/apt/archives/{} ;

ls $DEST/work-dir/var/cache/apt | grep -v "archives" | xargs -i rm $DEST/work-dir/var/cache/apt/{} ;
rm -f $DEST/work-dir/var/log/* 2> /dev/null

cd $DEST/work-dir

zerosize() {
  find $* | while read file; do
    echo -n "."
    rm -f $file
    touch $file
  done
}

echo -n "Zerosizing man, doc, info..."
    zerosize usr/share/doc -type f -size +1c
    zerosize usr/share/doc -type l

    zerosize usr/share/man -type f -size +1c
    zerosize usr/share/man -type l


    zerosize usr/share/info -type f -size +1c
    zerosize usr/share/info -type l

    zerosize usr/share/gnome/help -type f -size +1c
    zerosize usr/share/gnome/help -type l

    zerosize usr/share/gtk-doc -type f -size +1c
    zerosize usr/share/gtk-doc -type l
echo ""

    chown -R man:root usr/share/man

cd $DEST

echo ###
echo "Now you can clean manually $DEST/work-dir if you like."
echo "After that type 1 and press Enter to continue."
echo ###
echo "1)Type 1 and press Enter to continue."
echo ###

read n
case $n in
    1) mksquashfs $DEST/work-dir $DEST/work-dir.squashfs -comp xz -b 512k -Xbcj x86 ;;
esac


echo ###
echo "Do you want to delete $DEST/work-dir?"
echo ###
echo "1)Type 1 YES - delete $DEST/work-dir."
echo "2)Type 2 NO and exit."
echo ###
echo "Type the number and press Enter."
echo ###

read n
case $n in
    1) rm -rf $DEST/work-dir;;
    2) exit;;
esac

Testing example remastered module (xz compressed without xorg) after the procedure above + initrd.lz (modded to autologin as root) and vmlinuz for frugal install you can download from here.
Added /etc/apt/apt.conf to prevent installing recommended packages.
The remastering script is included and can be started from terminal or console by typing:

Code: Select all

/opt/bin/remaster-mint-cli
I will not update or support this experiment further. It is only testing example how to make Linux Mint (or Ubuntu) smaller and rebuild it as you wish.
Maybe this information will help a little with Mintpup project. Anyone ineterested from Linux Mint puppifying should read the updates from wanderer here:
http://www.murga-linux.com/puppy/viewtopic.php?t=99909

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#17 Post by mcewanw »

Hi Toni,

After reading your post above, I modified initrd.lz to make root the login user rather than mint. I was hoping that would allow full version of xfce live frugal-installed Linux Mint (I have the 64bit 17.2 version) itself to autologin to a root GUI (just as an experiment). Unfortunately, I haven't managed to get that to work. I have managed to get to login screen and been able to login to a root GUI from there (had to use System -> Login Display to allow root login as far as I recall).

Have you managed to get full live frugal-installed xfce Linux Mint (whatever version you have) to autologin as root user into Desktop and if so, how?

Cheers, William
github mcewanw

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#18 Post by saintless »

Hi William.
My experiment was with save partition with most packages and xorg removed already. I didn't test the modded initrd.lz with fresh frugal install official Mint but I'm sure the problem is in your description:
mcewanw wrote:(had to use System -> Login Display to allow root login as far as I recall).
i guess you have to deactivate the display manager or install different one.
If the tty*.conf files in /etc/init have root inside, then the changed initrd.lz does the job. The problem is in the included display manager.

Toni

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#19 Post by mcewanw »

Thanks Toni,

I had a feeling it might be MDM display manager related. I'm not in official Linux Mint just now, but I don't think it had an /etc/init directory with tty confs. I do notice that in MintPup - is that something you added to use sysinitv and autologin lines in the tty conf files?

William
github mcewanw

User avatar
saintless
Posts: 3862
Joined: Sat 11 Jun 2011, 13:43
Location: Bulgaria

#20 Post by saintless »

I didn't add any /etc/init files.
I don't have the original LinuxMint image anymore but it should have the tty* files in /etc/init. They are part of upstart init and I see posts in Linux Mint forum about the same files:
http://forums.linuxmint.com/viewtopic.p ... 4#p1028444

Toni

Post Reply