0% found this document useful (0 votes)
15 views45 pages

Chapter+3+ +Linux+and+Ecology

Uploaded by

emyrkaroui123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views45 pages

Chapter+3+ +Linux+and+Ecology

Uploaded by

emyrkaroui123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Introduction to the Linux Ecology HOWTO

Benefits from Embedded Linux Systems

1
Contents
Introduction Useful resources
Reducing power consumption Conclusions
Reducing consumables
Using computers longer
Small GNU/Linux
distributions
Reducing storage space
Other uses of older
computers

2
Answer
Windows and Destruction of our Environment!
Each new version of Windows at least doubles the RAM, disk space
and CPU power requirements. There are parts of the system that you
cannot remove, even if you don't use them.
This is particularly true with Windows Vista, which is said to obsolete
50% of existing business PCs when it came out.
You have to replace your computer to use the latest OS and software.
Manufacturing new computers consumes a lot of materials and
discarding less recent ones generate toxic waste that has to be
processed with very special care.

3
The Linux Ecology Howto
http://computerecology.org/
http://www.tldp.org/HOWTO/Ecology-HOWTO/
Started in 1999 by Werner Heuser, the creator of
TuxMobil
(http://tuxmobil.org/), a website gathering resources
for mobile GNU/Linux users (notebooks, phones and
PDAs).
Contributions from Wade Hampton and from other
community members (and maybe one day from you
too!).

4
Free Electrons contributions
Free Electrons contributions to the Linux Ecology
HOWTO:
Updates: updated resources and removed obsolete
ones.
Added new useful resources from Embedded Linux
projects.
Creating this overview presentation.
Many more details and ideas found on the HOWTO!

5
Switch off your computer
Switch off your computer whenever you do not use it!
It's not because your computer never crashes or is very resistant
to attacks from the Internet that you should always keep it on!
Switching off your computer at night and during meal breaks
can bring substantial power savings (roughly 2/3).
System administrators: you could force automatic sleep and
wakeup through the network (useful for managing nightly
backups).
Benefits: energy consumption and costs, longer computer life.

6
Hibernate to disk (1)
Use Hibernate to disk instead of shutting down your system
Doesn't work on very old computers without ACPI support.
Booting up is much faster.
No need to wait for services and graphics to start up.
Most of the time is saved by getting back to your work
as you left it before suspending your computer (open files,
terminals, browser windows). No need to re-open everything!
Very useful too when you replace the battery of a laptop.
Unlike Suspend to RAM, your computer can stay off and even
without a power supply as long as needed.
Also useful on desktop computers!

7
Hibernate to disk (2)
Available by default in user-friendly distributions.
Example: Ubuntu (since 6.06): just choose Hibernate
or Suspend (to RAM) from the battery icon.
Also available from the shutdown (Quit) menu.
Otherwise, get the software
from http://www.suspend2.net/
It consists of a kernel patch and a hibernate
script. Just run this script to hibernate.
Requirements: a swap partition a least as big as system RAM.
Very easy to install with packages!
Fedora Core example: http://mhensler.de/swsusp/

8
CPU frequency control
Supported by all kernel versions in all recent distributions
Power consumption is roughly proportional to frequency.
Useful to adapt the frequency to computer usage
(word processing or e-mail consumes very few CPU cycles).
Not possible with all CPUs (mainly “mobile” processors).
Typically available through Gnome or KDE applets

9
CPU frequency control implementation
Mechanism: supplied by the kernel
Allows frequency control by reading / writing files
in /sys/devices/system/cpu/cpu0/cpufreq/
Policy: implemented by any “governor” program.
Such programs check the system state (CPU load, battery state,
board temperature) and change the frequency according to user
preferences.
Governor programs are easy to write and several ones are available.
Check your GNU/Linux distribution for information
about the governor it uses.

10
Laptop mode
http://www.xs4all.nl/~bsamwel/laptop_mode/
Ideas: spin up the hard disk only when reading uncached data,
delay and group disk writes, to save battery life.
Available in the standard Linux kernel since 2.6.6.
Control scripts available through the laptop-mode-tools
package.
May not be activated by default by distros:
not recommended for servers and laptops running only on AC
power (risk to loose data in a crash or sudden power off).

11
CPU activity control
Busy CPUs consume more than idle ones, at the same
frequency
Keeping CPU activity under control can save a lot of energy.
In server rooms, reducing power consumption even reduces
air conditioning costs, reducing even further the power bill.
So, let's find ways of reducing CPU activity! A few ideas:
Desktops, laptops: disable screen savers (CPU hungry)
Desktops, laptops: beware of web browsers (see next page)

12
Web browser control
Web browsers can create a lot of activity (CPU or I/O) on your computer!
Web pages containing Flash, Java, or just animated images
can consume a lot of CPU.
When you leave your computer and keep it on,
make sure you close all browser pages with animations.
Disabling animated images in Mozilla Firefox
go to about:config, find image.animation_mode and change its value
to none or once.
Otherwise, your PC may be left running at full speed while you are not using it.
You can also reduce disk activity by disabling the browser disk cache
(Firefox: browser.cache.disk.enable set to false in
about:config).

13
Display power control (1)
Switching off the display after an inactivity timeout
Easy to do in all recent
GNU/Linux distributions.
Configurable at least
in KDE and Gnome.
KDE display
power management:
Control Center
-> Peripherals
-> Display
-> Power Control

14
Display power control by script
If handled by your own scripts
you can control the display power with one of these commands:
xset dpms force standby
xset dpms force suspend
xset dpms force off
Note that suspend and off usually save much more energy than
just standby (which just switches off the screen, but not the
control circuitry).
No danger to switch off recent models of LCD displays or hard disk
drives. This doesn't reduce their life cycle (according to
manufacturers).

