License

Copyright (C) 2008-2017 Oliver Bohlen.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.

A copy of the license is included in the section entitled "GNU Free Documentation License".

Introduction

This documentation comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

Howto: Thinclient - Install on local device for Gentoo Linux

If you want to install your Thinclient on a local device you can do it by this way.

If you want to use this solution you need the following howto(s) finished:

Required software

The required software has to be installed with the following command(s):
chroot /gtc/test /bin/bash -c 'env-update &>/dev/null && source /etc/profile && emerge sys-boot/grub'

Changes in /gtc/test/etc/thinclient/scripts/gtc-diskinst

File permissions:
Owner: root
Group: root
Permissions: -rwxr-xr-x

Click here for a download of the complete file: /gtc/test/etc/thinclient/scripts/gtc-diskinst

Changed on 28.06.09
Issued by olli
Beginning line 2

This is the script you can use out of a booted Thinclient to install it on a local device

#!/bin/bash

usage() {
 echo "Usage: 
 $0 device [mbr]

Example for installing on /dev/sda2 and installing Grub in MBR of /dev/sda: 
 $0 /dev/sda2 /dev/sda
Example for installing on /dev/sda2 without installing Grub:
 $0 /dev/sda2"
 exit 1
}

exist() {
 echo "Device $1 is not a block-device or does not exist"
 exit 1
}

nomount() {
 echo "Device $1 could not be mounted. Is it formatted?"
 exit 1
}

nouuid() {
 echo "Couldn't get a valid UUID for the device"
 exit 1
}

# Get script name
script=`basename $0`

[ -z "$1" ] && usage
#[ "$#" -ne 1 ] && usage
export DEV=`echo $1 | sed 's/^\/dev\///'`
[ -b /dev/$DEV ] &>/dev/null || exist $DEV
if [ -z "$2" ]
then
 echo "Not writing MBR"
else
 export MBR=`echo $2 | sed 's/^\/dev\///'`
 [ -b /dev/$MBR ] &>/dev/null || exist $MBR
fi

# Prompt/Select profile for profilebased installations
if [ $script = "gtc-profileinst" ]
then
 echo "Available profiles:
"
 ls -1 /_gtcroot/etc/thinclient/profiles
 echo "
Please enter the profile: "
 read profile
 if [ -z "$profile" ]
 then
  echo "You have to enter a Profilename"
  exit 1
 fi
 if [ -d "/_gtcroot/etc/thinclient/profiles/$profile" ]
 then
  echo "Profile $profile selected"
 else
  echo "Profile $profile does noch exist"
  exit 1
 fi
fi

if [ $script = "gtc-srvinst" ]
then
 echo "Please enter the IP of your GTC-Server [XXX.XXX.XXX.XXX]:"
 read ip
 if [ -z "$ip" ]
 then
  ip="XXX.XXX.XXX.XXX"
 fi
 echo "Please enter the subnet mask of your GTC-Server [XXX.XXX.XXX.XXX]:"
 read sn
 if [ -z "$sn" ]
  then
  sn="XXX.XXX.XXX.XXX"
 fi
 echo "Please enter the gateway for your GTC-Server [XXX.XXX.XXX.XXX]:"
 read gw
 if [ -z "$gw" ]
 then
  gw="XXX.XXX.XXX.XXX"
 fi
 echo "Please enter a hostname and domainname for GTC-Server [mygtcserver.mydomain.org]:"
 read hn
 if [ -z "$hn" ]
 then
  hn="mygtcserver.mydomain.org"
 fi
 bootflag="gtcprofile=$hn gtcserver ip=$ip:$ip:$gw:$sn BOOTIF=eth"
fi


echo "Mounting /dev/$DEV to /var/dev..."
mkdir -p /var/dev
mount /dev/$DEV /var/dev || nomount $DEV

rm -rf /tmp/gtc-started
if [ -d "/_gtcroot" ]
then
 touch /tmp/gtc-started
 echo "This seems to be a startet GTC - using /_gtcroot"
else
 mkdir /_gtcroot
 mount -B / /_gtcroot
fi

echo "Syncing files... This may take a long time..."
rsync -av --numeric-ids --delete --exclude=/_tmpupdate --exclude=/srv --exclude=/usr/portage/distfiles --exclude=/proc --exclude=/tmp --exclude=/sys  --exclude=/home --exclude=/usr/src --exclude=/media --exclude=/var/tmp/portage --exclude=/root --exclude=/gtcdvd --exclude=/gtcdvd.iso --exclude=/_gtcroot --exclude=/_gtcdvdroot --exclude=/boot/grub/grub.conf --exclude=/boot/grub/grub.cfg /_gtcroot/ /var/dev/ || exit 1
if [ -f /tmp/gtc-started ]
then
 echo "Leaving /_gtcroot mounted"
 rm /tmp/gtc-started
