Author Archive

Timezone change

Posted by on Tuesday, 7 April, 2009

A lot of people have been plagued by the timezone changes of NZ.

Thanks debian maintainers for being complete pricks and not updating the package even though you had MONTHS to deal with it.

For anyone else who urgently needs a fix, here it is.

Get the new zone file
wget http://wishes.debian.co.nz/trash/NZ.zi

compile it with zic ..
zic NZ.zi

Check it worked.
ls -l /etc/localtime and make sure it links to /usr/share/zoneinfo/Pacific/Auckland

Sometimes its a file instead of a link (if its a file its just the same as the Auckland file anyway)

ls -l /usr/share/zoneinfo/Pacific/Auckland and make sure it has been updated

If it hasnt then give me a yodel on the contact page and ill email you a fix.

If you’re not in Auckland then make the link to appropriate zone 🙂 Last-Modified: 2008-01-07 13:09:18


Partitioning basics

Posted by on Tuesday, 7 April, 2009

Most computer users are aware of the existence of their hard drive, even if they’re not familiar with how it works. It’s hard not to be, since the first things people tend to ask when you get a new computer are how much hard drive space you have, how fast the machine is, and how much memory is included. From there, if you’re used to using Windows, then you’ve probably dealt with the installer letting you break your hard drive into “multiple drives,” probably referred to as C:, E:, F:, and so on.

You may not realize it, but if you’ve done this, you’ve already created partitions. A partition is a virtual drive inside a drive, created through storing information about the drive’s virtual layout in special locations on the drive itself. The system’s BIOS and operating system(s) then utilize this information to determine where to look on the drive for boot instructions and data.

A hard drive may look like a short, rectangular box, but the data is stored on a round section that looks somewhat like a stack of records . The way data gets written to and read from this drive involves drive heads, which are housed on the carriage assembly shown in the image. Each of these electromagnetic heads alters data on a hard drive by manipulating the magnetic media at such a miniscule level that the head turns on and off individual bits and bytes.

When a PC boots, once the BIOS finishes loading hardware information, it looks to the very first spot on the hard drive, which is referred to as the Master Boot Record (MBR). How do we find this spot? The data on a hard drive is stored in a series of rings called tracks, and the tracks are subsequently broken up into equally sized pieces called sectors . Tracks are numbered from 0 on up, and the counting starts at the outermost ring. Sectors are numbered from 1 on up.

The MBR is on track 0, sector 1: the very first location on the drive. In this tiny spot on your hard drive, two key pieces of information live. The first is the data on how many partitions you’ve created on the drive, and their vital statistics. The second is vital to whether your machine will boot properly or not without a floppy disk: the MBR contains a pointer to the specific partition or hard drive that has the boot information.

If you’re familiar with Linux installation, then you’ll know that the boot loaders LILO and GRUB place information in the MBR.

When you partition a hard drive, you’re creating a virtual drive within a drive. Rather than dealing with tracks and sectors, though, you’re dealing with cylinders. A hard drive these days is actually a stack of platters with drive heads that work with the top and bottom of each platter. Every one of those platters has identical tracks and sectors, and a cylinder is comprised of the data contained within a particular ring of tracks as shown in Figure 1.
Fig 1

There are BIOS limits on the number of partitions you can have on a single drive in a PC. Perhaps one day this issue will change, when drives get so large that you might want more than sixteen partitions, but until then I wouldn’t expect it to change soon. How you lay out these partitions is important, since of those sixteen partitions, only four of those can be primary, the rest have to be logical. So if you want one through four partitions then make them all primary. If you want five through sixteen partitions, then you make three of the partitions primary, the fourth a special type of container partition an extended, and then you make as many as you need (up to a total of sixteen) as logical partitions inside the extended one.

Confused? It doesn’t really make a lot of sense at first glance, but that’s how it works. You might notice that you don’t really get sixteen partitions out of the deal. You get fifteen, since the extended partition is just a container for other partitions; you won’t have any data in it. See Figure 2 for a conceptual view of how these partitions might work.
Fig 1

Notice in Figure 4 how there’s this weird label associated with each of the partitions I mentioned. In the Windows world, partitions and hard drives are labeled exactly the same way, starting with C:, then D:, and so on. In the Linux world, each drive also has a letter associated with it, and from there it gets more complicated (but in the end it makes a lot more sense once you understand it).

