SlideShare a Scribd company logo
1 of 34
Download to read offline
Embedded Linux
MiniOS for X86
Information Technology Institute (ITI)
Sherif Mousa
Embedded Linux @ Information Technology Institute 1
Embedded Linux @ Information Technology Institute 2
3
Introduction
Embedded Linux @ Information Technology Institute
Introduction
• This tutorial will show you how to create your
own "Minimal Linux Distribution" on a USB Flash
memory.
• You will learn about:
– The FHS (Filesystem Hierarchy Standard).
– Linux minimal common commands that make the
system start and operate well
– How to deal with Grub bootloader (install, edit conf)
– How to use the Linux kernel
– Dealing with some root commands (mount,
mkfs.ext2, grub-install)
4Embedded Linux @ Information Technology Institute
Prerequisites
• You will need to install these packages first
on Ubuntu
sudo apt-get update
sudo apt-get install ncurses-dev bison texinfo
flex vim
• You should be good in working with at least
one Linux distribution like UBUNTU, and can
understand the command you write and its
options.
5Embedded Linux @ Information Technology Institute
Basic Linux Structure
• Boot Loader to start the system from its storage media.
• Linux Kernel image with or without initram filesystem
(initrd.img).
• Root Filesystem (main directories and sub directories).
• Configuration files and startup scripts in the (/etc)
directory.
• Essential Linux commands needed for system to operate
well.
• C & GCC Shared Libraries needed for any C or C++
application to run.
• GUI system or not.
• Extra Programs.
6Embedded Linux @ Information Technology Institute
7
Root FileSystem /
Embedded Linux @ Information Technology Institute
Creating Root Filesystem /
• Open a new Terminal, you will be right now inside your
home directory. Assume that the user name currently
running is (shatrix), you will be in: /home/shatrix
• Create any directory to contain the whole OS files and
enter it
mkdir minios
cd minios
mkdir tools system
cd system
• Now you are in:
– /home/shatrix/minios/system
8Embedded Linux @ Information Technology Institute
Creating Root Filesystem /
• Execute these commands:
– mkdir bin boot dev etc lib proc root sbin media
sys tmp var usr
– mkdir usr/bin usr/sbin usr/lib
– chmod 1777 tmp
• Now you have the main filesystem directories
to contain the whole system.
9Embedded Linux @ Information Technology Institute
10
Configuration Files
Embedded Linux @ Information Technology Institute
Conf Files & Startup Scripts
• Inside (/etc), create these files & fill them with
these contents:
• gedit group
– copy and paste this line inside it:
root:x:0:
• gedit passwd
– copy and paste this line inside it:
root:x:0:0:root:/root:/bin/sh
• gedit shadow
– copy and paste this line inside it:
root::10:0:0:0:::
11Embedded Linux @ Information Technology Institute
Conf Files & Startup Scripts
• gedit inittab
null::sysinit:/bin/mount -t proc proc /proc
null::sysinit:/bin/mkdir -p /dev/pts
null::sysinit:/bin/mount –a
null::sysinit:/sbin/ifconfig lo 127.0.0.1 up
::sysinit:/etc/rc
tty1::respawn:/sbin/getty 38400 tty1
null::shutdown:/bin/umount -a -r
12Embedded Linux @ Information Technology Institute
Conf Files & Startup Scripts
• gedit rc
#!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
/sbin/hwclock -s
/bin/hostname EmbeddedLinuxMiniOS
/bin/echo " "
/bin/echo " Y A T T A "
/bin/echo " My First Embedded Linux "
/bin/echo " "
• chmod +x rc
13Embedded Linux @ Information Technology Institute
Conf Files & Startup Scripts
• gedit profile
export PS1='EmbeddedLinuxMiniOS #'
export USER=`id -un`
export HISTSIZE=1000
echo "ya welcome ya welcome ^__^"
echo " "
• After Finishing back to the main dir:
– /home/shatrix/minios/system
14Embedded Linux @ Information Technology Institute
15
Linux Kernel
Embedded Linux @ Information Technology Institute
Linux Kernel
• To make your own Linux kernel is not easy like
1 2 3…
• Now, we can just use the Linux kernel already
exists in our Ubuntu distribution.
• So, copy the kernel & initrd files from /boot:
cp /boot/vmlinuz-3.2.0-57-generic-pae boot/
cp /boot/initrd.img-3.2.0-57-generic-pae boot/
16Embedded Linux @ Information Technology Institute
17
Linux Basic Commands
Embedded Linux @ Information Technology Institute
Linux Commands
• Any Linux distribution need some basic
commands to operate correctly, like (mount,
ls, pwd, ifconfig, cd, mkdir, touch, file, rm, vi)
and more. We need these commands, so
there are two ways to get them:
– Getting the source code for each command
needed, compile it separately and copy it to any
bin directory inside the distribution.
– Using BusyBox.
18Embedded Linux @ Information Technology Institute
Linux Commands (BusyBox)
• BusyBox combines tiny versions of many common
UNIX utilities into a single small executable. It provides
replacements for most of the utilities you usually find
in GNU fileutils, shellutils, etc. The utilities in BusyBox
generally have fewer options than their full-featured
GNU cousins; however, the options that are included
provide the expected functionality and behave very
much like their GNU counterparts. BusyBox provides a
fairly complete environment for any small or
embedded system.
• Get Busybox:
https://launchpad.net/ubuntu/precise/+source/busybox/
1:1.18.5-1ubuntu4.1/+files/busybox_1.18.5.orig.tar.bz2
19Embedded Linux @ Information Technology Institute
BusyBox
• Put the tar file in your /home/shatrix/minios/tools dir and
open a new Terminal and go to this dir:
– tar xvf busybox_1.18.5.orig.tar.bz2
– cd busybox_1.18.5/
• Configure Busybox as required:
– make defconfig
– make menuconfig
• The command (make menuconfig) will open a GUI
terminal-based configuration for the BusyBox program, you
can choose what to be installed and what not to be
installed, or you can just choose to exit this configuration
and remember to save your configuration settings on exit.
20Embedded Linux @ Information Technology Institute
BusyBox Configuration
• menuconfig
21Embedded Linux @ Information Technology Institute
BusyBox Build
• Then execute this command to compile and install BusyBox
inside our system:
make CONFIG_PREFIX=/home/shatrix/minios/system install
• After finishing, close this Terminal and get back to the main
Terminal and execute these commands
ls bin
ls sbin
• You will see that the commands have been installed inside
the binary directories of our system. Also you need to know
that all these commands are linked to one executable file
named busybox inside /bin and all these commands shown
are just symbolic links to that command.
22Embedded Linux @ Information Technology Institute
C & GCC Libraries
cp -d /lib/i386-linux-gnu/ld-* /lib/i386-
linux-gnu/libc-2* /lib/i386-linux-
gnu/libcrypt* /lib/i386-linux-gnu/libc.so*
/lib/i386-linux-gnu/libdl* /lib/i386-linux-
gnu/libgcc_s* /lib/i386-linux-gnu/libm.so*
/lib/i386-linux-gnu/libm-2* /lib/i386-linux-
gnu/libpthread* /lib/i386-linux-
gnu/libresolv* /lib/i386-linux-gnu/librt*
/lib/i386-linux-gnu/libutil* .
23Embedded Linux @ Information Technology Institute
24
Boot Loader
Embedded Linux @ Information Technology Institute
Boot Loader
• Till now this system can run on any x86 cpu,
and it can be copied to any storage (Flash
memory, partition, CD) to be a stand alone
operating system.
• Now, we just need a bootloader to start the
system.
• We can use the bootloader already installed
on UBUNTU (grub).
25Embedded Linux @ Information Technology Institute
Boot Loader (Grub)
• We will use the grub already installed in our Linux
distribution, we just need to write the grub
configuration file manually.
• grub.cfg:
– This is a text file contains the menu entries or the list of
operating systems that grub should list them when the
computer starts. We will create it manually.
– Go to the PATH of our system
– Create (boot/grub) dir
– Create (boot/grub/grub.cfg) file
cd /home/shatrix/minios/system
mkdir boot/grub
gedit boot/grub/grub.cfg
Boot Loader (Grub)
• copy and paste these lines in the grub.cfg file
set menu_color_normal=yellow/red
set menu_color_highlight=black/light-gray
menuentry 'LINUX MiniOS FOR X86' {
set root=(hd0,1)
linux /boot/vmlinuz-3.2.0-57-generic-pae
root=UUID=<disk-uuid> rw
initrd /boot/initrd.img-3.2.0-57-generic-pae
}
• The red text <disk-uuid> will be replaced with
a value after that, don’t forget.
28
Install The Final MiniOS
Embedded Linux @ Information Technology Institute
Putting System on Flash
• Plug the USB Flash in, It will take a name like that sdx.
• First we need to format and partition it, from Terminal run
these commands only if you are sure about the flash device
name:
– sudo umount /media/flash-disk-mounted-folder
– sudo mkfs.ext2 /dev/sdx1
• If you have one hard disk and you have connected only one
flash disk, it will take the name sdb, the command should
be:
• sudo mkfs.ext2 /dev/sdb1
• Then mount the flash back again
– sudo mkdir /media/flash
– sudo mount /dev/sdb1 /media/flash
Putting System on Flash
• Copy all the OS files from the
</home/shatrix/minios/system> to the
mounted partition.
– cd /home/shatrix/minios/system
– cp -a * /media/flash
• Finally install grub to the Flash device:
sudo grub-install --root-directory=/media/flash /dev/sdb
• Remember that the sdb will be the Flash disk
device name in /dev, and /media/flash is the
directory where the flash disk is mounted
Editing grub.cfg (UUID)
• To get the UUID for any partition or Flash:
– sudo blkid
• copy the UUID for the required device and
paste it in its correct place in the grub.cfg file
on the Flash memory.
– sudo gedit /media/flash/boot/grub/grub.cfg
• In the kernel line (root=UUID=<disk-
uuid>)
• make it ( root=UUID=the-result-uuid-from-blkid )
Congratulations ^__^
• If you make all these steps as it is, your flash memory
can now boot with the new Linux OS.
• Restart your computer, and select to boot from the
USB flash from your BIOS settings.
• The Grub from the Flash memory should start now,
with one selection:
– (LINUX Minimal OS FOR X86)
• Press Enter to start the system, and enjoy.
• When the system starts, go to the first console by
typing Ctrl+Alt+F1 ,it will ask for login, type ( root ) and
press enter, the system will start without asking for
password.
32Embedded Linux @ Information Technology Institute
33Embedded Linux @ Information Technology Institute
eng.sherif.mosa@gmail.com
http://about.me/shatrix
34Embedded Linux @ Information Technology Institute

