Archive for May, 2010

GRUB – Booting

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 30th, 2010

Welcome to the tutorial guide. The tutorial will provide a user with guidance and instructions on GRUB booting. Please note that GRUB has two distinct boot methods. One of the two is to load an operating system directly, and the other is to chain-load another boot loader which then will load an operating system actually.

As the boot method that is to load and operating system directly is best and a reason for it is that a user don’t need to install or maintain other boot loaders and GRUB is flexible enough to load an operating system from an arbitrary disk/partition. Let’s start to load an operating system directly by following the step as mentioned below:

How to boot an OS directly with GRUB
Multiboot is the native format supported by GRUB. For the sake of convenience, there is also support for Linux, FreeBSD, NetBSD and OpenBSD. If a user wants to boot other operating systems, then he/she will have to chain-load
A user can follw the steps so that GRUB can boot any Multiboot-compliant OS:
• A user should set GRUB’s root device to the drive where the OS images are stored with the command root
• Then a user can load the kernel image with the command kernel
• Now, if a user needs modules, then he/she can load them with the command module or modulenounzip
• Finally, a user can run the command boot
A user can boot Linux, FreeBSD, NetBSD and OpenBSD in a similar manner. A user can load a kernel image with the command kernel and then run the command boot. If the kernel requires some parameters, then a user has to append the parameters to kernel, after the file name of the kernel.
Load another boot loader to boot unsupported operating systems
If a user wants to boot an unsupported operating system (e.g. Windows 95), chain-load a boot loader for the operating system. Normally, the boot loader is embedded in the boot sector of the partition on which the operating system is installed. A user can follow the steops as mentioned below@
• A user can set GRUB’s root device to the partition by the command rootnoverify
• grub> rootnoverify (hd0,0)
• now a user can set the active flag in the partition using the command makeactive:
• grub> makeactive
• now a user can load the boot loader with the command chainloader
• grub> chainloader +1

Please note that `+1′ indicates that GRUB should read one sector from the start of the partition.
• Now a user can run the command boot.
GNU/Hurd
As GNU/Hurd is Multiboot-compliant, it is easy to boot it. A user should not forget that he has to specify a root partition to the kernel. A user can follow these steps as meintoned:
• First of all, a user has to set GRUB’s root device to the same drive as GNU/Hurd’s.
• Following command can be helpful for the user. find /boot/gnumach
• Now a user can load the kernel and the module, like this:
o grub> kernel /boot/gnumach root=hd0s1
o grub> module /boot/serverboot
o finally, a user can run the command boot

GNU/Linux
It is easy to boot GNU/Linux from GRUB, because it resembles to boot a Multiboot-compliant OS.
o First of all a user can set GRUB’s root device to the same drive as GNU/Linux’s.
o Following command be prove helpful. The command find /vmlinuz
o Now a user can load the kernel by running following command:grub> kernel /vmlinuz root=/dev/hda1

If a user wants to specify some kernel parameters, then a user can append them to the command. For example, to set vga to `ext’, a user can run following command:
grub> kernel /vmlinuz root=/dev/hda1 vga=ext

o If a user is using an initrd, then he/she has to execute the command initrd after kernel by running following command: grub> initrd /initrd