So let’s start with the hard drives, themselves. The primary drive in your machine is drive a, the secondary is b, and so on. Then you have to distinguish between an IDE drive, and a SCSI drive; most people these days use IDE drives in their home computers, if you’re using a SCSI drive, you had to go out of your way to get it, so hopefully you’ll know that’s what you’ve got. Linux sees all IDE drives as hd, and all SCSI drives as sd.

Therefore, if the first drive on your machine is an IDE, then Linux sees that drive as hda. The second IDE drive is hdb, and so on. If your first drive is a SCSI, then it’s seen as sda, the second as sdb, and so on. On a machine where for some odd reason you’ve mixed and matched hardware between SCSI and IDE, Linux will letter the drives in the order that the computer sees them.

Now on to the partitions. Each partition gets a number, just as you saw in Figure 4. No matter what drive we’re talking about, the partitions are simply numbered in order: 1, 2, 3, 4, and so on. The number is then tacked onto the end of the drive reference, so the first partition on the first IDE hard drive is hda1, the second on that drive is hda2, etc. If your second drive is a SCSI, then you’d end up with sdb1, sdb2, sdb3, and so on.

There’s just one more thing in Figure 4 I haven’t explained yet. Understanding it requires wrapping your mind around the fact that everything to Linux is a file. Your hard drive is a file, your partitions are files, your printers are files, your directories are files, your monitor’s a file, and so on.

All devices on your system (pieces of hardware that Linux needs to interact with) have a corresponding file in the /dev directory. This fact includes both your hard drives and your partitions. This is why, in Figure 4, you see references to /dev/hda1, /dev/hda2, and so on. That’s how the Linux kernel looks at your drives and partitions. The nice thing is that of course, each type of hard drive needs a different driver to interface with the kernel, but we’re spared that much of it. We can just use these handy shortcuts.

Aside from the drive designators (/dev/hda1, etc.), your partitions are named after where you want the kernel to place them within the filesystem. Unlike Windows where you treat every partition as a different drive, Linux leaves the physical locations out of it and just lets you navigate through directories and files. So your root directory (/) might be on /dev/hda1, your home directories (all stored in /home) might all be on /dev/hda2, and then maybe Fred’s home directory (/home/fred) is even on another machine across the network but you’re using NFS to attach it to this machine as well.

You create Linux partitions during the installation process. How many you make depends on quite a number of factors, but I have some general advice that I tend to give anyone that asks me. Let’s start with the general ones that all Linux machines must have and work from there.

All Linux boxes need a root partition (/), and a swap partition. Typically speaking, you want the boot partition as close to the start of the drive as possible, so on the lowest cylinder number, which means that if you only used these two partitions you would put root on the drive first?making root /dev/hda1 and swap /dev/hda2. The swap partition, in general, should be either the same size as your machine’s memory (RAM), or up to twice that size, depending on who you talk to. Root’s size depends on how much room your particular Linux distribution requires.

You can make more than two partitions, and in most cases you should. At the very least, I tend to advise making a boot partition (/boot) as well, and placing that on the drive first. That way, if something in your root partition gets damaged, at the very least you’ll be able to boot the machine to try to fix it. Another popular addition is a home partition (/home), so that if you want to completely reinstall the machine you can wipe everything but leave home untouched?though keep in mind that if you do this, you need to create user accounts in the same order as you had the last time or your permissions will be quite messed up in /home.

When you’re dealing with servers, there are even more partitions you might want to create. A temporary partition (/tmp) will make sure that temp files can’t fill up your filesystem, and also protects the root and boot portions from potential damage since temporary files are changed so often. For the same reason, on a server machine you might want to create a separate /var partition, since that’s where your log files, mail, and other such items are kept and constantly changed.

If you’re using a network and want to keep certain items on a central machine, then you might create a separate /usr partition on the server and then mount it using NFS onto all of your Linux boxes. You might do the same with /home, so everyone has access to their full home directories no matter what machine they log into.

There’s lots more you can do here as well. If you use Samba to access files from Windows, Macintosh, and other machines on your network, then they too will ultimately show up as partitions plugged into your filesystem.

