Need a Linux guru to help me work around a hardware failure

Discussion in 'Technology' started by Foosinho, Dec 23, 2008.

  1. Foosinho

    Foosinho New Member

    Jan 11, 1999
    New Albany, OH
    Club:
    Columbus Crew
    Nat'l Team:
    United States
    This is an odd request, but I've reached the limits of my capabilities, unfortunately. I have a fairly decent desktop machine that is sitting idle because a power spiked killed the hard drive controller (and the drive attached). (Save the "get a UPS" speech - I know, I know.) I know the controller is bad, because I hooked a known-good drive to the controller and I was unable to get it to work. However, the rest of the computer is peachy - it'll run an Ubuntu Live CD without complaint, and I can do everything I want with it in that state.

    However, since it's a Live CD, I cannot easily install other desktop software. This is the ONLY non-laptop in the house hooked to a keyboard, mouse, and monitor. The laptops are both Windows, and must stay that way. I want a non-terminal login to do code development and other "desktopy" stuff in Linux.

    I have an always-on server (running tftp, dhcp, and all the other stuff you need to netboot, in theory) with tons of storage space. What I want to do is netboot the desktop machine, mount an NFS share on /, and go about my business with all disk access via NFS. While I think I can manage to get the netboot and mounting the NFS share on / business handled, what I CAN'T figure out is how to get a valid Linux install in a subdirectory on my server. Most stuff I've seen suggests installing to a local disk and copying it to the server before disconnecting the disk and netbooting, but obviously since I have a bum disk controller that isn't an option. I also don't have another machine with similar hardware to do this with. I found something called "rpmstrap" that is supposed to do exactly this, but I cannot get it to work on CentOS (my server OS).

    Does anybody know how to do this? The graphical installer for Ubuntu isn't smart enough to let me do a chroot installation or anything like that - so I can't get past the disk partitioning step. I'm kinda at a loss, but I'd really like to salvage this hardware. It's only a few years old.
     
  2. ElJefe

    ElJefe Moderator
    Staff Member

    Feb 16, 1999
    Colorful Colorado
    Club:
    FC Dallas
    Nat'l Team:
    United States
    Two questions:

    1. If the controller is crapped out, how does the CD-ROM drive work? Is it hooked up to a different controller?

    2. Why not just replace the controller and drive? They're not terribly expensive, you know.
     
  3. Foosinho

    Foosinho New Member

    Jan 11, 1999
    New Albany, OH
    Club:
    Columbus Crew
    Nat'l Team:
    United States
    Good question. It must be. That does lead to the rather embarrassing admission that I never did try a known-good drive on the other channel of the working IDE controller. D'oh. TBH, I can't remember why, and the system has been sitting idle since last spring. It may have had two CD drives, and has since been partially cannibalized for parts.

    1. I'm cheap.
    2. I'm poor.
    3. I'm intrigued by the idea of going diskless is as many systems as I can to reduce unnecessary hard drives (and thus, unnecessary power consumption). My NAS is technically diskless, if you can believe that. (The only hard drive is 100% used for NFS storage - the OS runs off of a LiveCD, and the settings are stored to floppy. Whenever I build my new NAS server - years away, I'm sure - I plan to put the entire OS on a "LiveUSB" setup.) I threw in the towel in making my MythDora MythTV frontend diskless when I made my last upgrade, but I just noticed that MythBuntu has built-in support for diskless frontends, so I'm thinking about making the switch to MythBuntu during the long Christmas weekend just so I can rip that noisy drive out of the frontend.

    Realistically, if I'm going mount my home directory via NFS anyway, there is no compelling reason to have a giant hard drive in that machine for what amounts to a relatively small amount of disk space needed for a system image.

    At any rate, I did find this, which looks promising. That's an older version of Ubuntu, and the instructions aren't terribly dissimilar from what I've already tried, but my understanding is that the newer LiveCDs have better support for installing stuff when in "live" mode. I'm downloading a new LiveCD, and will try that. I have to wrap presents tonight too, so this may have to wait until Friday. :(
     
  4. Foosinho

    Foosinho New Member

    Jan 11, 1999
    New Albany, OH
    Club:
    Columbus Crew
    Nat'l Team:
    United States
    Well, disregarding the fact that I may be a knucklehead and might have been able to salvage this PC with a hard drive, I have managed to achieve what I set out to do - install Ubuntu onto a machine that only has access to NFS shares starting from a LiveCD. There is one little catch-22 I haven't quite worked out; this definitely would have been easier if my server was already an Ubuntu install. But this method worked.

    Key: $> = root on diskless machine booted by LiveCD. On Ubuntu, you can get a root shell by typing "sudo su". #> = root on NFS server. %> root on the new install (either via chroot or booting in.

    Set up DHCP to deal out an IP address and send the machine to the tftp server. I like to assign static IPs via DHCP.
    #> vi /etc/dhcpd.conf
    host basement-desktop {
    next-server 192.168.1.3;
    filename "pxelinux.0";
    hardware ethernet 00:19:21:68:de:f1;
    fixed-address 192.168.1.11;
    }

    Configure the tftp server
    #> vi /tftp/pxelinux.cfg/01-00-19-21-68-de-f1
    LABEL linux
    KERNEL vmlinuz-2.6.17-10-generic
    APPEND root=/dev/nfs initrd=initrd.img-2.6.17-10-generic nfsroot=192.168.1.3:/home/netboot/image/ubuntu-desktop ip=dhcp rw

    Obviously, the paths, MAC addresses, kernel, etc will all be dependent on your specific setup. I strongly suggest reading a HOWTO on netbooting Ubuntu - I've glossed over a lot of details just to show the specific settings you need to get it to work. It's complicated. In my case, I had to come back when I was done to tweak these to the appropriate values, as I was unsure of what kernel I was going to be able to get running. It turns out that you cannot build an initrd image for a kernel that you aren't currently running. That creates a bit of a catch-22 as you cannot boot a diskless machine via the network without a working initrd image. I ended up having to use the kernel the LiveCD booted with, instead of a newer kernel. I haven't worked out how to do kernel upgrades short of creating a LiveCD with the newer kernel... yet.

    Create share on server. Export via NFS. Create whatever directory is appropriate - I put all this stuff on /home because /home is 1.5TB on my machine.
    #> mkdir /home/netboot/image/ubuntu-desktop
    #> vi /etc/exports
    /home/netboot/image/ubuntu-desktop 192.168.1.0/255.255.255.0(rw,no_root_squash,async)

    Boot desktop via LiveCD. Download newest debootstrap.deb file, and install.
    $> mkdir /tmp/work
    $> cd /tmp/work
    $> wget https://archive.ubuntu.org/path/to/debootstrap.deb
    $> ar -x debootstrap_1.0.10_all.deb
    $> cd /
    $> zcat /tmp/work/data.tar.gz | tar xv

    Mount the NFS share.
    $> mkdir /tmp/netboot
    $> mount -t nfs -o nfsvers=3,nolock 192.168.1.3:/home/netboot/image/ubuntu-desktop /tmp/netboot

    The filesystem options are important - many tools that need a file lock will FAIL without those. There is a tedious workaround involving using dd to create a file you can mount as a loopback device, but it appears that using those options fix the NFS locking issues.

    Run debootstrap
    $> /usr/sbin/debootstrap --arch i386 intrepid /tmp/netboot http://archive.ubuntu.com/ubuntu
    This is probably faster if you download from CD if you have a recent LiveCD, which I didn't. This will install a base OS to the loopback filesystem.

    Chroot into the new barebones OS to set a few important things up.
    $> LANG= chroot /tmp/netboot /bin/bash

    Set up the fstab
    %> vi /etc/fstab
    # <file system> <mount point> <type> <options> <dump> <pass>
    proc /proc proc defaults 0 0
    /dev/nfs / nfs nfsvers=3,nolock 1 1
    none /tmp tmpfs defaults 0 0
    none /var/run tmpfs defaults 0 0
    none /var/lock tmpfs defaults 0 0
    none /var/tmp tmpfs defaults 0 0
    /dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0

    Mount the necessary filesystems
    %> mount -t proc proc /proc
    %> mount -t sysfs sysfs /sys

    Reconfigure the console for the next boot.
    %> dpkg-reconfigure console-setup

    Set up the network.
    %> vi /etc/network/interfaces
    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet manual

    Set up your hostname
    %> echo UbuntuHostName > /etc/hostname

    Create a user and set it up appropriately
    %> adduser myusername
    %> addgroup --system admin
    %> adduser myusername admin
    %> visudo
    %admin ALL=(ALL) ALL

    In another terminal window (back on the LiveCD booted machine), copy the kernel you are currently using (running uname will tell you) to the home directory for the user you just created.
    $> cp /boot/vmlinuz-2.6.17-10-generic /tmp/netboot/home/myusername/.
    $> cp -R /lib/modules/2.6.17-10-generic /tmp/netboot/lib/modules/.

    Back in the chroot, create an initrc for the kernel
    %> vi /etc/initramfs-tools/initramfs.conf
    BOOT=nfs
    %> mkinitramfs -o /home/<USERNAME>/initrd.img-2.6.17-10-generic

    On the SERVER, copy the kernel and initrd files to the tftp server.
    #> cp /home/<USERNAME>/* /tftp/.

    Assuming you took care to ensure the server setup has the right filenames for the kernel and initrd, you are now finally ready to try to net boot. Reboot the diskless machine, remove the CD, and make sure the BIOS will try to boot over the network. If you did it right, you should boot into a basic terminal installation of Ubuntu. Log in as the user you created earlier, "sudo su", and then install the full-bore system:
    %> apt-get install ubuntu-desktop

    That should do it! I'm on the final install step right now - it's a lot of data, so I set it to download overnight and periodically have gone downstairs to see if it's waiting for my input.
     
  5. Foosinho

    Foosinho New Member

    Jan 11, 1999
    New Albany, OH
    Club:
    Columbus Crew
    Nat'l Team:
    United States
    Update: my kernel catch-22 has resolved itself - the apt-get install ubuntu-desktop updated the kernel and generated a new initrd for me. All I had to do was - on the server - copy the kernel and initrd to the tftp server directory, and modify the file for that IP to serve the newer kernel.

    Easy peasy, lemon squeezy.

    I now have a diskless desktop machine on my LAN with a full-blown Ubuntu installation on it. It's ALIVE!
     
  6. Grouchy

    Grouchy Member+

    Evil
    Apr 18, 1999
    Canal Winchester
    Club:
    Columbus Crew
    Nat'l Team:
    United States
    I would have replaced the controller or picked up a small USB drive and installed Linux there but it's alive so, carry on ...
     
  7. Foosinho

    Foosinho New Member

    Jan 11, 1999
    New Albany, OH
    Club:
    Columbus Crew
    Nat'l Team:
    United States
    It actually works pretty well. Even got MythTV frontend packages installed on it, so I can watch TV on my MythTV system on the widescreen LCD if my wife has commandeered the HDTV.

    Now I just need to figure out why my linux hosts aren't inserting their hostnames into the local DNS server when they get IP addresses via DHCP, but the Windows laptops are. :( I'm tired of having to remember (or look up!) IP addresses when I want to SSH to any of my boxes.
     

Share This Page