More Related Content

What's hot

Yocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerYocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerSherif Mousa
 
Introduction to yocto
Introduction to yoctoIntroduction to yocto
Introduction to yoctoAlex Gonzalez
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoSherif Mousa
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/CoreShay Cohen
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMSherif Mousa
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Jian-Hong Pan
 
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...The Linux Foundation
 
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM SystemsXPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM SystemsThe Linux Foundation
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumScyllaDB
 
[오픈소스컨설팅]Virtualization kvm-rhev
[오픈소스컨설팅]Virtualization kvm-rhev[오픈소스컨설팅]Virtualization kvm-rhev
[오픈소스컨설팅]Virtualization kvm-rhevJi-Woong Choi
 
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...The Linux Foundation
 
Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)Novell
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveAlison Chaiken
 

What's hot (20)

The kvm virtualization way
The kvm virtualization wayThe kvm virtualization way
The kvm virtualization way
 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
Yocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerYocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution Maker
 
Introduction to yocto
Introduction to yoctoIntroduction to yocto
Introduction to yocto
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to Yocto
 
systemd
systemdsystemd
systemd
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
 
Toolchain
ToolchainToolchain
Toolchain
 
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM SystemsXPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
XPDDS18: CPUFreq in Xen on ARM - Oleksandr Tyshchenko, EPAM Systems
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in Cilium
 
