Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15530230
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2008-04-09 22:14:10

Part 1 - Introduction

Curious about Linux? Want to try it out without needing to install anything to your hard disk? Then what you need is a "Live Linux" distribution which will run entirely from a CD and RAM. If your tablet doesn't have a CD drive then you can create a LiveUSB version that will run from a usb flash drive. This article contains instructions for doing both.

One of the strengths of a Live version of Linux is that no matter how much you mess things up you always start over with a clean installation when rebooting. However, this can also be a weakness because you're stuck with the programs that were included on the CD. While you can install new programs they are "installed" to RAM which vaporizes when you shut down. The same goes if you change settings like the desktop wallpaper, preferences and the like. But there are ways around this problem by using a feature called persistence. With a persistent system your new programs, changes and preferences are stored to a USB flash drive. The next time you start up all of your changes are restored. To use persistence you can create a specially formatted USB flash drive and plug it into your PC while booting from the LiveCD. Or, if you're booting from a USB flash drive instead of a CD you can format the flash drive to contain two partitions; one for the files on the CD and one for the persistent filesystem. I'll describe all of these methods in this article.

First let me say that there are a bazillion different distributions or "flavors" of Linux out there and it is difficult for a new user to know where to start. So I'll interject my personal recommendation into the mix here and say that if you are used to Windows XP then the distributions that you're likely to be most comfortable with at first will be based on the K Desktop Environment (KDE). The other very popular type of Linux desktop  environment is called Gnome and there are of course raging debates about which is better, but it all boils down to personal preference. You can even install both if you want, and there are several others if you don't like either of these.

A Linux operating system is a motley collection of many hundreds of "packages" for controlling the display, network adapters, speaking TCP/IP on the network, reading and writing files to the disk, etc. You can roll your own by mixing and matching your favorite utilities but that's for the more experienced user. Believe me, I'm not in that group yet. I've only been playing around with Linux for a couple of years and am by no means a programmer or an expert. For the rest of us there are Linux "distributions" which are pre-packaged groups of utilities, files and even programs. One of the most popular and active distributions at the moment is Ubuntu , which uses the Gnome desktop environment, and its cousin Kubuntu which uses the K desktop environment (KDE).

I am going to base this article on Kubuntu which works very well on my X41 Tablet with minimal fuss. If you want to modify this procedure for Ubuntu it will probably also work but I haven't personally tested it. Read on for further instructions.

Part 2 - Creating a LiveCD Version of Kubuntu

If you have a CD or DVD drive on your tablet this is the quickest way to get started. Even if you plan to make a LiveUSB flash drive you will need the files from the CD so do this on a PC that has a CD or DVD burner.

1. Download the latest Kubuntu Desktop CD version from here: As of the date of this update, October 2007, the latest Version is 7.10, named "Gutsy", and the filename is kubuntu-7.10-desktop-i386.iso for most PCs (others are available for the Mac and other special circumstances). Warning -- this is a 695 MB file and will take a while to download.

2. Using Nero or your favorite burning software burn the .iso (image) file to a CD. Do not simply copy the file to a CD because the resultant CD must be made bootable. To do this with Nero 6 go to the "Recorder" menu and choose "Burn Image". You can use CD-RW media here if you want so that 6 months from now when a new release of Kubuntu comes out you can just re-burn the CD.

If your tablet has a CD drive and you don't care to experiment with the persistence feature then you're done!

Go have fun. Boot your PC from the CD and when the menu appears you can simply press "Enter" at the prompt to start up into the LiveCD version of Kubuntu. If you are curious you can explore the menu options by pressing F1 and reading about the different ways to use the LiveCD.

If you want to create a LiveUSB flash drive version or experiment with the persistence feature then read on.

Part 3 - A LiveUSB flash drive version of the Live CD

