debootstrap minimal rootfs

So, last night I was bored and got around to toying with debootstrap( again, but first time in a while ). I’m curious how you Robert get such a small barefs. I have not read your scripts in their entirety, but it stands to reason with a little bit of help from google I should be able to get close. But this has not been the case so far.

Basically what I did once in the chroot was as follows . . .

  • export LANG=C

  • /debootstrap/debootstrap --second-stage

  • apt-get purge tasksel info install-info vim-common vim-tiny man-db manpages aptitude

  • apt-get autoremove

  • apt-get clean

  • rm -rf /usr/share/man/??

  • rm -rf /usr/share/man/??_*

  • apt-get install localepurge deborphan debfoster

  • localepurge

  • rm -rf /usr/share/doc/

  • rm -rf /usr/share/doc-base/

  • dpkg --purge man-db manpages

  • rm -r /var/lib/apt/lists
    Then as a test, just to see if it could be done . . .

  • wget --no-check-certificate https://rcn-ee.net/deb/wheezy-armhf/v3.8.13-bone68/linux-image-3.8.13-bone68_1wheezy_armhf.deb

  • dpkg -i linux-image-3.8.13-bone68_1wheezy_armhf.deb // Cheating ? testing if this works . . .hah!

  • rm linux-image-3.8.13-bone68_1wheezy_armhf.deb

  • rm -r /var/lib/apt/lists

  • deborphan --guess-all

  • apt-get autoremove --purge

  • apt-get clean

So . . .

root@darkness:/# du -hsx * | sort -rh | head -10
58M usr
42M lib
8.1M boot
7.6M var
3.6M sbin
3.6M bin
1.5M etc
32K root
28K run
8.0K dev

What am I missing here ? A couple packages, purgelocales deborphan etc, but this seems large for a stripped down debootstrap rootfs. Including modules, and kernel.

Oh and right I still have qemu static in place, but . . .

root@darkness:/# du -h /usr/bin/qemu-arm-static
1.8M /usr/bin/qemu-arm-static

So, last night I was bored and got around to toying with debootstrap( again,
but first time in a while ). I'm curious how you Robert get such a small
barefs. I have not read your scripts in their entirety, but it stands to
reason with a little bit of help from google I should be able to get close.
But this has not been the case so far.

Oh, lots of 'little' things.. :wink:

Basically what I did once in the chroot was as follows . . .

export LANG=C
/debootstrap/debootstrap --second-stage
apt-get purge tasksel info install-info vim-common vim-tiny man-db manpages
aptitude
apt-get autoremove
apt-get clean
rm -rf /usr/share/man/??
rm -rf /usr/share/man/??_*
apt-get install localepurge deborphan debfoster
localepurge
rm -rf /usr/share/doc/
rm -rf /usr/share/doc-base/
dpkg --purge man-db manpages
rm -r /var/lib/apt/lists

Then as a test, just to see if it could be done . . .

wget --no-check-certificate
https://rcn-ee.net/deb/wheezy-armhf/v3.8.13-bone68/linux-image-3.8.13-bone68_1wheezy_armhf.deb
dpkg -i linux-image-3.8.13-bone68_1wheezy_armhf.deb // Cheating ? testing if
this works . . .hah!
rm linux-image-3.8.13-bone68_1wheezy_armhf.deb
rm -r /var/lib/apt/lists
deborphan --guess-all
apt-get autoremove --purge
apt-get clean

So . . .

root@darkness:/# du -hsx * | sort -rh | head -10
58M usr

From /usr/ nuke:

/usr/share/locale/*
/usr/share/man/*
/usr/share/doc/*

42M lib
8.1M boot
7.6M var
3.6M sbin
3.6M bin
1.5M etc
32K root
28K run
8.0K dev

What am I missing here ? A couple packages, purgelocales deborphan etc, but
this seems large for a stripped down debootstrap rootfs. Including modules,
and kernel.

apt:

(don't store apt cache, this slows things down, but saves lots of space)

cat /etc/apt/apt.conf.d/02nocache
02nocache
Dir::Cache {
  srcpkgcache "";
  pkgcache "";
}

( similar to apt-get clean, but automatic)

cat /etc/apt/apt.conf.d/02apt-get-clean
#Custom apt-get clean
DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb
/var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true";
};
APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb
/var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true";
};
Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";

(only store compressed indexs)

cat /etc/apt/apt.conf.d/02compress-indexes
Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";

(drop apt translations)

cat /etc/apt/apt.conf.d/02-no-languages
Acquire::Languages "none";

Regards,

btw, for about a week i was playing with removing even more utils by
using busybox.

But kept running into issues:

(current list)

https://github.com/RobertCNelson/omap-image-builder/blob/master/scripts/chroot.sh#L502

I'm hoping later versions of busybox/toybox could helps us create a
debian image that's even smaller..

Regards,

Thanks for your replies Robert. I think I already nuked *man, and *doc, but will double check. Also going ot go over the while list of things you mentioned.

btw, for about a week i was playing with removing even more utils by
using busybox.

But kept running into issues:

(current list)

https://github.com/RobertCNelson/omap-image-builder/blob/master/scripts/chroot.sh#L502

I’m hoping later versions of busybox/toybox could helps us create a
debian image that’s even smaller…

Funny you mentioned that. Was doing some reading on stripping down debian last night and on their wiki they mention that busybox has to be exempted from removal from wheezy ( some kind of bug ), so I’m assuming there are already some aspects of busybox “installed”. After that, I was looking at my /bin directory ( 3.7M or so ), while the BusyBox executable total size was only 1.7-ish. Not much of a gain . . . but depending on what someone is doing I suppose every little bit matters.

ug !

root@darkness:/# apt-get update
E: Syntax error /etc/apt/apt.conf.d/02apt-get-clean:9: Extra junk at end of file

There is nothing at line #9, even used nano, went in an deleted at line 9 . . . googling . . .

Here's a pastebin versions with no line mess ups..

https://paste.debian.net/280457/

Regards,

Here’s a pastebin versions with no line mess ups…

https://paste.debian.net/280457/

Regards,

Worked great Robert, thanks. I blame Windows . . .cough

Ok, so now after apt-get update, I’m down to 137M versus 171M previously. Lets see if apt-get clean does anything.

Ok, nada on that front. So in order to shrink back to 122M I’ll have to delete the apt/lists.

Nuking /user/share → doc, man, and locales gave me back around 1.3-1.4M.

So instead of boring you with the output of dpkg --get-selections. Would you happen to know of a good “list” of packages to remove ? The debian wiki is a bit less than forthcoming on this subject. But I did find a decent guide for reducing Ubuntu which mostly seem applicable for this situation as well.

Ok, so now after apt-get update, I'm down to 137M versus 171M previously.
Lets see if apt-get clean does anything.

Ok, nada on that front. So in order to shrink back to 122M I'll have to
delete the apt/lists.

Oh yeah do:

apt-get clean
rm -rf /var/lib/apt/lists/*

Now that you've setup the apt/conf filters, you need to manually purge
the apt lists.. (as they are now ignored thanks to the filters).

Nuking /user/share -> doc, man, and locales gave me back around 1.3-1.4M.

So instead of boring you with the output of dpkg --get-selections. Would you
happen to know of a good "list" of packages to remove ? The debian wiki is a
bit less than forthcoming on this subject. But I did find a decent guide for
reducing Ubuntu which mostly seem applicable for this situation as well.

try removing:

apt-get remove aptitude aptitude-common dmidecode groff-base info
install-info manpages man-db tasksel tasksel-data vim-common vim-tiny
wget whiptail

Regards,

try removing:

apt-get remove aptitude aptitude-common dmidecode groff-base info
install-info manpages man-db tasksel tasksel-data vim-common vim-tiny
wget whiptail

Thanks for your help Robert. Most of that was already removed but whiptail, wget, and groff-base got me down to 119M. dmidecode did not exist. All the rest I had removed.

I would like to get it down further, as in like under 100M, but as it stands. It is not all that bad. I mean there comes a time where everyone starts feeling like they’re picking nits . . . But that won’t stop me from reading more on the subject, and possibly removing unneeded kernel modules, etc.

“Worst case” I could always use your barefs, but figured I would play around with this to give me a break from staring at a screen full of C ( blankly I might add ) for a while.

Part of this was that I wanted to test if I could debootstrap, reduce the image a decent bit( and I’ve done that already - with your help too ), and then pull in one of your linux-images, then use dd to “extract” MLO / uboot.bin to create a working bootable system without even touching it with a beaglebone prior to boot.

Why ? Well it keeps me busy. Because I can, and I was curious . . . Thanks again :slight_smile:

Just an update:

rm -r /usr/share/i18n/charmaps/*
rm -r /usr/share/i18n/locales/*

got me down to around 104M. WIse ? not sure, but I’m sure I’ll find out heh. But I did do some googling that suggests this is ok. We’ll see.