2016/04/26

FreeBSD 10.3 RELEASE AMD64

Introduccion:

Instalar FreeBSD 10.3 RELEASE AMD64
Se instalaran algunos paquetes binarios

Requerimientos:

* Conexion a Internet
* Instalador de FreeBSD
* Leer este tutorial

El proceso:

Iniciar el equipo desde el medio de instalacion

FreeBSD Installer
---------------------------------------------------------------------------------------------------

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

<Install> < Shell > <Live CD>

Keymap Selection

>>> Continue with default keymap

<Select> <Cancel>

Set Hostname

freebsd.example.com

< OK >

Distribution Select

[*] doc        Additional documentation
[  ] games   Games (fortune, etc.)
[  ] lib32      32-bit compatibility libraries
[*] ports     Ports tree
[*] src         System source code

< OK >

Partitioning

Auto (UFS)   Guide Disk Setup
Manual         Manul Disk Setup (experts)
Shell              Open a shell nd partition by hand
Auto (ZFS)    Guided Root-on-ZFS

< OK >

              ZFS Configuration

>>> Install             Proceed with Installation
T Pool Type/Disks:      stripe: 0 disks
- Rescan Devices        *
- Disk Info                   *
N Pool Name               zroot
4 Force 4K Sectors?   YES
E Encrypt Disk?         NO
P Partition Scheme    GPT (BIOS)
S Swap Size                2g       <- Este valor se puede cambiar RAM x 2 => 8g
M Mirror Swap?         NO
W Encrypt Swap?      NO

< Select >

              ZFS Configuration

Select Virtual Device type:

stripe  Stripe - No Redundancy
mirror   Mirror - n-Way Mirroring
raidz1   RAID-Z1 - Single Redundant RAID
raidz2   RAID-Z2 - Double Redundant RAID
raidz3   RAID-Z3 - Triple Redundant RAID

< OK >

              ZFS Configuration

[*] xyz0  VirtIO Block Device   <- Esto puede cambiar, use un disco virtual

< OK >

              ZFS Configuration
Last Change! Are you sure you want to destroy
the current contents of the following disks:

vtbd0

< YES >

Overall Progress:
]]]]]]]]]]]]]]] 40%

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:

vtnet0    VirtIO Networking Adapter

< 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?

< YES > < NO >

              Network Configuration
Static Network Interface Configuration

IP Address          172.16.3.50  <- Ajuste estos parametros a su red
Subnet Mask      255.255.0.0
Default Router   172.16.1.1

< OK >

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

< YES > < NO >

              Network Configuration
Would you like to try
stateless address
autoconfiguration
(SLAAC)?

< YES > < NO >

              Network Configuration
Static IPv6 Network Interface Configuration

IPv6 Address     fc00::3:50
Default Router  fc00::1:1

< OK >

              Network Configuration
Resolver Configuration

Search            samdom.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 >

Select local or UTC (Greenwich Mean Time) clock
Is this machine's CMOS clock set to UTC? If it is to local time,
or you don't know, please choose NO here!

< YES > < NO >

              Time Zone Selector
Select a region

1 Africa
2 America -- North and South
3 Antarctica
4 Arctic Ocean
5 Asia
6 Atlantic Ocean
7 Australia
8 Europe
9 Indian Ocean
0 Pacific Ocean
a UTC

< OK >

              Countries in America -- North and South
Select a country or region

1   Anguilla
2   Antigua and Barbuda
3   Argentina
4   Aruba
5   Bahamas
6   Barbados
7   Belize
8   Bolivia, Plurinational State of
9   Bonaire, Sint Eustatius and Saba
10 Brazil
11 Canada
12 Cayman Islands
13 Chile
14 Colombia
15 Costa Rica
16 Cuba

< OK >

              Confirmation
