You are not logged in.

#1 2004-03-17 11:55:43

tehdely
Member
Registered: 2004-02-20
Posts: 148
Website

I need volunteers for a dangerous mission!

I've migrated two Arch boxes, manually, from devfs to regular static /dev.  I decided to write a script to automate the process.

This thing is dangerous.  I have yet to test it on any of my own boxen, so I'm looking for people who

1) Want to move to static /dev from devfs (obviously)
2) Don't mind reinstalling if my script borks their machines
3) Like giving feedback

The tarball is here.  Untar it, cd into the directory, and run ihatedevfs from that directory.  You must be in that directory when you run it.  Also, being root helps  lol

Also, obviously, you must have built a kernel with devfs disabled that you're ready to boot into.

Here's the code just for anyone who wants to see something scary  :twisted:

ihatedevfs:

#!/bin/sh

# ihatedevfs - Michael Baehr <usemike@spamblocked.com>
#
# Usage:  Run this on any arch linux system (as root) and you will find the infernal devfs
# replaced with a real man's /dev, and the necessary changes to various sytem files made so
# that you can actually use your system afterwards.
#
# This is a hack.  I am not responsible for any loss of data, computer, life, pets, or sanity
# that may result from usage of this shell script.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#

STARTDIR=`pwd`

if [ $UID -ne 0 ]; then
    echo "You must be root before I let you fuck up your system irreparably."
    # Damn straight
    exit
fi

FSTAB=/etc/fstab
MENU_LST=/boot/grub/menu.lst
MAKEDEV=$STARTDIR/MAKEDEV-1.7
SNDDEVICES=$STARTDIR/snddevices
DEVTOOL=$STARTDIR/iloveflatdev
INITTAB=/etc/inittab
SECURETTY=/etc/securetty
GROUP=/etc/group
NEWDEV=/mnt/temporary/dev

add_groups()
{
    echo audio::420:root >> $GROUP
    echo floppy::421:root >> $GROUP
    echo dialout::422:root >> $GROUP
}

remount()
{
    if [ ! -e /mnt/temporary ]; then
        mkdir /mnt/temporary
    fi
    i=`mount | grep "on / " | sed s: .*on.*::`
    # Get the current root partition and remount it at /mnt/temporary
    mount $i /mnt/temporary
    # Copy our scripts into the chroot, just in case
    # we're on a different partition (home?)
    cp $MAKEDEV /mnt/temporary/dev/
    cp $SNDDEVICES /mnt/temporary/dev/
    cp $DEVTOOL /mnt/temporary/dev/
}

find_corresponding_node()
{
    i="$(file $1 | awk '{print $4}' | sed -e 's?/?\/?')"
   # Find major/minor numbers for this devfs node
    for j in "$(file $NEWDEV/* | grep $i | sed -e s/:.*//)"; do
   # Find the corresponding node in our new /dev directory
        echo $j | awk '{print $1}' | sed s:/mnt/temporary::g
      # We only want the first, so break out
        break
    done
}

update_fstab()
{
    for i in $(grep ^/dev $FSTAB | sed s/ .*//); do
        file $i | grep cannot >& /dev/null
        if [ ! $? -gt 0 ]; then
      # Node doesn't exist, don't replace it in fstab
            continue
        fi
        j=`find_corresponding_node $i`
        echo $j
        sed -i s:$i:$j: $FSTAB
    done
}

update_menu_lst()
{
    for i in $(grep root= $MENU_LST | sed -e s/.*root=// -e s/ ro//); do
        j=`find_corresponding_node $i`
        sed -i s:$i:$j: $MENU_LST
    done
}

update_ttys()
{
    sed -i s:vc/:tty:g $INITTAB
    sed -i s:vc/:tty:g $SECURETTY
}

cleanup()
{
    cd $STARTDIR
    umount /mnt/temporary
    rm -r /mnt/temporary
}

add_groups
remount
# We need to chroot in order to create the device nodes,
# as one of the scripts, (snddevices), is stupid
chroot /mnt/temporary /dev/iloveflatdev
rm /mnt/temporary/dev/iloveflatdev
# We don't need this script cluttering up /dev, now do we? Nah.
update_fstab
update_menu_lst
update_ttys
cleanup

# Done.  Pray.

iloveflatdev

#!/bin/sh

# We use two scripts to populate /dev.  One of them is MAKEDEV
# which comes our way via Linux from Scratch, and the other one
# is snddevices, from alsa-driver.
#
# Both of them want a few groups to exist that aren't part of Arch's
# default setup, so we create them first
#

cd /dev

./MAKEDEV-1.7 generic
./snddevices

rm MAKEDEV-1.7
rm snddevices

mkdir pts
mkdir shm

# Boh.

:idea:  lol  8)  :?  :!:

Thank you guinea pig Itachi for pointing out my first fatal, system-borking bug! ( /me updates the script, heh )
Edit2: And second bug.    :twisted:

Both fixed, don't worry.  Oh, and his sytem booted fine smile


[Arch GNUstep Repository] [ PKGBUILDS ]
[code][gnustep]
Server = ftp://blkwidow.lerp.com/pub/mirror/arch/gnustep[/code]

Offline

#2 2004-03-17 12:52:01

Guest
Guest

Re: I need volunteers for a dangerous mission!

Glad to help.  And yeah, after the third "oh shit sorry" from him most of the fatal bugs were fixed and I booted fine.

I expected this old computer to bust into flames and explode, but was pleasantly disappointed.

#3 2004-03-17 21:26:36

tehdely
Member
Registered: 2004-02-20
Posts: 148
Website

Re: I need volunteers for a dangerous mission!

You're too kind.

Edit: Current things I need to fix:

1) Doesn't fix /etc/conf.d/gpm and /etc/X11/XF86Config to point to the new pointer devices (/dev/psaux instead of /dev/misc/psaux)
2) Doesn't distinguish between block and character devices, which seems to be a problem with cdroms


[Arch GNUstep Repository] [ PKGBUILDS ]
[code][gnustep]
Server = ftp://blkwidow.lerp.com/pub/mirror/arch/gnustep[/code]

Offline

Board footer

Powered by FluxBB