Linux on the laptop

Source: Internet
Author: User
Tags apm syslog

In the past few years, Linux has gone out of the data center and entered the desktop system or even the laptop system. Like Linux in a server system, Linux in a PC system also provides speed and reliability, as well as a large number of powerful and tested applications. Linux is quite common in desktop systems, but it is not so common to use Linux in laptops. Most Linux distributions do not provide limited power and wireless network support for mobile users.

This article provides mobile users with ten weapons required to use Linux. They include how-to, tips, and configuration solutions to help you build a mobile Linux environment that can be relied on. [1 ]. It's time to take it!

If Linux runs in your desktop system, you should know that it runs fast, reliable, and can easily solve the problem. However, the cost of such performance is power.

In a desktop system, power will never be a problem: your desktop system or disk-side computer-with high-speed processors, multi-function boards, and various peripherals-will be connected to the power supply on the wall, your LCD and other devices have their own power interfaces. There will never be a shortage of power.

However, in the notebook, power resources are very valuable. A limited power point must be shared by all components. In fact, if you try to perform some complex work in a battery-powered laptop system, you may encounter power limitations.

The default configurations of most Linux distributions are designed for systems with unlimited power supply. Therefore, if you want to use Linux in a mobile environment, you need to optimize the configuration to use many existing tools to manage and save energy.

Energy saving: apmd Service Management
Linux advanced power management daemon, apmd, manages various basic node functions from within the operating system. For example, apmd can detect power status changes, start and stop various services, and call other programs for Power status. To configure apmd, you must configure the apmd daemon and APM configuration scripts.

The configuration file of apmd is usually in/etc/sysconfig/apmd, which contains various basic configurations of the apmd daemon. The default configuration is normal, so you only need to modify a small amount. The most important entries include power_services, lowpower_services, and cpufreq.

* Power_services lists all services that are stopped when the power is switched to battery. (These services will be started again when the notebook is re-connected to the AC power supply .) By default, this list is very short, so you should add services including crond, autofs, cups, PCMCIA, and syslog To this list. [2]

* Services in the lowpower_services list include services that are stopped when the battery power is reduced to a standard.

* CPU freq enables the processor frequency adjustment function. More information about CPU frequency adjustment will be provided later. When you have configured the processor frequency adjustment function, you should set this option to yes.

After you have adjusted these options, run the Command Service apmd restart to load new settings.

The next step is to configure the APM script. This script is generally stored in/etc/sysconfig/APM-scripts/apmscript. Running apmscripts directly from/etc/rc. Local is a good idea, because it can automatically adapt the system to the battery state at startup. This script has several sections for specific power management information. We need to pay attention to the resume and change functions.

But do not edit apmscripts first -- let's look at some power management-related tools first.

Energy saving: CPU frequency adjustment

CPU is the most power-consuming component in the notebook system. To prolong battery life, most new CPUs support frequency adjustment (also known as clock adjustment clock Modulation) so that the battery can run at a lower speed when it becomes a major energy source. The reduction depends on different processors.