Does the abbreviation `COT' look reasonable?

< YES >

              System Configuration
Choose the services you would like to be started at boot:

[  ] local_unbound  Local caching validating resolve
[*] sshd                   Secure shell daemon
[  ] moused               PS/2 mouse pointer or console
[  ] ntpd                    Synchronize system and network time
[  ] powerd               Adjust CPU frequency dynamically if supported
[*] dumpdev            Enable kernel crsh dumps to /var/crash

< OK >

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

< YES >

Add Users

Username: jdoe
Full name: John Doe
Uid (Leave empty for default):
Login group [jdoe]:
Login group is jdoe. Invite jdoe into other groups? []:wheel
Shell (sh csh tcsh nologin) [sh]:
Home directory [/home/jdoe]:
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          : jdoe
Password           : ********
Full Name         : John Doe
Uid                    : 1001
Class                 :
Groups              : jdoe wheel
Home                : /home/jdoe
Home Mode     :
Shell                 : /bin/sh
Locked             : no
OK? (yes/no)   : yes
adduser: INFO : Successfully added (jdoe) 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
Add User           Add a user to the system
Root Password  Change root password
Hostname          Set system hostname
Network             Networking configuration
Services             Set daemons to run on startup
Time Zone         Set system timezone
Handbook         Install FreeBSD Handbook (requires network)

< 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?

< YES > < NO >

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

<Reboot> <Live CD>

 Instalar algunos paquetes binarios

# /usr/sbin/pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:10:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Installing pkg-1.7.2...
Extracting pkg-1.7.2: 100%
---
For more information on available commands and options see 'pkg help'.

# pkg info pkg
pkg-1.7.2
---

# pkg update
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.

# pkg search openntpd
openntpd-5.7p4_2,2             Network Time Protocol (NTP) daemon

# pkg install openntpd
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
Updating database digests format: 100%
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        openntpd: 5.7p4_2,2
        libressl: 2.2.6
        ca_root_nss: 3.22.2

The process will require 10 MiB more space.
3 MiB to be downloaded.

Proceed with this action? [y/N]: y

Fetching openntpd-5.7p4_2,2.txz: 100%   41 KiB  42.4kB/s    00:01   
Fetching libressl-2.2.6.txz: 100%    2 MiB   1.2MB/s    00:02   
Fetching ca_root_nss-3.22.2.txz: 100%  324 KiB 331.5kB/s    00:01   
Checking integrity... done (0 conflicting)
[1/3] Installing libressl-2.2.6...
[1/3] Extracting libressl-2.2.6: 100%
[2/3] Installing ca_root_nss-3.22.2...
[2/3] Extracting ca_root_nss-3.22.2: 100%
[3/3] Installing openntpd-5.7p4_2,2...

Agregamos las tres lineas al archivo rc.conf para que inicie con el sistema

# echo '# OpenNTP' >> /etc/rc.conf
# echo 'openntpd_enable="YES"' >> /etc/rc.conf
# echo 'openntpd_flags="-sv"' >> /etc/rc.conf

Verificamos que se agregaron las tres lineas al archivo rc.conf

# cat /etc/rc.conf | egrep "OpenNTP|openntpd"
# OpenNTP
openntpd_enable="YES"
openntpd_flags="-sv"

Iniciamos el servico

# /usr/local/etc/rc.d/openntpd start
Starting openntpd.
ntp_adjtime adjusted frequency by 0.000000ppm

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

Si root tiene un monton de correos, los podemos eliminar con

# cat /dev/null > /var/mail/root

Comandos basicos de la utilidad pkg:

Buscar un programa
# pkg search name

Instalar un programa
# pkg install name

Informacion de un programa instalado
# pkg info name

Desinstalar un programa
# pkg delete name

Actualizar todos los programas instalados
# pkg upgrade

Ejemplo de pkg:

# pkg search nvidia-driver
---
nvidia-driver-346.96           NVidia graphics card binary drivers for hardware OpenGL rendering
nvidia-driver-304-304.128      NVidia graphics card binary drivers for hardware OpenGL rendering
nvidia-driver-340-340.93       NVidia graphics card binary drivers for hardware OpenGL rendering

Como se puede ver hay varias versiones del driver de nvidia, para instalar una especificamente, la 340 en este caso

# pkg install nvidia-driver-340

Luego para verificar el paquete instalado

# pkg info nvidia-driver-340
nvidia-driver-340-340.93
---

2015/10/05

NIS

Introduccion:

Instalar un Network Information System (NIS)

Requerimientos:

* FreeBSD instalado
* Conexion a Internet
* Leer este tutorial

Manuales:

https://www.freebsd.org/doc/handbook/network-nis.html
http://daemon-notes.com/articles/network/unix-lan/nis
http://blog.zespre.com/posts/2014/12/freebsd-nis-nfs

Proceso:

-------------------------------------------------------------------------------------------------------------------------------------
NIS Master Server

# cat /etc/rc.conf
...
# Network Information System (NIS)
# NIS Master Server
nisdomainname="samdom.dominio.com"
nis_server_enable="YES"
nis_yppasswdd_enable="YES"
# A server that is also a client
nis_client_enable="YES" # run client stuff as well
nis_client_flags="-S samdom.dominio.com,alpha"

# mkdir /var/yp/samdom.dominio.com

# service ypserv start

# cp /etc/master.passwd /var/yp/master.passwd
# cd /var/yp
# edit /var/yp/master.passwd

Borro todos los usuarios especiales y solo dejo los que iniciaran en los equipos.

# chmod 0600 /var/yp/master.passwd

# ypinit -m samdom.dominio.com
Server Type: MASTER Domain: samdom.dominio.com

Creating an YP server will require that you answer a few questions.
Questions will all be asked at the beginning of the procedure.

Do you want this procedure to quit on non-fatal errors? [y/n: n] 

Ok, please remember to go back and redo manually whatever fails.
If you don't, something might not work.

Can we destroy the existing /var/yp/samdom.dominio.com and its contents? [y/n: n]  y

At this point, we have to construct a list of this domains YP servers.
alpha.samdom.dominio.com is already known as master server.
Please continue to add any slave servers, one per line. When you are
done with the list, type a <control D>.
        master server   :  alpha.samdom.dominio.com
        next host to add:  ^D
The current list of NIS servers looks like this:

alpha.samdom.dominio.com

Is this correct?  [y/n: y]  y

[..output from map generation..]

NIS Map update completed.

alpha.samdom.dominio.com has been setup as an YP master server without any errors.

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

# cd /var/yp

# make samdom.dominio.com
`samdom.dominio.com' is up to date.

