Saturday, 12 May 2007

Creating a LiveUSB PCLinuxOS

The objective is "simple" to have a 2Gb flash memory stick with a bootable PCLinuxOS that I can plug in almost any computer to have in a few seconds my "own" computer running on it!

Is like to have my own computer in a memory stick in my pocket! Nice!

Also, I will use it to test for some more time PCLinuxOS running on my PIV Dual Core 3000MHz 1Gb ram before I decide to remove Windows XP from it.

This tasks took me some time to figure out, but this is not something that normal user will do.
What normal users need is to get PCLinuxOS pre-installed in their computers (dual boot with PCLinuxOS beeing the default!?). Apparently Dell has arrived to an agreement to pre-install Ubuntu on their machines, I don't know the extent of that agreement but definitely that is the way how Linux will really get to the mass public.

Doing some googleing I found that there are two ways to prepare the LiveUSB. One from within Windows and the other from withing PCLinuxOS. As I had disconnected the monitor from my Windows box to see the PCLinuxOS box, I'll prepare it from withing PCLinuxOS. Also this is probably the way that most people do it. Load PCLinuxOS from the LiveCD and prepare the LiveUSB.

The link for the instructions on how to prepare the LiveUSB for PCLinuxOS are:

Create from Windows a Live-USB on a Flash Memory Stick
Create from PCLinuxOS a Live-USB on a Flash Memory Stick

In any case, in the end I didn't follow the instructions exactly as they are on those webpages. Those instructions have a weak point, they create only one partition on the flash and I learnt that to have a proper LiveUSB is necessary two have at least two (so you can keep all your configuration, changes, documents, etc on the memory stick).

These are the stepts that I followed:

  1. I have already the PCLinuxOS LiveCD physically in my CDROM and loaded as my OS.

  2. I logged as root.
    So we have full privileges to do what we need.

  3. Inserted the 2Gb USB flash memory stick.
    It can be done probably in just 1Gb, and if you have a bigger memory you can created a bigger second partition (will see it later).

  4. Open a terminal and type "fdisk -l" (without the quotes obviously)
    We do this to know which devices the PCLinuxOS is detecting. One of the will be your USB memory and it will be called something like /dev/sdx1 where x is the letter assigned by PCLinuxOS, usually a, b, c, etc... depending on how many USB devices you have connected.

  5. Type "umount /dev/sdx1" (replacing x with your flash drive letter)
    This will unmount your flash drive in case that it was already mounted. In Linux drives need to be mounted to a mounting point (like a logical directory) before the can be accessed, but that is not a problem for us now).

  6. Type "fdisk /dev/sdx" (replacing x with your flash drive letter).
    It will appear a menu where you will type:

  1. "p" to show the current partitions on the usb drive. Then type "d" + enter + the number of the partition to delete them all

  2. "n" to make a new partition.

  3. "p" to make the partition primary

  4. "1" to make this partition one

  5. hit enter to use the default first cylinder

  6. "+800M" to reserve 800Mb for this first partition. This is enough to fit the LiveCD info and a bit more just in case we need more space later.

  7. "a" to make this partition active

  8. “1” to select partition 1

  9. “t” to change it’s file system

  10. “6” to select the fat16 file system

  11. "n" to make a new partition.

  12. "p" to make the partition primary

  13. "2" to make this partition two

  14. hit enter to use the default first cylinder

  15. hit enter to use the default last cylinder, it will take the rest of the space available

  16. "a" to make this partition active

  17. “2” to select partition 2

  18. “t” to change it’s file system

  19. “83” to select the Linux file system

  20. type w to write the new partition table

  1. type umount /dev/sdx1 (replacing x with your device) to unmount the partition

  2. type umount /dev/sdx2 (replacing x with your device) to unmount the partition

  3. Now we are going to give format to the partitions. For that we need to do

    1. type mkfs.vfat -F 16 -n usb /dev/sdx1 to format the first partition as fat (replace x with your flash drive)

    2. type mkfs.ext3 /dev/sdx2 to format the second partition as Linux native (replace x with your flash drive). We need this file system to be able to save all our configuration and documents to the USB.