To do this you will need a flash drive of at least 1 GB. If you also want to add a second partition to the drive for the persistence feature then a 2 GB drive is recommended. Although it is possible to squeeze both onto a 1 GB drive (I've done it) you won't have much room for adding programs.

Here is the procedure for a single-partition (no persistence feature) LiveUSB version of Kubuntu. If you eventually plan to add the persistence feature then you'll need to do this first anyway:

1. Plug your flash drive into your Windows XP computer and navigate to it in Windows Explorer (My Computer).

2. Right-click on the drive and choose "Format" Choose "FAT" filesystem (FAT32 will also work) and Label the drive as "Kubuntu". This name is arbitrary; choose whatever name you wish.

3. When the drive has finished formatting insert the Kubuntu CD that you made in part 2 of this article. Hold down the SHIFT key when inserting the CD so that the autorun utility doesn't start up and get in the way. If it does, just close the window that opens. Then copy all of the files from the CD to the USB flash drive.

4. Next we will make a few changes. Remove the CD.

Steps 5 and 6 are optional. If space is at a premium on your USB flash drive (for example if you want to cram two partitions onto a 1 GB drive) then you can free up a little more room by doing the next two steps.

5. Delete the following folders:
    bin
    disctree
    programs
    preseed

6. Delete the following files:
    start.exe
    start.bmp
    start.ini
    ubuntu
    wubi-cdboot.exe
    autorun.inf

The files and folders listed above are to support the use of the CD on a Windows machine. They contain installable versions of Firefox, Thunderbird and other open-source Windows software but they are not needed in Linux so you can remove them to save space.

7. Open the folder "casper" and move the following two files outside the folder (to the flash drive root directory):
    vmlinuz
    initrd.gz

8. Open the folder "install" and move the following file to the flash drive root directory:
    mt86plus

9. Open the folder "isolinux" and move all of its contents to the flash drive root directory. Again, if you're trying to free up as much space as possible then you can delete the following:
    isolinux.bin
    isolinux.cfg
    the isolinux folder

The reason for doing steps 7 - 9 is that the program syslinux is a very simple bootloader that does not understand folders, so all of the files needed to start up into the syslinux environment must be in the root of the usb flash drive and not inside a folder.

If you're really ambitious you will note that there are a lot of help files in many different languages, so you can delete the language files that you won't be using. But this step is not necessary; if you have space on the drive then just leave everything in place.

10. Next open Notepad and then copy the following text and paste it into Notepad. Save the file to the flash drive as "syslinux.cfg".

    DEFAULT live
GFXBOOT bootlogo
GFXBOOT-ACCESS-OPTIONS v1 v2 m1
APPEND  boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL live
  menu label ^Start or install Kubuntu
  kernel vmlinuz
  append  boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL xforcevesa
  menu label Start Kubuntu in safe ^graphics mode
  kernel vmlinuz
  append  boot=casper xforcevesa initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL check
  menu label ^Check CD for defects
  kernel vmlinuz
  append  boot=casper integrity-check initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL memtest
  menu label ^Memory test
  kernel mt86plus
  append -

LABEL hd
  menu label ^Boot from first hard disk
  localboot 0x80
  append -

DISPLAY isolinux.txt
TIMEOUT 300
PROMPT 1
F1 f1.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt
F5 f5.txt
F6 f6.txt
F7 f7.txt
F8 f8.txt
F9 f9.txt
F0 f10.txt


Be sure to remove the extension ".txt" that Notepad will add to the file. To see this you may need to go to the control panel and choose "Folder Options" and then click on the "View" tab and uncheck "Hide extensions for known file types". That's a nasty default setting in Windows that you should change anyway or it will get you in trouble some day.

This syslinux.cfg file is the one that creates the menu structure that you'll see when booting the flash drive.

Finally we need to make the flash drive bootable. You will need a small utility that can be downloaded from the internet to do this.

11. Download the latest version of syslinux from the following web site:
You want the .zip version of the file. As of the date of this article it is version 3.31 and the filename is syslinux-3.31.zip.

12. After downloading the file to your desktop, open the zip folder and navigate to the "win32" folder. We only need the file called "syslinux.exe". Copy this file to your desktop and then you can, if you wish, delete everything else.

13. Open a command prompt window (Start/Run/Command)

14. Navigate to your Desktop. For example if your user name is John Doe you would type:
cd \Documents and Settings\John Doe\Desktop
By the way, if you aren't used to typing commands at a command prompt you should be aware that Windows XP has a very handy time-saving feature called command completion that makes it unnecessary to type everything out. For example, if you start typing "cd Doc" and then you press the TAB key, Windows will figure out that the only folder beginning with "Doc" is "Documents and Settings" and will fill in the rest of the text for you.

15. Run the following command to make the flash drive bootable:
syslinux -a x:
You will need to substitute the drive letter of your usb flash drive for "x:". For example, if your flash drive is E: you would type the following command:
syslinux -a E:
Be careful here; don't accidentally type the drive letter of your hard drive!

The command "syslinux -a x:" writes a small bootloader to the master boot record of the usb flash drive and also installs a hidden, system file on the drive called "ldlinux.sys". The -a in the command will set the partition as active so that it can be booted.

That's it! Now you can plug the flash drive into your PC and boot from it. The procedure for doing this will vary between PC models. On some like my X41T you can press F12 while the PC is starting up and this will bring up a boot menu allowing you to choose which device to boot from (hard disk, CD, USB, etc). If your machine does not have this feature then restart the PC and press whatever key is required to enter the BIOS setup (usually DEL or F1). Look through the menus and find the menu for boot devices. Move your USB device higher in priority than your hard disk and then save settings, exit, and try again.

After you've explored the Linux environment if you then want to experiment with the persistence feature, read on.

Part 4 - Adding Persistence to the LiveCD version.

The LiveCD version of Kubuntu can take advantage of a feature called persistence that will remember all of the changes and settings that you make while running the LiveCD. In order to use the feature you need to have a partition available somewhere that is formatted with the Linux ext2 or ext3 filesystem and having the name "casper-rw". This partition can be on a hard disk or on a removeable drive like a USB flash drive. The latter is preferable if you don't want to mess with partitioning your hard disk.

To use the persistent feature you will plug the specially formatted usb flash drive into your PC when booting it from the Live CD. Then Kubuntu Live will create what's called a Union Filesystem on the flash drive that is differential; that is it will contain only the differences between the read-only files on the CD and the live filesystem that exists in RAM. Every change that you make to the Linux environment will be written to the flash drive. The next time that you start up the system will merge the read-only files from the CD with the changes on the flash drive to create the RAM image that is executing. Pretty neat trick, right?

Do the following steps if you will be running LiveLinux from a CD. If you are going to put everything on a usb flash drive then skip over this and go to Part 5.

The following steps need to be done in the Linux environment. While you can almost do this in Windows if you have Partition Magic or equivalent partitioning software or the utilities that let you format disks with the Linux ext2 or ext3 filesystem, the problem that you will run into is that you will be unable to label the disk partition with the name "casper-rw" in all lower-case letters; it will come out in upper-case letters and the LiveCD will not recognize the name unless it is all lower-case. So let's run Linux where doing this is a snap.

1. Start your PC from the LiveCD and wait until the Linux desktop is displayed.

2. Plug in a USB flash drive. The drive will be completely reformatted so be sure that there is nothing on it that you want to keep. You should use a drive of at least 512 MB in size although smaller will work but you'll soon run out of space.

3. The drive will automatically mount, an icon will appear on the desktop that looks like a flash drive, and a Konqueror window will open to display the drive contents. Close the window.

4. Go to the Start menu (The big "K" on the lower left of the taskbar) and choose "System" and then "Konsole Terminal Program".

5. Type the following terminal command:
fdisk -l
That last character is a lower-case L, not the number 1. The command will display something like the following:
Disk /dev/sdb: 1024 MB 1024966656 bytes
16 heads, 63 sectors/track, 1986 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device: /dev/sdb1  Boot: *  Start: 1  End: 1986 Blocks: 1000912+ Id: 6 System: FAT16
What we're looking for is the device name of the usb flash drive; it's on the last line in the terminal display. In the example here it's /dev/sdb1. Note carefully the name of the device on your system.

6. Next we need to "unmount" the drive. Linux will not let us reformat a mounted drive as a safety precaution.

Type the following command:
sudo umount /dev/sdb1
Substitute the name of your device if it's not sdb1 like the example. By the way "sudo" is the prefix that you add to any command if you want it to run with root user privileges. All of the low-level commands require root privileges. "Root" in Linux is the same as "Administrator" in Windows. Normally you would be asked to enter a password but with the LiveLinux CD the default password is blank so you won't need to enter one.

7. Now let's format the drive. Enter the following command
sudo mkfs.ext3 -b 4096 -L casper-rw /dev/sdb1
You'll need to substitute the name of your device as determined in step 5 if it differs from this example. Be careful to type this exactly (Linux names and commands are case-sensitive). Also, be sure to get the device name correct so that you don't format the wrong drive!

Here, mkfs is the command to format a drive with a filesystem; the type of filesystem being created is Linux ext3, the -b 4096 tells the system to format with a block size of 4096 and the -L is to label the partition with the name "casper-rw".

**As a footnote here, either ext2 or ext3 filesystems are supposed to work. Ext2 is the basic Linux filesystem and is smaller in size so it is preferable for small drives. Ext3 is a journaling file system like NTFS that takes up a little more room on the drive but is more robust. Prior versions of Ubuntu/Kubuntu Live worked fine with ext2 filesystems but I have not been able to make an ext2 filesystem work with the latest version of Kubuntu. I also had the same problem with the latest version of Knoppix, so perhaps there is a bug with the Union filesystem that plagues both distributions. So that's why the above instructions have you format the drive with the ext3 filesystem.

8. Unplug the usb flash drive.

To use the persistence feature, restart your PC from the CD with the USB flash drive simultaneously connected. When you get to the boot menu on the CD, type the word "persistent" on the boot: command line and then press enter. The first time boot with a new flash drive may take a while so be patient while the initial differential file system is being set up. Subsequent boots will be quicker. Test by making a few changes; for example change the desktop wallpaper. Restart the computer and you should see that your changes were saved.

Now that persistence works, here's a tip. The bouncing cursor (launch feedback) in KDE is very annoying to me. If you find it annoying too then change it. Press ALT+F2 and type "kcontrol" to bring up the KDE Control Center. Expand "Appearance & Themes" and click on "Launch Feedback". Change the "Busy Cursor" to something else to your preference. Save your changes. No more bouncy cursor. Isn't persistence a nice feature?

If you want to add persistence to the bootable usb flash drive version then read on.

Part 5 - Adding Persistence to the Bootable USB version of the Live CD

One way to do this is to use two flash drives; the one that you created in part 3 of this article containing the LiveUSB files and the one from part 4 containing space for a persistent partition, but that's awkward. You can modify the LiveUSB drive to add a second partition for a more elegant solution. If you do this it's best to have a drive with preferably 2 Gb of space. I've done it with 1 GB drives but you really get cramped for space.

The following instructions will assume that you have a usb flash drive containing a LiveUSB version of Kubuntu, that the drive is working and now you only want to add a second partition to it.

The following must be done in Linux, so you have a slight dilemma. You must either have:
a) Another PC that runs Linux
b) A CD ROM so that you can run the LiveCD and simultaneously work on the usb flash drive
c) Two flash drives each containing a LiveUSB version of Linux; the one that you will partition and another that will run Linux to do the partitioning.