# cat /var/yp/securenets
# allow connections from local host -- mandatory
127.0.0.1       255.255.255.255
# allow connections from my LAN
# on    the 192.168.128.0 network
#192.168.128.0  255.255.255.0
# on    the 172.16.0.0 network
172.16.0.0      255.255.0.0
# allow connections from any host
# between 10.0.0.0 to 10.0.15.255
#10.0.0.0       255.255.240.0

# shutdown -r now

# dmesg -a
...
Setting NIS domain: samdom.dominio.com.
Starting rpcbind.
Starting ypserv.
Starting ypbind.

-------------------------------------------------------------------------------------------------------------------------------------
NIS Slave Server

# cat /etc/rc.conf
...
# Network Information System (NIS)
# NIS Slave Server
nisdomainname="samdom.dominio.com"
nis_server_enable="YES"
nis_yppasswdd_enable="YES"
# A server that is also a client
nis_client_enable="YES" # run client stuff as well
nis_client_flags="-S samdom.dominio.com,alpha"

# mkdir /var/yp/samdom.dominio.com

# ypinit -s alpha samdom.dominio.com
Server Type: SLAVE Domain: samdom.dominio.com Master: alpha

Creating an YP server will require that you answer a few questions.
Questions will all be asked at the beginning of the procedure.

Do you want this procedure to quit on non-fatal errors? [y/n: n]  n

Ok, please remember to go back and redo manually whatever fails.
If not, something might not work.
There will be no further questions. The remainder of the procedure
should take a few minutes, to copy the databases from alpha.
Transferring netgroup...
ypxfr: Exiting: Map successfully transferred
Transferring netgroup.byuser...
ypxfr: Exiting: Map successfully transferred
Transferring netgroup.byhost...
ypxfr: Exiting: Map successfully transferred
Transferring master.passwd.byuid...
ypxfr: Exiting: Map successfully transferred
Transferring passwd.byuid...
ypxfr: Exiting: Map successfully transferred
Transferring passwd.byname...
ypxfr: Exiting: Map successfully transferred
Transferring group.bygid...
ypxfr: Exiting: Map successfully transferred
Transferring group.byname...
ypxfr: Exiting: Map successfully transferred
Transferring services.byname...
ypxfr: Exiting: Map successfully transferred
Transferring rpc.bynumber...
ypxfr: Exiting: Map successfully transferred
Transferring rpc.byname...
ypxfr: Exiting: Map successfully transferred
Transferring protocols.byname...
ypxfr: Exiting: Map successfully transferred
Transferring master.passwd.byname...
ypxfr: Exiting: Map successfully transferred
Transferring networks.byname...
ypxfr: Exiting: Map successfully transferred
Transferring networks.byaddr...
ypxfr: Exiting: Map successfully transferred
Transferring netid.byname...
ypxfr: Exiting: Map successfully transferred
Transferring hosts.byaddr...
ypxfr: Exiting: Map successfully transferred
Transferring protocols.bynumber...
ypxfr: Exiting: Map successfully transferred
Transferring ypservers...
ypxfr: Exiting: Map successfully transferred
Transferring hosts.byname...
ypxfr: Exiting: Map successfully transferred