As you can see, Linux deals with drives and partitions quite differently from other non-Unix operating systems. It takes a bit of getting used to, but once you understand the basic concepts life gets a lot easier. The nice thing is that you don’t have to remember what drive you have particular types of data on! There’s still lots more to learn but this primer should get you started on the basics. From there, look into SMB, NFS, mounting, devices, and more.

Dee-Ann LeBlanc has been writing about computers since 1994, when she did her first computer book. Since then, she’s written 10 books, over forty articles, a number of courses, and twelve presentations (which she also presented), with most of these works involving Linux. Her latest book is Linux Routing from New Riders, and you can find out more at http://www.Dee-AnnLeBlanc.com/.

Artwork provided by Bryan Hoff (http://www.themeparkmultimedia.com/)

Last-Modified: 2007-03-07 19:38:50


Boot messages Explained Kernel Messages

Posted by on Tuesday, 7 April, 2009

Most users when inserting a new Linux CD can be somewhat paniced by the verbose text that the kernel spits out. Some distros have a flash screen which hide this and others just let loose.
Dont fret! its only debug so you know whats happening!
After a while using Linux you will be able to understand a bit about what it means or is saying.

The Linux kernel is the central interface between the user and the hardware. As such, it has to incorporate support for hardware if you are to use it. Often, though, cryptic device names are used by the system, making it difficult at first inspection to determine if some particular hardware is supported. The command ‘dmesg’, which is used to print kernel messages, is very useful in determining if a piece of hardware has been found, and if so, what the system is referring to it as.

Kernel output on an i386 system

Shown below is a dmesg from an x86 system immediately after boot. The output is indented by several space, and comments and descriptions are left justified.

    Linux version 2.2.14-5.0 (root@porky.devel.redhat.com) (gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)) #1 Tue Mar 7 20:53:41 EST 2000

First up is the kernel version (2.2.14) and build (5), along with who built it, with what compile it was built, and when it wass built. This can be some inportant information, as some kernel versions and the GCC project don’t interact correctly.

    Detected 300683434 Hz processor.

My K6/2-300 processor running at 300 MHz.

    Console: colour VGA+ 80x25

A standard PC console screen (15 inch monitor).

    Calibrating delay loop... 599.65 BogoMIPS

The useless benchmark of BogoMIPS. They’re bogus (hence the name), but are often used as a relative processor speed indicator.

    Memory: 63008k/65536k available (1084k kernel code, 412k reserved, 968k data, 64k init, 0k bigmem)

My memory statistics. My machine has 64MB of real memory.

    Dentry hash table entries: 262144 (order 9, 2048k)

The dentry cache (dcache) represents the kernel’s view of the namespace of mounted filesystems. There’s pretty good documentation of it in Documentation/filesystems/vfs.txt in the kernel source tree.

    Buffer cache hash table entries: 65536 (order 6, 256k)

In 2.2, the buffer cache is used for caching and aggregating data for writes to block devices. After 2.3.6, it is used for caching fs metadata, such as inode information.

    Page cache hash table entries: 16384 (order 4, 64k)

In 2.2, the page (VM) cache is used for caching swap, read and mmap data (which was bad, because shared writable mappings were ugly). After 2.3.6, it also is used for write data (i.e., the buffer and page caches are mostly unified), and all became happiness and light (sorta like BSD).

    VFS: Diskquotas version dquot_6.4.0 initialized

My kernel support quotas (though I’m not using them).

    CPU: AMD AMD-K6(tm) 3D processor stepping 00

A quick identification of the processor.

    Checking 386/387 coupling... OK, FPU using exception 16 error reporting.
    Checking 'hlt' instruction... OK.

I seem to recall there being some Intel processor issues, which the kernel has to know about if it’s to invoke corrections.

    POSIX conformance testing by UNIFIX
    PCI: PCI BIOS revision 2.10 entry at 0xfb490

And we start the probing of the PCI bus for peripherals.

    PCI: Using configuration type 1
    PCI: Probing PCI hardware
    PCI: 00:38 [1106/0586]: Work around ISA DMA hangs (00)
    Activating ISA DMA hang workarounds.
    Linux NET4.0 for Linux 2.2

