2012/04/18

FreeBSD

Introduccion:

Instalar FreeBSD 9.1-RELEASE AMD64 -> FreeBSD 10.0-RELEASE AMD64

Requerimientos:

* Conexion a Internet
* Disco de instalacion de FreeBSD
* Leer este tutorial

El proceso:

Iniciar el equipo con el disco de FreeBSD

FreeBSD Installer

Welcome
Welcome to FreeBSD! Would you
like to begin an installation
or use the live CD?

<Install>


Would you like to set a
non-default key mapping
for your keyboard?

<No>   <- Cuando mi teclado es English
<Yes>  <- Cuando mi teclado es Spanish o Latin America

Latin American

Spanish ISO-8859-1

Set Hostname
Please choose a hostname for this machine.

If you are running on managed network, please
ask your network administrator for an appropriate
name.

freebsd.example.com

<OK>

Distribution Select
Choose optional system components to install:
[ * ] doc        Additional documentation
[    ] games   Games (fortune, etc.)
[    ] lib32     32-bit compatibility libraries
[ * ] ports     Ports tree
[ * ] src        System source code

<OK>

Partitioning
Would you like to use the guided
partitioning tool (recommended for
beginners) or to set up partitions
manually (experts)? You can also open a
shell and set up partitions entirely by
hand.

<Manuall>

Partition Editor
Create partitions for FreeBSD. No changes will be
made until you select Finish.

ada0                      298 GB

<Create>

GPT      GUID Partition Table

<OK>

The partition table has been
successfully created. Please
press Create again to create
partitions.

<OK>

ada0                      298 GB    GPT

<Create>

Type:      freebsd-boot
Size:      512K
Mountpoint:
Label:

<OK>

ada0                      298 GB    GPT
    ada0p1              512 kb   freebsd-boot

<Create>

Type:      freebsd-ufs
Size:      16GB
Mountpoint: /
Label: exrootfs

<OK>

ada0                      298 GB    GPT
    ada0p1              512 kb   freebsd-boot
    ada0p2              16.0 GB   freebsd-ufs  /

<Create>

Type:      freebsd-swap
Size:      32GB
Mountpoint:
Label: exswap

<OK>

ada0                      298 GB    GPT
    ada0p1              512 kb   freebsd-boot
    ada0p2              16.0 GB   freebsd-ufs  /
    ada0p3              32.0 GB   freebsd-swap none

<Create>

Type:      freebsd-ufs
Size:      64GB
Mountpoint: /var
Label: exvarfs

<OK>

ada0                      298 GB    GPT
    ada0p1              512 kb   freebsd-boot
    ada0p2              16.0 GB   freebsd-ufs  /
    ada0p3              32.0 GB   freebsd-swap none
    ada0p4              64.0 GB   freebsd-ufs  /var

<Create>

Type:      freebsd-ufs
Size:      16GB
Mountpoint: /tmp
Label: extmpfs

<OK>

ada0                      298 GB    GPT
    ada0p1              512 kb   freebsd-boot
    ada0p2              16.0 GB   freebsd-ufs  /
    ada0p3              32.0 GB   freebsd-swap none
    ada0p4              64.0 GB   freebsd-ufs  /var
    ada0p5              16.0 GB  freebsd-ufs /tmp

<Create>

Type:      freebsd-ufs
Size:      XXGB          <- lo que quede disponible
Mountpoint: /usr
Label: exusrfs

<OK>

ada0                      298 GB    GPT
    ada0p1              512 kb   freebsd-boot
    ada0p2              16.0 GB   freebsd-ufs  /
    ada0p3              32.0 GB   freebsd-swap none
    ada0p4              64.0 GB   freebsd-ufs  /var
    ada0p5              16.0 GB  freebsd-ufs /tmp
    ada0p6              XX.0 GB freebsd-ufs /usr

<Finish>

Confirmation
Your changes will now written to disk. If you
have chosen to overwrite existing data, it will
be PERMANENTLY ERASED. Are you sure you want to
commit your changes?

<Commit>

(inicia particionado e instalacion)

FreeBSD Installer
========================

Please select a password for the system management account (root):
Changing local password for root
New Password: ********
Retype New Password: ********


Network Configuration
Please select a network interface to configure:

em0 Intel(R) PRO/1000 Legacy Network Connection 1.0.3
em1 Intel(R) PRO/1000 Legacy Network Connection 1.0.3
em2 Intel(R) PRO/1000 Legacy Network Connection 1.0.3
em3 Intel(R) PRO/1000 Legacy Network Connection 1.0.3

<OK>

Network Configuration
Would you like to
configure IPv4 for this
interface?

<Yes>

Network Configuration
Would you like to use
DHCP to configure this
interface?

<No>

Network Configuration
Static Network Interface Configuration

IP Address   192.168.0.2
Subnet Mask 255.255.255.0
Default Router 192.168.0.1

<OK>

Network Configuration
Would you like to
configure IPv6 for this
interface?

<Yes>

Network Configuration
Would you like to try

stateless address
autoconfiguration
(SLAAC)?

<Yes>

Network Configuration
Resolver Configuration
Search            example.com
IPv6 DNS #1   2001:4860:4860::8888
IPv6 DNS #2   2001:4860:4860::8844
IPv4 DNS #1   8.8.8.8
IPv4 DNS #2   8.8.4.4