o In end, a user can run the command boot
A user should know that if he/she is using an initrd and specify the `mem=’ option to the kernel to let it use less than actual memory size, then he/she will also have to specify the same memory size to GRUB. In order to let GRUB know the size, a user should run the command uppermem before loading the kernel.

FreeBSD
GRUB can load the kernel directly, either in ELF or a.out format. But this is not recommended, since FreeBSD’s bootstrap interface sometimes changes heavily, so GRUB can’t guarantee to pass kernel parameters correctly.
NetBSD
GRUB can load NetBSD a.out and ELF directly. This can be provided in the steps as below:
o A user can set GRUB’s root device with root
o Now a user can load the kernel with kernel. It is recommended that at user should append the ugly option –type=netbsd, if he/she wants to load an ELF kernel, like this: grub> kernel –type=netbsd /netbsd-elf
o Finally, a user can run boot.
DOS/Windows
As GRUB cannot boot DOS or Windows directly, so a user should chain-load them. However, their boot loaders have some critical deficiencies, so it may not work to just chain-load them. In order to overcome the problems, GRUB provides a user with two helper functions.
If a user has installed DOS (or Windows) on a non-first hard disk, then he/she has to use the disk swapping technique, because that OS cannot boot from any disks but the first one. The workaround used in GRUB is the command map like this:
grub> map (hd0) (hd1)
grub> map (hd1) (hd0)
This performs a virtual swap between the first and second hard drive.

A user should note that this is effective only if DOS (or Windows) uses BIOS to access the swapped disks. If that OS uses a special driver for the disks, this might not work.
A user might encounter another problem if he/she has installed more than one set of DOS/Windows onto one disk, because in this way a user could be confused if there are more than one primary partitions for DOS/Windows. There is a solution to this which is that a user should use the partition hiding/unhiding technique.
If GRUB hides a DOS (or Windows) partition, DOS (or Windows) will ignore the partition. If GRUB unhides a DOS (or Windows) partition, DOS (or Windows) will detect the partition. If a user has installed DOS (or Windows) on the first and the second partition of the first hard disk, and wants to boot the copy on the first partition, then he/she can run following command:
grub> unhide (hd0,0)
grub> hide (hd0,1)
grub> rootnoverify (hd0,0)
grub> chainloader +1
grub> makeactive
grub> boot
SCO UnixWare
It is known that the signature in the boot loader for SCO UnixWare is wrong, so a user will have to specify the option –force to chainloader. This is provided below:
grub> rootnoverify (hd1,0)
grub> chainloader –force +1
grub> makeactive
grub> boot
QNX
As QNX seems to use a bigger boot loader, so a user has to boot it up. This is provided below:
grub> rootnoverify (hd1,1)
grub> chainloader +4
grub> boot

If a user wants to make the system robust then he should know that when testing a new kernel or a new OS, it is important to make sure that users computer can boot even if the new system is unbootable. This is important if a user maintains servers or remote systems. In order to do this a user has to setup following:
• A user has to maintain a system which is always bootable. For instance, if a user tests a new kernel, then he/she will need to keep a working kernel in a different place.
• A user should direct GRUB to boot a working system when the new system fails. This is possible with the fallback system in GRUB.
The former requirement is very specific to each OS, so it is best to use GRUB.

There are two possibilities: one of them is quite simple but not very robust, and the other is a bit complex to set up but probably the best solution to make sure that a users system can start as long as GRUB itself is bootable.

Booting once-onlyA user can teach GRUB to boot an entry only at next boot time. Suppose that a user has an old kernel old_kernel and a new kernel new_kernel. A user should know that old_kernel can boot his/her system correctly, and he/she wants to test new_kernel.

In order to ensure that the system will go back to the old kernel even if the new kernel fails, a user can specify that GRUB should try the new kernel only once and boot the old kernel after that.
A user has to modify his/her configuration file. An example is provideed below:
default saved # This is important!!!
timeout 10

title the old kernel
root (hd0,0)
kernel /old_kernel
savedefault

title the new kernel
root (hd0,0)
kernel /new_kernel
savedefault 0

A user should note that this configuration file uses `default saved’ at the head and `savedefault 0′ in the entry for the new kernel. This means that GRUB boots a saved entry by default, and booting the entry for the new kernel saves `0′ as the saved entry.
With this configuration file, after all, GRUB always tries to boot the old kernel after it booted the new one, because `0′ is the entry of the old kernel.
The next step is to tell GRUB to boot the new kernel at next boot time. In order to do this a user has to execute grub-set-default by running following code:
# grub-set-default 1
This command sets the saved entry to `1′, that is, to the new kernel.
A user should note that if GRUB stops booting, if there is any error in the boot entry, such that the new kernel has an invalid executable format. Here a user has to use the fallback mechanism of GRUB.

Booting fallback systems
As GRUB supports a fallback mechanism of booting one or more other entries if a default boot entry fails, so it is a good idea sthat a user should specify multiple fallback entries.
Suppose that a user has three systems, `A’, `B’ and `C’. `A’ is a system which a user wants to boot by default. `B’ is a backup system which is supposed to boot safely. `C’ is another backup system which is used in case where `B’ is broken.

Then a user may want GRUB to boot the first system which is bootable among `A’, `B’ and `C’. A configuration file can be written in this way:
default saved # This is important!!!
timeout 10
fallback 1 2 # This is important!!!

title A
root (hd0,0)
kernel /kernel
savedefault fallback # This is important!!!

title B
root (hd1,0)
kernel /kernel
savedefault fallback # This is important!!!

title C
root (hd2,0)
kernel /kernel
savedefault
Please note that `default saved’, `fallback 1 2′ and `savedefault fallback’ are used. GRUB will boot a saved entry by default and save a fallback entry as next boot entry with this configuration.
When GRUB tries to boot `A’, GRUB saves `1′ as next boot entry, because the command fallback specifies that `1′ is the first fallback entry. The entry `1′ is `B’, so GRUB will try to boot `B’ at next boot time.

Similarly, when GRUB tries to boot `B’, GRUB saves `2′ as next boot entry, because fallback specifies `2′ as next fallback entry. This makes sure that GRUB will boot `C’ after booting `B’.
It is imporant to know that GRUB uses fallback entries both when GRUB itself fails in booting an entry and when `A’ or `B’ fails in starting up the system. This solution ensures that a users system is started even if GRUB cannot find his/her kernel or if a users kernel panics.

It is recommended that a user should run grub-set-default when `A’ starts correctly or a user fix `A’ after it crashes, since GRUB always sets next boot entry to a fallback entry. A user can run a command in a startup script such as rc.local to boot `A’ by default:
# grub-set-default 0
Please note that `0′ is the number of the boot entry for the system `A’.
If a user wants to see what is current default entry, then he/she can look at the file /boot/grub/default (or /grub/default in some systems). As this file is plain-text, a user can just cat this file. A user should not modify this file directly. The reason behind this is that GRUB may fail in saving a default entry in this file, if a user change this file in an unintended manner.

If a user followed this tutorial guide then he/she would have learnt about GRUB booting.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

GRUB - How to install GRUB using grub-install

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 29th, 2010

Welcome to the tutorial guide. The tutorial will provide a user wigh guidance and instructions on how to install GRUB by using grub-install.

Before a user starts with the installation process, it is good idea that a user should know that this procedure is not very safe. There are several ways in which a users computer can become unbootable. For example, most operating systems don’t tell GRUB how to map BIOS drives to OS devices correctly. GRUB merely guesses the mapping. This will succeed in most cases, but not always. This is why GRUB provides a user with a map file called the device map, which a user should fix if it is wrong.
If a user is still interested in installing GRUB under a UNIX-like OS (such as GNU), then he/she should invoke the program grub-install as the superuser (root).
The usage is basically very simple. A user needs to specify one argument to the program, namely, where to install the boot loader. The argument can be either a device file (like `/dev/hda’) or a partition specified in GRUB’s notation. For example, under Linux the following will install GRUB into the MBR of the first IDE disk:
# grub-install /dev/hda
Please note that under GNU/Hurd, this has the same effect:
# grub-install /dev/hd0
If it is the first BIOS drive, this is the same as well:
# grub-install ‘(hd0)’
Or a user can omit the parentheses:
# grub-install hd0
A user should note that all the mentioned examples assume that GRUB should use images under the root directory. If a user wants GRUB to use images under a directory other than the root directory, then he/she will need to specify the option –root-directory. The typical usage is that a user can create a GRUB boot floppy with a filesystem. Please view an example as below:
# mke2fs /dev/fd0
# mount -t ext2 /dev/fd0 /mnt
# grub-install –root-directory=/mnt fd0
# umount /mnt
Another example is when a user can have a separate boot partition which is mounted at /boot. Since GRUB is a boot loader, it doesn’t know anything about mountpoints at all. Thus, a user will need to run grub-install like this:
# grub-install –root-directory=/boot /dev/hda
By looking at the mentioned example, it is quite difficult to guess BIOS drives correctly under a UNIX-like OS. Thus, grub-install will prompt a user to check if it could really guess the correct mappings, after the installation. A user should note that if the output is wrong, it is unlikely that thencomputer will be able to boot with no problem.
Please note that grub-install is actually just a shell script and the real task is done by the grub shell grub. This is why a user can run grub directly to install GRUB, without using grub-install. A user should not do that unless he/she is familiar with the internals of GRUB and installing a boot loader on a running OS can be extremely dangerous.
How to make a GRUB bootable CD-ROM
GRUB supports the no emulation mode in the El Torito specification. This means that a user can use the whole CD-ROM from GRUB and a user don’t have to make a floppy or hard disk image file, which can cause compatibility problems.
For booting from a CD-ROM, GRUB uses a special Stage 2 called stage2_eltorito. The only GRUB files that user can need to have in his/her bootable CD-ROM are this stage2_eltorito and optionally a config file menu.lst. A user doesn’t need to use stage1 or stage2, because El Torito is quite different from the standard boot process.
A user can note example of procedures if he/she wants to make a bootable CD-ROM image. These are provided below:
- a user should make a top directory for the bootable image, say, `iso’:
$ mkdir iso
- then a user should make a directory for GRUB:
$ mkdir -p iso/boot/grub
- after making a directory for GRUB, a user can then copy the file stage2_eltorito:
$ cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub
- a user can now make the config file menu.lst under iso/boot/grub, and copy any files and directories for the disc to the directory iso/.
- Finally, make a ISO9660 image file. This is provided below:
$ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
-boot-load-size 4 -boot-info-table -o grub.iso iso
This produces a file named grub.iso, which then can be burned into a CD (or a DVD). mkisofs has already set up the disc to boot from the boot/grub/stage2_eltorito file, so there is no need to setup GRUB on the disc.
A user should note that the -boot-load-size 4 bit is required for compatibility with the BIOS on many older machines.
A user can use the device `(cd)’ to access a CD-ROM in his/her config file. This is not required; GRUB automatically sets the root device to `(cd)’ when booted from a CD-ROM. It is only necessary to refer to `(cd)’ if a user wants to access other drives as well.

If a user followed advise and guidance as provided in this tutorial guide then he/she would have learnt about installing GRUB using grub-install.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

GRUB - Naming convention

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 29th, 2010

Welcome to the tutorial guide. The tutorial will provide guidance and instructions on naming convention.

A user should note that the device syntax used in GRUB is different from what a user has seen before in the operating system(s). A user can specify a drive/partition.
Please have a look at the following examples and explanations:
(fd0)
First of all, GRUB requires that the device name be enclosed with `(’ and `)’. The `fd’ part means that it is a floppy disk. The number `0′ is the drive number, which is counted from zero. This expression means that GRUB will use the whole floppy disk.
(hd0,1)
Please note that `hd’ means it is a hard disk drive. The first integer `0′ indicates the drive number, that is, the first hard disk, while the second integer, `1′, indicates the partition number. A user should note that the partition numbers are counted from zero, not from one. This expression means the second partition of the first hard disk drive. In this case, GRUB uses one partition of the disk, instead of the whole disk.
(hd0,4)
This specifies the first extended partition of the first hard disk drive. A user should note that the partition numbers for extended partitions are counted from `4′, regardless of the actual number of primary partitions on the hard disk.
(hd1,a)
This means the BSD `a’ partition of the second hard disk. In order to specify which PC slice number should be used, a user can use: `(hd1,0,a)’. If the PC slice number is omitted, GRUB searches for the first PC slice which has a BSD `a’ partition.
If a user wants to access the disks or partitions with GRUB, then he/she needs to use the device specification in a command, like `root (fd0)’ or `unhide (hd0,2)’. If a user wants to find out which number specifies a partition that he/she wants, the GRUB command-line options have argument completion. According to this a user can only need to type
root (
followed by a , and GRUB will display the list of drives, partitions, or file names. In other words, it is quite easy to determine the name of the users target partition, even with minimal knowledge of the syntax.
A user should note that GRUB does not distinguish IDE from SCSI - it simply counts the drive numbers from zero, regardless of their type. Normally, any IDE drive number is less than any SCSI drive number, although that is not true if a user changes the boot sequence by swapping IDE and SCSI drives in his/her BIOS.
If a user wants to specify a file then he/she should have a look at the following example:
(hd0,0)/vmlinuz

This specifies the file named `vmlinuz’, found on the first partition of the first hard disk drive. Note that the argument completion works with file names, too.

If a user followed advise and guidance as provided in this tutorial guide then he/she would have learnt about GRUB naming convention.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

How to secure GRUB

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 23rd, 2010

Welcome to the tutorial guide. The guide will provide a user with guidance and instructions on how to secure GRUB.

A user should know that the standard GRUB installation is not secure. This means everyone that has physical access to the computer may change settings for the boot up. If a user can boot into a single-usermode then he/she will not be asked for a password. In this way, the system is in a risk to an attack.

If a user uses the security features from the GRUB then he/she can secure the boot menu and every entry. This has an advantage over LILOs plain text password, becsue the GRUB uses a MD5 encrypted password which can not be read simply by reading the GRUB configuration file.

How a user can do this is by following the steps as mentioned:
- A user has to generate the MD5 password enter the GRUB shell (grub):
grub> md5crypt
Password: **********
Encrypted: $1$wgf8G0$Tt7XAsoiEAOU4PALAzkaL0
- then a user has to copy the encrypted password and exit the GRUB shell (quit). - - - - now a user will need to edit the GRUB configuration (/boot/grub/menu.lst) and insert the following line (before the title-Sections):
password –md5 PASSWORD
- now a user can swap PASSWORD with the above created MD5 password.
In this way, the GRUB prevents people from editing the boot up commands by asking for the password.

If a user wants to protect a boot menu entry from being booted then he/she needs to insert the line lock right after title. Entries before lock can be executed so it’s important where lock is inserted!
An example will clarify this process:
default 0
fallback 1
timeout 10
password –md5 $1$wgf8G0$Tt7XAsoiEAOU4PALAzkaL0
title Linux-2.4.25
root (hd0,4)
kernel /bzImage-2.4.25-super root=/dev/hda6 ro
title Linux-2.4.22-supermount-acpi
lock
root (hd0,4)
kernel /bzImage-2.4.22-super-acpi root=/dev/hda6 ro

If a user followed this tutorial guide then he/she would have leanrt asbout how to secure GRUB.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

Installing the GRUB ootloader

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 22nd, 2010

Welcome to the tutorial guide. The tutorial will provide a user with guidance and instructions on how to install the GRUB ootloader.

In order to install a GRUB ootloader to the harddisk, a user can follow the steps as mentioned below:
grub-install /dev/sda

After running the mentioned command, GRUB will be installed. The file /boot/grub/menu.lst as boot menu.
A user will receive errors and if this is the case then a user can note the errors and solutions to them. These are provided below:
Error 18
Error 18: Selected cylinder exceeds maximum supported by BIOS
This error is returned when a read is attempted at a linear block address beyond the end of the BIOS translated area. The reason for this happening is that if the disk is larger than the BIOS can handle (512MB for (E)IDE disks on older machines or larger than 8GB on others.). In other words, the BIOS is unable to start executing the kernel because the kernel is not located within the block it can access at boot up time.

This can be circumvented by creating a boot partition at the beginning of the disk that is completely within the first 1023 cylinders of the hard drive. This partition will contain the kernel.
Please note that the kernel itself does not suffer from the same limitations as the BIOS so after the BIOS has loaded the kernel the kernel will have no problem accessing the whole harddrive. The newer BIOSes will automatically translate the harddrives size in a way that it can be completely contained within the first 1023 cylinders and hence modern computers do not suffer from this problem.

The same error can happen when the BIOS detects a disk in a different way as Linux does. This happens when a user is changing motherboards or when moving a GRUB-bootable disk from one computer to another. If this is the case then a user can just boot with a GRUB floppy, read the C/H/S numbers from the existing partition table and manually edit the BIOS numbers to match. If a user is using a SUSE linux and installing on VM Ware then this problem can be solved by creating a small partition at the very beginning of the harddisc, and mounting it as /boot.
Error 18 on Dual Boot Systems Using a Single Hard Drive
A user should note that this error exixts when a user is creating a dual boot system (with Windows) on a single hard disk drive, as in a notebook PC, because the Linux partitions end up being beyond the LBA range. If a user has a large notebook drive then he/she should re-install Windows into a smaller primary partition (or resize the partition), then create an extended partition in the unallocated space and create partitions for Linux Root, Linux Swap, and Linux Home, then in the remaining unallocated space create another NTFS partition for Windows. It is recommended that the Linux partitions must be immediately after the Primary Windows partition so they are still within the LBA range. This is that a user can place additional NTFS or FAT32 partitions after the Linux partitions.
If a user has a large note book with 160GB notebook drive, then following gave the Error 18:
Primary: 80GB Windows NTFS
Extended: 4GB (FAT32), 50GB (NTFS), 4GB Linux Root (ext3), 2GB Linux Swap, 20GB Linux home (ext3).

The following worked:
Primary: 80GB Windows NTFS
Extended: 4GB Linux Root (ext3), 2GB Linux Swap, 20GB Linux home (ext3), 4GB (FAT32), 50GB (NTFS).
A solution is to have the NTFS file system split into two partitions.
It is good to note that the reason for the 4GB FAT 32 partition is that it makes it possible for both Windows and Linux to access that partition, which can be useful when transferring files between the two operating systems.
How to remove GRUB after Error 18 on a Dual Boot System (Windows/Linux) Using a Single Hard Drive
If a user installed GRUB on a dual boot system with a single hard drive, and gets Error 18, then a user will not be able to boot Windows. In order to deal with this, a uer has to go through following steps:
- boot the system from a Windows Recovery CD,
- then select “R” for Repair, and
- then run “fixmbr” (fix master boot record) at the DOS prompt in C:\windows.
After going through these steps, GRUB will be removed. If a user doesn’t have a recovery CD, then he/she can download floppies from Microsoft for XP.
Error 21
Error 21: Unknown boot failure
Symptom
When a user is booting, then he/she can get line saying
Error 21
then the system stops.
A user should note that the main reason for getting this error is that an incorrect device list handed over to grub’s setup command.
There is a solution to this. A user can resolve this error, by using the grub-install and watch its output thoroughly:
tweedleburg:~ # grub-install /dev/sda

GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> setup –stage2=/boot/grub/stage2 (hd0,0) (hd0,0)
Checking if “/boot/grub/stage1″ exists… yes
Checking if “/boot/grub/stage2″ exists… yes
Checking if “/boot/grub/e2fs_stage1_5″ exists… yes
Running “embed /boot/grub/e2fs_stage1_5 (hd0,0)”… failed (this is not fatal)
Running “embed /boot/grub/e2fs_stage1_5 (hd0,0)”… failed (this is not fatal)
Running “install –stage2=/boot/grub/stage2 /boot/grub/stage1 (hd0,0) /boot/grub/stage2 p/boot/grub/menu.lst “… succeeded
Done.
grub> quit
tweedleburg:~ #
A user should watch the underlined line. If a user runs into grub error 21, then he/she needs to check that there are no non-existant devices. If there are, then a user may have found the issue. In this case, a user can call
grub
and issue the correct setup command in its shell. It is good to know what is a shell. A shell is known as a command interpreter. It is a specialised program for accepting typed user commands, translating those into programs to run, running those programs, and displaying (or doing something) with the results. Please have a look at the example of a shell which is DOS shell. This is called COMMAND.COM.
There is another reason for the error to exist which is:
A users bootloader tries to load /boot/grub/menu.lst from a hard disk which doesn’t exist. An example will simplity this. If a user has installed Linux for booting from USB and removed the USB disk, and the MBR has been changed. Please note that MBR stands for Master Boot Record
The solution to this is to re-attach the missing disk, and then re-run grub-install.
The reason is that a users initrd is broken. A user can call grub and test it. This is provided below:
GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]

grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0×83

grub> kernel /boot/vmlinuz
[Linux-bzImage, setup=0×3000, size=0×1ffb98]

grub> initrd /boot/initrd

Error 16: Inconsistent filesystem structure

grub>
When a user is booting from USB, then he/she can get a line saying
GRUB
nothing else.
This is because there is a problem with users device map. A user should know that when booting from USB, a users USB disk corresponds to (hd0), the first harddisk. grub-install will tell a user where its device map is - try correcting it.
Invalid or damaged bootable partition
If a user has a invalid or damaged bootable partition then he/she will note that when booting, he/she does not get a grub menu, but a message saying
Invalid or damaged Bootable partition
The reason can be that a user has installed grub to a partition that no longer exists. For example, if a user installed onto a disk that was the third in the device order and now another disk has been removed and grub can no longer access the “third” disk. A user must know that the first disk is called hd(0), the second hd(1) and the third hd(2). When trying to re-install grub, a user would see
tweedleburg:/boot/grub> grub-install –recheck /dev/sdc

GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> setup –stage2=/boot/grub/stage2 –force-lba (hd0) (hd2,0)

Error 21: Selected disk does not exist
grub> quit
tweedleburg:/boot/grub>
Where (hd2) does not exist. In /etc/grub.conf a user will find
setup –stage2=/boot/grub/stage2 (hd0,0) (hd2,0)

If a user followed advise and guidance as presented in this tutorial guide then he/she would have learnt about installing the GRUB ootloader.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

GRUB boot menu

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 17th, 2010

Welcome to the tutorial guide. The tutorial will provide guidance and instructions on GRUB.
Before we start with the tutorial, it is good idea to know about GRUB.

GNU GRUB is a very powerful boot loader, which can load a wide variety of free operating systems, as well as proprietary operating systems with chain-loading1. GRUB is designed to address the complexity of booting a personal computer; both the program and this manual are tightly bound to that computer platform, although porting to other platforms may be addressed in the future.

One of the important features in GRUB is flexibility; GRUB understands filesystems and kernel executable formats, so a user can load an arbitrary operating system the way a user likes, without recording the physical position of his/her kernel on the disk. A user can therefore load the kernel just by specifying its file name and the drive and partition where the kernel resides.

The default location is in /boot/grub/menu.lst. The .lst suffix stands for menu list, not menu first. The file contains configuration options colour, timeout and password settings) and a list of menu entries. The file is often managed by some tool from the distribution itself, so when kernels are installed or removed the boot menu list gets automatically updated. Another common location is /etc/grub.conf but this is often a link file to the /boot/grub file.

Manual configuration
In order to configure grub, a user should first of all find out his/her distribution. It is good to know that SUSE uses /boot/grub/menu.lst, Red Hat and Ubuntu use /boot/grub/grub.cfg. Let’s have a quick look at the example entries.

Basic entry to boot a linux kernel located on the first disk:
title Linux kernel 2.6.4
root (hd0,0)
kernel /boot/vmlinuz-2.6.4 root=/dev/hda1 ro 3
initrd /boot/initrd.img

A user should understand that:
• title denotes the selectable boot-menu title;
• root (hd0,0) says /boot partition is on the first partition first drive or that the SUB-folder /boot to the / partition refers to same structure;
• kernel tells grub where to find the linux kernel. The “root” mentioned after vmlinuz refers to the / entry in the /etc/fstab file. Kernel parameters such as desired runlevel (3) may be presented at the end of the kernel-line;
• initrd describes the use and location of a preconfigured ramdisk.

Please note that grub starts counting disks from 0, while skipping other IDE devices. This is why /dev/hda1=(hd0,0) and /dev/hdc1=(hd1,0) when a cdrom-drive is attached as slave on the first IDE-channel. When adding drives to an existing configuration, a user should refresh drives.map from within grub, especially when more than one drive/partition is bootable.

Debian
Debian manages the menu file with update-grub. This script checks which kernels are located in /boot/ and generates a menu entry for them. It adds its own configuration options to the menu.lst file. These concern the options that are given to the generated menu entries. A user should note that update-grub is automatically run after kernel packages have been installed or removed, but if this is not the case then update-grub can be added as a postinst_hook and a postrm_hook in the /etc/kernel-img.conf file.

Red Hat
Red Hat also manages the menu.lst file itself. It should be updated automatically when a kernel rpm is installed or removed.

SuSE
SuSE manages the menu.lst of GRUB using YAST.
Booting Windows/DOS
title Win
rootnoverify (hd0,0)
makeactive
chainloader +1

If a user wants to have dual-booting with Linux on the first disk and Windows on the 2nd or some other disk, then he/she will run into a common trouble: WARNING Windows only wants to boot from partitions on first disk in the system. A user should note that GRUB can trick Windows with the map command. An example entry to correct this problem is provided as:
title Win
rootnoverify (hd1,0)
map (hd0) (hd1)
map (hd1) (hd0)
makeactive
chainloader +1
Shutdown the machine from the menu
Another menu entry that can be handy is one to shutdown the machine:
title Halt!
halt

Removing obsolete kernels
If a user wants to remove obsolete kernel entries from the boot menu then a user needs to uninstall the old kernels by:
rpm -e kernel-default-2.6.25.18-0.2

If a user followed this tutorial guide then he/she would have learnt about GRUB boot menu.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

Inputting Ubuntu NetBook Remix 10.04 on Flash Drive in Windows

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 17th, 2010

Welcome to the tutorial guide. The tutorial will provide a user with guidance and instructions on how to input Ubuntu Netbook remix 10.04 on flash drive in Windows.
Please note that a user needs a minimum 1GB capacity for the flash drive. Other things that a user should be aware of are following:
• Windows PC to perform conversion
• ubuntu-10.04-netbook-i386.iso
• 1GB or larger USB flash drive (fat32 formatted) Universal USB Installer

If a user wants to install Ubutu NetBook Remix on USB from Windows then he/she should follow the steps as mentioned below:
-first of all, a user needs to download the Torrent, and then proceed to download the ISO
-after downloading the Torrent, a user has to download the Universal USB Installer, select Ubuntu Netbook Remix 10.04
-and then a user can follow the onscreen instructions
-after the Installer is finished, a user can then restart his/her computer,
-and then set the BIOS Options or Boot Menu to boot from the USB device and reboot

If a user followed the guidance and instructions as provided in this tutorial guide then he/she would have learnt about inputting Ubuntu NetBook Remix 10.04 on Flash Drive in Windows.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

Wolvix – installation

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 16th, 2010

Welcome to the tutorial guide. The guide will provide guidance and instructions to a user on how to install Wolvix to a flash drive using Windows.

Before a user can go ahead with the process of installation, he/she should note the requirements for this:
A minimum Flash Drive Capacity is: 625MB (before persistence)
The requirements are provided below:
-Windows PC to perform conversion
-wolvix-2.0.0-build58.iso
-1GB or larger USB flash drive
-Universal USB Installer (does the USB conversion)

Now, let’s go through the installation process. A user has to follow the steps in order to start the installation process.
- first of all, a user needs to download the wolvix-2.0.0-build58.iso
- now, a user has to download and launch the Universal USB Installer, select from the end of the list
- after the script has finished, a user has to restart the PC
- after restarting the PC, a user has to set the BIOS or Boot Menu to boot from the USB device,
- a user should not forget to save the changes
- now a user can reboot

Please note the username and password for Wolvix Login:
The username is : root and the password is: toor

If the steps are followed as mentioned then a user will be booting from the Wolvix USB and would have learnt about how to install Wolvix to a flash drive using Windows.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

CRUX – Configuration

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 16th, 2010

Welcome to the tutorial guide. The guide will provide a user with guidance and instructions on CRUX configuration. The guide will cover initialization scripts, passwords and upgrading the Kernel.
A user should note that there are various runlevels for initialization scripts. The runlevels that are used in CRUX are :
Runlevel Description
0 Halt
1 (S) Single-user Mode
2 Multi-user Mode
3-5 (Not used)
6 Reboot

Now, lets have a look at the layout for the initialization scripts. The initialization scripts in CRUX follow the BSD-style. The layout is provided below:
File Description
/etc/rc System boot script
/etc/rc.single Single-user startup script
/etc/rc.modules Module initialization script
/etc/rc.multi Multi-user startup script
/etc/rc.local Local multi-user startup script (empty by default)
/etc/rc.shutdown System shutdown script
/etc/rc.conf System configuration
/etc/rc.d/ Service start/stop script directory
Depending on needs and requirements, a user can modify /etc/rc.modules, /etc/rc.local and /etc/rc.conf.

Configuration Variables in /etc/rc.conf
The configuration variables that are found in /etc/rc.conf are provided below:
Variable Description
FONT Specifies which console font to load at system startup. The contents of this variable will be passed as argument to setfont(1). The available fonts are located in /usr/share/kbd/consolefonts/.
Example: FONT=default
KEYMAP Specifies which console keyboard map to load at system startup. The contents of this variable will be passed as argument to loadkeys(1). The available keyboard maps are located in /usr/share/kbd/keymaps/.
Example: KEYMAP=sv-latin1
TIMEZONE Specifies the timezone used by the system. The available zone description files are located in /usr/share/zoneinfo/.
Example: TIMEZONE=Europe/Stockholm
HOSTNAME Specifies the hostname.
Example: HOSTNAME=pluto
SYSLOG Specifies the system logging daemon(s) to run at startup.
Example: SYSLOG=sysklogd
SERVICES Specifies which services to start at system startup. The services specified in this array must have a matching start/stop script in /etc/rc.d/. When entering multi-user mode the specified scripts will be called in the specified order with the argument start. At system shutdown or when entering single-user mode these scripts will be called in the reverse order with the argument stop.
Example: SERVICES=(crond identd sshd sendmail)

A user should note that when starting with CRUX 2.5, glibc does not contain all possible locales. This is why a user has to generate the locales that he/she needs or wants to use. An example will help in this case. A typical setup for swedish users, where sv_SE* can be replaced with the locale that a user wants:
# localedef -i sv_SE -f ISO-8859-1 sv_SE
# localedef -i sv_SE -f ISO-8859-1 sv_SE.ISO-8859-1
# localedef -i sv_SE -f UTF-8 sv_SE.utf8

If a user is looking for the network configuration then he/she should note that the network configuration is found in the service script /etc/rc.d/net and a user has to enable the service script. In order to enable this service a user has to add net to the SERVICES array in /etc/rc.conf.
By default this service script only configures the lo device and a static IP adress for eth0. If a user is interested in setting up other network devices such as eth0, eth1, then he/she has to add additional ip(8) commands. An example is provided to simplify this:
#!/bin/sh
#
# /etc/rc.d/net: start/stop network
#

case $1 in
start)
# loopback
/sbin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host
/sbin/ip link set lo up
# ethernet
/sbin/ip addr add 192.168.1.100/24 dev eth0 broadcast +
/sbin/ip link set eth0 up
# default route
/sbin/ip route add default via 192.168.1.1
;;
stop)
/sbin/ip route del default
/sbin/ip link set eth0 down
/sbin/ip addr del 192.168.1.100/24 dev eth0
/sbin/ip link set lo down
/sbin/ip addr del 127.0.0.1/8 dev lo
;;
restart)
$0 stop
$0 start
;;
*)
echo “usage: $0 [start|stop|restart]”
;;
esac

# End of file
If a user is interested in configuring the system to be a DHCP client then he/she needs to use the dhcpcd(8) command. An example will simplify this:
#!/bin/sh
#
# /etc/rc.d/net: start/stop network
#

case $1 in
start)
# loopback
/sbin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host
/sbin/ip link set lo up
# ethernet
/sbin/dhcpcd -t 10 -h $HOSTNAME eth0
;;
stop)
/usr/bin/killall -q /sbin/dhcpcd
/sbin/ip link set lo down
/sbin/ip addr del 127.0.0.1/8 dev lo
;;
restart)
$0 stop
$0 start
;;
*)
echo “usage: $0 [start|stop|restart]”
;;
esac

# End of file

CRUX uses MD5SUM passwords by default. If a user wants to use the traditional DES passwords, then he/she can turn the MDSUM passwords off. Please note that DES passwords are considered less secure.
In order to disable the MD5SUM passwords, a user has to change the MD5_CRYPT_ENAB variable in /etc/login.defs to no.
If a user is compiling programs that use the crypt(3) function to authenticate users, then user should ensure that these programs are linked against the libcrypt library, which means use -lcrypt when linking. This contains the MD5SUM version of the crypt function.

If a user is interested in upgrading the kernel manually then he/she can do so by manually replacing the kernel source with a newer version. In this way the package database will remain consistent and it will not affect the kernel headers.

If a user followed this tutorial guide then he/she would have learnt about CRUX configuration.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

Crux - the Ports System

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on May 16th, 2010

Welcome to the tutorial guide. The tutorial will provide a user with guidance and instructions on the ports system.

Before we go ahead with the tutorial guide, it is a good idea that a user knows about Port.
A port is a directory containing the files needed for building a package using pkgmk. The pkgmk is the directory and has the files Pkgfile and .footprint. A port directory can contain patches and or other files needed for building the package, however the actual source code for the package is not necessarily present in port directory. Instead the Pkgfile contains an URL which points to a location where the source can be downloaded.

The use of the word port is borrowed from the BSD world, where a port refers to a program that has been ported to a system or platform. The word can sometimes be a bit misleading since most programs require no actual porting to run on CRUX.

The term Ports System refers to a remote repository containing ports and a client program capable of downloading ports from that repository. CRUX users use the ports(8) utility to download ports from the repository and place them in /usr/ports/. The ports utility uses rsync(1) to do the actual downloading/synchronization.

CRUX ports are organised in collections. There are three different layers of ports:
Please note that core, opt and xorg are the three primary collections of CRUX.

The user contributed collection contrib. is a new collection which is provided by experienced port maintainers. The main purpose is to reduce the number of duplicate ports provided in the individual collections. This collection is disabled by default. Please note that by using HttpUp, a user can publish his or her own ports easily; the only requirement for that is some webspace to upload the ports.

How to use the Ports System
A user should note that when CRUX is installed for the first time the local ports structure (/usr/ports/) is empty. In order to bring the local ports structure up to date a user can use the ports utility with the -u option. An example is provided below:
$ ports -u
The -u option means update, and tells ports to contact the ports repository and download new and updated ports. The output from this execution is provided below:
Updating file list from crux.nu::ports/crux-2.6/core/
Updating collection ports/crux-2.6/core/

Updating file list from crux.nu::ports/crux-2.6/opt/
Updating collection ports/crux-2.6/opt/

Updating file list from crux.nu::ports/crux-2.6/xorg/
Updating collection ports/crux-2.6/xorg/

Finished successfully
The output reveals which files are downloaded, updated and deleted.

Listing Local Ports
When the local ports structure has been updated the directory /usr/ports/ will contain two package categories, core and opt. Under each of these directories a user will find ports. A user can simply browse around in the directory structure to find out which ports are available.
$ cd /usr/ports/core/
$ ls
autoconf/ gdbm/ ncurses/ sendmail/
automake/ gettext/ net-tools/ shadow/
bash/ glibc/ netkit-base/ slocate/
bc/ grep/ netkit-ftp/ strace/
bin86/ groff/ netkit-telnet/ sysfsutils/
bindutils/ grub/ nfs-utils/ sysklogd/
binutils/ gzip/ openssh/ sysvinit/
bison/ hdparm/ openssl/ tar/
bzip2/ hotplug/ patch/ tcp_wrappers/
coreutils/ httpup/ pciutils/ tcsh/
cpio/ iptables/ perl/ time/
curl/ jfsutils/ pkg-config/ traceroute/
db/ kbd/ pkgutils/ udev/
dcron/ less/ portmap/ unzip/
dhcpcd/ libstdc++-compat/ ports/ usbutils/
diffutils/ libtool/ ppp/ util-linux/
e2fsprogs/ libusb/ procps/ vim/
ed/ lilo/ prt-get/ wget/
expat/ m4/ psmisc/ which/
file/ make/ rc/ xfsprogs/
filesystem/ man/ rdate/ zip/
findutils/ man-pages/ readline/ zlib/
flex/ mktemp/ reiserfsprogs/
gawk/ module-init-tools/ rsync/
gcc/ nasm/ sed/

A user can also use ports with the -l option to list all local ports. An example is provided below:

$ ports -l
core/autoconf
core/automake
core/bash
core/bc
core/bin86
core/bindutils
core/binutils

If a user is looking for a specific package it might be easier to use this approach in order to find out if the package is available and if so in which category it is located.

Listing Version differences
In order to find out if the ports structure carries ports that are different versions then a user can use the option -d. If version differences are found, the output from the above command could look something like this:
$ ports -d
Collection Name Port Installed
core glibc 2.3.6-3 2.3.6-2
opt gtk 2.8.12-1 2.8.11-1
If no version differences were found, i.e. the system is in sync with the ports structure. Then output will simply be:
$ ports -d
No differences found

How to build and install the packages
After a user finds a port then he/she can build and install the packages. This is done by simply going into the desired port directory and then by using pkgmk to build it. An example is provided below:
$ cd /usr/ports/core/gawk
$ pkgmk -d
Please note that the -d option means download missing source files and tells pkgmk to download the source(s) specified in the Pkgfile. When the download is completed the package will be built. If the package was built successfully then a user can use pkgadd to install or upgrade it. An example is provided below:
$ pkgadd gawk#3.1.5-3.pkg.tar.gz
If a user wants to simply the process then he/she can do so by using the options -i (for install) or -u (for upgrade). An example is provided below:
$ pkgmk -d -i
or
$ pkgmk -d -u
In this way the package will be downloaded, built and then installed/upgraded in the upgrade the package. Please note that the package will only be installed/upgraded if the build is successful.

How to enable the contrib collection
Please note that the ‘contrib’ collection contains useful ports of experienced port maintainers. This is because the contrib. collection is not provided by the CRUX development team.
If a user wants to enable the ports then he/she can do so by running following command:
$ cd /etc/ports
$ mv contrib.rsync.inactive contrib.rsync
In order to let prt-get know that a user wants it to use the contrib tree to, a user should edit /etc/prt-get.conf and uncomment the line prtdir /usr/ports/contrib. This can be done by removing the hashmark in the beginning of the line. After this is done, a user will notice that it looks like this:
###
### prt-get conf
###

# note: the order matters: the package found first is used
prtdir /usr/ports/core
prtdir /usr/ports/opt

# the folloing line enables the user maintained contrib collection
prtdir /usr/ports/contrib

After this a user can not run ports -u and a user can use the ports from contrib.

How to build ports as unprivileged user
If a user wants to build ports then he/she should note that building packages requires root-privileges. This is critical because a badly designed port can damage a users system. The fakeroot command provides a way to build ports as normal user. If a user builds packages from user contributed repositories then he/she should always invoke fakeroot:
$ fakeroot pkgmk -d
A user can also make prt-get to use fakeroot.

If a user followed this tutorial guide then he/she would have learnt about the ports system.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

« Previous entries