Difference between revisions of "Minimal"

From PostgreSQL_wiki
Jump to: navigation, search
(Installatie voorbereiding)
(chrooted)
Line 18: Line 18:
 
==== chrooted ====
 
==== chrooted ====
 
<pre>
 
<pre>
  +
:/# cat /etc/fstab
:/#
 
  +
# UNCONFIGURED FSTAB FOR BASE SYSTEM
mount -t proc proc /proc && mount -t sysfs sysfs /sys
 
  +
LABEL=webboot / ext2 defaults,errors=remount-ro,noatime 0 1
mount -a
 
  +
proc /proc proc defaults 0 0
echo "127.0.0.1 localhost" > /etc/hosts
 
  +
tmpfs /tmp tmpfs defaults,noatime 0 0
  +
tmpfs /var/lock tmpfs defaults,noatime 0 0
  +
tmpfs /var/log tmpfs defaults,noatime 0 0
  +
tmpfs /var/run tmpfs defaults,noatime 0 0
  +
tmpfs /var/tmp tmpfs defaults,noatime 0 0
   
  +
:/# mount -t proc proc /proc && mount -t sysfs sysfs /sys
echo "webboot" > /etc/hostname
 
  +
:/# mount -a
  +
:/# echo "127.0.0.1 localhost" > /etc/hosts
   
  +
:/# echo "webboot" > /etc/hostname
cat /etc/network/interfaces
 
  +
  +
:/# cat /etc/network/interfaces
 
auto lo
 
auto lo
 
iface lo inet loopback
 
iface lo inet loopback
Line 34: Line 43:
 
nameserver 10.68.71.187
 
nameserver 10.68.71.187
   
apt-get install linux-image-3.2.0-3-686-pae
+
:/# apt-get install linux-image-3.2.0-3-686-pae
apt-get install locales-all
+
:/# apt-get install locales-all
   
addgroup --system admin
+
:/# addgroup --system admin
useradd -s /bin/bash -g admin -m -k /dev/null martin
+
:/# useradd -s /bin/bash -g admin -m -k /dev/null martin
passwd root
+
:/# passwd root
passwd martin
+
:/# passwd martin
   
apt-get install ntfsprogs scrounge-ntfs dosfstools rsync localepurge gddrescue rungetty sshfs sudo
+
:/# apt-get install ntfsprogs scrounge-ntfs dosfstools rsync localepurge gddrescue rungetty sshfs sudo
 
</pre>
 
</pre>
   

Revision as of 21:39, 12 September 2012

Debian minimal

Een minimal Linux komt op zijn tijd erg goed gelegen, vooral als data extractie in Windows omgevingen voor migratie uit de Windows omgeving aan de orde is. Webhuis heeft voor twee situaties een speciale minimal Linux ontwikkeld, webboot en de bootable USB-stick. Beide versie beschikken over basale tools voor data extractie. Het grote voordeel ligt in de veel hogere en efficientere werkwijze.

Debian minimal webboot

Webboot is een diskless Debian versie, die boot met behulp van PXE start. Diskless boot is een samenspel tussen een werkstation en een servr. Het werkstation moet beschikken over de mogelijk om vanaf de netwerkkaart te booten, met het PXE protocol. De server moet het volgende doen:

  • Beschikken over een werkende dhcp service
  • Een tftpd-hpa service
  • Een netboot kernel en initrd aanbieden

Installatie voorbereiding

Een webboot installatie vondt plaats op een andere host dan op de machine waarop de installatie uiteindelijk draait. De installatie verloopt in stappen:

  • Met debootstrap in een installatie directory
  • Chroot naar de installatie directory

Noodzakelijke programmatuur:

# apt-get install debootstrap fakeroot
# debootstrap --arch i386 wheezy webboot-wheezy http://mirror.webhuis.nl:3142/debian
# chroot webboot-wheezy/

chrooted

:/# cat /etc/fstab
# UNCONFIGURED FSTAB FOR BASE SYSTEM
LABEL=webboot / ext2 defaults,errors=remount-ro,noatime 0 1
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults,noatime 0 0
tmpfs /var/lock tmpfs defaults,noatime 0 0
tmpfs /var/log tmpfs defaults,noatime 0 0
tmpfs /var/run tmpfs defaults,noatime 0 0
tmpfs /var/tmp tmpfs defaults,noatime 0 0