else
 umount /_gtcroot 2>/dev/null
 rmdir /_gtcroot 2>/dev/null
fi
>/var/dev/etc/mtab
touch /var/dev/etc/thinclient/thinclient.conf.local
chmod 0644 /var/dev/etc/nsswitch.conf
mkdir -p /var/dev/proc
mkdir -p /var/dev/tmp
chmod 1777 /var/dev/tmp
mkdir -p /var/dev/sys
mkdir -p /var/dev/home
mkdir -p /var/dev/media
mkdir -p /var/dev/root
chmod 700 /var/dev/root
mkdir -p /var/dev/usr/portage/distfiles
mkdir -p /var/dev/var/tmp/portage
sync

if [ $script = "gtc-diskinst" ]
then
 echo "Setting hostname (for profiling)"
 bootflag="gtcprofile=`hostname`"
fi

if [ $script = "gtc-profileinst" ]
then
 echo "Setting hostname/profile to $profile"
 bootflag="gtcprofile=$profile"
fi
rm -f /var/dev/etc/udev/rules.d/70-persistent-net.rules

# Set several local settings if this ist a srvinst
if [ $script = "gtc-srvinst" ]
then
 echo "# Server settings:
NAMESERVER=$ip
NAMESERVERBACKUP=''
SEARCH=gtc
LDAP=yes
LDAP_SERVER=gtc.
LDAP_TLS=yes
LDAP_BASEDN='dc=gtc'
PAM_MOUNT=yes
PAM_MOUNT_SERVER=gtc.
PAM_MOUNT_FS=cifs
PAM_MOUNT_SHARES='share'
 " >> /var/dev/etc/thinclient/thinclient.conf.local
fi

echo "Getting UUID..."
mount | grep "^proc" || mount -t proc proc /proc
mount | grep "^\/sys" || mount -t sysfs sys /sys
export UUID=`blkid | grep $DEV | perl -pe 's/^.+ UUID="//; s/".+$//'`
[ -z "$UUID" ] && nouuid
echo $UUID | grep "........-....-....-....-............" >/dev/null || nouuid
echo "UUID is $UUID"

echo "Writing fstab"
rm /var/dev/etc/fstab
echo "
UUID=$UUID	/	auto	defaults	0 0
proc	/proc	proc	defaults	0 0
shm	/dev/shm	tmpfs	nodev,nosuid,noexec	0 0
" > /var/dev/etc/fstab
chmod 755 /var/dev/etc/fstab

cd /

### GRUB ###

echo "Writing Grub configuration"
echo "
set timeout=10
set default=0

menuentry 'Local GTC' {
        set uuid_root=$UUID
        search --no-floppy --fs-uuid \$uuid_root --set=root
        set root=\$root
        echo    'Loading kernel...'
        linux    /boot/kernel root=UUID=$UUID root=/dev/nfs gtchdd scandelay=10 ramdisk_size=256000 lockd.udpport=32768 lockd.tcpport=32768 i915.modeset=1 radeon.modeset=1 $bootflag
        echo    'Loading initrd...'
        initrd  /boot/initrd
}
" >/var/dev/boot/grub/grub.cfg

echo "Searching for other Systems"
os-prober 2>/dev/null | grep ":chain$" | sort >/tmp/os
cat /tmp/os | while read os
do
 chaindev=`echo $os | cut -d: -f1`
 chainname=`echo $os | cut -d: -f2 | perl -pe 's/ \(loader\)$//'`
 chainuuid=`blkid | grep $chaindev | perl -pe 's/^.+UUID="//; s/".+$//'`
 echo "$chaindev - $chainname - $chainuuid"
 echo "
menuentry '$chainname ($chaindev)' {
        set uuid_root=$chainuuid
        search --no-floppy --fs-uuid \$uuid_root --set=root
        set root=\$root
        chainloader +1
}
" >> /var/dev/boot/grub/grub.cfg
done

if [ -z $MBR ]
then
 echo "Bootmanager is prepared but not installed"
 umount /var/dev
else
 echo "Installing Grub in MBR of /dev/$MBR"
 mount -t proc proc /var/dev/proc
 chroot /var/dev /bin/bash -c "/usr/sbin/grub-install --no-floppy --recheck /dev/$MBR"
 umount /var/dev/proc
 umount /var/dev
fi


echo "The installation is finished and should run!!!"


Please send a feedback to: doc<at>gabosh.net

Howto listing
File Index

Here you can find the official Gentoo Linux Forums where you can find a lot of answers.

Here a link to the official Gentoo Linux Homepage.

Edit Howto

About / Impressum

Click here for About / Impressum

Wishlist

If you want to support my work you can find my Amazon whishlist here