Cpufreq is a Linux kernel patch that provides clock adjustment (available at http://brodo.de/cpufreq ). Some releases include this function by default, while others require additional patching.
To check whether cpufreq has been added to the kernel, run CAT/proc/cupfreq. You should see an output similar to this:

Minimum CPU frequency-maximum CPU frequency-Policy
CPU 0 1998345 kHz (100%)-1998345 kHz (100%)-Performance

If you see all two rows of output, it indicates that cpufreq has been loaded into your system kernel. If you see no CPU information in the first line, it indicates that cpufreq exists but the driver is not loaded correctly.

You should be able to use the modprobe command to select the CPU driver for your system from table 1. The simplest way to load the driver is to add the modprobe command to/etc/rc. Local. If your kernel basic supports cpufreq, You need to download the patch package and patch the kernel.

--
Table 1: clock adjustment modules in Linux

Module Processor
The general speedstep of speedstep appears in cpufreq of the old version.
Speedstep-ich CPU used by most of the CIOs prior to the Pentium processor
Speedstep-Centrino supports the Pentium processor of the Pentium Technology
P4-clockmod Pentium 4 clock adjustment; common in Pentium 4 mobile processor
Longrun supports Longrun technology's transmeta Crusoe Processor
Powernow supports amd K6, K7, and K8 processors of powernow technology.
Longhaul supports longhaul Processors
--

After cpufreq runs properly, you can read/write/proc/cpufreq. You can use commands similar to the following to set a value:

# Echo-n "0% 100% 100% performance">/proc/cpufreq
# Echo-n "0% 60% 60% powersave">/proc/cpufreq
# Echo-n "0% 12% 80% userspace">/proc/cpufreq

The first value is the processor number, which is usually 0 in a single-processor notebook system. The second and third values indicate the range of percentages allowed to adjust the processor frequency. The last parameter indicates the mode (Governor ). The three optional modes are performance, powersave, and userspace. Performance provides the maximum performance in battery mode. powersave keeps the processor power at the lowest level, while userspace is a relatively good intermediate state, which determines the operating frequency of the processor as needed.

It is very likely that you want the system to work at full load when it is connected to the AC power supply, while the system runs at a low level when it depends on the battery. Once you confirm these values, you can write them into/etc/sysconfig/APM-scripts/apmscript. By the way, cpufreq automatically modifies your set value to the nearest reasonable value if necessary. Therefore, depending on the processor, the value you require may be different from the actual result you get.

In list 1, an example of apmscript is modified from the ora core 1 release.

--
List 1: Set the CPU frequency in apmscript

If test "x $ cpufreq" = "xyes"; then
If APM | lc_all = C grep-Q on-line &>/dev/NULL; then
Echo-n "0% 100% 100% performance">/proc/cpufreq
Else
Echo-n "0% 12% 60% userspace">/proc/cpufreq
Fi
Fi
--

If cpufreq is not started, do not forget to enable cpufreq in apmd configuration.

Save More energy: Close the hard disk
In addition to the CPU, your laptop is powered by hard disks. As long as it is rotated, it requires power support.

The default Linux configuration makes it almost impossible to stop the hard disk, because the operating system will refresh the information to the hard disk every other time. Therefore, you need two tools for stopping the hard disk: a script for setting laptop_mode in the kernel and the hdparm utility.

The laptop_mode switch used to stop the hard disk, but added more settings to be adjusted. There are a lot of scripts for setting the notebook mode on the Internet, but it's pretty good to download from the http://www.linux-mag.com/downloads/2004-07/laptop/laptop_mode.sh. The advantage of this script is that it supports both the 2.4 and 2.6 kernels. Run the script with the start or stop parameter and run it at startup, for example, from/etc/rc. Local or only when it enters battery mode.

After laptop_mode is enabled, use the hdparm program to set the waiting period before the hard disk is stopped. You can use the-S parameter of hdparm to set the shutdown timeout and use the-C parameter to check the driver status. View the specific timeout value in the hdparm manual.

The hdparm command can be added to apmscript to automatically modify the timeout value when switching the AC power source and battery. When connected to the AC Power Supply
# Hdparm-s 48/dev/hda
Set the wait time to 4 minutes. This value applies to most laptops. When running in battery mode
# Hdparm-s 12/dev/hda
Set the wait time to 1 minute. Depending on the hard drive start/stop speed and battery life, you can increase or decrease these values accordingly.

Persistent resistance: exchange zone management

The last step to extend battery life is to disable swap partitions when the system is running in battery mode. The consequence of disabling swap partitions is to force all programs and data to be kept in the memory, thus reducing the hard disk data traffic. At the same time, disabling swap partitions also allows the hard disk to go to The stopped state faster. Note that your system requires sufficient physical memory to support all programs.

To start or stop swap partitions, call the Swapon and swapoff commands with the-A (all) parameter. These commands can also be added to apmscript.

The final APM script for the laptop system is shown in List 2.

--
List 2: Saving Energy from apmscript
/Etc/rc. Local
Modprobe p4-clockmod
SH/etc/sysconfig/APM-scripts/laptop_mode.sh start
SH/etc/sysconfig/APM-scripts/apmscript change

/Etc/sysconfig/APM-scripts/APM-script
If test "x $ cpufreq" = "xyes"; then
If APM | lc_all = C grep-Q on-line &>/dev/NULL; then
Echo-n "0% 100% 100% performance">/proc/cpufreq
Hdparm-s 48/dev/hda
Swapon-
Else
Echo-n "0% 12% 60% userspace">/proc/cpufreq
Hdparm-s 12/dev/hda
Swapoff-
Fi
Fi
--

Turning to the mobile world: minipci prism2 card
The real benefit of using a notebook is that you can make endless creations. As shown in power management, smart cropping allows you to make better use of your system.

Many new laptops, such as IBM, have standard configurations that contain wireless NICs based on a technology called minipci. Many of them are based on prism2, so many users install the Linux-WLAN-ng driver to make it work. Unfortunately, the Linux-WLAN-ng driver lacks many features, including compatibility with wireless extensions, so that many NICs can only be configured through exclusive interfaces.

The fact that Linux contains orinoco_pci drivers is actually a prism2-based driver that can be used to drive a prism2-based Built-in unlimited Nic. Better yet, the orinoco_pci driver can use wireless extensions and tools such as iwconfig and iwpriv.

To use the orinoco_pci driver, edit modules. conf and replace the existing wireless Nic alias with the following:

Alias eth1 orinoco_pci

Then you can choose to restart the system or uninstall the old module and run modprobe orinoco_pci. Your built-in wireless Nic should be correctly driven by the Orinoco PCI kernel module so that you can use a standard wireless tool set.

Best: Use a Windows Driver in Linux
If you are unfortunately using a wireless network card that is still not supported by Linux, you will be glad to know that you only need $20, you can use the driver provided by the vendor for windows in your Linux system. All you need to do is go to linuxant (http://www.linuxant.com/) and download driver loader. If you do not have the CD provided by the vendor, driver loader will help you download the appropriate driver from the vendor's website.

Keep moving: Basic street Scanning

If you want to scan your car along the street or walk along the street, you will soon find Kismet and airsnort are essential tools. These two tools provide a unique wireless network attack and diagnostic tool for Linux.

According to the Kismet website (http://www.kismetwireless.net/), Kismet is a complete wireless network detection, sniffing and intrusion detection tool. This free tool allows you to scan wireless networks, perform real-time WEP decoding, and even tell you the IP range used in this network. Kismet will tell you which (if yes) encryption method is used on the network, how many customers are connected to each network, and display Access Point devices that keep the default factory configuration. If you have some WEP keys that you have the right to access, you can even perform real-time WEP decoding and sniffing. Combined with driftnet (http://www.ex-parrot.com /~ Chris/driftnet) or ethereal (http://www.ethereal.com/) tools, you will be able to complete the analysis of any information transmitted in the network.

Airsnort is a great WEP recovery tool. If you often travel and new WEP keys cannot be sent to your mailbox in time, or you are a security expert and have a paranoid attitude towards your wireless network security (or you just want to attack each other with your friends ), airsnort can restore the WEP Key of the network in about one hour, depending on the information traffic on the network. (WEP has a basic defect that allows attackers to obtain keys by analyzing the so-called initial vector Initialization vectors .)

Call data using mobile phones

There are countless types of mobile phones in the current market, but most of the mobile phones with data transmission capabilities use a common communication method to communicate with the data MODEM in mobile phones or network providers. The Linux abstract Control Model (ACM) is designed to communicate with abstract devices. Therefore, it can also be used for data MODEM in mobile phones. Linux ACM maps this device to a tty device in the/dev directory, and then you can communicate with the data modem like a common Modem.

(By default, most Linux distributions do not have ACM modules that can be used. Therefore, you sometimes need to re-compile the kernel to make ACM work normally. In addition, some versions of Red Hat and Fedora Linux require that the module be loaded with modprobe to enter the kernel. After the Linux ACM module is re-compiled, it works properly on both the 2.4 and 2.6 kernels. If you find that you are stuck when trying to make ACM work normally, consider recompiling your kernel .)

To use ACM, first you need a cable to connect to your mobile phone from your laptop. In most cases, a universal USB cable that can be connected to a mobile phone can be used, but sometimes a mobile phone tool must be purchased from a mobile phone supplier. Spending more than $20 to buy a mobile phone tool should be better than buying a cheap cable from eBay and then encountering various troubles.

Once you have this line, run the command tail-F/var/log/messages. (If your laptop is running and stopping syslog in battery mode, you can see this information by either powering in or manually starting the syslog service .) If you connect the cable to your cell phone or laptop, you will see a message similar to this:

Kernel: hub. C: new USB device 00: 1d. 1-2, assigned address 2
Kernel: USB. C: registered new driver ACM
Kernel: ttyacm0: usb acm Device
Kernel: ACM. C: v0.21: USB abstract Control Model driver for USB

Here, the ACM module of the kernel discovers this device and maps it to the logical device/dev/input/ttyacm0 to connect to the mobile phone. Now you can use/dev/input/ttyacm0 as a common Modem for communication and prepare for a dial-up connection. For example, "Call home" shows how to use the popular dialing program wvdial for dialing.

----
Call home

To use the wvdial dialing program to dial data through a mobile phone, perform the following steps.

Step 1: add the modem to/etc/wvdial. conf
First, add your modem to wvdial. conf. After addition, other tools such as Red Hat Network Manager can be used to set data connections, or you can perform hard encoding like in this example.

The modem configuration in wvdial. conf should be similar to this:

[Mobile] modem =/dev/input/ttyacm0 baud = 57600 setvolume = 2 dial command = atdt init1 = atz flowcontrol = hardware (crtscts)

Step 2: configure the dialing program interface

Now that you have added the modem to wvdial. conf, you need to create a dialing program interface for the dialing connection. You need to do this in/etc/sysconfig/network-scripts. Create a file and name it ifcfg-ISP (ISP is your Internet provider name ). This configuration file should be similar to the following:

Onboot = No userctl = Yes peerdns = Yes type = modem device = ppp2 bootproto = dialup CCP = off Pc = off AC = off bsdcomp = off vj = off vjccomp = off linespeed = 57600 modemport =/dev/input/ttyacm0 idletimeout = 600 provider = ISP defroute = Yes persist = No papname = username wvdialsect = ISP modemname = Mobile demand = No

You should change the username to the user name you registered at the ISP. Next, add the verification information.

Step 3: prove your identity

After configuring the dialing program interface, you must provide the user name, password, and phone number used for dialing. This information should be added to/etc/wvdial. conf and/etc/PPP/chap-secrets.

Return to/etc/wvdial. conf and add the following information at the bottom:

[Dialer ISP] username = Username Password = mypassword phone = [phone number to ISP] Stupid mode = 1

Add the following line to/etc/PPP/chap-secrets:

"Username" "ISP" "mypassword"

Now you have made all preparations for connection. Input

# IFUP ISP

To activate the dialing program interface. The mobile phone should understand that it is dialing data, and you should be able to see the status information from the log file. Once the verification is passed, most ISPs will assign an IP address, and then you can communicate on the network. After you finish, enter ifdown ISP to close the connection.

---- Phoning home ends

Connect to Verizon's leleoffice Service

Verizon Wireless provides two wireless services. The first type is mobileoffice, which provides a connection of up to 14.4 K and charges are charged by minutes. The second type is expressnetwork, which provides 144 K connections, but is expensive. You will be charged USD per month for unlimited use.

The mobileoffice Service uses the same configurations as the traditional dial-up connections. You only need a few configuration skills.

Start by completing several steps in call home and convert the connection to the Verizon leoffice that supports Verizon Wireless.

Note that you need to dial #777 from your mobile phone. This must be modified in step 3 of "call home. Then, add an initialization string. A specific initialization string is configured with a register that notifies Verizon of the modem connector you want to connect to their mobile office service. Add the following sentence to the modem section in/etc/wvdial. conf:

Init3 = at $ qcmdr = 2

If you have purchased Verizon's high-speed expressnetwork service, set the qcmdr value to 3.

Init3 = at $ qcmdr = 3

You can use the username and password qnc to pass identity authentication on the mobileoffice network. You need to modify both/etc/wvdial. conf and/etc/PPP/chap-secrets.

To log on to the expressnetwork service, use the xxxxxxxx@vzw3g.com as the user name to log on; those X represent your 10-digit mobile phone number. The logon password is vzw. Of course, you must subscribe to the expressnetwork service to log on successfully.

That's all! After completing these settings, you should connect to one of the Verizon service networks. Contact Verizon for any charges.

Create X servers with dynamic 3D configurations

Many laptops have limited VRAM, which leads to a conflict: either disabling 3D display support or restricting the color depth.

Setting up a dynamic 3D X Server gives you the best experience in both cases. It runs in 2D mode while you are working normally, and creates a new X Server when you play the game.

You can achieve this through a script and a new xf86config file.

First, create a separate xf86config file. The main XF86-Config configuration award is used for the 2D display you need for your daily work, and the new configuration will be tailored to 3D environments.

Copy the existing configuration file to a new file and name it xf86config. 3D (these files should be in the/etc/X11 directory ). Edit the resolution and color depth required for setting the new 3D configuration file.

Next, create a 3D STARTUP script for the game. Creating a new 3D server is accomplished by using a short script and X's desktop switch hotkey. This script should be similar to the following:

/Usr/x11r6/bin/X: 1-xf86config xf86config. 3D/
-Depth 16-auth/var/TPD/: 1. Xauth vt8 &
Display =: 1.0
Export display

Chromium
Display =: 0.0
Export display

In this example, a 3D X server is created to run chromium. Run this script to create a new window and then run chromium. From here you can use X's hotkey ALT-CTRL-BACKSPACE to abort X sessions and return the original 2D desktop, or you can switch between two desktops with a ALT-CTRL-F7 and ALT-CTRL-F8. It is generally a good idea to stop the process when you end the game.

Go on again
This article only introduces a few tips for Linux Optimization for mobile environments. Linux is an extremely flexible operating system. With a little creativity, it can provide mobile computers with many features that can rival commercial operating systems.

(Original link: http://www.linux-mag.com/content/view/1689/2190. Thanks to Linux magazine for providing us with such high-quality magazines .)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.