bravo has been setup as an YP slave server without any errors.
Remember to update map ypservers on alpha.

-------------------------------------------------------------------------------------------------------------------------------------
NIS Client

# cat /etc/rc.conf
...
# Network Information System (NIS)
# NIS Client
nisdomainname="samdom.dominio.com"
nis_client_enable="YES" # run client stuff as well
nis_client_flags="-S samdom.dominio.com,alpha

# /etc/netstart

# service ypbind start

DDNS + DHCPd

Introduccion:

Instalar un servidor DDNS que sera actualizado desde el servidor DHCPd.

Requerimientos:

* FreeBSD instalado
* Conexion a Internet
* Leer este tutorial

Proceso:
(pendiente, pero los comandos y los archivos son validos para poner a funcionar todo)

Comandos usados:

# bsdconfig
# passwd
# freebsd-update fetch
# freebsd-update install
# portsnap fetch extract
# portsnap fetch update
# cd /usr/ports/dns/bind910
# make config-recursive
# make install clean
# rndc-confgen -a
wrote key file "/usr/local/etc/namedb/rndc.key"
# cd /usr/ports/net/isc-dhcp43-server
# make config-recursive
# make install clean

Por un tema de cambio de rutas en FreeBSD 8.2 y FreeBSD 10.2 creo un link simple
# ln -s /usr/local/etc/namedb/ /etc/namedb

Ajusto y/o creo los siguientes archivos

------------------------------------------------------------------------------------------------------------------------------------
# cat /etc/rc.conf

hostname="alpha.samdom.dominio.com"

# Servicio SSH
sshd_enable="YES"

# Primera tarjeta de red (INTERNET)
ifconfig_em0="inet 192.168.16.22 netmask 255.255.240.0"
defaultrouter="192.168.16.1"

# Segunda tarjeta de red (LAN)
ifconfig_em1="inet 172.16.100.1 netmask 255.255.0.0"

# NTP
ntpd_enable="YES"
ntpd_config="/etc/ntp.conf"

# ISC-DHCPd Server
dhcpd_enable="YES"
dhcpd_conf="/usr/local/etc/dhcpd.conf"
dhcpd_ifaces="em1"

# ISC BIND
named_enable="YES"

# Activamos OpenBSD Packet Filter (PF)
pf_enable="YES"                 # Enable PF (load module if required)
pf_rules="/etc/pf.conf"         # rules definition file for pf
pf_flags=""                     # additional flags for pfctl startup
pflog_enable="YES"              # start pflogd(8)
pflog_logfile="/var/log/pflog"  # where pflogd should store the logfile
pflog_flags=""                  # additional flags for pflogd startup
gateway_enable="YES"            # Enable as LAN gateway (PF)

# Network Information System (NIS)
# NIS Master Server
nisdomainname="samdom.dominio.com"
nis_server_enable="YES"
nis_yppasswdd_enable="YES"
nis_client_enable="YES"
nis_client_enable="YES" # run client stuff as well
nis_client_flags="-S NIS domain,server"

# IPv6
#ipv6_activate_all_interfaces="YES"
ifconfig_em1_ipv6="inet6 2001:0db8:1000:8b00::2 prefixlen 64"
ipv6_defaultrouter="2001:0db8:1000:8b00::1"

------------------------------------------------------------------------------------------------------------------------------------
# cat /etc/ntp.conf

# Associate to the public NTP pool servers
server 0.pool.ntp.org prefer
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org

# Location of drift file
driftfile /var/db/ntp.drift

# Location of the log file
logfile /var/log/ntpd

# Restrictions
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
restrict 127.127.1.0

------------------------------------------------------------------------------------------------------------------------------------
# cat resolv.conf

# Generated by resolvconf
#nameserver 192.168.16.1
#nameserver 192.168.16.8

# FreeBSD DNS
search samdom.dominio.com
#nameserver 2001:4860:4860::8888
#nameserver 2001:4860:4860::8844
#nameserver 8.8.8.8
#nameserver 8.8.4.4
nameserver 127.0.0.1

------------------------------------------------------------------------------------------------------------------------------------
# cat /usr/local/etc/namedb/named.conf

Google Drive

------------------------------------------------------------------------------------------------------------------------------------
# cat /usr/local/etc/namedb/dynamic/samdom.dominio.com