The reason for this is that you can't partition a drive that is "mounted" and in use, so you can't run Linux from your LiveUSB drive and simultaneously modify the partition table. Only people who have tablets without an optical drive (like my X41T) are likely to have to resort to option c). However, if you have a desktop PC with an optical drive then you can do the partitioning on your desktop machine.

1. Start your PC with the LiveCD version of Kubuntu.

2. Insert your previously formatted LiveUSB flash drive into a USB port. The drive will automount, a USB flash drive icon will appear on the desktop and a window will open showing drive contents. Close the window.

3. Open a terminal window (ALT+F2 then Konsole).

4. Type the following command to determine the flash drive's device name:
fdisk -l
Note the device name (something like /dev/sdb1) then unmount the drive:
sudo umount /dev/sdb1
Substitute the correct device name in the command if your device has a different name.

5. Download and install the Gnome Partition Editor. On the K menu go to "System" and choose "Adept Manager Manage Packages". This is one of the applications used to install new software. When the program opens look near the top of the window for the Search box. Type in the search term "gparted" and the list of programs should reduce to only the one for the Gnome Partiton Editor. Click on the package name to expand and see details. Then click on the "Request Install" button. At the top of the window click on the "Apply Changes" button and the package will be downloaded and installed. After installation you can find the program on the K menu under "System".