[오픈소스컨설팅]Virtualization kvm-rhev
[오픈소스컨설팅]Virtualization kvm-rhev[오픈소스컨설팅]Virtualization kvm-rhev
[오픈소스컨설팅]Virtualization kvm-rhev
 
4. linux file systems
4. linux file systems4. linux file systems
4. linux file systems
 
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
Rootlinux17: Hypervisors on ARM - Overview and Design Choices by Julien Grall...
 
LFCollab14: Xen vs Xen Automotive
LFCollab14: Xen vs Xen AutomotiveLFCollab14: Xen vs Xen Automotive
LFCollab14: Xen vs Xen Automotive
 
Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)
 
Automated deployment
Automated deploymentAutomated deployment
Automated deployment
 
Systemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to loveSystemd: the modern Linux init system you will learn to love
Systemd: the modern Linux init system you will learn to love
 

Viewers also liked

linux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixlinux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixSherif Mousa
 
Linux Porting to a Custom Board
Linux Porting to a Custom BoardLinux Porting to a Custom Board
Linux Porting to a Custom BoardPatrick Bellasi
 
Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionSherif Mousa
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
Device tree support on arm linux
Device tree support on arm linuxDevice tree support on arm linux
Device tree support on arm linuxChih-Min Chao
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013Wave Digitech
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device driversHoucheng Lin
 