Google Drive

------------------------------------------------------------------------------------------------------------------------------------
# cat /usr/local/etc/namedb/dynamic/16.172.in-addr.arpa

Google Drive

------------------------------------------------------------------------------------------------------------------------------------
# cat /usr/local/etc/dhcpd.conf

Google Drive

------------------------------------------------------------------------------------------------------------------------------------
# cat /etc/pf.conf

Google Drive

------------------------------------------------------------------------------------------------------------------------------------
# touch /var/log/ntpd
# /usr/local/etc/rc.d/named start
# /usr/local/etc/rc.d/isc-dhcpd start
# shutdown -r now

# rndc status
version: BIND 9.9.8 (Extended Support Version) <id:2d6d4ba>
CPUs found: 1
worker threads: 1
UDP listeners per interface: 1
number of zones: 163
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0/0/1000
tcp clients: 0/100
server is up and running

Para poder editar mis archivos de zonas hay que congelarlos con:

# rndc freeze samdom.dominio.com
# rndc freeze 16.172.in-addr.arpa

Luego de editarlos (recordar actualizar el serial "2015100101" de cada uno) descongelarlos con:

# rndc thaw samdom.dominio.com
# rndc thaw 16.172.in-addr.arpa

2015/02/06

Instalar fuentes en FreeBSD

Introduccion:

Instalar fuentes adicionales en FreeBSD.

Requerimientos:

* FreeBSD instalado
* The X Window System instalado

* Leer este tutorial

El proceso:

Type1 Fonts

# cd /usr/ports/x11-fonts/urwfonts
# make install clean

# edit /etc/X11/xorg.conf

Agregamos al final la linea FontPath     "/usr/local/lib/X11/fonts/urwfonts/", se ve asi:

Section "Files"
        ModulePath   "/usr/local/lib/xorg/modules"
...
        FontPath     "/usr/local/lib/X11/fonts/75dpi/"
        FontPath     "/usr/local/lib/X11/fonts/urwfonts/"


Para cargar las nuevas fuentes sin reiniciar las X, ejecutamos desde la cuenta del usuario

$ xset fp+ /usr/local/lib/X11/fonts/urwfonts
$ xset fp rehash

TrueType® Fonts

# edit /etc/X11/xorg.conf

Agregamos al final la linea FontPath     "/usr/local/lib/X11/fonts/TrueType/", se ve asi:

Section "Files"
        ModulePath   "/usr/local/lib/xorg/modules"
...
        FontPath     "/usr/local/lib/X11/fonts/urwfonts/"
        FontPath     "/usr/local/lib/X11/fonts/TrueType/"

Agregamos al final la linea Load  "freetype", se ve asi:

Section "Module"                              
...
        Load  "dri2"                          
        Load  "freetype"

# mkdir /usr/local/lib/X11/fonts/TrueType

# cd /usr/ports/x11-fonts/ttmkfdir
# make install clean

Copiar las fuentes al directorio /usr/local/lib/X11/fonts/TrueType

# cp /usr/home/jdoe/*.ttf /usr/local/lib/X11/fonts/TrueType

Luego las hacemos compatibles con FreeBSD

# cd /usr/local/lib/X11/fonts/TrueType
# ttmkfdir -o fonts.dir

Para cargar las nuevas fuentes sin reiniciar las X, ejecutamos desde la cuenta del usuario

$ xset fp+ /usr/local/lib/X11/fonts/TrueType
$ xset fp rehash

2014/12/01

Dispositivos USB

Introduccion:

Montar memorias USB en FreeBSD
El usuario root no tiene problemas para montar un dispositivo USB mediante el comando

Ver el dispositivo detectado por el sistema
   # dmesg
   # camcontrol devlist

Montar el dispositivo detectado
   # mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /mnt

Este tutorial explica como permitir que los usuarios no-root puedan montar dispositivos USB.

Requerimientos:

* Acceso a root
* Leer este tutorial

Tutoriales:

https://www.freebsd.org/doc/handbook/usb-disks.html
http://www.codebuddies.de/2014/03/28/0x0b-howto-mount-a-extfat-filesystem-on-freebsd
https://forums.freebsd.org/threads/mount-exfat-fuse-as-regular-user.46985
http://olivier.cochard.me/bidouillage/installation-et-configuration-de-freebsd-comme-poste-de-travail
http://blog.desdelinux.net/freebsd-que-hacer-despues-instalar
https://forums.freebsd.org/threads/formatting-a-usb-stick.10986
http://www.freebsdonline.com/content/view/890/524
http://bsdgurl.net/text/formatting-external-disk-to-fat32.txt