6. Start the Partition Editor (K > System > Gnome Partition Editor). This is a graphical program that looks a lot like PartitionMagic and is very easy to use. But be careful! You'll note that when the program starts it will probably be displaying the partition structure of your hard drive. Don't mess with your hard disk right now! In the upper right corner of the program's window is a device selection button. Click on it and switch to displaying your usb flash drive. For this example that would be /dev/sdb. Yours may differ.

7. Now you'll want to resize the flash drive to create room for a second partition. If you have a 2 GB drive then a good choice is to divide the drive into two 1 GB partitions. If you have a 1 GB drive then make the existing partition as small as you can to leave the maximum amount of room for the second partition.

Resize by right-clicking on the graphic display and choosing "Resize/Move". Drag the right handle on the graphic image to shrink the size of the partition and then click on the "Resize/Move" button. Next click on the "Apply" button on the top toolbar to apply your changes. As soon as the change is applied the drive will automount and you will get an error message. Ignore it and just cancel the error message dialog box. You should now see on the display that there is one partition and some unallocated space on the drive.

Right-click on the unallocated space and choose "New". Keep all of the default choices for size (as large as possible), Create As: (Primary Partition), and filesystem (ext3). Click on "Add". Then click on "Apply" on the toolbar to apply the changes. Again the new partition will automount and a window will open to display the drive contents. Close the window and close the partiton editor.

