Open Source Software and Linux:

/boot

Dec 28 2008   3:33PM GMT

Adventures with Linux and external hard drives



Posted by: John Little
Linux, bios, /boot, external hard drive

I received a Western Digital 1TB external hard drive for my linux server on Christmas. Way cool! Now I could set up a linux NAS filer and backups for the server and other Linux and Windows machines that we have.

While the linux server was running I plugged the external hard drive into the USB port. Checking DMESG I saw that the machine recognized the external hard drive. Ok, I’m on my way..or so I thought. I rebooted the machine to make sure that the external hard drive was recognized properly on a reboot.

This is where the fun began. The server would not boot past the BIOS. A quick check of Western Digital’s site suggested turning off the legacy usb setting which I did. I also turned on boot on no errors (meaning boot regardless of any errors). Still no luck. Ok I’ve never had much luck with Western Digital products and I’ve spent a couple of hours researching and working on this. I rebooted and tried different BIOS settings so many times that my family told me I was creating my own Denial-of-Service attack since the firewall is housed on this server. By the way I tried the WD external on two Windows machines as well. Only one booted properly with the external hard drive plugged into the USB port.

I checked Fry’s web site to see what other products were available. I saw a Buffalo on there for about $105 on sale. The next day I go over to Fry’s. The hard drive is no longer on sale or at least they don’t show it that way in the computer. I asked the sales guy what else he had. He checked stock and found that he was overstocked on SimpeTech external drives and sold me that one for $105.

I headed home with great expectations of this working. It didn’t. So I checked SimpleTech’s web site. There is not much there. So I started searching for simpletech, linux and boot. I finally ran across an obscure post that said to wipe out all of the partitions that came on the external hard drive an create a bootable partition.

So I plugged the hard drive back into the server and fired up fdisk. I deleted all of the partition on the external hard drive and created a single partition of 200MB.

fdisk /dev/sda
Command (m for help): p
Command (m for help): d
Command (m for help): w

Use the p to print to screen a list of the partitions. Starting with the highest numbered partition keep repeating d until all of them are deleted. Type w to write the new partition table to disk and exit. At the prompt after exiting type

partprobe

You can safely ignore any output to this command including the part about rebooting. Now go back into fdisk on your drive and create a typical boot partition. Linux usually uses about 200MB so that is what we will use. Note that if you use the complete 1TB formatting the partition will take a very long time.

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601): +200M

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@virtual-host ~]#

Now we need to format the partition and put a boot sector on the drive.

partprobe
mkfs -j -L /boot /dev/sda1
mke2fs 1.39 (29-May-2006)
Filesystem label=/boot
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
50200 inodes, 200780 blocks
10039 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@virtual-host ~]#

The -j makes it a journaled ext3 file system and the -L creates the label /boot which you can use in /etc/fstab if you were to boot off of this drive. You can label it anything that you want.

Now we need to create a boot partition table on the drive. The partition table from your machine that has the external drive plugged in will do nicely.

[root@virtual-host ~]# dd if=/dev/hda of=/dev/sda bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.003661 seconds, 140 kB/s
[root@virtual-host ~]#

Now try rebooting your machine. You will find that it will reboot or start from a powered down condition. Voila! This is good news!

Out of curiosity I began to wonder if the machine would boot without any partitions or partition table installed. It will-another informational finding.

With that information in hand you could try removing the new partitions first and try rebooting the external hard drive and see if that works. That would save you some time from going through the whole process of installing the boot partition and the partition table. Just follow the instructions above to delete the existing partitions and reboot to see if it works.

I suspect that this would have worked on the Western Digital drive as well. However no amount of searching turned up that particular solution. Only after I did the search with SimpleTech did I run across that information. There are also a ton of posts out there about this problem with the Western Digital external hard drive and very few with SimpleTech. None of the posts that I found for Western Digital external hard drives provided this particular solution. Take that information for what it is worth to you.

-j

Sep 11 2008   12:36AM GMT

Troubleshooot your Linux boot process with GRUB



Posted by: John Little
Linux, /boot, grub, /root, grub.conf, menu.lst

