Ph: 25032000100128

Archive

Posts Tagged ‘kernel’

Find your partitions and kernel from the GRUB command line

April 15th, 2009

You may find that grub is pretty useless when your menu.lst is missing or misconfigured. It’s not easy to figure out how to make grub tell you where the files are that you need. Here’s the methods I use to find out where everything is that I need in order to boot, just using the grub bootloader and nothing else.

Start by specifying the boot partition.

grub> root (hd1,0)

root (hd1,0)
 Filesystem type is fat, partition type 0x6
grub>

That’s not the right one. That’s probably a USB thumbdrive or other storage device.

You can find it by using tab completion. Type this:

grub> root (hd0,

and hit tab from here…

Possible partitions are:
  Partition num: 0, Filesystem is ext2fs, part type 0x83
  Partition num: 1, Filesystem is unknown, part type 0x82
  Partition num: 2, Filesystem is ext2fs, part type 0x83

I’m looking for a Linux partition, which is type 83. (82 is swap)

grub> root (hd0,0)

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

Now I’ll search for /sbin/init which will tell me where my root partition is.

grub> find /sbin/init

find /sbin/init
(hd0,1)
grub>

So now I know num 2 is the root partition, which means num 0 is probably boot.

If you didn’t compile your kernel yourself, it probably has a file name that is hard to remember, and you are likely to have an initrd too. You can find the full file names using tab completion here too.

grub> rootninja (hd0,0)/

Hitting tab after that slash will tell you all the files in the root of that partition.

Possible files are lost+found boot kernel.x86 kernel-stripped.i386 grub System.map things-in-a-bag vmlinux vmlinux-2.6.27

Looks like I have two kernels, kernel.x86 and kernel-stripped.i386, a boot and grub directory, and a few extra files. Now I know how to make my kernel line! If you had initrd files, you’d see them in here too.

Two more commands and it will start to boot.

kernel /vmlinux-2.6.27 root=/dev/sda3

[Linux-bzImage, setup=0x2c00, size=0x2ddaf0]

boot

Decompressing Linux...

I’ll need just a few lines for the menu.lst so I won’t have to poke around and bring the system up manually from now on.

timeout 3
default 0
title rootninja
root (hd0,0)
kernel /vmlinux-2.6.27 root=/dev/sda3

howto boot, broken, command line, configure, grub, kernel, menu.lst, partitions, root, tab, vmlinuz

Kernel panic after sysctl changes for Oracle

April 2nd, 2009

I changed the kernel semaphores and ip local port range as usual in /etc/sysctl.conf for an Oracle 11g install, and what happened?

boom, headshot!

kernel.sem = 250 32000 100 128
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000

What a pain in the butt…

1. reboot from a livecd

2. mount LABEL=/ /mnt

3. vi /mnt/etc/sysctl.conf

4. comment out the changes, :wq

5. init 6

Linux kernel, livecd, oracle, panic, sem, semaphores, shmall, shmmax shmmni, sysctl

See console messages in remote shells

March 14th, 2009

In Ubuntu, Fedora and other systems I’ve seen rsyslog running on, to see the console messages you have to have physical access to the server usually through a KVM or IP-KVM setup. Kernel messages are sent to /dev/console while mail, crit, debug, and others get sent to files.

to tail

Any of these message can be monitored remotely since they’re output as files by using the tail utility. Executing tail with the –follow switch in a shell allows you to watch the ouput as it is written to a file, in real time. So all you have to do is write kern messages to a file too…

$ sudo tail -n 88 -f /var/log/messages

or not to tail

But why tail a file when you could just send the kernel messages straight to a user account name. Instead of specifying a path to a file within rsylog.conf, add a user name instead or in addition to a file path.

kern /dev/console,rootninja

Now whenever i’m logged in as rootninja it’s just like i’m right there at the console.

log spillage

If you’re spewing out logs faster than rsyslog can handle and you’re comfortable with the possibility of losing data if you get a system crash between the write and the next disk sync, you can begin each file entry with a minus sign to omit syncing and squeeze out that last bit of performance. I wouldn’t suggest this unless you know you need it. When debugging talky apps, this would be better than just writing out your own files. I only mention this because I haven’t convinced any of the developers I work with to write to syslog for any of the apps they’re writing, even when these apps are interrelated… but that’s a whole new story!

advanced stuff

I haven’t even scratched the surface. I like being able to use templates for output and to send logs to remote IP’s, but other features of rsyslog are beyond anything that I have needed. You can use z0 through z9 for compressing messages sent over TCP. Rsyslog will compress any messages over 60 bytes long. I think the CPU overhead is probably a bad trade-off for just a minor improvement. It’s usually safe to try out new settings since misconfigurations in rsyslog.conf are usually ignored (such as using templates before defining them), so your configurations probably won’t fall down go boom, but that also makes it less obvious to know if things are working like you want.

From syslog’s website: http://www.rsyslog.com/

Rsyslog is an enhanced multi-threaded syslogd with a focus on security and reliability. Among others, it offers support for on-demand disk buffering, reliable syslog over TCP, SSL, TLS and RELP, writing to databases (MySQL, PostgreSQL, Oracle, and many more), email alerting, fully configurable output formats (including high-precision timestamps), the ability to filter on any part of the syslog message, on-the-wire message compression, and the ability to convert text files to syslog. It is a drop-in replacement for stock syslogd and able to work with the same configuration file syntax.

Go here if you want to join the rsyslog mailing list: http://lists.adiscon.net/mailman/listinfo/rsyslog

Uncategorized kernel, messaes, performance, remote, rsyslog, shell, syslog

gentoo unknown filesystem type ‘ext2′

February 18th, 2009

I usually make my boot partition ext2 because it doesn’t stay mounted and doesn’t get written to unless i’m installing a new kernel or tweaking the options like vga=0×317 or whatever. So having a journal is a waste and it may as well just be ext2. But strangely enough, when I boot, grub sees the boot partition, grub.conf, and the kernel and loads with no problem. But when I try to mount /dev/sda1 from a shell it doesn’t seem to know what i’m talking about! I can mount ext3 and other file systems just fine, but not ext2? I could dig around in the kernel config and figure out what’s missing, but that really didnt matter in this case, so here’s the quick and easy fix with no fishy side effects:

mygentoo ~ # tune2fs -O has_journal /dev/sda1

Now I can mount it from bash just fine… well, that was weird.

Linux, wtf boot, ext2, file systems, grub, journal, kernel

shell scripting on an old ppc

October 10th, 2008

In a shell script you’re probably testing a variable against some constant or another variable, but why not run a command in a subshell and compare the output?  You could even compare the output of two subshell commands!  I guess most of the time i’m doing something like this i’m using perl or python.  But I needed a way to double check which disk had a powerpc boot partition on it before copying it over to a blank disk and I didn’t have much to work with on those old boards, so I whipped this up right quick:

#!/bin/sh

#check to see if sda has a PPC boot partition

if [ "`/sbin/fdisk -l /dev/sda | grep PPC`" == "" ]; then

if [ "`/sbin/fdisk -l /dev/sdb | grep PPC`" == "" ]; then

echo “both disks have PPC boot partitions”

exit 1;

else

echo “run this: dd if=/dev/sdb of=/dev/sda”

fi

else

if [ "`/sbin/fdisk -l /dev/sdb | grep PPC`" == "" ]; then

echo “run this: dd if=/dev/sda of=/dev/sdb”

else

echo “both disks have PPC boot partitions”

exit 1;

fi

fi

Shell scripting if-then-else tests with commands embedded in backticks.  Why?  Because i’m messing with some old power pc blades running 2.4 kernels with no modern day apps like ssh, rsync, or python.  I don’t know why I didn’t think of this before now?

[image]http://blog.rootninja.com/wp-content/uploads/2008/09/rootninja_80×151.jpg” alt=”root|ninja” width=”80″ height=”15″ />

Linux 2.4, if-then-else, kernel, Linux, ppc, shell scripts


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser
Mobilytics