Here's what your drive should look like when successfully partitioned:

8. Unfortunately the Gnome Partition Editor does not have provisions for naming partitions so you will see that the drive icon on your desktop has the name "usbdisk". We need to change the name to "casper-rw" to be compatible with the name that LiveKubuntu expects. So open a terminal window and enter the following commands:
fdisk -l
to find the device name of the new partition. If your LiveUSB partition was /dev/sdb1 then the new partition should be /dev/sdb2. Check it to be sure.

Change the name by entering the following command:
sudo e2label /dev/sdb2 casper-rw

9. That should do it for the partitioning step. Unplug the drive and shut down. Take the drive over to your Windows PC for the final step. You will need to replace the file "syslinux.cfg" with a modified version to allow booting with persistence enabled. On your Windows PC open Notepad and then copy and paste the following text into Notepad:
    DEFAULT persistent
GFXBOOT bootlogo
GFXBOOT-ACCESS-OPTIONS v1 v2 m1
APPEND  boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL persistent
  menu label ^Start Kubuntu in persistent mode
  kernel vmlinuz
  append  boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash persistent--

LABEL live
  menu label ^Start or install Kubuntu
  kernel vmlinuz
  append  boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL xforcevesa
  menu label Start Kubuntu in safe ^graphics mode
  kernel vmlinuz
  append  boot=casper xforcevesa initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL check
  menu label ^Check CD for defects
  kernel vmlinuz
  append  boot=casper integrity-check initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --

LABEL memtest
  menu label ^Memory test
  kernel mt86plus
  append -

LABEL hd
  menu label ^Boot from first hard disk
  localboot 0x80
  append -

DISPLAY isolinux.txt
TIMEOUT 300
PROMPT 1
F1 f1.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt
F5 f5.txt
F6 f6.txt
F7 f7.txt
F8 f8.txt
F9 f9.txt
F0 f10.txt
What I've done here is to modify the menu file so that all you have to do to enter persistent mode is press the "Enter" key when the boot menu appears.

Plug your usb flash drive into the Windows PC and save the Notepad file to the flash drive as "syslinux.cfg". Answer "yes" to overwrite the existing file with the same name.

Try it out by making a change to the Linux desktop; for example you could eliminate the bouncy cursor as detailed in the part 4 article or change the desktop wallpaper, etc. Reboot and see if your changes are persistent. If so, congratulations!

Screenshots

Here's a view of the desktop of my X41 Tablet PC running Linux:




One neat feature of Linux is the ability to have multiple desktops; I'm currently using four. Screenshots of each are below:






As you can see I like eye candy. Note the applets on the right side of Desktop 1, for example, from a program called SuperKaramba which is one of the programs that you might want to download and experiment with. I like to know some of the things that are going on beneath the hood like the processor loading and clock rate, the upload and download speeds on the network, the wireless access point that is currently in use, CPU temperature and so on, and the system monitor applet lets me keep track of these. And the current weather information is handy. But I digress.

Closing Thoughts:

If you have any questions about this procedure or about Linux then ask away. Have fun exploring Linux!

**Edited 10/18/2007
Added reference to latest version of Kubuntu, 7.10
Persistence is working again with this release


Edited by K0LO - 18 Oct 2007 at 1:09pm
阅读(2652) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~