Red Hat and subsequently Fedora and CentOS use the the GRUB (Grand Unified Boot Loader) to initialize the kernel and boot into Linux. I’m going to look at some of the common error messages possible when booting Linux and how to edit the GRUB boot loader to test and fix the errors.

GRUB has 6 basic editing commands:

b=boot the currently listed operating system
d=delete the current line
e=edit the current line
a=append a parameter to GRUB
o=create an empty line underneath the current line
O=create an empty line above the current line

These are the commands with which I will initially be working to access the grub configuration file.

After you boot to the GRUB menu screen highlight the line the Linux version that you want to edit. I like to use e so that I can choose which line that I want to edit.

On Red Hat and it’s derivatives you will usually see three lines at this point:

root
kernel
initrd

While any of the three could need editing to pass a parameter to the kernel you will want to use the kernel line. Highlight this line and press e to edit. Move to the end of the line to add a parameter. The kernel has many parameters that you can add here. I will use some of the more commonly used.

Booting into a different runlevel is probably one of the most common tasks of a Linux administrator. The Red Hat kernel has 7 parameters that you can use to boot to the runlevel that you want. These are 1, single (or s), emergency, 2, 3, 4, or 5. If you add single or s to the end of this line you will boot into single user mode. If you boot into runlevel 0 or 6 you will either halt or reboot your machine.

Another common area that not only administrators but users as well find themselves requiring is the VGA setting. Occasionally on updating a video driver or for various other reasons your machine may continue booting but only showing a black screen without any output. A possible way to overcome this so that you can see the output and at least get to runlevel 3 is vga=ask.

Some other commonly used parameters are selinux=[0|1] where 0 disables selinux, acpi=[force|off|noirq|ht|strict] and mem=n[KMG].

The ACPI option controls parameters that the Advanced Configuration and Power Interface (ACPI) subsystem can use. This is the main option for the Advanced Configuration and Power Interface (ACPI). The values are:
force: Force ACPI to be enabled. Can be used to override the kernel configuration option that disabled it.
off: Disable ACPI. Can be used to override the kernel configuration option that enabled it.
noirq: Prevent ACPI from being used for IRQ routing.
ht: Run only enough of the ACPI layer to enable HyperThreading on processors that are capable of it.
strict: Make the ACPI layer be less tolerant of platforms that are not fully compliant with the ACPI specification.

The mem option forces a certain amount of memory used by the kernel. When
used with the memmap= option, physical address space collisions can be avoided. Without the memmap= option, this option could cause PCI devices to be placed at addresses that belong to unused RAM. n specifies the amount of memory to force and is measured in units of kilobytes (K), megabytes (M), or gigabytes (G).

That covers some basics kernel parameters, how to access and edit them. You will find these most useful generally on a new install or after adding new hardware that is either not detected or acting properly.

If you want to see more on the various kernel options and parameters install the kernel-doc package. The documentation can then be found under /usr/share/doc/kernel-doc-2.6.18/Documentation on recent Red Hat and CentOS versions.

Next post I’ll get into some of the error messages that are common when you Linux machine refuses to boot.

-j


Sep 8 2008   3:37PM GMT

Graphical Linux File Structure representation



Posted by: John Little
Linux, /boot, linux kernel, kernel, /home, file system, /root, /sbin, /bin, Filesystem Hierarchy Standard, fhs

I ran across the following jpeg file on another blog. I thought it a reasonable idea to distribute this as much as possible as it is a very good representation of the Linux file structure.

A couple of things to note about this graphic:
The author did it in caps for readability. None of the files or directories shown are in caps on a Linux system. The ROOT label at the top is to designate that it is representing the root file system. It does not represent the root’s home directory which is /root in the lower right hand corner of the graphic. This probably should have been labeled “ROOT FILESYSTEM”.

For new Linux users reading this you should note that most systems today will by default create three to four partitions for mounting various directories:
/boot holds the kernel and files that the boot loader uses to boot Linux
/ holds the user (/bin)and system (/sbin) binaries as well as other configuration and log files
/home holds the directories of users that have been added to the system
/swap the partition the system uses for swap memory

Here’s the graphic. Enjoy!
-j

Click to enlarge
Linux File System Graphic