The above could probably be done also from the “Administration Center->Mount Points->Create, delete and resize hard disk partitions” but I tried and didn't get good results, may be my fault so I decided to do it manually.

  1. Now in theory it is enough to remove and reinsert the USB memory, but I found that not to work well in my system, that is why I recommed to reboot your computer with they USB key removed and insert it when loaded up.

  2. Log in again as root, open a terminal

  3. Type mkdir /tmp/usb

  4. Type mount /dev/sdx1 /tmp/usb (replace x with your USB drive)

  5. Type mount /mnt/cdrom (or cdrom2 if you have more than one)

  6. Type cd /mnt/cdrom (or cdrom2)

  7. Type cp -rf livecd.sqfs isolinux/* /tmp/usb
    This is going to take some time as it has to copy the whole CD

  8. Type cd /tmp/usb

  9. Type mv isolinux.cfg syslinux.cfg

  10. We are going to add now a new menu option when loading PCLinuxOS. To do this type:
    vi syslinux.cfg
    (or use your favorite editor)
    Just below "gfxboot bootlogo" insert the following lines:

    label LiveUSB_SDA
    kernel vmlinuz
    append livecd=livecd initrd=initrd.gz root=/dev/rd/3 acpi=on vga=788 keyb=en lang=en splash=silent fstab=rw,noauto changes=/dev/sda2

    If you happen to have more USB drives connected (as it happens to me) it will be useful to add a similar section just below but replacing "sda" by "sdb" (both in label and in changes). It depends on what drive letter your system assigns to the USB memory stick. In any case, you should always leave he sda option for when you plug your usb memory in a computer different than yours, for example in an Internet Cafe, where chances are that your USB drive will be the only available.

  11. Type cd

  12. Type umount /tmp/usb

  13. Type syslinux -sf /dev/sdx1 (replacing x with your USB device)

  14. Reboot your computer and set your system BIOS to boot from USB-HDD. Also set the boot priority to boot the USB device first if this option is available. Some BIOS have the option to select each boot from which device we want to boot. For example, in mine pressing F11 while booting displays a menu with all the devices from which I could boot, including the USB key.

  15. Now the computer can complaying saying that there is no boot sector or something similar. Mine did. In that case you need to:

    1. Reboot again wih the LiveCD,

    2. log in as root

    3. open a terminal

    4. type “lilo -M /dev/sdx” (replacing x with your USB device)

    5. reboot your computer and make the bios to boot from the usb device (if you have not done it already).

      Now it should work, if it doesn't I would recommend repeating from step 19, at lest that happened to me the first time and the second one worked.

Configuring the first installation of PCLinuxOS to HD

One of the delicate points of the configuration of the PCLinuxOS in my PII was to make it work nicely with my multifunction printer (FAX, scanner, copier and printer) connected directly to the home network, which I need to use every day for work.

What I wanted was an easy integration, similar to the one I had in MS Office. I need to be able also to easily print to the FAX from Word and Explorer (well, the Open Office and PCLinuxOS equivalents).

My multifunction printer is a Brother MFC-5440CN and I found that brother has drivers for Linux for the CUPS system. I learnt that CUPS is a stardard system for printing in Linux, that was created to solve the problems with printing that Linux seemed to experience years ago, or so I read...

I installed the drivers, what not difficult but required to use the command line. I have no trouble with that, but I recognise that many users will do not know how to do it and might be frightened with a command line. This is something that need to be solved and it is a problem from Brother. The driver was installed using something that is called rpm that seems to be a tool to install applications (I'm learning all this as I go...)

PCLinuxOS has a very nice tool to install applications and even update them automatically from Internet, may be that tool could be used also to intall the Brother drivers, but I don't know if that tool "Synaptic" is compatible with rpm or not (and a standard user doesn't need to know). If they are compatible Brother should issue the instructions explaining how to do it from Synaptic. Ideally there should be a way so with simply clicking in a link in the Brother website, the Synaptic utility automatically starts, downloads and install the printer drivers that I needed. May be it can do it already, but it wasn't there. If it doesn't do it, then that is an idea for the developers... and the driver providers.

In the end I managed to make everything to work printer over the network (that one was easy), scanner and fax, but it took me some time and some googling and figuring for work arounds. That is something that a normal user would not be able to do and is quite a big problem for the popularisation of systems like Linux. I believe that in my case the problems resides more in the drivers provided by Brother because for example it is not possible to print directly to the "fax-printer" BRFAX that the drivers create, instead it is necessary to go through a Brother program called brpcfax and that causes problems to integrate the printing to fax easily. Later, when I describe who to configure my LiveUSB (live system running from a 2Gb flash memory stick) I'll explain in detail how to configure the fax, just in case you arrived here from google trying to learn how to do it :-)

Once the multifunction printer MFC-5440CN was working with all its functions in PCLinuxOS I could start doing my daily work... WITHOUT WINDOWS!!!! and from my old PII 300Mhz 512Mb running in multitasking (couple of word documents, a couple of big spread sheets, a couple of firefox sessions each with 5 or 7 websites (tabs) opened, the calculator... ) and almost at the same speed that I had with XP in my powerful PIV Dual Core 3000MHz and 1Gb AMAZING how inefficient Microsoft is!

Installing PCLinuxOS to Hard Disk

I have to recognize that I was a bit "silly" trying to install the PCLinuxOS Live CD to hard disk. I started googleing looking on how to install it to disk, I was trying to locate the version of PCLinuxOS that I needed to download in order to install it to HD. I was surprised that I couldn't find it easily, all I was finding was the live cd version... strange...

Finally, I found an entry where explained how to install to HD... just click on the Install icon on the Desktop loaded with the Live CD!!!!

I felt really bad for the 30 mins that I lost looking for the HD version :-)

The installation to HD involves creating partitions on your HD and writting a new Master Boot Record (MBR) so the BIOS knows what to load when the PC boots. I'm going to install it in my old PII 300Mhz with 512Mb of RAM that was running XP quite slowly. This is a old computer that I used mainly to download music and films so I backed up the useful information to my recently purchased 250Gb external USB drive and wiped out the old PC's HD! I felt good and uneasy at the same time wiping out a HD that has been with me for almost 10 years! (If I remember well).

I followed the instructions of the installation wizard, selecting the option of deleting the current partitions, this created new ones and asked me to reboot and select existing ones. I did so and everything installed smoothly. I didn't check the time it took to install, but I think it was something between 20 and 30 minutes. It has to read, decompress and write the whole CD and that takes some time by the forces of physics :-)

There I was, with a PII 300MHz running PCLinuxOS much faster than it was running XP and just in a while!

Why PCLinuxOS?

There is a recurring reason around Internet this days triggered by Windows Vista. We have quite a reasonable computer PIV Dual Core with 1Gb RAM and 3D graphic card, a computer with the power of some supercomputers of not that many years ago, and still this is almost the minimum hardware required for Windows Vista. I'm not going to replace my "supercomputer" just to put Vista and have it running like if it was my old Pentium II.

Therefore, as many are doing, I decided to have a look at the current state of Linux. A couple of years ago I tried but I didn't like too much what I saw, it was still quite behind Windows, but this time I had a good surprise!

I googled a bit and found the versions that run out of a CD without the need for installing. I wanted to try this just in case I didn't like Linux as installing in the HD means reconfiguring the boot sector, partitioning, etc which is quite cumbersome and dangerous if you do not do a proper backup of your whole computer.

From the live versions I read quite a bit about Ubuntu and PCLinuxOS so I download and burned to CD both, which I tried on my old Pentium II 300MHz with 512Mb and in my
laptop Dual Core with 1Gb of RAM.

Ubuntu: I didn't like too much the initial aspect of Ubuntu, that brown is a bit horrible, it doesn't look unprofessional, but obviously that can be solved changing the theme. The problem with Ubuntu is that it didn't make the WIFI connection on my laptop to work from start, it complained about having to run drivers not supported and I didn't manage to make the connection to work within 2 minutes. That was critical for me. If with Ubuntu I don't manage to make WIFI to run in two minutes then probably I'm going to have a lot of other problems that will take a lot of my previous time to solve. Ubuntu scored bad for me.

PCLinuxOS: When I tried PCLinuxOS on my Laptop I got the WIFI connection working in less than 30 seconds! Even before the Desktop loaded as the configuration is done automatically during the very brief setup of the live cd. That was amazing for me specially compared to the previous experience with Ubuntu so I decided to try more this PCLinuxOS.

When the Desktop loaded, it was neat and very professional looking. It was very easy to customize, change the screen resolution, fonts, etc. It comes with a lot of applications installed in the live cd, like Open Office with all the equivalents to MS Office (word, excel, powepoint, etc), firefox, multimedia applications, etc... quite complete for only a standard (compressed) CD.

Making PCLinuxOS to view the rest of my home network (from computers running microsoft) was reasonably easy with something called "smb4k" under "PC" (like "Start" in MS)->Internet->File Transfer. I put a shortcut to smb4k in the desktop and I have easy access to the home network. There are other mechanism, but that was the first that I found in a couple of minutes.

Then to make the PCLinuxOS box visible to the rest of the network it seemed a bit more complicated. It is necessary to configure Samba, not too complex, but I had to google a bit to learn how Samba works and how is configured. I had heard of Samba before, but I didn't know what it was for exactly.

Once I had access to my network from PCLinuxOS, I took the Office documents created by MS in my windows boxes and opened with Open Office. I was pleasantly surprised. They looked almost identical, the functions are very similar, the look of everything is very professional (by the way, I reduced the standard system font from 12pt to 8pt which is more reasonable for me because I want to be able to see us much info on the screen in a single shot as possible). It was very natural to work with Open Office, even many shortcuts are the same than in MS Office, for example to insert a row in Excel you do Alt+I and select row from the menu, something that I do very often en Excel and that I can do exactly the same in Open Office Calc.

Some may criticize that PCLinuxOS and even Open Office it is copying MS, but the truth is that this kind of similitudes makes very easy the transition from the MS world to the Linux world and that is very welcomed. I do not want to start learning how to use my office tools again, I want just to get rid of Microsoft and continue working in a nice and easy Linux environment like is PCLinuxOS and Open Office.

Resume
Ubuntu defrauded me with WIFI and was enough reason to drop it, I was greatly surprised by PCLinuxOS in all aspects and I decided to go for it. It seems as if I could do my every day work in PCLinuxOS!

Next step is to install it to HD!