Showing posts with label Slackware. Show all posts
Showing posts with label Slackware. Show all posts

2012-01-04

Using LILO to boot disks by UUID

If you're plugging USB drives in an out and using LILO to boot a Linux distro (eg. Slackware) you may have ended up with a kernel panic because your /dev/sd# were shuffled around and the kernel was no longer able to find its root partition on the expected device. Of course, having Linux failing to boot just because you happened to plug an extra drive sucks big time, so we want to fix that.

The well known solution of course it to use UUIDs or labels, since these are fixed. However, while recent versions of LILO are supposed to support root partitions that are identified by UUID/Label, in practice, this doesn't work UNLESS you are using an initrd disk. I'm not sure who of LILO or the kernel is responsible for this new layer of "suck" (I'd assume the kernel, since the expectation is that LILO is using the dev mappings that are being fed by the kernel), but I can only say that there really are some areas of Linux that could still benefit from long awaited improvements...

Thus, to be able to use UUIDs or labels for your root partition in LILO, you must boot using an initrd. Worse, as previously documented, you will most likely need to compile a new kernel that embeds the initrd, lest you want to run into the following issue while running LILO:
Warning: The initial RAM disk is too big to fit between
the kernel and the 15M-16M memory hole.

In practice (as also illustrated by this post), this means you will need to:
  1. Create an initrd cpio image that can be embedded into a kernel with:
    cd /boot
    mkinitrd -c
    cd initrd-tree
    find . | cpio -H newc -o > ../initrd.cpio
  2. Recompile a kernel, while making sure that you have the General Setup → Initial RAM filesystem and RAM disk (initramfd/initrd) support selected, and then set General Setup → Initramfs source file(s) to /boot/initrd.cpio

  3. Edit your /etc/lilo.conf and add an append = "root=UUID=<YOUR-DISK-GUID>" to your Linux boot entry. An example of a working lilo.conf is provided below. Note that you probably also want to use a fixed IDs for boot=, so that running LILO is also not dependent on the current /dev/sd# organization.. 

  4. Run LILO, plug drives around and watch in amazement as your system still boots the Linux partition regardless of how the drives are assigned
Example lilo.conf:
# Start LILO global section
boot = /dev/disk/by-id/ata-ST3320620AS_ABCD1234
compact
lba32
# LILO doesn't like same volume IDs of RAID 1
disk = /dev/sdb inaccessible
default = Windows
bitmap = /boot/slack.bmp
bmp-colors = 255,0,255,0,255,0
bmp-table = 60,6,1,16
bmp-timer = 65,27,0,255
# Append any additional kernel parameters:
append=" vt.default_utf8=1"
prompt
timeout = 35
# End LILO global section

image = /boot/vmlinuz
  append = "root=UUID=2cc11aaf-f838-4474-9d9a-f3881569f97c"
  label = Linux
  read-only
image = /boot/vmlinuz.rescue
  append = "root=UUID=2cc11aaf-f838-4474-9d9a-f3881569f97c"
  label = Rescue
  read-only
other = /dev/sda
  # Windows doesn't go to S3 sleep and has issues with backup,
  # unless it sees its disk as first in BIOS...
  boot-as = 0x80
  label = Windows
other = /dev/disk/by-id/ata-ST3320620AS_ABCD1234-part4
  label = OSX
Oh, and of course, don't forget to edit your /etc/fstab as required, if you still use /dev/sdX# entries there.

2011-08-31

Enabling serial console on Linux Slackware

I'm doing this frequently enough to warrant a post.
  1. Make sure you use a kernel with console enabled

  2. Confirm that your serial tty's are detected with dmesg | grep tty:
    [    0.000000] console [tty0] enabled
    [ 1.323949] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
    [ 1.568561] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
    [ 1.592267] 00:0c: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
    [ 1.614293] 00:10: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A

  3. Edit /etc/securetty and uncomment the lines matching the ttyS you got from dmesg. Else you won't be able to logon as root.

  4. Edit your /etc/inittab and uncomment the lines:
    s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100
    s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100
    While you're at it, you probably want to change the 9600 vt100 to 115200 linux, if you use putty in serial mode to connect for instance.

  5. If you want the boot messages on serial as well (recommended!), make sure you append a console= line to your kernel. For instance, if using LILO and for 115200 bauds, you would add a line:
    append = "console=ttyS0,115200"

2011-06-30

Slackware 13.37 and minicom

Doesn't work by default. Wanna know why? /etc/minirc.dfl is missing a Line Feed. Yes, really, all you need to do is add an extra blank like there.

2009-10-09

Installing Slackware on the SheevaPlug

And so, finally, we come to the final part of our series regarding the setting up of our SheevaPlug with Linux. Thanks to the good guys at armedslack, we will have the best Linux distro ever, running on one of the coolest little devices around.

For this setup, we will install Slackware on an 8 GB High speed SDIO MMC card, and leave the NAND flash untouched with its updated Ubuntu version. This will also suppose that you have a working kernel that supports ext4 and all the features you want already installed on the flash (if not, refer to this post to to set it up). Now, we are going to deviate a little bit from the "official" armedslack intallation guide for the SheevaPlug, as we are not going to use TFTP for our packages but instead read them directly from an USB device.

And so, without further ado:
  1. Download the packages from armedslack.org. The only directories you really need are the "slackware", "isolinux" and "kernels" directory from ftp://ftp.armedslack.org/armedslack/armedslack-current/. If you're downloading from a Linux system, one way to do it, as advertised in the armedslack installation readme is:
    rsync --exclude '*/source/*' --delete -Pavv ftp.armedslack.org::armedslack/armedslack-current .
    (NB: If you use Filezilla to download from FTP, please note that it seems to default to ASCII mode instead of binary, so don't be surprised if your files are corrupted!)
    This amounts to about 2 GB of files, so it will take a while, but the filesystem used for the target shouldn't matter much, as long as it is accessible from the default armedslack kernel. So if you have a FAT formatted USB stick lying around, with more than 3 GB space available, you should probably use that.
    I also have to point out that we are downloading slackware-current, which contains an up-to-date version of the packages, but is different from a dot release, so you might see some versioning differences between current and what you get on the official x86 dot releases.
    For the remainder of this guide, I will assume that you have the directories (slackware/, isolinux/ and kernels/) in an "armedslack/" directory at the root of a FAT formatted USB device. Note that if you're not using a FAT formatted device, you will need to copy the kernel and initrd image on a separate device that can be read from U-boot

  2. Alright, time to reboot the system, with your USB and MMC card plugged in and enter the Marvell>> U-boot prompt through the serial console. There, you need to issue the following:
    Marvell>> usb start
    
    (Re)start USB...
    USB: scanning bus for devices... 2 USB Device(s) found
    scanning bus for storage devices... 1 Storage Device(s) found
    Marvell>> fatload usb 0 0x00800000 armedslack/kernels/kirkwood/uImage-kirkwood
    reading armedslack/kernels/kirkwood/uImage-kirkwood
    ...
    ................................................................................

    1887248 bytes read
    Marvell>> fatload usb 0 0x01100000 armedslack/isolinux/uinitrd-kirkwood.img
    reading armedslack/isolinux/uinitrd-kirkwood.img
    ...
    ................................................................................

    10985095 bytes read
    Marvell>> setenv bootargs console=ttyS0,115200 nodhcp kbd=uk root=/dev/ram rw;bootm 0x00800000 0x01100000
    If all is well, you should be seeing your usual Slackware installation screen.
    Please note that because of the "kbd=uk" line above, your keyboard will be automatically set to uk, so change it accordingly.
    Also, if you want to use a network session rather than the serial console, you should issue:
    dhcpcd eth0
    
    /etc/rc.d/rc.dropbear start
    Then you can find your IP address through ifconfig and ssh to it.

  3. If needed, you should use fdisk to partition your MMC device:
    fdisk /dev/mmcblk0
    On my system, I created a 512MB /dev/mmcblk0p1 partition for Swap (type 0x82) and left the rest as /dev/mmcblk0p2 for Linux (type 0x83)

  4. If you had a look at dmesg, you should see that your USB device has been detected by the kernel (normally as /dev/sda). Since we have our Slackware package on that device, this is what we are going to use for the source. I have found out however that:
    - If you attempt to mount the directory manually and chose the Install from a pre-mounted directory option in SOURCE MEDIA SELECTION, MAKE SURE that your path ends with the slackware/ directory where the a/, ap/, d/... packages reside and NOT the one where extra/, isolinux/, kernels/... reside. If you don't, setup will happily list the packages but fail to install them and produce a completely irrelevant error!
    - If you select "Install from a hard drive partition" but haven't previously mounted the partition, it will fail to mount the directory properly.
    For now, we will use the "Install from a hard drive partition" option, but we first need to mount that partition manually.
    And remember that the Slackware setup process uses /mnt for its own purpose, so you should not use that location as a mountpoint. So:
    mkdir /usb
    
    mount /dev/sda1 /usb
    echo "mmc0" > /sys/class/leds/plug\:green\:health/trigger
    setup
    The "echo mmc0" line in there is a trick to get the blue LED act as an MMC card access indicator, as, if you're like me, you want to see some indication of r/w access to your root device.

  5. Setup should be smart enough to detect your Swap & Linux mmc partitions, and format them (the default ext4 is a good choice for a filesystem). With regards to the SOURCE MEDIA SELECTION screen, you should now select "2 Install from a hard drive partition" then enter "/dev/sda1" as the device and "/armedslack" as the path (or whatever you called your directory on the USB). If you did mount your partition beforehand, this will work and you will then be able to select the packages straight off the USB.

  6. From there, it's your run-of-the-mill package selection and installation. On my 8 GB SD Card, I found that selecting everything but GNU Emacs, TeX, KDEI and the Kernel sources resulted in a 3.7 GB installation, thus leaving about 2.9 GB free space, which is fine. Of course, if you want more space, you can fine tune your package selection or use a bigger SD card.

  7. After you've gone through the rest of the configuration (network, etc) you can reboot the system and get back to the Marvell>> U-Boot prompt. There we will want to test that the custom kernel we've been using to boot Ubuntu can also boot our Slackware installation. Again, this supposes that you followed the steps from my earlier post regarding custom kernel installation and flashing. If not, now is probably a good time to follow this post to to flash the uImage-kirkwood kernel that you used for setup.

    To test that your current NAND kernel can boot Slackware:
    # Preliminary check to see if your bootargs_console variable is
    
    # properly defined. if not, make sure you set it up
    Marvell>> printenv bootargs_console
    bootargs_console=console=ttyS0,115200
    # This defines our root device. Make sure that use the right device, and that you mount it "ro"
    Marvell>> setenv bootargs_root root=/dev/mmcblk0p2 rootfs=ext4 ro
    Marvell>> setenv bootargs $(bootargs_console) $(bootargs_root)
    Marvell>> printenv bootcmd
    bootcmd=nand read.e 0x800000 0x100000 0x400000; bootm 0x800000
    # Your bootcmd should only read the kernel and boot from it.
    # If not, just issue the 2 commands above instead of what follows
    Marvell>> run bootcmd
    You should then be able to boot into your newly installed Slackware Linux. If not, you might want to check your parameters and install & flash a kernel that works.
    Now, while we have confirmed that your system can indeed boot, we haven't yet saved anything on the flash to make it the default, so you need to reboot into the Marvell prompt once more, and this time:
    # First, we start by saving the current working bootargs so that if you ever want
    
    # to get back to Ubuntu, you can issue a "setenv bootargs $(bootargs_rescue)"
    Marvell>> setenv bootargs_rescue $(bootargs)
    Marvell>> setenv bootargs_root root=/dev/mmcblk0p2 rootfs=ext4 rootwait ro
    Marvell>> setenv bootargs $(bootargs_console) $(bootargs_root)
    Marvell>> saveenv
    Saving Environment to NAND...
    Erasing Nand...Writing to Nand... done
    Marvell>> reset
  8. After this last command, the plug should automatically boot into Slackware and you can finalize your installation.

    IMPORTANT: You VERY MUCH want to add a rootwait parameter to your bootargs, which ensures that the SD is ready before the kernel attempts to mount it as rootfs. Otherwise, you may end up with maddening kernel panics when mounting rootfs, especially after a power failure, that are really due to the SD card not being ready yet.
    Another alternative would be to add rootdelay=## but if you read here, you'll see that rootwait is the smarter option.

    One thing you might want to do, as we did during the install, is set the blue LED as an MMC access indicator.
    On my system, I did that by editing /etc/rc.d/rc.S and adding the line:
    # Set the blue LED as SD access indicator
    
    echo "mmc0" > /sys/class/leds/plug\:green\:health/trigger
    just before the section
    # Enable swapping:
    
    /sbin/swapon -a



2007-05-13

MY ASUS P5B Deluxe Linux (Slackware 11.0) settings

Putting this here so that, if I ever have to reinstall Slackware in a hurry (as happened the other day), I can quickly revert to them, but first I gotta give you a handful of disclaimers
1. Because of ASUS & intel's new lousy 4 pin CPU fan control and the fact that my (whatever model) Zallman cooler only provides a 3 pin connector, my PSU is plugged to the CPU fan control, my CPU Fan is plugged to FAN2 or FAN3, and my side case fan is plugged to FAN1 or something. In short, my setup is nonstandard, so if you use my sensors.conf on a regular setup, your Fan labels will be screwed up (but all the rest should be OK)
2. Likewise, my fancontrol file is only meant to work for my rig! If you use it and fry yours, instead of running pwmconfig as you should, tough luck!
3. Kernel 2.6.21 has disabled one of the P5B Deluxe network adapters (the 88E8056), because the driver is reported as broken.
To re-enable it, look for "broken" in drivers/net/sky2.c

Here goes nothing:
o /etc/sensors.conf for MY Asus P5B-Deluxe
# Winbond W83627DHG configuration
# This is for an Asus P5B Deluxe Edition
chip "w83627dhg-*"
# Temperatures
label temp1 "MB Temp"
set temp1_over 50.0
set temp1_hyst 45.0
label temp2 "CPU Temp"
set temp2_over 60.0
set temp2_hyst 50.0
compute temp2 @+10,@-10
ignore temp3
# Fans
label fan1 "Side Fan"
set fan1_min 1000
label fan2 "PSU Fan"
set fan2_min 1000
label fan5 "CPU Fan"
set fan5_min 1000
ignore fan3
ignore fan4
# Voltages
label in0 "Vcore"
set in0_min 1.32
set in0_max 1.60
label in1 "+12V"
compute in1 @*(66/10), @/(66/10)
set in1_min 12.0 * 0.95
set in1_max 12.0 * 1.05
label in2 "+3.3V"
set in2_min 3.3 * 0.95
set in2_max 3.3 * 1.05
label in5 "+5V"
compute in5 @*(32/10), @/(32/10)
set in5_min 5.0 * 0.95
set in5_max 5.0 * 1.05
ignore in3
ignore in4
ignore in6
ignore in7
ignore in8

o MY /etc/fancontrol
INTERVAL=5
FCTEMPS=hwmon0/device/pwm4=hwmon0/device/temp2_input
FCFANS= hwmon0/device/pwm4=hwmon0/device/fan5_input
MINTEMP=hwmon0/device/pwm4=0
MAXTEMP=hwmon0/device/pwm4=45
MINSTART=hwmon0/device/pwm4=30
MINSTOP=hwmon0/device/pwm4=100

o MY /etc/rc.d/rc.fancontrol
#!/bin/sh
#
# /etc/rc.d/rc.fancontrol
#

fancontrol_start() {
/usr/local/sbin/fancontrol | logger &
}

fancontrol_stop() {
killall fancontrol
}

fancontrol_restart() {
fancontrol_stop
sleep 5
fancontrol_start
}


case "$1" in
'start')
fancontrol_start
;;
'stop')
fancontrol_stop
;;
'restart')
fancontrol_restart
;;
*)
echo "usage $0 start|stop|restart" ;;
esac

