debootstrap minimal rootfs

749 views
Skip to first unread message

William Hermans

unread,
Jul 8, 2015, 10:12:46 PM7/8/15
to beagl...@googlegroups.com
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 . . .


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.






 

William Hermans

unread,
Jul 8, 2015, 10:21:37 PM7/8/15
to beagl...@googlegroups.com
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


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert Nelson

unread,
Jul 8, 2015, 10:23:42 PM7/8/15
to Beagle Board
On Wed, Jul 8, 2015 at 9:12 PM, William Hermans <yyr...@gmail.com> wrote:
> 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.. ;)
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,

--
Robert Nelson
https://rcn-ee.com/

Robert Nelson

unread,
Jul 8, 2015, 10:29:58 PM7/8/15
to Beagle Board
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..

William Hermans

unread,
Jul 8, 2015, 10:34:52 PM7/8/15
to beagl...@googlegroups.com
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.

William Hermans

unread,
Jul 8, 2015, 10:51:55 PM7/8/15
to beagl...@googlegroups.com
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 . . .

Robert Nelson

unread,
Jul 8, 2015, 11:02:42 PM7/8/15
to Beagle Board
On Wed, Jul 8, 2015 at 9:51 PM, William Hermans <yyr...@gmail.com> wrote:
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.. 


Regards,

William Hermans

unread,
Jul 8, 2015, 11:09:08 PM7/8/15
to beagl...@googlegroups.com
Here's a pastebin versions with no line mess ups.. 


Regards,

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

--

William Hermans

unread,
Jul 8, 2015, 11:17:21 PM7/8/15
to beagl...@googlegroups.com
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.

Robert Nelson

unread,
Jul 8, 2015, 11:22:16 PM7/8/15
to Beagle Board
On Wed, Jul 8, 2015 at 10:17 PM, William Hermans <yyr...@gmail.com> wrote:
> 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

William Hermans

unread,
Jul 8, 2015, 11:40:49 PM7/8/15
to beagl...@googlegroups.com
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 :)

William Hermans

unread,
Jul 9, 2015, 12:35:44 AM7/9/15
to beagl...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages