Doc 2:Configuracion_Servidores_Linux-20110928-SEPTIEMBRE-02
Curso Red Hat Linux 5
Tutor: FRT
Documentacion: docs.redhat.com
Fecha: Sep 2011
Tema 0. Introducción
********************
En el fichero /root/anaconda-ks.cfg se guarda la configuaricón de la instalación.
kickstart: instalación personalizada, guarda la configuración en el fichero anaconda-ks.cfg
dhclient: recarga la configuración del dhcp
Tema 1. Máquinas Virtuales
**************************
------------- CREAR MAQUINA VIRTUAL ------------
vcreate -L 5G -n lv.prueba vol0
[root@station9 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
home vol0 -wi-ao 512.00M
lv.prueba vol0 -wi-a- 5.00G
lv.vcracker vol0 -wi-a- 2.00G
lv.vserver vol0 -wi-a- 2.00G
root vol0 -wi-ao 8.00G
[root@station9 ~]#
virt-install --accelerate --os-type linux --os-variant rhel5.4 -n prueba -r 256 -f /dev/vol0/lv.prueba -l http://instructor.example.com/pub -x ks=http://instructor.example.com/vserver.php?S=9 -w bridge:xenbr0
Para borrar un volumen:
[root@station9 prueba]# lvremove -f /dev/vol0/lv.prueba
Logical volume "lv.prueba" successfully removed
Si en vez de utilizar el fs para máquina virtual lo quiero para fs:
[root@station9 prueba]# fsck.ext3 /dev/vol0/lv.prueba
e2fsck 1.39 (29-May-2006)
Couldn't find ext2 superblock, trying backup blocks...
fsck.ext3: Bad magic number in super-block while trying to open /dev/vol0/lv.prueba
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
[root@station9 prueba]# mkfs.ext3 /dev/vol0/lv.prueba
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
655360 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@station9 prueba]#
[root@station9 prueba]#
[root@station9 prueba]# mount -t ext3 /dev/vol0/lv.prueba /mnt/prueba
Para comprobar los datos del nuevo fs:
[root@station9 mnt]# dumpe2fs /dev/vol0/lv.prueba | more
dumpe2fs 1.39 (29-May-2006)
Filesystem volume name:
Last mounted on:
Filesystem UUID: dbbb7283-18fa-49d6-b0f0-5ed41b5e59bd
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode dir_index filetype needs_recovery sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 655360
Block count: 1310720
Reserved block count: 65536
Free blocks: 1254784
Free inodes: 655349
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 319
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
Filesystem created: Tue Sep 27 15:27:10 2011
Last mount time: Tue Sep 27 15:27:19 2011
Last write time: Tue Sep 27 15:27:19 2011
Mount count: 1
Maximum mount count: 33
Last checked: Tue Sep 27 15:27:10 2011
Check interval: 15552000 (6 months)
--------------FIN ------------------------------
Maquinas Virtuales:
Crear un volumen: lvcreate -L 5G -n lv.vserver vol0
Crear un volumen: lvcreate -L 3G -n lv.vcracker vol0
Borrar un volumn: lvremove /dev/vol0/lv.cracker
Crear una máquina virtual con el fichero de instalación personalizado de redhat, y así empieza a instalar una máquina virtual redhat:
virt-install --accelerate --os-type linux --os-variant rhel5.4 -n vserver -r 256 -f /dev/vol0/lv.vserver -l http://instructor.example.com/pub -x ks=http://instructor.example.com/vserver.php?S=9 -w bridge:xenbr0
Would you like a fully virtualized guest (yes or no)? no
Would you like to enable graphics support? (yes or no) yes
Creamos una segunda máquina virtual:
virt-install --accelerate --os-type linux --os-variant rhel5.4 -n vcracker -r 256 -f /dev/vol0/lv.vcracker -l http://instructor.example.com/pub -x ks=http://instructor.example.com/vserver.php?S=9 -w bridge:xenbr0
Si queremos ver las lista de máquinas virtuales:
[root@station9 ~]# virsh list
Id Name State
----------------------------------
0 Domain-0 running
8 vserver blocked
9 vcracker blocked
Tema 2. Inicialización y Resolución de problemas
************************************************
Sistema Operativo:
[root@station9 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.1 (Tikanga)
Kernel:
[root@station9 ~]# uname -r
2.6.18-92.1.6.el5xen
[root@station9 ~]# uname -a
Linux station9.example.com 2.6.18-92.1.6.el5xen #1 SMP Fri Jun 20 03:05:59 EDT 2008 i686 i686 i386 GNU/Linux
Estandar que cumplen este linux:
[root@station9 ~]# lsb_release
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Kernel que tengo instalados:
[root@station9 ~]# rpm -aq kernel\*
kernel-headers-2.6.18-53.el5
kernel-xen-2.6.18-92.1.6.el5
kernel-PAE-2.6.18-53.el5
kernel-PAE-devel-2.6.18-53.el5
[root@station9 ~]# yum list installed kernel\*
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
This system is not registered with RHN.
RHN support will be disabled.
Installed Packages
kernel-PAE.i686 2.6.18-53.el5 installed
kernel-PAE-devel.i686 2.6.18-53.el5 installed
kernel-headers.i386 2.6.18-53.el5 installed
kernel-xen.i686 2.6.18-92.1.6.el5 installed
Nivel de ejecución de la máquina, del 0 al 6: (se configura en el /etc/inittab). Por defecto en el 3 (texto) o en el 5 (grafico).
[root@station9 ~]# who -r
run-level 5 2011-09-26 10:04 last=S
[root@station9 ~]# /sbin/runlevel
N 5
Con runlevel veo el estado actual y el anterior. Si pone 3 4 estoy en el 3 y antes en el 4.
1 -> Entro como root y no pide passwd. (single user)
2 -> Sin conexiones, ni bluetooth, ni red, ....
3 -> Por defecto en modo texto
4 -> Para jugar
5 -> Por defecto en modo gráfico
6 -> Reboot
0 -> halt
[root@station9 ~]# who -r
run-level 5 2011-09-26 10:04 last=S
[root@station9 ~]# /sbin/runlevel
N 5
Para cargar grup de una maqina virtual:
xm create -c vserver -> nos lanzará el grup de la máquina virtual vserver.
Servicios: system-config-services
[root@station9 ~]# chkconfig --list
NetworkManager 0:off 1:off 2:off 3:off 4:off 5:off 6:off
NetworkManagerDispatcher 0:off 1:off 2:off 3:off 4:off 5:off 6:off
acpid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off
apmd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
avahi-daemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
avahi-dnsconfd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
bluetooth 0:off 1:off 2:on 3:on 4:on 5:on 6:off
conman 0:off 1:off 2:off 3:off 4:off 5:off 6:off
cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
dhcdbd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
dnsmasq 0:off 1:off 2:off 3:off 4:off 5:off 6:off
dund 0:off 1:off 2:off 3:off 4:off 5:off 6:off
firstboot 0:off 1:off 2:off 3:on 4:off 5:on 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
haldaemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
hidd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
hplip 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ibmasm 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
irda 0:off 1:off 2:off 3:off 4:off 5:off 6:off
irqbalance 0:off 1:off 2:on 3:on 4:on 5:on 6:off
kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off
libvirtd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off
mcstrans 0:off 1:off 2:on 3:on 4:on 5:on 6:off
mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
mdmpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
messagebus 0:off 1:off 2:off 3:on 4:on 5:on 6:off
microcode_ctl 0:off 1:off 2:on 3:on 4:on 5:on 6:off
multipathd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
netplugd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
nscd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
pand 0:off 1:off 2:off 3:off 4:off 5:off 6:off
pcscd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
portmap 0:off 1:off 2:off 3:on 4:on 5:on 6:off
psacct 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off
readahead_early 0:off 1:off 2:on 3:on 4:on 5:on 6:off
readahead_later 0:off 1:off 2:off 3:off 4:off 5:on 6:off
restorecond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rhnsd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcgssd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcidmapd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcsvcgssd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
smartd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
vncserver 0:off 1:off 2:off 3:off 4:off 5:off 6:off
winbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off
wpa_supplicant 0:off 1:off 2:off 3:off 4:off 5:off 6:off
xend 0:off 1:off 2:on 3:on 4:on 5:on 6:off
xendomains 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ypbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off
yum-updatesd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
Secuencia de Arranque:
1 - Bios
2 - Bootloader (mbr) 512 bytes
3 - kernel
4 - init (proceso 1)
- /etc/rc.d/rc.sysinit
- /etc/rc.d/rc[0-6].d/
- /etc/rc.d/rc.local
5 - Consolas virtuales
6 - Gestor X
1 - Bios
No se explica
2 - Bootloader (mbr) 512 bytes. En wikipedia con gráficos.
446 bytes - Gestor de arranque GRUB. (solo la primera parte del grup 1st-stage). Como es tan pequeño solo 446 hay 3 links a stage1, stag2 y a initrd (mini driver para cargar el kernel)
Link 1: /boot/grup/stage1
Link 2: /boot/grup/stage2
[root@station9 ~]# ls -l
-rw-r--r-- 1 root root 512 Sep 26 09:45 /boot/grub/stage1 (/sbin/grub-install para reparar)
-rw-r--r-- 1 root root 104924 Sep 26 09:45 /boot/grub/stage2 (/boot/grub/grub.conf para configurarlo)
-rw------- 1 root root 1040 Sep 26 09:46 grub.conf
/boot no puede estar encima del raid ni de lvm, es una partición física.
Link 3: link a ramdisk para poder leer vmlinuz. Cada vez que se cambia el hardware hay que recrear el initrd y se recrea siempre al compilar el kernel.
[root@server109 ~]# ls -larth /boot/initrd-2.6.18-53.el5xen.img
-rw------- 1 root root 2.8M Sep 26 11:16 /boot/initrd-2.6.18-53.el5xen.img
64 bytes - 4 particiones primarias como máximo. Para hacer más creo una extendida
2 bytes - firma predeterminada
Configuración en grub:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/xvda
default=0 <---- Arranque por defecto
timeout=5 <---- Timeout máximo para interactuar
splashimage=(hd0,0)/grub/splash.xpm.gz <--- Imagen predeterminado
#hiddenmenu <----- Ocultar el menu
password pepe <--- poner la password para acceder a grub
# Title 0 (arranque 0)
title Red Hat Enterprise Linux Server (2.6.18-53.el5xen)
root (hd0,0) <---- Disco 1, particion 1
kernel /vmlinuz-2.6.18-53.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet <--- Solo lectura y redhat graphic boot (rhgb) y silent si no hay error. El kernel carga en memoria los drivers para gestionar discos, pero no puedo cargar el kernel si antes no he cargado los drivers, para evitar "este círculo vicioso" antes se carga unos minidrivers en el initrd que permiten leer el kernel.
initrd /initrd-2.6.18-53.el5xen.img
-----------------------
si quiero cifrar la password de grub con grub-md5-crypt la cifro y ya lapuedo añadir al .conf
[root@station9 ~]# grub-md5-crypt
Password:
Retype password:
$1$ygLiI0$thRmaJNfxmDUwuW60vDEj/
[root@station9 ~]#
[root@station9 ~]#
[root@station9 ~]# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/vol0/root
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
password --md5 $1$ygLiI0$thRmaJNfxmDUwuW60vDEj/
title Red Hat Enterprise Linux Server (2.6.18-92.1.6.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.1.6.el5
module /vmlinuz-2.6.18-92.1.6.el5xen ro root=/dev/vol0/root rhgb quiet
module /initrd-2.6.18-92.1.6.el5xen.img
title Red Hat Enterprise Linux Server (2.6.18-53.el5PAE)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.el5PAE ro root=/dev/vol0/root rhgb quiet
initrd /initrd-2.6.18-53.el5PAE.img
title Install Red Hat Enterprise Linux 5
root (hd0,0)
kernel /vmlinuz-5 ks=http://192.168.0.254/workstation.cfg ksdevice=eth0 noipv6
initrd /initrd-5
password --md5 $1$FSUEU/$uhUUc8USBK5QAXc.BfW4m.
Si es una máquina virtual que no tiene grub necesito un comando de xen xm create -c domain
----------------
Para reinstalar el grub por si se ha corrompido o windows nos ha fastidiado el mbr.
grub
root (hd0,0)
setup (hd0)
quit
3 - kernel
- Detecta dispositivos
- Inicializa drivers
- Monta fs root como ro
- Carga proceso inicial init con pid 1
- Log en /var/log/dmesg
4 - init (proceso 1) en el /etc/inittab. Para ver el arbol de procesos pstree
- Inicializa runlevel
- Scripts de inicialización
- Runlevel scripts directorios
- Trap key sequences
- Define UPS
- Spawn gettys on virtual consoles 6 por defecto
- Initialize X in runlevel 5 (por defecto)
------------------
[root@station9 ~]# man 5 inittab <------------ manual del fichero de configuración la página 5.
[root@station9 ~]# cat /etc/inittab
#
# inittab This file describes how the INIT process should set up
# the system in a certain run-level.
#
# Author: Miquel van Smoorenburg,
# Modified for RHS Linux by Marc Ewing and Donnie Barnes
#
# Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault: <---- inicio por defeco en runlevel 5
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5 <------------ carga el runlevel 5 y "wait" hasta que no termine no continua y carga
l6:6:wait:/etc/rc.d/rc 6
# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now <-------- capturar ctrl+alt+delete para reiniciar.
# When our UPS tells us power has failed, assume we have a few minutes
# of power left. Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
# Run gettys in standard runlevels
# Terminales que se abren por defecto
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
# Run xdm in runlevel 5
# Si estoy en el runlevel 5 miro en el fichero /etc/X11/prefdm mi gestor de X preferido y lo lanzo.
x:5:respawn:/etc/X11/prefdm -nodaemon
------------------
[root@station9 ~]# pstree
init─┬─/usr/share/virt
├─acpid
├─atd
├─auditd─┬─python
│ └─{auditd}
├─automount───4*[{automount}]
├─avahi-daemon───avahi-daemon
├─blktapctrl───{blktapctrl}
├─2*[bonobo-activati───{bonobo-activati}]
├─bt-applet
├─clock-applet
├─crond
...
------------------------
- /etc/rc.d/rc.sysinit ../init.d/yum-updatesd
lrwxrwxrwx 1 root root 19 Sep 26 09:44 /etc/rc5.d/K35vncserver -> ../init.d/vncserver
lrwxrwxrwx 1 root root 16 Sep 26 09:44 /etc/rc5.d/S99smartd -> ../init.d/smartd
lrwxrwxrwx 1 root root 16 Sep 26 09:45 /etc/rc5.d/K73ypbind -> ../init.d/ypbind
lrwxrwxrwx 1 root root 17 Sep 26 09:45 /etc/rc5.d/K35winbind -> ../init.d/winbind
lrwxrwxrwx 1 root root 14 Sep 26 09:45 /etc/rc5.d/S58ntpd -> ../init.d/ntpd
lrwxrwxrwx 1 root rTema 0. Introducción
********************oot 17 Sep 26 09:45 /etc/rc5.d/K01dnsmasq -> ../init.d/dnsmasq
lrwxrwxrwx 1 root root 20 Sep 26 09:46 /etc/rc5.d/S99xendomains -> ../init.d/xendomains
lrwxrwxrwx 1 root root 14 Sep 26 09:46 /etc/rc5.d/S98xend -> ../init.d/xend
lrwxrwxrwx 1 root root 18 Sep 26 09:46 /etc/rc5.d/S97libvirtd -> ../init.d/libvirtd
lrwxrwxrwx 1 root root 19 Sep 26 12:08 /etc/rc5.d/K90bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root 14 Sep 26 12:09 /etc/rc5.d/K89hidd -> ../init.d/hidd
Si empieza por k los mato y si empiezan por S los levanta. El número indica el orden en que se levantan.
Un fichero de ejemplo es el anacron:
#!/bin/sh
# Startup script for anacron
#
# chkconfig: 2345 95 05 se encarga de servicios que no tienen un uso constante, cuando se detectan esos servicios lo gestiona xinetd, tienen que ser servicios que estén preparados para xinetd. La conf en /etc/xinetd.conf.
Montaje de unidades: mount ...
Las unidades que se montan en el arranque están en:
[root@station9 ~]# cat /etc/fstab
/dev/vol0/root / ext3 defaults 1 1
/dev/vol0/home /home ext3 defaults 1 2
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda3 swap swap defaults 0 0
Cuando se toque el /etc/fstab hacer mount -a para montar todo por precaución y en el reinicio no nos muestre error.
Si estoy modo "emergencia" y pienso que está el fs / en rw pero no me permite escribir debo remontar el / a rw ya que
"modo emergencia" está entre montar / en ro y montar / en rw:
a) ... proceso de arranque ...
b) montar / en ro
c) error (pero al mismo tiempo informa de que está en rw)
d) montar / en rw
Estoy en el paso c, debo hacer:
mount -o remount,rw /
Ya puedo editar en modo "emergencia" el /etc/fstab si al reiniciar no nos deja escribir.
Modo rescate:
"linux rescue" desde un CD por ejemplo software Linux Rescue CD.
Si estoy en modo rescate a todos los comando vgdisplay debo anteponerles lvm vgdisplay:
vgdisplay = lvm vgdisplay
En modo rescate el directorio más importante es tmp (están los logs, dispositivos detectados, ... ) se perderán cuando haya rebotado. Se guarda todo en RAM y si hay poca RAM y detecta SWAP utiliza esta como almacenamiento.
Todo lo montado del disco duro rescatado estará en /mnt/sysimage/*, es decir: el fstab del rescue estará en:
/etc/fstab y el fstab del disco duro fisico estará en:
/mnt/sysimage/etc/fstab cualquier cambio debe hacer en /mnt/sysimage para que al rebotar en modo normal tengan efecto los cambios.
Con el comando:
chroot /mnt/sysimage
cambio la raiz del sistema de / a /mnt/sysimage, ahora cualquier cambio utiliza todo lo del HDD y no lo del entorno rescate. Para salir exit y volvemos al entorno de rescate.
En linux rescue man no funciona y debemos declarar:
chroot /mnt/sysimage
export MANPATH=/usr/share/man
Tema 3. Kernel y Configuración de red
*************************************
Puedes y debes tener más de un kernel, con yum siempre tienes 3 kernel instalados.
Esta en /boot/vmlinuz-version, es el único paquete que puede tener más de una versión instalada. Con el initrd pasa lo mismo hay un initrd para cada kernel. Los "modules" son los drivers y extensiones y para cada kernel debe tener compilado un module.
Existen un tipo de driver "dkms" que se recompila sobre la marcha al cargarse para tener el driver a la última recompilado con el último kernel. Asi no es necesario tener todos los drivers de cada kernel.
En rhel 5 hay 3 kernel posibles con 32 bits:
- kernel: donde la arquitectura intel solo permite direccionar 4 gb de ram (max 32 procesadores)
- kernel-PAE: utiliza un truco, si tengo más de 2 cores cada core gestiona 4 gb de ram (max 32 procesadores)
- kernel-xen: es un kernel-pae con soporte para virtualizar. (max 32 procesadores)
En rhel 5 de 64 bits:
- kernel: soporta 512 gb de ram (max 64 procesadores)
- kernel-xen: kernel para virtualización. (max 126 procesadores)
Para monitorizar procesos y recursos:
- kernel: uname, uptime, tload
- procesos: ps, top, gnome-system-monitor
- memoria: free, vmstat 2 20 (cada 2 segundos y máximo 20 veces), swapon -s, pmap
- disco: df, fdisk -l, iostat 2 20 (idem), lsof (ficheros abriertos de ...)
- soporte: sosreport
Monitorizacion del kernel con /proc y /sys
/proc y /sys son 2 fs que no existen en el HDD, ya que los crea el kernel en tiempo real, en /proc info del hard y soft que está funcionando y en /sys es info de todos los dispositivos de almacenamientos de bloques. Cada proceso tiene un directorio en /proc.
En /proc es de solo lectura excepto /proc/sys modifico el kernel en tiempo real, pero no es persistente y al reiniciar se pierden los cambios. Esto ficheros se pueden machacar pero no se pueden modificar (vi, nano, ,....) debo utilizar "echo cambio > fichero_a_modificar".
Para hacer los cambios persistentes lo añado al fichero /etc/sysctl.conf y para aplicarlos sysctl -p
Tema 4. Administración de usuarios
**********************************
Comandos: useradd passwd usermod chage groupadd gpasswd groupmod
En /etc/login.defs ---> para modificar la expiración por defecto de cada usuario.
Tener en cuenta la UMASK de directorios y ficheros, 002 para usuario no de sistema, los ficheros tendrán 664 y los directorios 775
Se pueden crear grupos privados.
Permisos especiales SGID, son directorios colaborativos, si hago que un directorios sea colaborativos y tengo permiso para escribir en el, el fichero generado se creará con los permisos del directorio o grupo colaborativo.
Sticky bit: si tengo permiso en un directorio w puedo borrar cualquier fichero aunque sea de root, pero añadiendo este bit, solo el propietario del fichero puede modificarlo/borrarlo aunque sea el directorio 777
ACLs
----
Para ver si una partición está montada como acl:
[root@station9 prueba]# fdisk -l
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2308 18434587+ 8e Linux LVM
/dev/sda3 2309 2373 522112+ 82 Linux swap / Solaris
[root@station9 prueba]# tune2fs -l /dev/sda1 | grep options
Default mount options: user_xattr acl
[root@station9 prueba]#
Si no está montada como acl no sirven de nada las acls, al mismo tiempo si el fs al que nos llevamos un fichero con acl no soporta acl como vfat ... tampoco sirven de nada las acls.
Para montar un fs como acl o desmontar:
tune2fs -o acl /dev/sda1 (añade)
tune2fs -o -acl /dev/sda1 (quita)
Comandos:
getfacl fichero ---> obtiene las acl de un fichero
setfacl -m u:usuario:permisos fichero ---> modifica las acl de ese fichero.
Tema 5. SELinux
**********************************
Con ls -Z y ps -Z veo el contexto de ficheros y procesos.
[root@station9 prueba]# ls -Z
-rwxrwxrwx+ root student root:object_r:user_home_t a
[root@station9 prueba]#
[root@station9 prueba]# ps -Z
LABEL PID TTY TIME CMD
root:system_r:unconfined_t:SystemLow-SystemHigh 4848 pts/0 00:00:00 bash
root:system_r:unconfined_t:SystemLow-SystemHigh 10004 pts/0 00:00:00 ps
[root@station9 prueba]#
Para gestionar contextos: semanage fcontext -l, por ejemplo para ver el contesto del fichero /etc/hosts
[root@station9 prueba]# semanage fcontext -l | grep host
/usr/share/ghostscript/fonts(/.*)? all files system_u:object_r:fonts_t:s0
/etc/vhosts regular file system_u:object_r:httpd_config_t:s0
/bin/hostname regular file system_u:object_r:hostname_exec_t:s0
/var/tmp/host_0 regular file system_u:object_r:krb5_host_rcache_t:s0
/etc/ssh/ssh_host_key regular file system_u:object_r:sshd_key_t:s0
/etc/ssh/ssh_host_dsa_key regular file system_u:object_r:sshd_key_t:s0
/etc/ssh/ssh_host_rsa_key regular file system_u:object_r:sshd_key_t:s0
/var/lib/amanda/\.amandahosts regular file system_u:object_r:amanda_config_t:s0
[root@station9 prueba]#
Para forzar la restauración original: restorecon -FRvv
Tcp wrap ---> con ldd vemos si un comando está utilizando la librería tcpwrap y por tanto compatible.
[root@station9 mnt]# ldd /usr/sbin/sshd | grep wrap
libwrap.so.0 => /usr/lib/libwrap.so.0 (0x00d3c000)
Dentro de /etc/ hay host.allow y host.deny
No hay comentarios:
Publicar un comentario