o My /etc/rc.d/rc.local
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.

# Why can't Linus respect the BIOS settings dammit!
/usr/bin/setleds +num
# ICH8R Software RAID Volumes
echo Mounting RAID Volumes
dmraid -ay
mount -v -t ntfs /dev/mapper/isw_fhbagdjeh_Twix1 /mnt/vista32
mount -v -t ntfs /dev/mapper/isw_fhbagdjeh_Twix2 /mnt/vista64
mount -v -t ntfs /dev/mapper/isw_fhbagdjeh_Twix3 /mnt/strider
mount -v -t ntfs /dev/mapper/isw_fhbagdjeh_Secure1 /mnt/secure
# This is to use the nv framebuffer for X rather than nVidia's
# lousy driver (plus it will remove the bootup penguins)
/usr/sbin/fbset -depth 32
# Harware monitoring stuff
/usr/local/bin/sensors -s
echo Starting Fan Control
if [ -x /etc/rc.d/rc.fancontrol ]; then
. /etc/rc.d/rc.fancontrol start
fi

o /etc/rc.d/rc.local_shutdown
#!/bin/sh
#
# /etc/rc.d/rc.local_shutdown: Local system shutdown script.

if [ -x /etc/rc.d/rc.fancontrol ]; then
. /etc/rc.d/rc.fancontrol stop
fi

o And while I'm at it, my /etc/fstab...
/dev/sda4        /                xfs         defaults         1   1
/dev/sda1 /mnt/osx hfsplus rw 1 0
/dev/sda2 /mnt/winxp ntfs rw 1 0
/dev/sda3 /mnt/alfie ntfs rw 1 0
/dev/cdrom /mnt/cdrom auto noauto,owner,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0

o ...as well as my ~/.profile
alias a=alias
a dir='ls -alFh'
a dim='ls -alFh | most'
a so='source ~/.profile'
a s='screen -D -R'

I think that's about it really