15
Virtual servers
Idea: run several virtual servers inside a real one
Great for security, to isolate independent services.
Shared: CPU, network bandwidth (sometimes)
Dedicated: storage space, RAM.
Great for optimizing the usage of hardware resources.
Used by companies to consolidate multiple servers in just a
few ones. Otherwise, servers stay idle for most of the time.
Other advantage: easy hardware upgrades.
Already very popular in web hosting.
Could be used much more often in enterprise networks!

16
Virtual server solutions
User Mode Linux - The first solution available.
http://user-mode-linux.sourceforge.net/
Allows to run 1 or several Linux kernel executables
on a Linux machine (with a standard kernel) as regular programs.
Xen: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/
A popular alternative, with very little performance overhead. Also
allows live server migration to other hardware. Requires a patched
Linux kernel.
KVM: http://kvm.qumranet.com/
Virtualization supported by the mainstream kernel (no patches).
Recent, but may quickly replace its competitors.

17
PowerTOP
http://linuxpowertop.org
A very nice utility showing the top 10 sources of power
consumption.
Requirements: a tickless 2.6.21 kernel, and a “mobile” CPU.
Best run on laptops running on battery (to estimate battery
savings).
PowerTOP measures the number of wake-ups, and counts the time
spent in low-power modes.
It detects issues in both kernel space (drivers) and user space.
It already uncovered several bugs in today's distributions.
Expect next distributions to save more battery time.

18
PowerTOP in action

19
Reducing power consumption - Summary
Power controls are now easy to use in GNU/Linux distributions.
Just need to know how to use a mouse.
In particular, hibernation to disk works almost everywhere.
CPU frequency scaling (if supported by the CPU) is easier too.
Unlike in proprietary systems:
Extreme flexibility in choosing power saving policy.
Unlimited capability to get involved and cooperate.
Unlimited capability to detect issues and fix them.
No black boxes, no hidden parts.