Embedded linux system development (slides)
Embedded linux system development (slides)Embedded linux system development (slides)
Embedded linux system development (slides)Jaime Barragan
 
U-Boot community analysis
U-Boot community analysisU-Boot community analysis
U-Boot community analysisxulioc
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 
Building Embedded Linux
Building Embedded LinuxBuilding Embedded Linux
Building Embedded LinuxSherif Mousa
 
Intervista a Lorena Cecchini di ISPRA TV
Intervista a Lorena Cecchini di ISPRA TVIntervista a Lorena Cecchini di ISPRA TV
Intervista a Lorena Cecchini di ISPRA TVPaola Vaccaro
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_BootingRashila Rr
 
Tutorial membangun linux from scratch dari awal
Tutorial membangun linux from scratch dari awalTutorial membangun linux from scratch dari awal
Tutorial membangun linux from scratch dari awalMuhammad Dzulfikri
 
Embedded Linux Talk Uni Forum
Embedded Linux Talk Uni ForumEmbedded Linux Talk Uni Forum
Embedded Linux Talk Uni ForumSumant Diwakar
 

Viewers also liked (20)

linux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixlinux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrix
 
Linux Porting to a Custom Board
Linux Porting to a Custom BoardLinux Porting to a Custom Board
Linux Porting to a Custom Board
 
Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems Introduction
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Embedded Linux
Embedded LinuxEmbedded Linux
Embedded Linux
 
Device tree support on arm linux
Device tree support on arm linuxDevice tree support on arm linux
Device tree support on arm linux
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
Board Bringup
Board BringupBoard Bringup
Board Bringup
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
Embedded linux system development (slides)
Embedded linux system development (slides)Embedded linux system development (slides)
Embedded linux system development (slides)
 
U-Boot community analysis
U-Boot community analysisU-Boot community analysis
U-Boot community analysis
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
Building Embedded Linux
Building Embedded LinuxBuilding Embedded Linux
Building Embedded Linux
 
Intervista a Lorena Cecchini di ISPRA TV
Intervista a Lorena Cecchini di ISPRA TVIntervista a Lorena Cecchini di ISPRA TV
Intervista a Lorena Cecchini di ISPRA TV
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
Tutorial membangun linux from scratch dari awal
Tutorial membangun linux from scratch dari awalTutorial membangun linux from scratch dari awal
Tutorial membangun linux from scratch dari awal
 
Building
BuildingBuilding
Building
 
Paper5
Paper5Paper5
Paper5
 
Embedded Linux Talk Uni Forum
Embedded Linux Talk Uni ForumEmbedded Linux Talk Uni Forum
Embedded Linux Talk Uni Forum
 
Linux Mint
Linux MintLinux Mint
Linux Mint
 

Similar to Building Mini Embedded Linux System for X86 Arch

Similar to Building Mini Embedded Linux System for X86 Arch (20)

Linux basics
Linux basics Linux basics
Linux basics
 