<OK>

Nota:
En nuestro caso estamos usando los DNS publicos de Google (IPv4 8.8.8.8 8.8.4.4 IPv6 2001:4860:4860::8888 2001:4860:4860::8844), mas informacion aqui https://developers.google.com/speed/public-dns/
 
Select local or UTC (Greenwich Mean Time) clock
Is this machine´s CMOS clock set to UTC? If it is set to local time,
or you don´t know, please choose NO here!

<No>

Time Zone Selector
Select a region

2 America -- North and South

Countries in America -- North and South

14 Colombia

<OK>

Does the abbreviation `COT´ look reasonable?

<Yes>

System Configuration
Choose the services you would like to be started at
boot:
[*] sshd       Secure shell daemon
[  ] moused PS/2 mouse pointer on console
[  ] ntpd      Synchronize system and network time
[  ] powerd Adjust CPU frequency dynamically

<OK>

Dumpdev Configuration
Would you like to enable crash dumps?
If you start having problems with the
system it can help the FreeBSD
developers debug the problem. But the
crash dumps can take up a lot of disk
space in /var.

<Yes>

Add User Accounts
Would you like to add
users to the installed
system now?

<Yes>

FreeBSD Installer
==================
Add Users

Username: john
Full name: John Doe
Uid (Leave empty for default):
Login group [john]:
Login group is john. Invite john into other groups? []:
Shell (sh csh tcsh nologin) [sh]:
Home directory [/home/john]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a randon password? (yes/no) [no]:
Enter password: ********
Enter password again:  ********
Lock out the account after creation? [no]:
Username          : john
Password           : ********
Full Name         : John Doe
Uid                    : 1001
Class                 :
Groups              : john
Home                : /home/john
Home Mode     :
Shell                 : /bin/sh
Locked             : no
OK? (yes/no)   : yes
adduser: INFO : Successfully added (john) to the user database.
Add another user? (yes/no): no
Goodbye!

Final Configuration
Setup of your FreeBSD system is nearly complete. You can now
modify your configuration choices. After this screen, you will
have an opportunity to make more complex changes using a shell

Exit             Apply configuration and exit installer

<OK>

Manual Configuration
The installation is now finished.
Before exiting the installer, would
you like to open a shell in the new
system to make any final manual
modification?

<No>

Complete
Installation of FreeBSD
complete! Would you like
to reboot into the
installed system now?

<Reboot>

(retirar el CD/DVD en el reinicio para iniciar desde el disco duro)

Aplicar los ultimos parches

# freebsd-update fetch
# freebsd-update install
# reboot

Eso es todo, al iniciar tenemos nuestro FreeBSD funcionando!

Es buen momento para hacer que FreeBSD este con archivos actualizados, para esto agregamos en /etc/crontab las lineas asi:

00 06 * * * root /usr/sbin/freebsd-update cron

Con esa linea se ejecuta un proceso a las 06:00 horas y la ultima parte hace un aleatorio entre 1 y 3600 segundos para no saturar el servidor remoto.

Si luego queremos ajustar parametros de la instalacion:

# edit /etc/rc.conf

hostname="freebsd.example.com"
ifconfig_em0="inet 192.168.0.2 netmask 255.255.255.0"
defaultrouter="192.168.0.1"
ifconfig_em0_ipv6="inet6 accept_rtadv"
ssh_ennable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"

# Ajustar el idioma del teclado (solo activar una, si ninguna esta activa queda en English)
#keymap="spanish.iso.kbd"
keymap="latinamerican.kbd"

# edit /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

# edit /etc/hosts

::1             localhost localhost.my.domain
127.0.0.1  localhost localhost.my.domain

Para apagar nuestro FreeBSD instalado, usamos el comando:

# shutdown -h now

Para reiniciarlo

# shutdown -r now

Quien es John Doe? http://en.wikipedia.org/wiki/John_Doe

Para hacer la instalacion en un RAID1 http://www.unix.ck.ua/content/sozdaem-programmnyi-raid1-freebsd-90 

Nota:
FreeBSD envia automaticamente reportes de estado al usuario root y solo los vemos si iniciamos localmente con este usuario, pero podemos hacer que estos reportes sean enviados a una cuenta en otro lugar, por ejemplo a nuestra cuenta en Gmail, para hacer esto debemos:

# edit /etc/mail/aliases

 Buscamos una linea que dice

# root: me@my.domain

Y luego de esa creamos una nueva con nuestro mail
root:   micorreo@gmail.com

Guardamos los cambios en el editor y ejecutamos el comando

# cd /etc/mail && make

FreeBSD nos permite conectar por SSH a nuestro servidor, pero por seguridad no se puede hacer con el usuario root, entonces primero nos conectamos con el usuario john y luego podemos usar el comando su para subir a root, pero para que john pueda subir, hay que darle permisos a este usuario, para esto

# edit /etc/group

y la linea original

wheel:*:0:root

la dejamos asi

wheel:*:0:root, john

Guardamos cambios y ya podemos conectarnos, ejemplo desde otro equipo con FreeBSD desde el terminal

$ ssh john@IPMISERVIDOR
Password: ******** <- la clave del usuario john
$
Para subir a root escribimos su
$ su
Password: ********  <- la clave del usuario root
freebsd#