Translate

Sunday, 15 May 2011

Relacing a bootable disk which has a root partition (Suse Linux)

This weekend I replace an old IDE bootable hard disk containing a Suse Linux partition with a new Sata disk.

First stage was to clone the old disk using dd:

dd if=/dev/sdb of=/dev/sda

Where /dev/sdb is my old hard disk (the input file) and /dev/sda (the output file) is the new hard disk.  This took a few hours on a 120GB disk but is reported to be faster if you specify the block size in the dd options. However, the clone operation worked fine.

Having rebooted, I didn't initially realise that the Grub bootloader configuration would now be out of date and that the machine would continue to boot from the old hard disk. It is not possible to reassign the root partition in Yast, but there are some useful instructions on this site on how to do a fresh install of Grub onto a new disk.

Following these instructions, I first created a directory where the cloned root partition on the new disk could be mounted:

mkdir /mnt/new

Next I mounted the cloned root partition:

/mount /dev/sda6 /mnt/new

Next, to bind /dev to the cloned partition:

mount --bind /dev /mnt/new/dev

and then chroot into the new partition:

chroot /mnt/new

Now for a fresh install of Grub onto the cloned disk:

grub-install.unsupported /dev/sda    

The grub-install.unsupported command has to be used (rather than just grub-install) because Suse prefers you to use Yast for bootloader configuration. However, when I tried this, neither yast2 (the graphical interface) or yast (the character-based interface) worked within the chroot jail.

A reboot still gave the original result (i.e. the machine booted from the old disk) so the next stage was to edit the Grub bootloader configuration files.

First (and working within the chroot jail on the cloned partition), the new disk has to be entered into the /boot/grub/device.map file. Since I had two old IDE disks in the PC, there were two existing lines in the device.map file:

(hd0)  /dev/disk/by-id/ata-[device_ID of first hard disk]
(hd1)  /dev/disk/by-id/ata-[device_ID of second hard disk]

I added a third line for the next hard disk starting (hd2). If you don't know the disk ID, you can check it in the Yast2 bootloader configuration to copy the disk ID from there.

A reboot confirmed that Grub was happy with the new disk in the device.map file, so I created a new menu entry in the /boot/grub/menu.lst file. My original menu.lst file looked like this:

# Modified by YaST2. Last modification on Tue Mar  1 15:19:29\
# GMT 2011
# THIS FILE WILL BE PARTIALLY OVERWRITTEN by perl-Bootloader
# Configure custom boot parameters for updated kernels in
# /etc/sysconfig/bootloader

default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,5)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original
###name: linux
title Desktop -- openSUSE 11.3 - 2.6.34.7-0.7
    root (hd0,5)
    kernel /boot/vmlinuz-2.6.34.7-0.7-desktop \
root=/dev/disk/by-id/ata-[old disk_ID]-part[partition no.]\
resume=/dev/disk/by-id/ata-[old disk_ID-part[partition no.]\
splash=silent quiet showopts vga=0x31a
    initrd /boot/initrd-2.6.34.7-0.7-desktop

###Don't change this comment - YaST2 identifier: Original
###name: failsafe
title Failsafe -- openSUSE 11.3 - 2.6.34.7-0.7
    root (hd0,5)
    kernel /boot/vmlinuz-2.6.34.7-0.7-desktop \
root=/dev/disk/by-id/ata-[old disk_ID]-part[partition no.]\ showopts apm=off noresume nosmp maxcpus=0 edd=off \
powersaved=off nohz=off highres=off \
processor.max_cstate=1 nomodeset x11failsafe vga=0x31a
    initrd /boot/initrd-2.6.34.7-0.7-desktop


Using the first menu option as a model, I created a new menu option to boot from the new hard disk:

###New menu option###
title Suse linux 11.3
    root (hd2,5)
# Note: hd1 was still the 2nd old hard disk at this stage
    kernel /boot/vmlinuz-2.6.34.7-0.7-desktop \
root=/dev/disk/by-id/ata-[new disk_ID]-part[partition no.]\ resume=/dev/disk/by-id/ata-[new disk_ID]_ID-part\
[partition no.]splash=silent quiet showopts vga=0x31a
    initrd /boot/initrd-2.6.34.7-0.7-desktop

A reboot confirmed that this new option worked fine.

Th final stage was to comment out the lines in the /boot/grub/device.map file for the old disks, and assign(hd 0) to the new hard disk. Next, I edited the /boot/menu.lst file, commenting out the menu options for the old hard disk and retaining the menu option for the new hard disk, ensuring that the line beginning root now pointed to (hd0,5) since this hd0 was now the hard disk number for the new disk in device.map.      

I disconnected the old disks, rebooted and then selected the new menu option, but for some reason/etc/fstab now had a line for a root partition on one of the old drives (the drive which didn't actually have a root partition...) so the reboot failed. Changing /etc/fstab fixed this.

Monday, 2 May 2011

Building a silent PC for MythTV

I started using MythTV a few years ago as an experiment. My main intention was to access foreign-language TV and radio broadcasts on my lounge TV but I was amazed at the power and flexibility of this open-source PVR when I gave it a trial run.

My original MythTV PC recently hit the buffers, so I've built a new box with the following components:
  • Antec Fusion NSK-2480 case
  • Scythe mini-ninja (eBay) 
  • AMD Athlon II X3 400E Triple Core CPU
  • LiteOn IHOS104-32 4x Internal Blu-Ray BD-ROM
  • Seasonic X-460FL 460W ATX Fanless PSU
  • CORSAIR 4GB 1333MHz CL9 DDR3 Memory Kit
  • ASUS M4A78LT-M LE motherboard
  • 2 x Western Digital WD10EARS 1TB Hard Drive SATAII 5400rpm 64MB 
  • Noctua NF-S12B 120mm case fan
  • Sparkle GT220 coolpipe graphics card (passively cooled) 
This setup works well for a media centre PC because it is effectively silent. You might just pick up a feint whine from the hard disks if you are close to the PC but otherwise you can't hear it. The Noctua fan is completely silent at around 600rpm and is sufficient to cool the heatsink on the now-discontinued Scythe mini-ninja, so there is no need for a dedicated CPU fan. Likewise, the Seasonic PSU, although pricey, is also silent. Seasonic in the Netherlands told me the Antec Fusion NSK-2480 case and this PSU are a good match because of the "headroom" in this case.

I am currently running MythTV 0.24 under Suse Linux. A few Mythtv users have reported that the video runs in "slow motion" under this version, something which I managed to fix (on the basis of a forum post) by setting the audio output to ALSA:pulse.

High-definition Freeview has just arrived in my area. This is progressively being rolled out across the UK and uses the DVB-T2 standard. PC hardware to decode this signal is very new although the PCTV systems nanoStick T2 290e DVB-T2 USB tuner is available which I am currently running under Windows 7.  This works fine under PCTV's own software but under Windows Media Center the audio drifts out of sync with the video. This seems be a common problem with Windows Media Center (which doesn't occur with MythTV) and there doesn't seem to be a solution. The use of Windows 7 for high definition Freeview is a stopgap as far as I am concerned so I am watching with interest the development of a Linux driver.

Update: driver for the nanoStick T2 now built into the Linux Kernel.

BT Infinity on Linux

I recently upgraded to BT infinity and being a Linux user didn't know whether the new BT Home Hub 3 router would offer the same flexibility as my previous router, a Linksys Wireless-G ADSL Home Gateway.

Fortunately the functionality I required under Linux from the Linksys router is largely replicated on the BT Home Hub 3. You don't need a Windows or Mac disk to install anything, everything can be configured under a Linux-enabled browser such as Opera.

Dynamic DNS is supported, currently the router offers DynDNS, NoIP and DtDNS.

The Infinity router also allows port forwarding, although the way it is implemented is a bit awkward. You can't assign the same port to more than one device. Say, for instance, you exchange files with a smartphone using FTP on port 21, you can't assign 21 to another device (e.g. the PC from which you access the router). If you try, the Home Hub 3 will throw up an error. Fortunately there is a workaround. The router has a number of pre-configured port settings for games and applications including FTP and SSH. Under the "supported applications" tab within "port forwarding" (all under "advanced settings") you can Add a new game or application, so for the smartphone example you could add an entry for "FTP smartphone" and assign a port such as 2121 to the device. This can create additional work on Linux because you may have to change configuration files in order to associate a port number with a service, for instance you have to change /etc/ssh/sshd_config on SUSE for  SSH. A custom rule may also be required for the firewall. This is irksome but manageable, and once the port settings are configured the router seems to forward the relevant ports OK.

On balance the Home Hub seems a decent upgrade in terms of speed, about 22 MB/sec download where I am and around 4 MB/sec upload, an enormous improvement on copper-based ADSL where I could only scrape 2MB/sec download. From a Linux perspective, I haven't found any major issues with it although it's always worth bearing in mind that BT expect customers using Linux to set up their own Internet connections (as BT's own Web site makes clear). Some Linux users seem to have difficulty, particularly with certain distributions. I have always found knetworkmanager a user-friendly way of managing wireless connections under Linux.