20
Saving paper and ink
Printing multiple pages per sheet
KDE and Gnome have print configuration tools
If not available in your application, choose “Print to file”.
This will create a PostScript file (example: doc.ps)
With psnup (psutils package):
psnup -4 doc.ps > doc4p.ps (4 pages par sheet)
lpr doc4p.ps (printing)
With mpage (http://www.mesa.nl/pub/mpage/):
mpage -4 doc.ps (transforming and printing)

21
Double sided printing (1)
On printers supporting duplex printing
Can be enabled by default.
On most distributions with the CUPS printing system,
very easy to configure: open http://localhost:631/ with a
browser, authenticate, and configure your printers.
Can also be set on a job by job basis
through the KDE and Gnome print helper programs.
From the command line, can also be done with the lpr-
wrapper program (http://www.mscs.dal.ca/~selinger/lpr-
wrapper/):
lpr-wrapper -od doc.ps

22
Double sided printing (2)
Manually, on printers with no duplex support
Many graphical applications (such as
OpenOffice.org)
let you print on odd (right) pages first,
then on even (left) pages.
Otherwise, you can print to a file and print with
mpage:
mpage -j 1%2 doc.ps (only odd pages)
mpage -j 2%2 doc.ps (only even pages)

23
Using computers longer
Small GNU/Linux distributions

24
Damn Small Linux
http://www.damnsmalllinux.org/
Full featured Live-CD distro
derived from Knoppix.
Very active community!
Fits within 50 MB
Runs fine on a 486 PC
with 16 MB of RAM.
Software: Firefox, xmms, xpdf,
Sylpheed, FluxBox WM, Siag
spreadsheet, Ted word processor...
Used a lot on USB flashdisks.

25
Basic Linux
Basic Linux: http://www.volny.cz/basiclinux/
The lightest distro for old PCs!
Just needs 3 MB of RAM
and 6 MB of disk.
Features: X graphics, window
manager, clock, calculator,
text based e-mail reader, browser
(links), presentations (MagicPoint),
network dial-up...
Great for using an old PC as an X terminal!

26
Gentoo Linux
http://www.gentoo.org/
Gentoo Linux is a GNU/Linux distribution
targeting maximum configurability.
This is ideal for older systems:
you only add what you actually need and you don't
compile applications with capabilities you don't need
(often causing more libraries to be needed in your
system).

27
Using computers longer
Reducing storage space

28
Stripping
Applications and libraries are compiled by default with extra information
useful for debugging (to study core dumps, for example).
Stripping removes such extra information, which most users cannot exploit
anyway. This can reduce the size of executables from 20% (big executables) to
40% (small executables)!
Use the file command to tell whether a file needs stripping:
file hello
hello: ELF 32-bit LSB executable, Intel 80386,
version 1 (SYSV), for GNU/Linux 2.2.5, dynamically
linked (uses shared libs), not stripped
To strip an executable or library:
strip hello

29
Filesystem compression (2)
Read-only compressed filesystems
Idea: store parts of the system (typically executables, libraries and
kernel) in a separate read-only partition. Best for speed and security,
but makes software upgrades more difficult.
CramFS: http://en.wikipedia.org/wiki/Cramfs
Original solution. Dramatically outperformed by SquashFS.
SquashFS: http://squashfs.sourceforge.net/
Unlike CramFS, no filesystem and file size limitation.
Achieves much better compression and read speed (at least 5x faster).
Much faster than ext2 on slow storage (like USB flash disks).

30
Lightweight tools
Use the lighter uClibc C library Busybox commands:
(http://uclibc.org). Most commands are there! Even includes
Takes 400 KB instead of 1700 KB. vi, wget, a http server, a dhcp client
Used in many embedded systems and and server... You hardly make the
in tiny Linux distributions. difference!
Caution: must recompile all
So many other tools available!
applications!
Very often from embedded Linux:
Use Busybox (http://busybox.net), a lightweight web servers, GUI libraries and
toolbox implementing most Unix many more!
commands. Takes at most 500 KB Quite exhaustive review on:
instead of approximately 10-30 MB http://free-
from GNU! Used by almost all electrons.com/training/devtools
embedded Linux projects and small
Linux distros.

31
A smaller kernel
Possibility to disable
features not needed in a
simple system.
Saves a few hundred KB

Kernel configuration
interface for small
systems

32
Keeping older computers in use
Possible to reuse older computers as
Print server
File server (Samba or NFS) or media server
HTTP, FTP, BitTorrent server
Firewall, gateway, proxy
Video server (webcam)
Industrial control, home automation control

33
Using non-PC Linux machines (1)
No need to buy a PC to perform the services mentioned in the previous
slides. You just need a machine running Linux!
Linksys NSLU2: http://www.nslu2-linux.org/
Price: 90 € / USD!!!
Features: 266 MHz ARM CPU, 8MB of flash, 32MB of SDRAM
Connectivity: USB (for attached storage) + Ethernet + serial port
Extremely popular. Many use cases!
ASUS WL-500g Premium: http://wl500g.dyndns.org/
Price: 100 € / USD
125 MHz MIPS CPU, 8 MB flash, 32 MB RAM
Connectivity: 4x Ethernet, WAN, WiFi, 2x USB 2.0
Perfect to install a Debian GNU/Linux server booting from a USB disk!

34
Using non-PC Linux machines (2)
Devices based on the Linksys WRT chipset: http://openwrt.org/
Price: 50 - 100 € / USD
Typical config: 125-200 MHz ARM CPU, 4 MB flash, 16 MB RAM
Connectivity: Ethernet, WiFi, USB (sometimes), serial (often)
Very popular too!

35
Using non-PC Linux machines - Advantages
Many advantages
Much reduced power consumption compared to a PC
Produced with much less materials
No fan: no noise pollution
Significant costs savings (of course)
Increasingly easy to get tools for other CPU platforms:
packages, cross-compiling tools, distributions (Debian)
Many lightweight tools available.
Standard desktop tools easy to compile with less features.

36
Real-time preemption patches
Linux kernel patches from Ingo Molnar
http://people.redhat.com/~mingo/realtime-preempt/
Available for any recent kernel version (> 2.6.12)
When full preemption is enabled, add unprecedented
responsiveness to the Linux kernel. Less latency,
suitable for real real-time systems (less than 100 us!).
Definitely worth trying on old systems
to improve the user experience!

37
Repairing instead of replacing
BadRAM patch
http://rick.vanrein.org/linux/badram/
Makes it possible to live with partially defective RAM modules.
Sites collecting repairing, upgrading, disassembling
or modding instructions:
Laptops:
http://repair4laptop.org/
PDAs / Handhelds:
http://repair4pda.org/
Cell phones:
http://repair4mobilephone.org/
Mice:
http://repair4mouse.org/
Printers, toners and ink cartridges: http://repair4printer.org/

38
Energy consumption
Refrain from buying new computers (a lot of energy and materials consumed
at manufacturing time). Buying one also means discarding another.
Buy low consumption systems, in particular with “mobile” processors,
supporting frequency scaling. Laptops consume 50 to 80% less power. On the
other hand, their batteries contain toxic materials and they are more difficult
to repair or upgrade.
Buy LCD instead of CRT monitors
(consume 60% less and emit less mercury).
Switch off your DSL modem / wireless router / ISP box / printers at night or
during vacations if you don't use them. These devices consume quite a lot
(typically 15W).

39
Measure your consumption
You can buy a wattmeter to identify Wattmeter
the most consuming devices, or to measure (Brennenstuh
the impact of power saving techniques. l
PM 230)
Also measure consumption when
Price: 30-40
devices are switched off. Some power EUR / USD
adapters (usually old, big and heavy)
remain warm and still drain power.
Solution: also switch off the power adapter!

Multi-socket with indivi-


dual switches (Brennenstuhl
Premium Line)

40
System life
Battery life: use your batteries only when you are away from a power
source. That's probably better to remove the battery when your
notebook remains plugged in for a long time (could depend on the
battery type).
Use electrical surge protection devices to protect your equipment.

41
Managing electronic waste
Some countries (like France) now mandate electronics / electric device
stores to accept old devices for free when you buy a new one, to
ensure suitable processing of waste.
Idea: you may store your hardware waste in your cellar or attic (if you
have enough room), waiting for mature waste processing channels or
technologies to be available in your country.

42
Useful resources
Of course, the Linux Ecology HOWTO!
This was just an introduction.
http://www.tldp.org/HOWTO/Ecology-HOWTO/
Embedded Linux system techniques for reducing
size, increasing speed, reducing power
consumption:
http://free-electrons.com/articles/optimizations/
Lightweight tools and libraries for use in systems
with limited resources:
http://free-electrons.com/training/devtools

43
Conclusions
With Linux and Free Software...
Possible to significantly reduce power consumption.
No black box you have no control on.
Possible to extend the lifetime of your computer.
This reduces the consumption of materials.
No need to run old software on old computers.
Lots of reuse from the hottest embedded Linux projects!
Possible to run on low profile computers:
old computers or Consumer Electronics devices.
In a nutshell, lots of things you can't do with proprietary software!

44
Thank You

45

You might also like