Linux
Linux Linux
Linux
 
Root file system for embedded systems
Root file system for embedded systemsRoot file system for embedded systems
Root file system for embedded systems
 
Linux basics
Linux basics Linux basics
Linux basics
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linux
LinuxLinux
Linux
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux
LinuxLinux
Linux
 
Linux directory structure by jitu mistry
Linux directory structure by jitu mistryLinux directory structure by jitu mistry
Linux directory structure by jitu mistry
 
Linux Operating System
Linux Operating SystemLinux Operating System
Linux Operating System
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
beginner.en.print
beginner.en.printbeginner.en.print
beginner.en.print
 
beginner.en.print
beginner.en.printbeginner.en.print
beginner.en.print
 
beginner.en.print
beginner.en.printbeginner.en.print
beginner.en.print
 
Introduction to Operating Systems.pptx
Introduction to Operating Systems.pptxIntroduction to Operating Systems.pptx
Introduction to Operating Systems.pptx
 
Crafting GNU/Linux distributions for Embedded target from Scratch/Source
Crafting GNU/Linux distributions for Embedded target from Scratch/SourceCrafting GNU/Linux distributions for Embedded target from Scratch/Source
Crafting GNU/Linux distributions for Embedded target from Scratch/Source
 
Linux introduction (eng)
Linux introduction (eng)Linux introduction (eng)
Linux introduction (eng)
 
Lamp ppt
Lamp pptLamp ppt
Lamp ppt
 

More from Sherif Mousa

More from Sherif Mousa (7)

Android Session "g | Canal Cities" event
Android Session "g | Canal Cities" eventAndroid Session "g | Canal Cities" event
Android Session "g | Canal Cities" event
 
كيف تفشل
كيف تفشلكيف تفشل
كيف تفشل
 
Operating systems Basics
Operating systems BasicsOperating systems Basics
Operating systems Basics
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
003 scripting
003 scripting003 scripting
003 scripting
 
001 linux revision
001 linux revision001 linux revision
001 linux revision
 
Smile
SmileSmile
Smile
 