El proceso:

Agregamos nuestro usuario john al grupo operator

# pw usermod john -G operator

# edit /etc/devfs.rules

# USB Storage Devices
[localrules=5]
add path 'da*' mode 0660 group operator

# edit /etc/rc.conf

# USB Storage Devices          
devfs_system_ruleset="localrules"

# edit /etc/sysctl.conf

# USB Storage Devices
vfs.usermount=1

# sysctl vfs.usermount=1

# mkdir /mnt/usb

# chown john:john /mnt/usb

# camcontrol devlist
<Generic Flash Disk 5.00>          at scbus10 target 0 lun 0 (da0,pass7)

% ls /dev/da0*
/dev/da0s1

% mount -t msdosfs -o -m=644,-M=755 /dev/da0s1 /mnt/usb

% umount /mnt/usb

Si tenemos KDE para que al recibir la notificacion (junto a la hora) podamos montar y desmontar el dispositivo comodamente, debemos agregar una linea en /etc/fstab

# edit /etc/fstab

# USB Storage Devices                           
/dev/da0s1              /mnt/usb      msdosfs rw,noauto       0       0

Si necesitamos formatear el dispositivo USB (no debe estar montado)

Then we clean the drive (remove previous partition):

  # dd if=/dev/zero of=/dev/da0 bs=1m

Then we will create the slice:
  # fdisk -i da0
 
    Do you want to change our idea of what BIOS thinks ? [n]  Press Enter
    Do you want to change it?[n] Press Enter
    Do you want to change it?[n] Press Enter
    Do you want to change it?[n] Press Enter
    Do you want to change it?[n] Press Enter
    Do you want to change the active partition? [n] Press Enter
 
    Should we write new partition table? [n] Press y

Then we will create the FAT32 file system:

  # newfs_msdos -F32 /dev/da0s1

2014/06/20

LG Nexus 5 LG-D820 y LG-D821 Factory Images

Introduccion:

En este tutorial se enseña a flashear nuestro equipo LG Nexus 5, para el modelo LG-D820 que se comercializa para USA y para el modelo LG-D821 que se comercializa para Europa, con las imagenes de fabrica que proporciona Google.

Se pueden consultar las ultimas imagenes de fabrica en este lugar
https://developers.google.com/android/nexus/images

El proceso de flasheo no es complicado, pero requiere de unos conocimientos minimos para hacerlo, si usted no sabe que es un Terminal o si no tiene la paciencia para seguir este tutorial paso a paso, es mejor que pase de el y espere que la actualizacion le llegue mediante OTA (Over-The-Air) automaticamente en unas semanas.

Flashear un Nexus 5 es relativamente seguro, pero nada en la vida sera 100% seguro, si usted sigue este manual es bajo su propio riesgo entendiendo que existe un minimo de peligro de dañar su querido Nexus y puede tener que enviarlo al centro de servicio si algo sale mal.

Este proceso borrara todo el contenido de su Nexus 5, por favor haga una copia del contenido importante primero (fotos, contactos, etc.).

Para nuestro tutorial usaremos un equipo de Apple MAC con OS X, las imagenes de fabrica tambien se pueden flashear en computadores con Windows, pero yo prefiero hacerlo en un MAC ya que es mas facil al no tener que descargar drivers y otras cosas.

En este tutorial se uso la ultima version de la imagen de fabrica de Android 4.4.4, pero tambien se puede usar para versiones mas nuevas ajustando las rutas de descarga y los nombres de directorios.

Todo el proceso se hara, como explico usando un MAC, mediante el Terminal, mi intencion es que usando el terminal usted simplemente debe copiar los comandos y pegarlos en el Terminal de su computador y dar enter, pero recuerde que si esta intentando usar este manual con una version superior de Android a la 4.4.4, debe actualizar los links y los nombres de los directorios.

Requerimientos:

* Un computador Apple con OS X.
* Conexion a Internet.
* Un Nexus 5 de cualquiera de los dos modelos existentes (LG-D820 o LG-D821).
* El cable original USB de su equipo o uno compatible.

Actualizado (2014/11/12) para Android 5.0 (LRX21O)

Opcion 1. El proceso automatizado mediante un script:

Para hacer el proceso de una forma mas facil, he creado un script que ejecuta los comandos paso a paso, pero esta en desarrollo en estos momentos, aqui lo puede descargar desde Google Drive -> hammerhead.sh, para usarlo lo debe descargar al escritorio de su computador, luego se va al Terminal que se encuentra en Finder / Applications / Utilities / Terminal.

Debe ejecutar el script asi (ajuste el comando al nombre del script):
$ chmod +x ~/Desktop/hammerhead.sh
$ ~/Desktop/hammerhead.sh

y seguir las instrucciones del script.

Script actualizado (2014/11/12) para Android 5.0 (LRX21O)

Opcion 2. El proceso manual paso a paso:

Finder / Applications / Utilities / Terminal

1) Entrar al directorio
$ cd ~/Desktop

2) Descargar el archivo de imagen

Para Android 4.4.4 (KTU84P) use
$ curl -o hammerhead.tgz https://dl.google.com/dl/android/aosp/hammerhead-ktu84p-factory-35ea0277.tgz

Para Android 5.0 (LRX21O) use
$ curl -o hammerhead.tgz https://dl.google.com/dl/android/aosp/hammerhead-lrx21o-factory-01315e08.tgz

3) Verificar el md5sun del archivo (comparelo con el de la web)
$ md5 ~/Desktop/hammerhead.tgz

4) Verificar el sha-1 del archivo (comparelo con el de la web)
$ openssl sha1 ~/Desktop/hammerhead.tgz

5) Descomprimir el archivo
$ tar -xvzf ~/Desktop/hammerhead.tgz

6) Cambiar el nombre del directorio

Para Android 4.4.4 (KTU84P) use
$ mv hammerhead-ktu84p hammerhead

Para Android 5.0 (LRX21O) use
$ mv hammerhead-lrx21o hammerhead

7) Modificar flash-all.sh para incluir el path ~/Desktop/hammerhead/
$ sed -i '' 's/fastboot/~\/Desktop\/hammerhead\/fastboot/g' ~/Desktop/hammerhead/flash-all.sh

8) Descargar el fastboot que esta en el ADT Bundle
$ curl -o adt-bundle-mac-x86_64.zip https://dl.google.com/android/adt/adt-bundle-mac-x86_64-20140702.zip

9) Descomprimir el adt-bundle-mac-x86_64.zip
$ unzip adt-bundle-mac-x86_64.zip

10) Copiar el adb al directorio hammerhead
$ cp ~/Desktop/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb ~/Desktop/hammerhead


11) Darle permisos de ejecucion al adb
$ chmod +x ~/Desktop/hammerhead/adb

12) Copiar fastboot al directorio hammerhead
$ cp ~/Desktop/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/fastboot ~/Desktop/hammerhead

13) Darle permisos de ejecucion al fastboot
$ chmod +x ~/Desktop/hammerhead/fastboot

14) Conectar el Nexus 5 al Mac con el cable original USB o uno compatible

15) Reiniciar el Nexus 5 en "FASTBOOT MODE"
$ ~/Desktop/hammerhead/adb reboot bootloader

Nota:
Tambien se puede hacer manualmente al encender el Nexus 5 manteniendo presionadas las teclas Volumen abajo + Volumen arriba + boton encender simultaneamente.

Veremos en rojo el titulo

FASTBOOT MODE
...
LOCK STATE - locked <- en color negro!

16) Desbloquear el bootloader
$ ~/Desktop/hammerhead/fastboot oem unlock

En el terminal veremos algo como esto:
...
OKAY [101.578s]
finished. total time: 101.578s

Veremos un titulo Unlock bootloader?

Para confirmar

Volumen arriba + boton encender

Luego de unos 10 segundos, veremos

LOCK STATE - unlocked  <- en color rojo!

17) Entrar al directorio hamerhead
$ cd ~/Desktop/hammerhead

18) Ahora iniciamos la instalacion de la imagen de fabrica
$ ~/Desktop/hammerhead/flash-all.sh

En el terminal veremos algo como esto:

sending 'bootloader' (2508 KB)...
OKAY [  0.187s]
writing 'bootloader'...
OKAY [  0.474s]
finished. total time: 0.661s
rebooting into bootloader...
OKAY [  0.099s]
finished. total time: 0.099s
sending 'radio' (45409 KB)...
OKAY [  1.539s]
writing 'radio'...
OKAY [  3.112s]
finished. total time: 4.651s
rebooting into bootloader...
OKAY [  0.092s]
finished. total time: 0.092s
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
Bootloader Version...: HHZ11k
Baseband Version.....: M8974A-2.0.50.1.16
Serial Number........: 06a9bccg002be57a
--------------------------------------------
checking product...
OKAY [  0.100s]
checking version-bootloader...
OKAY [  0.100s]
checking version-baseband...
OKAY [  0.100s]
sending 'boot' (8700 KB)...
OKAY [  0.570s]
writing 'boot'...
OKAY [  0.749s]
sending 'recovery' (9284 KB)...
OKAY [  0.661s]
writing 'recovery'...
OKAY [  0.779s]
erasing 'system'...
OKAY [  1.292s]
sending 'system' (721400 KB)...
OKAY [ 22.793s]
writing 'system'...
OKAY [ 49.290s]
erasing 'userdata'...
OKAY [ 17.289s]
formatting 'userdata' partition...
Creating filesystem with parameters:
    Size: 29236371456
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 32768
    Label:
    Blocks: 7137786
    Block groups: 218
    Reserved block group size: 1024
Created filesystem with 11/1785856 inodes and 156120/7137786 blocks
sending 'userdata' (139109 KB)...
writing 'userdata'...
OKAY [ 15.596s]
erasing 'cache'...
OKAY [  0.638s]
formatting 'cache' partition...
Creating filesystem with parameters:
    Size: 734003200
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7472
    Inode size: 256
    Journal blocks: 2800
    Label:
    Blocks: 179200
    Block groups: 6
    Reserved block group size: 47
Created filesystem with 11/44832 inodes and 5813/179200 blocks
sending 'cache' (13348 KB)...
writing 'cache'...
OKAY [  2.196s]
rebooting...

finished. total time: 112.681s
$

Luego el Nexus 5 se reiniciara y veremos una barra azul de progreso

El equipo se reiniciara y ya nos mostrara la ventana para poner el idioma y comenzar la configuracion de nuestra cuenta de Google, pero no continuaremos ya que hay que bloquear nuevamente el bootloader.

19) Reiniciar el Nexus 5 en "FASTBOOT MODE"
$ ~/hammerhead/adb reboot bootloader

Veremos en rojo el titulo

FASTBOOT MODE
...
LOCK STATE - unlocked  <- en color rojo!

20) Bloquear el bootloader
$ ~/Desktop/hammerhead/fastboot oem lock

En el terminal veremos algo como esto:
...
OKAY [  0.040s]
finished. total time: 0.040s

Veremos en rojo el texto
FASTBOOT MODE
...
LOCK STATE - locked <- en color negro!

21) Reiniciamos normalmente el Nexus 5
$ ~/hammerhead/adb reboot

Ya podemos desconectar el Nexus 5 del computador y ya si configurar nuestra cuenta de Google.

2014/03/20

Wireshark

Introduccion:

Instalar el software Wireshark para hacer pruebas de monitoreo de trafico.

Requerimientos:

* FreeBSD instalado
* The X Window System instalado
* KDE instalado
* Conexion a Internet
* Leer este tutorial

Manuales utilizados:

https://forums.freebsd.org/viewtopic.php?&t=20109
http://watchingthecloud.blogspot.com/2010/06/how-to-see-connections-in-wireshark.html
http://wiki.wireshark.org/DisplayFilters

El proceso:

Agregar nuestro usuario no root al grupo wheel

# edit /etc/group

la linea original

wheel:*:0:root

queda asi

wheel:*:0:root, jdoe

Ahora debemos ajustar los permisos de /dev/bpf para que los usurios del grupo wheel puedan acceder

# edit /etc/devfs.conf

Al final agregamos las lineas

# Wireshark
own     /dev/bpf*       root:wheel
perm    /dev/bpf*       0640

Reiniciamos devfs

# /etc/rc.d/devfs restart

Instalamos el port de wireshark

# cd /usr/ports/net/wireshark
# make install clean
...
Installing wireshark-1.10.6... done
===>  Cleaning for libsmi-0.4.8
===>  Cleaning for adns-1.4_1
===>  Cleaning for GeoIP-1.4.8_3
===>  Cleaning for wireshark-1.10.6

Al terminar la instalacion, ya podemos iniciar wireshark desde el usuario jdoe y veremos las tarjetas en las que podemos hacer capturas.

Si luego de usarlo, queremos desinstalarlo, ejecutamos

# pkg delete libsmi-0.4.8 adns-1.4_1 GeoIP-1.4.8_3 wireshark-1.10.6

Para saber como se usa, es bueno ver el siguiente link

http://www.wireshark.org/docs