HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Smalltalk (http://www.howtoforge.com/forums/forumdisplay.php?f=11)
-   -   I'm bored (http://www.howtoforge.com/forums/showthread.php?t=644)

linuxfast 22nd September 2005 15:03

I'm bored
 
Was bored so I thought I would try this on one of my unused remote servers.

http://www.underhanded.org/papers/de...remotedeb.html

It's a method of formatting your swap partition and installing debian remotely, then changing your boot loader to let you boot from it.

It was very good fun and interesting too.....
My machine is now dead however, must have done something wrong LOL
Will probably try again on a test box at home.
If anyone has any experience in something similar, please let me know. Interested to know if Fedora can be installed remotely, maybe with rpmstrap ? Not been able to find much info on it yet.

:eek:

till 22nd September 2005 15:14

Hi,

here is a small shell script to install DEBIAN remotely. I've used it and it worked for me. The comments and questions are in german, but with a bit shell scripting knowledge you may understand it as well. The script is intended to be run from a net-booted linux rescue system that most server hosting providers are already offering in germany.

Code:

#!/bin/sh
##############################################################
#
# v1.6
# 25.03.2003 Christian Ney
#
# ---------------------------------------------------
# Dieses Dokument unterliegt der GPL, 
# und darf frei kopiert und geändert werden, so lange
# die Coprightinformation unverändert beigefügt
# wird.
# Bei Veröffentlichung und / oder kommerzieller
# Nutzung ist der Autor (chris@roothell.org) zu
# informieren.
# ---------------------------------------------------
#
# Die Benutzung dieses Scripts erfolgt auf eigene Gefahr
#
##############################################################

BLOCKS=`/sbin/fdisk -s /dev/hda`
SPACE=`expr $BLOCKS / 1024`

echo "---------------"
echo "Partitionierung"
echo "---------------"
echo ""

echo "Größe für das /-Filesystem (in MB) :"
read ROOT
LEFT=`expr $SPACE - $ROOT`
ALL=$ROOT
echo ""
echo "OK, / soll also $ROOT MB groß sein. Übrig sind $LEFT MB."

echo ""
echo "Größe für die swap-Partition in MB :"
read SWAP
LEFT=`expr $LEFT - $SWAP`
ALL=`expr $ALL + $SWAP`
echo ""
echo "Deine Partitionierung sieht im Moment folgendermaßen aus :"
echo "/dev/hda3 -> /    -> $ROOT MB"
echo "/dev/hda2 -> swap -> $SWAP MB"
echo "Übrig sind $LEFT MB."

echo ""
echo "Größe für das /boot-Filesystem in MB :"
read BOOT
LEFT=`expr $LEFT - $BOOT`
ALL=`expr $ALL + $BOOT`
echo ""
echo "Deine Partitionierung sieht im Moment folgendermaßen aus :"
echo "/dev/hda3 -> /    -> $ROOT MB"
echo "/dev/hda2 -> swap  -> $SWAP MB"
echo "/dev/hda1 -> /boot -> $BOOT MB"
echo "Übrig sind $LEFT MB."

echo ""
echo "Größe für das /usr-Filesystem in MB :"
read USR
LEFT=`expr $LEFT - $USR`
ALL=`expr $ALL + $USR`
echo ""
echo "Deine Partitionierung sieht im Moment folgendermaßen aus :"
echo "/dev/hda3 -> /    -> $ROOT MB"
echo "/dev/hda2 -> swap  -> $SWAP MB"
echo "/dev/hda1 -> /boot -> $BOOT MB"
echo "/dev/hda5 -> /usr  -> $USR MB"
echo "Übrig sind $LEFT MB."

echo ""
echo "Größe für das /home-Filesystem in MB :"
read HOMEDIR
LEFT=`expr $LEFT - $HOMEDIR`
ALL=`expr $ALL + $HOMEDIR`
echo ""
echo "Deine Partitionierung sieht im Moment folgendermaßen aus :"
echo "/dev/hda3 -> /    -> $ROOT MB"
echo "/dev/hda2 -> swap  -> $SWAP MB"
echo "/dev/hda1 -> /boot -> $BOOT MB"
echo "/dev/hda5 -> /usr  -> $USR MB"
echo "/dev/hda6 -> /home -> $HOMEDIR MB"
echo "Übrig sind $LEFT MB."

echo ""
echo "Größe für das /tmp-Filesystem in MB :"
read TMP
LEFT=`expr $LEFT - $TMP`
ALL=`expr $ALL + $TMP`
echo ""
echo "Deine Partitionierung sieht im Moment folgendermaßen aus :"
echo "/dev/hda3 -> /    -> $ROOT MB"
echo "/dev/hda2 -> swap  -> $SWAP MB"
echo "/dev/hda1 -> /boot -> $BOOT MB"
echo "/dev/hda5 -> /usr  -> $USR MB"
echo "/dev/hda6 -> /home -> $HOMEDIR MB"
echo "/dev/hda7 -> /tmp  -> $TMP MB"
echo "Übrig sind $LEFT MB."

echo ""
echo "Größe für das /var-Filesystem in MB (noch frei : $LEFT MB) :"
read VAR
LEFT=`expr $LEFT - $VAR`
ALL=`expr $ALL + $VAR`
echo ""
echo "Deine Partitionierung sieht im Moment folgendermaßen aus :"
echo "/dev/hda3 -> /    -> $ROOT MB"
echo "/dev/hda2 -> swap  -> $SWAP MB"
echo "/dev/hda1 -> /boot -> $BOOT MB"
echo "/dev/hda5 -> /usr  -> $USR MB"
echo "/dev/hda6 -> /home -> $HOMEDIR MB"
echo "/dev/hda7 -> /tmp  -> $TMP MB"
echo "/dev/hda8 -> /var  -> $VAR MB"
echo "Übrig sind $LEFT MB."

if [ "$1" = "--with-opt" ]; then
        echo ""
        echo "Größe für das /opt-Filesystem in MB (noch frei : $LEFT MB) :"
        read OPT
        LEFT=`expr $LEFT - $OPT`
        ALL=`expr $ALL + $OPT`
        echo ""
        echo "Deine Partitionierung sieht im Moment folgendermaßen aus :"
        echo "/dev/hda3 -> /    -> $ROOT MB"
        echo "/dev/hda2 -> swap  -> $SWAP MB"
        echo "/dev/hda1 -> /boot -> $BOOT MB"
        echo "/dev/hda5 -> /usr  -> $USR MB"
        echo "/dev/hda6 -> /home -> $HOMEDIR MB"
        echo "/dev/hda7 -> /tmp  -> $TMP MB"
        echo "/dev/hda8 -> /var  -> $VAR MB"
        echo "/dev/hda9 -> /opt  -> $OPT MB"
        echo "Übrig sind $LEFT MB."
fi

if [ $ALL -gt $SPACE ]; then
        echo ""
        echo "Plattengröße : $SPACE MB, du willst aber $ALL MB allokieren."
        echo "Partitionen sind zu groß für die Platte. Abbruch."
        exit 1
fi

echo ""
echo "---------------------"
echo "Netzwerkkonfiguration"
echo "---------------------"
echo ""

echo "IP-Adresse deines Servers :"
read IPADD
echo ""

NETMASK=255.255.255.0
NETWORK=`echo $IPADD | cut -d "." -f 1,2,3`.0
BROADCAST=`echo $IPADD | cut -d "." -f 1,2,3`.255
GATEWAY=`echo $IPADD | cut -d "." -f 1,2,3`.1

echo "Hostname deines Server (pxxxxx.pureserver.info) :"
read HOSTNAME
echo ""

cd /

echo "#!/bin/sh" > ./stage2.sh
echo "export IPADD=$IPADD" >> ./stage2.sh
echo "export NETMASK=$NETMASK" >> ./stage2.sh
echo "export NETWORK=$NETWORK" >> ./stage2.sh
echo "export BROADCAST=$BROADCAST" >> ./stage2.sh
echo "export GATEWAY=$GATEWAY" >> ./stage2.sh
echo "export HOSTNAME=$HOSTNAME" >> ./stage2.sh
echo "chmod u+x ./stage3.sh"
echo "./stage3.sh" >> ./stage2.sh
chmod u+x ./stage2.sh

# Get Debian-Start
wget http://linux.roothell.org/debian-rootie/debian-start.tar.gz
tar xzvf ./debian-start.tar.gz

# Partitionierung löschen
for i in `seq 1 9`
do
        /sbin/parted -s /dev/hda rm $i
done
       
# Partitionieren
/sbin/parted -s /dev/hda mkpart primary ext2 0 $BOOT && \
/sbin/parted -s /dev/hda set 1  boot on && \
/sbin/parted -s /dev/hda mkpart primary linux-swap $BOOT `expr $BOOT + $SWAP` && \
/sbin/parted -s /dev/hda set 2 swap on
        SWAP=`expr $BOOT + $SWAP`
/sbin/parted -s /dev/hda mkpart primary ext2 $SWAP `expr $SWAP + $ROOT` && \
/sbin/parted -s /dev/hda set 3 root on
        ROOT=`expr $SWAP + $ROOT`
        if [ "$1" = "--with-opt" ]; then
                EXTEND=`expr $ROOT + $USR + $HOMEDIR + $TMP + $VAR + $OPT`
        else
                EXTEND=`expr $ROOT + $USR + $HOMEDIR + $TMP + $VAR`
        fi
/sbin/parted -s /dev/hda mkpart extended $ROOT $EXTEND && \
/sbin/parted -s /dev/hda mkpart logical ext2 $ROOT `expr $ROOT + $USR` && \
        USR=`expr $ROOT + $USR` && \
/sbin/parted -s /dev/hda mkpart logical ext2 $USR `expr $USR + $HOMEDIR` && \
        HOMEDIR=`expr $USR + $HOMEDIR` && \
/sbin/parted -s /dev/hda mkpart logical ext2 $HOMEDIR `expr $HOMEDIR + $TMP` && \
        TMP=`expr $HOMEDIR + $TMP` && \
/sbin/parted -s /dev/hda mkpart logical ext2 $TMP `expr $TMP + $VAR` && \
if [ "$1" = "--with-opt" ]; then
                VAR=`expr $TMP + $VAR`
        /sbin/parted -s /dev/hda mkpart logical ext2 $VAR `expr $VAR + $OPT`
fi

# Filesysteme anlegen
if [ "$1" = "--with-opt" ]; then
        for i in "1" "3" "5" "6" "7" "8" "9"
        do
                /sbin/mke2fs -j /dev/hda$i
        done
else
        for i in "1" "3" "5" "6" "7" "8"
        do
                /sbin/mke2fs -j /dev/hda$i
        done
fi
       
/sbin/mkswap /dev/hda2

# Filesysteme mounten
/bin/mkdir /mnt/debian
/bin/mount -t ext3 /dev/hda3 /mnt/debian
/bin/mkdir /mnt/debian/boot
/bin/mount -t ext3 /dev/hda1 /mnt/debian/boot
/bin/mkdir /mnt/debian/usr
/bin/mount -t ext3 /dev/hda5 /mnt/debian/usr
/bin/mkdir /mnt/debian/home
/bin/mount -t ext3 /dev/hda6 /mnt/debian/home
/bin/mkdir /mnt/debian/tmp
/bin/mount -t ext3 /dev/hda7 /mnt/debian/tmp
/bin/mkdir /mnt/debian/var
/bin/mount -t ext3 /dev/hda8 /mnt/debian/var
if [ "$1" = "--with-opt" ]; then
        /bin/mkdir /mnt/debian/opt
        /bin/mount -t ext3 /dev/hda9 /mnt/debian/opt
        /usr/bin/touch /mnt/debian/opt/tmpfile
fi

# debootstrap starten
/usr/sbin/debootstrap woody /mnt/debian http://ftp.debian.de/debian/ && \

# Stage2-Script ins neue Root verschieben
/bin/mv /stage2.sh /mnt/debian/
/bin/mv /stage3.sh /mnt/debian/

# Chroot ins "neue" System
/usr/sbin/chroot /mnt/debian /stage2.sh


linuxfast 22nd September 2005 15:16

Cool thanks till.
Will have a look at this. All my servers are colo so theres no rescue installed.
Wondering if this is something else I can look at doing myself.

till 22nd September 2005 15:21

I dont know how these companies are managing it.

You can select in the server control area wether the server shall boot from its own harddisk or from a network booted rescue systems. I know how to enable netboot in the bios of my PC, but how to manage my bios remotely???

linuxfast 22nd September 2005 15:33

Ah I see
Worth trying to find out.
Short of having a second BIOS which is switchable, I have no idea... and obviously nobody would go to that trouble would they ?

Anyone know how it's done ?

And yeah, I had a oneandone server until I realised my mistake, they had a system like this

Thinking about it, surely it can be done by having a seperate partition with the rescue file system, and a custom boot loader which could be activated by a php script maybe.... but then again, the OS would need to be booting to do that (and thus not requiring rescuing !!!)

till 22nd September 2005 16:17

Yes and the customer has full control over the server and even if he/she formats the harddrive, the rescuesystem is working. Maybe they are using something like the ROLF network cards??

falko 22nd September 2005 17:52

Quote:

Originally Posted by linuxfast
If anyone has any experience in something similar, please let me know.

You can even find information about that topic here on HowtoForge! :D
http://www.howtoforge.com/dedicated_...e_systemimager

domino 22nd September 2005 23:00

Quote:

It was very good fun and interesting too.....
My machine is now dead however, must have done something wrong LOL
LOL, Funny how bordom sometimes gets you in big trouble.

linuxfast 23rd September 2005 13:41

Yeah looked at that Falko, I am sure I will find a use for that Howto but not been through it yet.
What I was trying to do however, is find a way whereby if your server becomes unbootable (and is a remote server), you could log into an independant system which would change the boot config of your machine, or at least enable you to mount the filesystem from your hard disk in order to let you fix the problems that are preventing it from booting

And yeah, very true Domino !


All times are GMT +2. The time now is 05:38.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.