This kernel supports the Net4 networking codebase, which has a lot of features yet to be fully utilized.

    Based upon Swansea University Computer Society NET3.039
    NET4: Unix domain sockets 1.0 for Linux NET4.0.
    NET4: Linux TCP/IP 1.0 for NET4.0
    IP Protocols: ICMP, UDP, TCP, IGMP

My core IP protocols supported. While not needed, IGMP can be fun. Note that some networks do not support muticasting.

    TCP: Hash tables configured (ehash 65536 bhash 65536)
    Initializing RT netlink socket
    Starting kswapd v 1.5
    Detected PS/2 Mouse Port.

Should be quite obvious…

    Serial driver version 4.27 with MANY_PORTS MULTIPORT SHARE_IRQ enabled
    ttyS00 at 0x03f8 (irq = 4) is a 16550A
    ttyS01 at 0x02f8 (irq = 3) is a 16550A

The information about my serial ports.

    pty: 256 Unix98 ptys configured
    apm: BIOS version 1.2 Flags 0x07 (Driver version 1.9)

My motherboard supports the APM standard for sleeping.

    Real Time Clock Driver v1.09
    RAM disk driver initialized: 16 RAM disks of 4096K size

My kernel supports RAM disks. While I’m not using any most days, sometimes I do use them; if you have the memory, they make a real fast filesystem (like /tmp or, for a webserver, the main pages loaded).

    VP_IDE: IDE controller on PCI bus 00 dev 39
    VP_IDE: not 100% native mode: will probe irqs later
    ide0: BM-DMA at 0xe000-0xe007, BIOS settings: hda:DMA, hdb:DMA
    ide1: BM-DMA at 0xe008-0xe00f, BIOS settings: hdc:DMA, hdd:DMA

My IDE controllers.

    hda: Maxtor 51369U3, ATA DISK drive

My hard drive in the machine.

    hdb: IDE/ATAPI CD-ROM 32X, ATAPI CDROM drive

My CDROM drive.

    ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
    hda: Maxtor 51369U3, 12949MB w/2048kB Cache, CHS=6577/64/63
    hdb: ATAPI 16X CD-ROM drive, 128kB Cache

Disk information.

    Uniform CDROM driver Revision: 2.56
    Floppy drive(s): fd0 is 1.44M
    FDC 0 is a post-1991 82077

Floppy drive information.

    md driver 0.90.0 MAX_MD_DEVS=256, MAX_REAL=12
    raid5: measuring checksumming speed
    raid5: MMX detected, trying high-speed MMX checksum routines
    pII_mmx : 761.238 MB/sec
    p5_mmx : 726.567 MB/sec
    8regs : 447.675 MB/sec
    32regs : 308.610 MB/sec
    using fastest function: pII_mmx (761.238 MB/sec)

A bunch of RAID and MD (used in multiple device devices, like disk arrays) information, again not used.

    scsi : 0 hosts.
    scsi : detected total.

While the kernel supports SCSI, I’m not using any on this host.

    md.c: sizeof(mdp_super_t) = 4096
    Partition check:
    hda: hda1 hda2 < hda5 hda6 >

My disk partition information. The brackets indicate extended partitions.

    autodetecting RAID arrays
    autorun ...
    ... autorun DONE.

Like I said above, I’m using not using any RAID arrays.

    VFS: Mounted root (ext2 filesystem) readonly.

At this point we’re almost done with the kernel and ready to start the system.

    Freeing unused kernel memory: 64k freed
    Adding Swap: 66488k swap-space (priority -1)
    ne2k-pci.c:vpre-1.00e 5/27/99 D. Becker/P. Gortmaker http://cesdis.gsfc.nasa.gov/linux/drivers/ne2k-pci.html
    ne2k-pci.c: PCI NE2000 clone 'RealTek RTL-8029' at I/O 0xe800, IRQ 11.
    eth0: RealTek RTL-8029 found at 0xe800, IRQ 11, 00:80:AD:41:22:10.

My ethernet device is a PCI NE2000 based device. (A real cheap NIC, but almost every OS supports it.)

    VFS: Disk change detected on device fd(2,0)

At this point, the kernel is done booting and we’re ready to start /sbin/init (unless we supplied some information about init upon boot). The system then starts rc.sysinit and begins normal boot operations. The kernel has finished booting.

Last-Modified: 2007-03-07 19:38:50