Author Topic: make a minimal ubuntu setup  (Read 1384 times)

Pinako

  • Hero Member
  • *****
  • Posts: 1263
    • View Profile
    • inportb
make a minimal ubuntu setup
« on: September 08, 2010, 02:23:48 AM »
This post shows you how to make a small Ubuntu (or Debian) chroot in two ways. While the resulting system might not be very useful on its own, it serves as a minimal base on which you could install the packages that you're really interested in. I'm going to put together an Ubuntu Maverick setup on the i386 architecture, but you could configure that.

Method 1: debootstrap
Code: [Select]
apt-get install debootstrap
debootstrap --variant=minbase --arch i386 maverick /path/to/destination/ http://archive.ubuntu.com/ubuntu/
This gets you a 133MB system in /path/to/destination/, which is pretty good... but we could do better than that.

Method 2: multistrap
Code: [Select]
apt-get install multistrap
cat <<EOT >multistrap.conf
[General]
directory=/path/to/destination/
cleanup=true
retainsources=
noauth=true
unpack=true
retries=5
debootstrap=Ubuntu Updates
aptsources=Ubuntu
[Ubuntu]
packages=
source=http://archive.ubuntu.com/ubuntu
suite=maverick
EOT
multistrap -f multistrap.conf
As you can see, this method uses a config file, but you end up with 86MB. This is pretty darn small for an Ubuntu system, and I doubt it'd be directly bootable without other packages, but it makes an excellent chroot environment.

Oh yes, you might get tons of complaints from Perl while configuring new packages, since it expects locales to be generated. Run dpkg-reconfigure locales within the chroot to set that up before installing any more packages.
Oh, silly me. Of course it would not boot if you don't install a kernel ;p but that is optional if you just want a chroot or container.
« Last Edit: September 08, 2010, 02:30:33 AM by inportb »

Primefalcon

  • Hero Member
  • *****
  • Posts: 2168
  • https://launchpad.net/~primefalcon
    • View Profile
    • Prime's Tech Talk
Re: make a minimal ubuntu setup
« Reply #1 on: September 08, 2010, 03:04:13 AM »
Sweet.....
Get 2.25G of space on Dropbox by CLICKING HERE, Rather than 2G otherwise. Sync files between multiple computers, Web and even share folders with your friends!

Pinako

  • Hero Member
  • *****
  • Posts: 1263
    • View Profile
    • inportb
Re: make a minimal ubuntu setup
« Reply #2 on: September 08, 2010, 05:10:12 AM »
Actually, I just noticed that the 86MB setup does -not- include apt, which could be a problem if you intend to manipulate the installed packages post-creation. However, you are able to specify the packages you want installed, including apt. I ended up with a ~120MB system after installing apt and gnupg and removing some cruft packages.

Primefalcon

  • Hero Member
  • *****
  • Posts: 2168
  • https://launchpad.net/~primefalcon
    • View Profile
    • Prime's Tech Talk
Re: make a minimal ubuntu setup
« Reply #3 on: September 08, 2010, 09:46:41 AM »
you know, being this heavily modified, you can hardly call it Ubuntu anymore...... How about InportbOS
Get 2.25G of space on Dropbox by CLICKING HERE, Rather than 2G otherwise. Sync files between multiple computers, Web and even share folders with your friends!

Pinako

  • Hero Member
  • *****
  • Posts: 1263
    • View Profile
    • inportb
Re: make a minimal ubuntu setup
« Reply #4 on: September 10, 2010, 01:37:59 AM »
Well actually, I just got it even smaller, perhaps at the cost of performance. The idea is to make a squashfs of the resulting filesystem... and loop-mount it underneath a writable layer using AuFS. After installing what I wanted, I ended up with a 185MB image, which was totally unacceptable. Using the default squashfs options (gzip everything), I got it down to a neat 54MB. Strangely, sequential reading from a loop-mounted squashfs is actually a lot faster than reading directly from ext4fs, and I guess that's because compression cuts down on disk access; random access, on the other hand, is about the same speed. Squashfs also has a non-compressed option, which still managed to shave 30MB off the disk usage, probably because the meta-data use less space.

I ended up using Debian for my project because it's lighter-weight and does the job. The good thing about multistrap (compared to, say, debootstrap) is that it piggybacks on the host's apt, so installing apt (and dependencies) into the guest is optional. All packages can be determined at build-time, so there's no need to chroot into the guest afterwards and install more.

hsnetworks

  • Founder DeAuthThis
  • Full Member
  • ***
  • Posts: 131
  • Founder DeAuthThis
    • View Profile
    • DeAuthThis
Re: make a minimal ubuntu setup
« Reply #5 on: September 11, 2010, 11:16:35 AM »
I've used ubuntu mini to build a distro from scratch

(oh sh*t, I just remembered one thing I didn't backup before formatting, my virtualbox machines!)

Primefalcon

  • Hero Member
  • *****
  • Posts: 2168
  • https://launchpad.net/~primefalcon
    • View Profile
    • Prime's Tech Talk
Re: make a minimal ubuntu setup
« Reply #6 on: September 11, 2010, 02:21:20 PM »
I've used ubuntu mini to build a distro from scratch

(oh sh*t, I just remembered one thing I didn't backup before formatting, my virtualbox machines!)
before you do anything else, boot up a livedisk of Ubuntu and install testdisk to it and run it
Get 2.25G of space on Dropbox by CLICKING HERE, Rather than 2G otherwise. Sync files between multiple computers, Web and even share folders with your friends!

hsnetworks

  • Founder DeAuthThis
  • Full Member
  • ***
  • Posts: 131
  • Founder DeAuthThis
    • View Profile
    • DeAuthThis
Re: make a minimal ubuntu setup
« Reply #7 on: September 11, 2010, 08:28:53 PM »
Its alright I can do it all again, its just reinforcement

Richard F

  • Full Member
  • ***
  • Posts: 118
  • I'm a Gentoo man!
    • View Profile
    • rf152 - Web Development
Re: make a minimal ubuntu setup
« Reply #8 on: March 19, 2011, 01:06:48 PM »
This is quite useful actually.

I'm using the first method to fit an ubuntu onto a 256mb pen drive (I have ~1.2M free space!)