Recently uploaded

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Recently uploaded (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Building Mini Embedded Linux System for X86 Arch

  • 1. Embedded Linux MiniOS for X86 Information Technology Institute (ITI) Sherif Mousa Embedded Linux @ Information Technology Institute 1
  • 2. Embedded Linux @ Information Technology Institute 2
  • 3. 3 Introduction Embedded Linux @ Information Technology Institute
  • 4. Introduction • This tutorial will show you how to create your own "Minimal Linux Distribution" on a USB Flash memory. • You will learn about: – The FHS (Filesystem Hierarchy Standard). – Linux minimal common commands that make the system start and operate well – How to deal with Grub bootloader (install, edit conf) – How to use the Linux kernel – Dealing with some root commands (mount, mkfs.ext2, grub-install) 4Embedded Linux @ Information Technology Institute
  • 5. Prerequisites • You will need to install these packages first on Ubuntu sudo apt-get update sudo apt-get install ncurses-dev bison texinfo flex vim • You should be good in working with at least one Linux distribution like UBUNTU, and can understand the command you write and its options. 5Embedded Linux @ Information Technology Institute
  • 6. Basic Linux Structure • Boot Loader to start the system from its storage media. • Linux Kernel image with or without initram filesystem (initrd.img). • Root Filesystem (main directories and sub directories). • Configuration files and startup scripts in the (/etc) directory. • Essential Linux commands needed for system to operate well. • C & GCC Shared Libraries needed for any C or C++ application to run. • GUI system or not. • Extra Programs. 6Embedded Linux @ Information Technology Institute
  • 7. 7 Root FileSystem / Embedded Linux @ Information Technology Institute
  • 8. Creating Root Filesystem / • Open a new Terminal, you will be right now inside your home directory. Assume that the user name currently running is (shatrix), you will be in: /home/shatrix • Create any directory to contain the whole OS files and enter it mkdir minios cd minios mkdir tools system cd system • Now you are in: – /home/shatrix/minios/system 8Embedded Linux @ Information Technology Institute
  • 9. Creating Root Filesystem / • Execute these commands: – mkdir bin boot dev etc lib proc root sbin media sys tmp var usr – mkdir usr/bin usr/sbin usr/lib – chmod 1777 tmp • Now you have the main filesystem directories to contain the whole system. 9Embedded Linux @ Information Technology Institute
  • 10. 10 Configuration Files Embedded Linux @ Information Technology Institute
  • 11. Conf Files & Startup Scripts • Inside (/etc), create these files & fill them with these contents: • gedit group – copy and paste this line inside it: root:x:0: • gedit passwd – copy and paste this line inside it: root:x:0:0:root:/root:/bin/sh • gedit shadow – copy and paste this line inside it: root::10:0:0:0::: 11Embedded Linux @ Information Technology Institute
  • 12. Conf Files & Startup Scripts • gedit inittab null::sysinit:/bin/mount -t proc proc /proc null::sysinit:/bin/mkdir -p /dev/pts null::sysinit:/bin/mount –a null::sysinit:/sbin/ifconfig lo 127.0.0.1 up ::sysinit:/etc/rc tty1::respawn:/sbin/getty 38400 tty1 null::shutdown:/bin/umount -a -r 12Embedded Linux @ Information Technology Institute
  • 13. Conf Files & Startup Scripts • gedit rc #!/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH /sbin/hwclock -s /bin/hostname EmbeddedLinuxMiniOS /bin/echo " " /bin/echo " Y A T T A " /bin/echo " My First Embedded Linux " /bin/echo " " • chmod +x rc 13Embedded Linux @ Information Technology Institute
  • 14. Conf Files & Startup Scripts • gedit profile export PS1='EmbeddedLinuxMiniOS #' export USER=`id -un` export HISTSIZE=1000 echo "ya welcome ya welcome ^__^" echo " " • After Finishing back to the main dir: – /home/shatrix/minios/system 14Embedded Linux @ Information Technology Institute
  • 15. 15 Linux Kernel Embedded Linux @ Information Technology Institute
  • 16. Linux Kernel • To make your own Linux kernel is not easy like 1 2 3… • Now, we can just use the Linux kernel already exists in our Ubuntu distribution. • So, copy the kernel & initrd files from /boot: cp /boot/vmlinuz-3.2.0-57-generic-pae boot/ cp /boot/initrd.img-3.2.0-57-generic-pae boot/ 16Embedded Linux @ Information Technology Institute
  • 17. 17 Linux Basic Commands Embedded Linux @ Information Technology Institute
  • 18. Linux Commands • Any Linux distribution need some basic commands to operate correctly, like (mount, ls, pwd, ifconfig, cd, mkdir, touch, file, rm, vi) and more. We need these commands, so there are two ways to get them: – Getting the source code for each command needed, compile it separately and copy it to any bin directory inside the distribution. – Using BusyBox. 18Embedded Linux @ Information Technology Institute
  • 19. Linux Commands (BusyBox) • BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system. • Get Busybox: https://launchpad.net/ubuntu/precise/+source/busybox/ 1:1.18.5-1ubuntu4.1/+files/busybox_1.18.5.orig.tar.bz2 19Embedded Linux @ Information Technology Institute
  • 20. BusyBox • Put the tar file in your /home/shatrix/minios/tools dir and open a new Terminal and go to this dir: – tar xvf busybox_1.18.5.orig.tar.bz2 – cd busybox_1.18.5/ • Configure Busybox as required: – make defconfig – make menuconfig • The command (make menuconfig) will open a GUI terminal-based configuration for the BusyBox program, you can choose what to be installed and what not to be installed, or you can just choose to exit this configuration and remember to save your configuration settings on exit. 20Embedded Linux @ Information Technology Institute
  • 21. BusyBox Configuration • menuconfig 21Embedded Linux @ Information Technology Institute
  • 22. BusyBox Build • Then execute this command to compile and install BusyBox inside our system: make CONFIG_PREFIX=/home/shatrix/minios/system install • After finishing, close this Terminal and get back to the main Terminal and execute these commands ls bin ls sbin • You will see that the commands have been installed inside the binary directories of our system. Also you need to know that all these commands are linked to one executable file named busybox inside /bin and all these commands shown are just symbolic links to that command. 22Embedded Linux @ Information Technology Institute
  • 23. C & GCC Libraries cp -d /lib/i386-linux-gnu/ld-* /lib/i386- linux-gnu/libc-2* /lib/i386-linux- gnu/libcrypt* /lib/i386-linux-gnu/libc.so* /lib/i386-linux-gnu/libdl* /lib/i386-linux- gnu/libgcc_s* /lib/i386-linux-gnu/libm.so* /lib/i386-linux-gnu/libm-2* /lib/i386-linux- gnu/libpthread* /lib/i386-linux- gnu/libresolv* /lib/i386-linux-gnu/librt* /lib/i386-linux-gnu/libutil* . 23Embedded Linux @ Information Technology Institute
  • 24. 24 Boot Loader Embedded Linux @ Information Technology Institute
  • 25. Boot Loader • Till now this system can run on any x86 cpu, and it can be copied to any storage (Flash memory, partition, CD) to be a stand alone operating system. • Now, we just need a bootloader to start the system. • We can use the bootloader already installed on UBUNTU (grub). 25Embedded Linux @ Information Technology Institute
  • 26. Boot Loader (Grub) • We will use the grub already installed in our Linux distribution, we just need to write the grub configuration file manually. • grub.cfg: – This is a text file contains the menu entries or the list of operating systems that grub should list them when the computer starts. We will create it manually. – Go to the PATH of our system – Create (boot/grub) dir – Create (boot/grub/grub.cfg) file cd /home/shatrix/minios/system mkdir boot/grub gedit boot/grub/grub.cfg
  • 27. Boot Loader (Grub) • copy and paste these lines in the grub.cfg file set menu_color_normal=yellow/red set menu_color_highlight=black/light-gray menuentry 'LINUX MiniOS FOR X86' { set root=(hd0,1) linux /boot/vmlinuz-3.2.0-57-generic-pae root=UUID=<disk-uuid> rw initrd /boot/initrd.img-3.2.0-57-generic-pae } • The red text <disk-uuid> will be replaced with a value after that, don’t forget.
  • 28. 28 Install The Final MiniOS Embedded Linux @ Information Technology Institute
  • 29. Putting System on Flash • Plug the USB Flash in, It will take a name like that sdx. • First we need to format and partition it, from Terminal run these commands only if you are sure about the flash device name: – sudo umount /media/flash-disk-mounted-folder – sudo mkfs.ext2 /dev/sdx1 • If you have one hard disk and you have connected only one flash disk, it will take the name sdb, the command should be: • sudo mkfs.ext2 /dev/sdb1 • Then mount the flash back again – sudo mkdir /media/flash – sudo mount /dev/sdb1 /media/flash
  • 30. Putting System on Flash • Copy all the OS files from the </home/shatrix/minios/system> to the mounted partition. – cd /home/shatrix/minios/system – cp -a * /media/flash • Finally install grub to the Flash device: sudo grub-install --root-directory=/media/flash /dev/sdb • Remember that the sdb will be the Flash disk device name in /dev, and /media/flash is the directory where the flash disk is mounted
  • 31. Editing grub.cfg (UUID) • To get the UUID for any partition or Flash: – sudo blkid • copy the UUID for the required device and paste it in its correct place in the grub.cfg file on the Flash memory. – sudo gedit /media/flash/boot/grub/grub.cfg • In the kernel line (root=UUID=<disk- uuid>) • make it ( root=UUID=the-result-uuid-from-blkid )
  • 32. Congratulations ^__^ • If you make all these steps as it is, your flash memory can now boot with the new Linux OS. • Restart your computer, and select to boot from the USB flash from your BIOS settings. • The Grub from the Flash memory should start now, with one selection: – (LINUX Minimal OS FOR X86) • Press Enter to start the system, and enjoy. • When the system starts, go to the first console by typing Ctrl+Alt+F1 ,it will ask for login, type ( root ) and press enter, the system will start without asking for password. 32Embedded Linux @ Information Technology Institute
  • 33. 33Embedded Linux @ Information Technology Institute