:/# mount -t proc proc /proc && mount -t sysfs sysfs /sys
:/# mount -a
:/# echo "127.0.0.1 localhost" > /etc/hosts

:/# echo "webboot" > /etc/hostname 

:/# cat /etc/network/interfaces 
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

:/# cat /etc/resolv.conf 
nameserver 10.68.71.187

:/# apt-get install linux-image-3.2.0-3-686-pae
:/# apt-get install locales-all

:/# addgroup --system admin
:/# useradd -s /bin/bash -g admin -m -k /dev/null martin
:/# passwd root
:/# passwd martin 

:/# apt-get install ntfsprogs scrounge-ntfs dosfstools rsync localepurge gddrescue rungetty sshfs sudo

dhcp

De dhcp service biedt voor een of meerdere werkstations of de volgende wijze een pxe optie:

host webboot.webhuis.nl {
        hardware ethernet 00:68:84:e2:ea:a1;
        next-server 10.99.99.11;
        option root-path "10.99.99.11:/var/lib/tftpboot";
        option host-name "webboot";
        fixed-address 10.99.99.19;
        filename "pxelinux.0";

De dhcp service (op 10.99.99.1) geeft hier aan dat het werkstation voor de volgende stap van het bootproces naar de service tftpboot op de server 10.99.99.11.

tftpboot

Op de server 10.99.99.11 is het bestand pxelinux.0 geinstalleerd. Dit bootprogramma instrueert het werkstation om het bestand pxelinux.cfg/default op te vragen.

pxelinux.cfg/default

Onderstaande pxe default configuratie geeft drie boot mogelijkheden.

  • webboot, een diskless Linux, die volledig in RAM draait.
  • amd64-minimal, een minimale 64 bits Linux
  • i386-minimal, een minimale 32 bits Linux
#       Configuratie voor pxe-boot
DISPLAY boot.txt
DEFAULT webboot
LABEL webboot
        kernel debian/squeeze/i386/vmlinuz-2.6.32-5-686
        append vga=791 initrd=debian/squeeze/i386/webboot_squeeze_2.6.32-5-686.cgz  --
LABEL
start_amd64_minimal
        kernel debian/squeeze/amd64/vmlinuz-2.6.32-5-amd64
        append vga=791 initrd=debian/squeeze/amd64/debirf-minimal_squeeze_2.6.32-5-amd64.cgz  --
LABEL
start_i386_minimal
        kernel debian/squeeze/i386/vmlinuz-2.6.32-5-686
        append vga=791 initrd=debian/squeeze/i386/debirf-minimal_squeeze_2.6.32-5-686.cgz  --
PROMPT 1
TIMEOUT 30

De default aktie is het starten van webboot na 5 seconden.

Debian minimal USB

Een bootable Debian USB is goud waard in een migratie uit Windows naar Linux.

  • maak met unetbootin een een netinstall aan op een partitie op een usb-stick
  • Boot de doel machine met de usb-stick en voer de installatie uit
  • Grub maakt een foutje door de devices te verwisselen, sda <-> sdb
  • Herstel de fout in grub edit en boot
  • Pas na de boot /etc/fstab aan en doe update-grub

De installatie is nog niet erg minimaal, maar hij werkt.

root@host:~# apt-get clean
root@host:~# apt-get install localepurge
root@host:~# localepurge
root@squeeze-usb-i386:~# ln -s /home/squeeze-usb-i386/var/lib/* /var
root@squeeze-usb-i386:~# ln -s /home/squeeze-usb-i386/var/cache/* /var

Installeer ook nog tools om met Windows file systems te werken:

apt-get install ntfsprogs scrounge-ntfs dosfstools rsync

Op de host

Maak een file system aan voor het OS op de USB stick.

root@host:~# fdisk /dev/sdb
root@host:~# mkfs.ext2 /dev/sdb1

Maak een folder aan op de host om daarin de installatie voor de usb-stick voor te bereiden.

root@host:~# mkdir /usbsystem
root@host:~# debootstrap --arch i386 squeeze /usbsystem http://ftp.nl.debian.org/debian
root@host:~# ./croot.sh /usbsystem

Doe eerst alle stappen uit chrooted en doe daarna:

root@host:~# umount /usbsystem/dev/ /usbsystem/sys /usbsystem/proc /usbsystem/tmp
root@host:~# umount /usbsystem-amd64/dev/ /usbsystem-amd64/sys /usbsystem-amd64/proc /usbsystem-amd64/tmp

chrooted

fstab

# UNCONFIGURED FSTAB FOR BASE SYSTEM
LABEL=USB_ROOT / ext2 defaults,errors=remount-ro,noatime 0 1
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults,noatime 0 0
tmpfs /var/lock tmpfs defaults,noatime 0 0
tmpfs /var/log tmpfs defaults,noatime 0 0
tmpfs /var/run tmpfs defaults,noatime 0 0
tmpfs /var/tmp tmpfs defaults,noatime 0 0

Ruim de bestanden in bovenstaande directories op na een umount.

   6  rm -f /etc/mtab && ln -s /proc/mounts /etc/mtab
   7  echo "127.0.0.1 localhost" > /etc/hosts
   9  apt-get install localepurge
  10  localepurge 
  15  apt-get install linux-image-2.6-686
  16  vi /etc/default/locale 
  17  apt-get install grub
  18  echo lang
  19  echo LANG
  20  echo $LANG
  21  vi /boot/grub/grub.cfg 
  22  groupadd martin
  23  useradd --home /home/martin --shell /bin/bash --gid martin
  24  mkdir /home/martin
  25  useradd --home /home/martin --shell /bin/bash --gid martin
  26  useradd --home-dir /home/martin --shell /bin/bash --gid martin
  27  useradd --home-dir /home/martin --shell /bin/bash --gid martin martin
  28  apt-get install rungetty
  29  sed -i '/getty/d' /etc/inittab
  30  vi rungetty-script
  31  cat >> /etc/inittab << face="courier new">1:2345:respawn:/sbin/rungetty --autologin martin
  32  EOF
  33  cat >> /etc/inittab << face="courier new">1:2345:respawn:/sbin/rungetty --autologin martin EOF
  34  cat >> /etc/inittab << face="courier new">1:2345:respawn:/sbin/rungetty --autologin martin
  35  vi /etc/inittab 
  36  apt-get clean
  37  exit
  38  history    1  uname -a
   2  vi /etc/fstab 
   3  vi /etc/fstab 
   4  vi /etc/fstab 
   5  vi /etc/apt/sources.list
   6  rm -f /etc/mtab && ln -s /proc/mounts /etc/mtab
   7  echo "127.0.0.1 localhost" > /etc/hosts
   8  history 
   9  apt-get install localepurge
  10  localepurge 
  11  apt-cache search linux | grep image | grep 386
  12  apt-cache search linux 
  13  apt-cache search kernel
  14  uname -a
  15  apt-get install linux-image-2.6-686
  16  vi /etc/default/locale 
  17  apt-get install grub
  18  echo lang
  19  echo LANG
  20  echo $LANG
  21  vi /boot/grub/grub.cfg 
  22  groupadd martin
  23  useradd --home /home/martin --shell /bin/bash --gid martin
  24  mkdir /home/martin
  25  useradd --home /home/martin --shell /bin/bash --gid martin
  26  useradd --home-dir /home/martin --shell /bin/bash --gid martin
  27  useradd --home-dir /home/martin --shell /bin/bash --gid martin martin
  28  apt-get install rungetty
  29  sed -i '/getty/d' /etc/inittab
  30  vi rungetty-script
  31  cat >> /etc/inittab << face="courier new">1:2345:respawn:/sbin/rungetty --autologin martin
  32  EOF
  33  cat >> /etc/inittab << face="courier new">1:2345:respawn:/sbin/rungetty --autologin martin EOF
  34  cat >> /etc/inittab << face="courier new">1:2345:respawn:/sbin/rungetty --autologin martin
  35  vi /etc/inittab 
  36  apt-get clean
  37  exit
  38  history

Terug naar: Webhuis bouwstenen