-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
Agent OSSOpen Source Software tutorials and reviews
Home About
How to create a very small Linux systemusing BuildrootPosted on
27/02/2011 by AgentOss
2 Votes
Have you ever tried to install amodern Linux distro onto asmall
capacity (usually 32megs or even less) usb driveor compact flash
card?Even with a minimal install, such a distribution will not fit!
Major Linux distros likeDebian/Slackware/Arch/etc need a bare
minimum of 300-400 megs of disk space.
The only minimal system I have been able to install so far on a
128Meg disk is NetBSD (http://www.netbsd.org ).
But there is a way to achieve such a thing : we will be using
Buildroot in order to generate a Follow
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
very small (embedded) Linux system (targeted at a standard intel
x86 computer)
In this tutorial I have used a Ubuntu 10.04 system as my build
machine.
Buildroot :
http://buildroot.uclibc.org/
Documentation :
http://buildroot.uclibc.org/buildroot.html
Prior to using it, youll have to install a development
environment on your system (GCCcompiler, Linux kernel headers, make
tools etc). On Debian/Ubuntu, this is done byinstalling packages
such as :
build-essentials
First of all, we need to download and setup Buildroot on our
build machine.
As a standard user (not root) :
# cd
# wget
http://buildroot.uclibc.org/downloads/buildroot-snapshot.tar.bz2
# tar xvjf buildroot*
# cd buildroot
Buildroot Configuration
# make menuconfig
Now you have to select some options :
My target architecture is an x86 system, optimized for Pentium
(i686). But your mileage mayvary
Target Architecture : i386
Follow Agent OSSGet every new post deliveredto your Inbox.
Powered by WordPress.com
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
Target Architecture Variant : i686
Toolchain >[X] Enable large file
System Configuration >System hostname : choose your system
nameSystem banner : anything you want[X] Generic serial port config
(can be useful)
Update 01-07-2012 :
Now you need to set
Port to run a getty (login prompt) on to tty1 instead of ttyS0,
in order to get a login promptwhen booting your generated
system!
Package Selection for the target
We select here the software packages we want to be in our
embedded system
[X] Show packages that are also provided by busybox[X]
Customize
In this example I chose the following :
- support for foreign keyboard layouts
Hardware handling >[X] kbd
- optional, but can be useful
[X] makedevs
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
- some lightweight networking apps : dropbear (SSH server) ,
thttpd (ultra small http server)
Networking applications >[X] dropbear
[X] thttpd
- I like the nano text editor too
Text editors and viewers >
[X] nano
Target filesystem options >[X] initramfs for initial ramdisk
of linux kernel
Uncheck the other options.
This way, our system files (rootfs) will be contained within the
kernel file, and loaded intoRAM by the kernel.
(note : cramfs does the same, but is older and limited to a
16Meg rootfs max.)
Bootloaders >
Uncheck everything here. We will test our image using qemu so we
dont need a bootloaderyet. If you want to put your embedded system
on a bootable USB drive, you can useSYSLINUX/EXTLINUX to make it
bootable (see here!).
Kernel >[X] Linux Kernel
Important :
in Defconfig name, enter the value : i386
it corresponds to the
linux-2.6.37/arch/x86/configs/i386_defconfig file
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
(otherwise the build system will complain that it couldnt find a
kernel configuration file).
Now select Exit to end the Buildroot configuration, save the
changes of course (Thesesettings are stored in the .config file in
the Buildroot directory).
Its time to start compiling!
# make
The first compilation will take some time, as software packages
for the toolchain and othercomponents are downloaded, extracted and
compiled on your build machine!
TIP :
If you need to configure the linux kernel for your special needs
(youll likely have to) :# make linux-menuconfig
Important especially : remember to include support for the EXT2
filesystem in your kernel, ifyou want to be able to mount EXT2
formatted devices (usb flash drive for example) fromyour embedded
system!
If everything went well, the compilation is finished and your
final system files (kernel andoptional boot and rootfs files) will
be found in the output/images sub-directory of yourBuildroot.
In our example, we can see that the obtained kernel file :
bzImage, is very small (above 5megs, with and LZMA compressed
initramfs filesystem)!
TIP
To force the complete rebuild of your embedded system :# rm -rf
output/build
# make
Testing our embedded system
We can use the QEMU emulator on our build host to do so.
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
# apt-get install qemu
# qemu -kernel output/images/bzImageThe default root login (as
generated by Buildroot) has no password. There also exists
astandard user named default (no password too).
login: rootpassword: (none)
Now you can play with your lightweight (yet somewhat limited)
sytem :
in order to start the network interface :
# ifconfig eth0
# udhcpc eth0
look at the busybox available commands :
# busybox
TIP
load a keymap :# loadkeys fr
Ok, we have a new system, but some things have to be improved in
order to make it moreusable. We are going to apply changes to the
root filesystem (rootfs) before its included inthe kernel by
Buildroots make process.
Wed like, amongst other things :- that our preferred keymap be
automatically loaded,- the network to be automatically up and
running,etc
To do that, changes will be applied in the rootfs files
contained in Buildroots output/target
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
subdir.
For the keymap :
# cd output/target
# nano etc/init.d/S99keymap
- file S99keymap #!/bin/sh
loadkeys fr- file S99keymap
# chmod 755 etc/init.d/S99keymap
AN ALTERNATIVE WAY TO DO THIS WITH BUSYBOX! :
BusyBox has internal keymap manipulation commands# dumpkmap
>etc/french.kmap
# loadkmap fr.kmap
# cp fr.kmap output/target/etc/
and then the S99keymap file contains the following line instead
:loadkmap
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
iface lo inet loopback
# automatically start eth0, with dhcpauto eth0iface eth0 inet
dhcp-
While we are at it, we can modify the etc/TZ file, in order to
have the correct timezone in ourembedded system.
Hare the TZ value below corresponds to Europe/Paris, see here
for your preferred value
:http://www.sonoracomm.com/support/20-voice-support/107-uclibc-tz
# echo "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"
>etc/TZ
SECURITY enhancements :
- Change the root password :
There maybe other ways to do the trick, but I found this one to
be working :
# apt-get install mkpasswd
# echo 'mynewpassword' | mkpasswd -s -m md5
then paste the obtained string :
$1$2VnNG40d$3SSSNXs.FfPnzlx9CMHZE/ (you willobtain another value,
this is just an example)in the output/target/etc/shadow file, like
this :
-etc/shadow
-root:$1$2VnNG40d$3SSSNXs.FfPnzlx9CMHZE/:10933:0:99999:7:::
Lets de-activate the default user login too :
modify the line :
default::10933:0:99999:7:::
into :
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
default:LK:10933:0:99999:7:::
(LK is for locked)
Other modifications (may be useful, some more testing needed!)
:
To improve device hotplug support, add the two following
lines
null::sysinit:/bin/echo /sbin/mdev
>/proc/sys/kernel/hotplugnull::sysinit:/sbin/mdev -s
in the output/target/etc/inittab file. So that it looks :
etc/inittab # Startup the systemnull::sysinit:/bin/mount -t proc
proc /procnull::sysinit:/bin/mount -o remount,rw
/null::sysinit:/bin/mkdir -p /dev/ptsnull::sysinit:/bin/echo
/sbin/mdev >/proc/sys/kernel/hotplugnull::sysinit:/sbin/mdev
-snull::sysinit:/bin/mount -anull::sysinit:/bin/hostname -F
/etc/hostname etc/inittab
Final generation of our embedded Linux system :
go back to the Buildroot directory, then
# make
TIP :
If you delete the whole output subir, your changes in the
output/target rootfs will be lost(obviously!) so it may be more
convenient to make your changes in the fs/skeleton subdir,so that
they will be used when generating the target subdir.
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
How to create a bootable Linux USB drive
using EXTLINUX
26 thoughts on How to create a very small Linux systemusing
Buildroot
Share this:
Like this:
Be the first to like this.
Like
There is still plenty of work to do in our embedded system, but
youve got the processuncovered.
This entry was posted in Howto, Linux and tagged buildroot,
embedded, lightweight, linux, smallest, system, tiny.
Bookmark the permalink.
by Gravity
Is This The Easiest GolfSwing EVER?
Titans fan who went viralgets showered with gifts
Actress loses lawsuitagainst IMDB for
If You Want To BeAwesome At Emails, Add
About these ads
Email Print Digg Facebook Reddit StumbleUpon Twitter
venkat says:
18/08/2011 at 00:45
hi,
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
I followed your procedure, but i am getting kernel panic when I
emulate using qemu.
please help me. what is your build environment?
Cheers,Venkat
Reply
AgentOss says:
18/08/2011 at 10:49
Hi
Im using a Debian 6.0 virtual machine (VirtualBox) for my
buildroot environment.
Try starting qemu with -m 256 (to emulate 256Megs of RAM). By
default qemuuses 128Megs, which might not be nough for bigger
kernels.
If that doesnt still work, please show a screen capture and your
qemu line
Reply
venkat says:
18/08/2011 at 11:43
Thank you so much for the response. I shall try that and I get
back to you .
Cheers,Venkat
Reply
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
David J says:
07/01/2012 at 07:08
Hi,I followed your steps, but in the end the qemu hangs on
starting tftpd.. After googling,it seems it didnt start console on
serial port, but I cant figure out what is the next. Theinittab
looks have the right ttyS0:
# Put a getty on the serial portttyS0::respawn:/sbin/getty -L
ttyS0 38400 vt100 # GENERIC_SERIAL
Can you help?
Reply
AgentOss says:
07/01/2012 at 13:31
Hi,
Looks like that we need to use tty1 instead of ttyS0 !
Then youll have a login prompt in your buildroot system.
Im updating this howto
Thanks & have fun!
Reply
David J says:
07/01/2012 at 17:41
Its working perfectly. This will be my starting point and look
forward to reducing thememory consumption. Do you have any
suggestion or link?
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
Thanks and have a great day!
DJ
Reply
AgentOss says:
07/01/2012 at 22:17
Good!
What are your memory requirements?
You could configure the kernel to remove unneeded drivers and
features, but thiswont give a big gain in memory consumption.
I found that a minimal buildroot generated system (no X) with
initramfs embeddedwithin the kernel needs at least 27M of RAM to
boot, not less.
If you have less RAM, you might try to generate a kernel with no
embeddedinitramfs, but then you need to create a virtual hard disk
with the root filesystem onit (when using qemu).
Reply
David J says:
08/01/2012 at 07:07
Thanks for reply.I try to get down to 10M. Generating a kernel
without initramfs seems a goodoption. How to create virtual disk
with qemu? Thanks again.
AgentOss says:
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
08/01/2012 at 21:00
In Buildroot > Filesystem Images menu :
- uncheck initramfs- check ext2 root filesystem
Then boot the system with :
qemu -kernel bzImage -append root=/dev/sda -hda rootfs.ext2
And remember to include support for ext2 fs in the kernel (not
as module), otherwisethe kernel wont be able to mount the
rootfs.
Still cant boot with less than 24Mb of RAM!
This is because the kernel needs this to decompress itself. We
could try with anuncompressed kernel (but so far I dont know how to
obtain it)
Or you may try with an older 2.6.27.58 kernel, with it I could
boot on a 16Mb system!
Reply
stewe says:
05/02/2012 at 21:12
hi
how it is possible that you have eth0 device present in the
system? I do it by virtualboxand there is only lo device and sit0,
i do the same with qemu but theres no eth0 at all what should i do
in order to setup networking? thx
Reply
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
AgentOss says:
05/02/2012 at 21:29
Hi,
Have you configured your kernel with the ethernet drivers?
(include them all indoubt)
Also, paste your dmesg to pastebin and give us the link here so
we can see whatshappening
Reply
stewe says:
05/02/2012 at 23:44
ive got it, i had to compile some additional network driver to
the kernel(Intel(R) 82575/82576 PCI-Express Gigabit Ethernet
support + Intel(R) 82576Virtual Function Ethernet support) and
switch network adapter in vmwaresetting like Intel PRO/1000 MT
Desktop (82540EM) under network adapter 1 advanced settings
Peter says:
18/01/2013 at 16:05
I tried to preapre my own linux by buildroot but after changed
of ttyS0 to ttyS1 I stillcannot see login promt, it hangs after
dropbear dsa key generated. I didnt add thttpd. Ihave tried to
change baudrate and ttyS to higher but after two days of compiling
mykernel still hangs after dropbear
Reply
AgentOss says:
18/01/2013 at 18:08
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
It should be tty1, not ttyS1 (S is for serial port)
Reply
Peter says:
18/01/2013 at 18:33
OMG, you are a GOD, what a stupid mistake.
Thank You!
Reply
Antoine says:
12/02/2013 at 15:38
Hi, I tried your tutorial, but buildroot fails at building
host-m4 :make[1]: Entering directory
`/home/antoine/buildroot-2012.11.1/output/build/host-m4-1.4.16
make[1]: warning: -jN forced in submake: disabling jobserver
mode.make[1]: *** INTERNAL: readdir: Not a directory. Stop.make[1]:
maint.mk: Field stem not cached: maint.mk
make[1]: Leaving directory
`/home/antoine/buildroot-2012.11.1/output/build/host-m4-1.4.16
I tried to use google, but I could not figure out what was
wrong
Reply
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
AgentOss says:
12/02/2013 at 18:03
Hi, sorry I dont know about that.
The best thing to do would be to ask in the official Buildroot
mailing lists!
Reply
xsmos says:
18/02/2013 at 18:47
I said I followed your tutorial to the letter but the launch of
the initramfs image with thelaunch qemu hangs a thttpd server
initializationmy config is as followsLubuntu 12.04 X64Intel core
I36 giga ramplease help me thank you
Reply
AgentOss says:
18/02/2013 at 19:01
maybe a problem with tty1 not enabled (see the other comments
above)
Reply
Peter says:
03/03/2013 at 12:31
Hi,
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
How can I build a system with buildroot which will be remember
changes which I madeon harddrive? So it will remember changes which
I made in rootfs.cpio filesystem, or itwill remember that Ive added
some new software.
Regards,Piotr
Reply
AgentOss says:
03/03/2013 at 14:31
Hi, I havent experimented that kind of things yet But look at
Slitaz, or even Slax.They have different mechanisms to do what you
are looking for
Reply
Albert says:
06/04/2013 at 09:17
after the configuration and when i excute the make command i get
this error message:
2013-04-06 08:12:51
http://ftp.gnu.org/pub/gnu/gmp/gmp-5.0.2.tar.bz2Connecting to
192.168.110.80:8080 failed: Connection timed out.Retrying.
2013-04-06 08:13:13 (try: 2)
http://ftp.gnu.org/pub/gnu/gmp/gmp-5.0.2.tar.bz2Connecting to
192.168.110.80:8080 failed: Connection timed out.Retrying.
2013-04-06 08:13:36 (try: 3)
http://ftp.gnu.org/pub/gnu/gmp/gmp-5.0.2.tar.bz2Connecting to
192.168.110.80:8080 failed: Connection timed out.Giving up.
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
2013-04-06 08:13:57
http://sources.buildroot.net//gmp-5.0.2.tar.bz2Connecting to
192.168.110.80:8080 failed: Connection timed out.Retrying.
2013-04-06 08:14:19 (try: 2)
http://sources.buildroot.net//gmp-5.0.2.tar.bz2Connecting to
192.168.110.80:8080 failed: Connection timed out.Retrying.
2013-04-06 08:14:42 (try: 3)
http://sources.buildroot.net//gmp-5.0.2.tar.bz2Connecting to
192.168.110.80:8080 failed: Connection timed out.Giving up.
Reply
AgentOss says:
06/04/2013 at 12:21
It looks like you are behind a proxy that prevents you from
downloading Check your network / ask your sysadmin!
Reply
Albert says:
06/04/2013 at 22:21
when i excute:# qemu -kernel output/images/bzImage
i get this message :
pci_add_option_rom: failed to find romfile pxe-rtl8139.bin
Reply
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
Recent Posts
Wifi repeater/range extender script
Debian 6.0 (Squeeze) on the Xplore iX104C3 rugged Tablet PC
Debian Wheezy and systemd
Home mail server with Postfix + Dovecot (IMAP) +
Squirrelmail/Roundcube on NetBSD 6.0.1
Wireless Ad-hoc server script
Leave a Reply
Alfred says:
10/04/2013 at 09:26
when i excute ifconfig eth0ifconfig eth0 error fetching
interface information device not found
Reply
AgentOss says:
10/04/2013 at 18:23
Maybe your ethernet driver (module) is missing. Verify that you
have it in yourkernel config.
Reply
Enter your comment here...
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
Categories
Arch
Bash scripts
BSD
Debian
Howto
Linux
Mageia
Tags
Archives
Select Month
Links
BSD Guides
Distrowatch
HowtoForge
LinuxQuestions
Mageia Linux
nixCraft
3130 access point AMD apache arch backtrack bootable bootloader
brazos bridge buildroot busybox
compact flash compilation configuration crux debian desktop
distro DM1 drive e-350 embeddedextlinux fast boot fedora fglrx g4
hardware hibernation hotspot ibm imac g3 install KDE kernel
laptoplightweight linux macintosh mageia mandriva mp3 netbook
netboot netinstall old computer openbsdopensuse package manager
pclinuxos player ports powermac powerpc recycled review server
simple
smallest sony vaio syslinux system thinkpad 365x tiny touchpad
ubuntu usb wifi windows wireless x xfcexorg zacate
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
February 2011
M T W T F S S
Mar
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 2627
28
Enter your email address to follow this blog and receive
notifications of new posts by email.
Join 15 other followers
Follow Blog via Email
RSS
RSS - Posts
RSS - Comments
-
How to create a very small Linux system using Buildroot | Agent
OSS
http://agentoss.wordpress.com/2011/02/27/how-to-create-a-very-small-linux-system-using-buildroot/[23/7/2013
14:30:39]
Blog at WordPress.com. | The Able Theme.
wordpress.comHow to create a very small Linux system using
Buildroot | Agent OSS
N0ZW0tdXNpbmctYnVpbGRyb290LwA=: form3: email: Enter your email
addressinput0: comment:
N0ZW0tdXNpbmctYnVpbGRyb290LwA=: form0: s: submit:
N0ZW0tdXNpbmctYnVpbGRyb290LwA=: archive-dropdown:
N0ZW0tdXNpbmctYnVpbGRyb290LwA=: form2: email: input13: