Operating Systems and Systems Integration

Solving Problems with Booting

1 Aim

A number of students made some mistakes when installing Linux. This is intended to be a quick guide to people to solve these problems.

2 Background

Booting depends on LILO.

You can read the user manual for LILO (in Red Hat 7) by typing:

xdvi /usr/share/doc/lilo-21.4.4/doc/user &

or

gv /usr/share/doc/lilo-21.4.4/doc/User_Guide.ps &

There are a number of reasons why Linux didn’t start for a few students. Here are some of these reasons:

• LILO was installed in the boot partition instead of in the master boot record. Esily fixed.

• Linux partitions have been deleted. Hmm,… reinstall!

• You entered /root instead of /boot as the mountpoint for /dev/hda7. This is not so simple, but I’ll describe a solution here.

• I can boot, but I forgot my root password! (Blush with shame). Okay, that’s easily fixed. Boot into single user mode and type passwd, enter a new password. Remember it!

• I can boot, but I forgot my normal account password. Easy. Log in as root, and

type passwd username

• I can boot, but I didn’t make a non-root account for myself. Easy. Log in as root,

and type useradd username
Then type passwd username

3 Procedure

3.1 Determining the cause of the problem

1. Boot the machine into Linux from the boot disk you created as the last step of the installation process.

Solving Problems with Booting Operating Systems and Systems Integration

2

What? You mean you didn’t make one? Oh, dear, well, borrow a boot disk from someone who did make one. This is not the network installation boot disk, but is the emergency boot disk created at the last stage of installation.

2. If it doesn’t boot, then use the procedure you used to run fdisk in the first class to examine the partition table. If the Linux partitions are not there, tough! You need to reinstall. Otherwise, you can ask Nick to have a look if he is around.

3. After logging in as root, type emacs /etc/lilo.conf

3.2 Put boot loader in the right place (MBR)

This is the easiest to fix.

1. The top line of /etc/lilo.conf should read:

boot=/dev/hda

and not

boot=/dev/hda7
If you see boot=/dev/hda7, change that to boot=/dev/hda

2. Save the file lilo.conf by pressing [figure: Control-x][figure: Control-s]within emacs.

3. Exit from emacs by typing [figure: Control-x][figure: Control-c].

4. As root, type:

/sbin/lilo

5. If you see no error messages, then the problem is solved, and you can boot in future without the floppy disk.

6. To check that all is well, remove the boot disk, reboot the computer, and when it restarts, log in to your own (non-root) account.

7. In future, always log in using your own account; do not log in as root.

3.3 I think I typed /root instead of /boot

Hmm, it still doesn’t boot? Let’s check another possibility.

There are two disk partitions used to hold data in our Linux system: hda7 and hda9. Linux does not have a C: dirve, a D: drive, an E: drive,…, but it puts all the partitions under one root directory called ‘/’. The problem described here is that the student selected that the small 8 or 16 MB partition hda7 be mounted on /root, instead of /boot. This means that the boot files are not below the disk cylinder 1024. This prevents the operating system from being started by the bios. To solve this, we need to perform the following steps (described in detail further below in section 3.3.1 on the following page

• edit the \underline{f}ile \underline{s}ystem \underline{tab}le to always mount hda7 on /boot in the future.

• change to single user mode (like Windows’ safe mode)

• unmount /root and mount it on /mnt

• copy all files from /mnt to /root, inlcuding those “hidden” files that begin with a dot

Solving Problems with Booting Operating Systems and Systems Integration

3

• move all files from /boot to /mnt

• unmount the partition hda7 from /mnt, and mount it where it was supposed to be,

on /boot.

• run lilo.

Note that /root is the home directory for the root user. The /boot partition contains the essential files required to boot the operating system, including the operating system kernel.

This procedure uses methods that you will learn about later. I do not expect you to understand a great deal of it yet (you will understand it in its entirely later). If you feel nervous about doing this, you could ask Patrick, our helpful and capable technician to do it. Show him this document.

3.3.1 How to diagnose the /boot ⇔ /root problem

1. Log in as root

2. Type emacs /etc/fstab

This is the \underline{f}ile \underline{s}ystem \underline{tab}le. It is a very important configuration file in Linux. It is described in the current Linux Training Materials Project document at

    http://nicku.org/ossi/lab/workshop-notes.pdf in sections ??, ??, and

??.

3. There are two lines in this file that mount the hard disk partitions containing Linux file partitions; they should look something like this (from memory):

LABEL=/         /       ext2    defaults        1 1
LABEL=/boot     /boot   ext2    defaults        1 2

If instead, they look something like this:

LABEL=/         /       ext2    defaults        1 1
LABEL=/root     /root   ext2    defaults        1 2

then you have the problem that the next section shows you how to fix.

3.3.2 How to fix the /boot ⇔ /root problem

Here we assume that you are logged in as root, and that you are editing /etc/fstab in emacs.

1. Change the line that looks like this:

LABEL=ROOT      /root   ext2    defaults        1 2

to this:

/dev/hda7       /boot   ext2    defaults        1 2

2. Save the file by typing [figure: Control-x][figure: Control-s], then exit emacs by typing [figure: Control-x] [figure: Control-c].

3. Change to single user mode by typing at the command prompt: telinit 1

The screen will change to text mode.

Solving Problems with Booting Operating Systems and Systems Integration

4

4. Unmount the hda7 partition by typing umount /root

5. Mount it temporarily on the directory /mnt by typing:

mount /dev/hda7 /mnt

6. Move all the files from /mnt to /root, except for the directory ‘.’ and the directory ‘..’. This is a bit tricky, since most files will be “hidden”, that is, their file name begins with a dot ‘.’. To move the files:

(a) type ls -a

(b) For each file file listed, type: mv file /root

(c) Do not try to move the current directory ‘.’ or the parent directory ‘..’, or

you may be sorry!

7. Set the correct permissions on the /root directory by typing chmod 700 /root

8. Now move all the files from the /boot directory to the small hda7 partition by typing:

cd /boot
mv * /mnt

9. Unmount hda7 from the directory /mnt by typing:

umount /mnt

10. Mount hda7 on /boot (the proper place it would have been if you didn’t make the mistake!) by typing:

mount /dev/hda7 /boot

11. Run lilo (this step actually puts the boot loader into the master boot record /dev/hda):

lilo

12. If you see no error messages, remove the boot disk and reboot the computer by either typing [figure: Alt][figure: Control][figure: Delete]or by typing

shutdown -r now

13. If you see error messages when you typed lilo above, then talk with Nick if he is nearby.

14. Your computer should reboot successfully; if not, talk with Nick.

3.4 Always log in as your own personal account

Always log in as your own personal account from now on. Do not log in as root in the future; otherwise two things will inevitably happen:

• I will look upon you with great scorn.

• One day you will make a typing mistake and destroy some important files (or maybe delete all of your files on the entire hard disk!)