Instalación Raspberry Pi Zero W

    Este cacharro, de 15$, es una joya para realizar pruebas o simplemente para cacharrear con el Sistema Operativo para cualquier freak o con ganas de aprender

    En esta entrada veremos como instalar y realizar las configuraciones básicas para tener un equipo rápido, básico y preparado para lo justo y necesario basado en Raspbian; la versión de Debian preparada para Raspberry.

    Para empezar, se necesitará una tarjeta SD. Por ejemplo, una Micro SD de 64GB Clase 10 U3 microSDXC en la que instalaremos el sistema Operativo.
    En mi caso, lo estoy realizando con un MacOS el proceso, pero sirve tanto WIN/Linux por lo que para iniciar el proceso, vamos a descargar la última versión:

    cd /tmp/
    curl -O --retry 60 -m 60 -w 5 -H 'Cache-Control: no-cache, no-store' https://downloads.raspberrypi.org/raspbian_lite_latest -L -o raspbian-stretch-lite.zip

    Una vez descargado, formatearemos la tarjeta. Es importante seleccionar el disco! (no usar el /dev/disk3, si no estás seguro del disco)

    diskutil list
    diskutil eraseDisk FAT32 SDCARD MBRFormat /dev/disk3
    diskutil unmountDisk /dev/disk3

    Ahora iniciaremos el flasheado del zip descargado hacia la tarjeta:

    cd /tmp
    sudo unzip -p raspbian-stretch-lite.zip | sudo dd of=/dev/disk3 bs=4096 ; sync

    Este proceso puede llegar a tardar 20 minutos por lo que paciencia hasta que volvamos a la prompt.
    Ahora, creremos un fichero que nos va a permitir conectar por SSH a la Raspberry, en adelante RPI:

    Aprovecharemos para aplicar la siguiente configuración antes de desconectar:

    cat >> /Volumes/boot/config.txt << EOF
    dtoverlay=dwc2
    gpu_mem=16
    dtoverlay=disable-bt
    boot_delay=0
    disable_splash=1
    EOF
    
    cat > /Volumes/boot/cmdline.txt << EOF
    dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes fsck.mode=force rootwait modules-load=dwc2,g_ether quiet plymouth.ignore-serial-consoles init=/usr/lib/raspi-config/init_resize.sh
    EOF

    y configuraremos la WIFI:

    cat > /Volumes/boot/wpa_supplicant.conf <<EOF
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=ES
    network={
            ssid="HOME WIFI"
            psk="123456"
            key_mgmt=WPA-PSK
    }
    EOF

    Finalmente, desmontaremos la unidad de la SD

    diskutil unmountDisk /dev/disk3

    Listos! Ya podemos quitar la SD del equipo y conectar a la RPI para iniciar. En este punto, podemos empezar a realizar un scan de la red hasta detectar conectividad:

    nmap -sP 10.0.1.0/24
    nmap -sn 10.0.1.0/24
    arp -a | egrep -i "B8:27:|DC:A6:|E4:5F:"

    Una vez tengamos ping (10.0.1.61), podremos ya conectar por una de las siguientes opciones con el password, por defecto: raspberry

    ssh-keygen -R 10.0.1.61
    ssh -l pi 10.0.1.61
    ssh -l pi raspberrypi
    ssh -l pi raspberrypi.local

    Bien, ahora vamos a realizar las configuraciones básicas para tener nuestra RPI Zero W lista.

    En primer lugar, asignaremos una IP fija con su respectiva configuracion de red:

    cat >> /etc/dhcpcd.conf << EOF
    interface wlan0
    static ip_address=10.0.1.71/24
    static routers=10.0.1.1
    static domain_name_servers=8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 1.1.1.1 1.0.0.1
    EOF
    

    Añadiremos los DNS:

    cat >> /etc/resolv.conf << EOF
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    nameserver 208.67.222.222
    nameserver 208.67.220.220
    nameserver 1.1.1.1
    nameserver 1.0.0.1
    options timeout:2 attemps:2
    EOF
    
    chattr +i /etc/resolv.conf
    

    Modificaremos el password por defecto. Tanto del usuario pi como root

    echo "pi:123456" | chpasswd
    echo "root:123456" | chpasswd
    

    Configuraremos apt para aceptar las instalaciones y evitando que nos pregunte por ello (lo veremos mas adelante)

    cat > /etc/apt/apt.conf.d/apt-yes << EOF
    APT::Get::Assume-Yes "true";
    EOF
    
    sed -i '/^exit 0/i export DEBIAN_FRONTEND=noninteractive' /etc/rc.local
    export DEBIAN_FRONTEND=noninteractive
    

    Eliminaremos software que a priori no deberíamos necesitar (siempre se puede instalar según se requiera)

    rm -r /usr/lib/xorg/modules/linux /usr/lib/xorg/modules/extensions /usr/lib/xorg/modules /usr/lib/xorg
    apt-get --yes purge --auto-remove cups-bsd cups-client fonts-droid fuse gettext-base ghostscript gnome-accessibility-themes gnome-themes-standard-data libasound2 libasprintf0c2 libasyncns0 libaudit0 libcaca0 libcupsimage2 libfile-copy-recursive-perl libflac8 libfm-data libfuse2 libgif4 libgs9 libgs9-common libid3tag0 libijs-0.35 libjbig2dec0 libjson0 libmad0 libmenu-cache1 libmikmod2 libmtdev1 libogg0 libopenjpeg2 libpaper-utils libpaper1 libpciaccess0 libpoppler19 libportmidi0 libqt4-network libqt4-xml libqtdbus4 libsamplerate0 libsndfile1 libutempter0 libvorbis0a libvorbisenc2 libvorbisfile3 libvte-common libwebp2 libwnck-common poppler-data python-numpy python-support tcl8.5 update-inetd xbitmaps zenity-common aspell aspell-en console-setup-linux cups-common dconf-gsettings-backend dconf-service dictionaries-common fontconfig fontconfig-config gconf2-common glib-networking glib-networking-common glib-networking-services gsettings-desktop-schemas gsfonts hicolor-icon-theme iso-codes libaspell15 libatk1.0-0 libatk1.0-data libavahi-client3 libavahi-common-data libavahi-common3 libavahi-glib1 libbluetooth3 libbluray1 libcdio-cdda1 libcdio-paranoia1 libcdio13 libck-connector0 libcolord1 libcups2 libdatrie1 libdconf0 libdrm2 libenchant1c2a libexif12 libfontconfig1 libfontenc1 libgconf-2-4 libgdk-pixbuf2.0-common libgdu0 libglapi-mesa libgnome-keyring-common libgnome-keyring0 libgphoto2-port0 libhunspell-1.3-0 libicu48 libjasper1 libjpeg8 liblcms1 liblcms2-2 libltdl7 libmng1 libnettle4 liborc-0.4-0 libpam-ck-connector libpixman-1-0 libpolkit-agent-1-0 libpolkit-backend-1-0 libproxy0 libqtcore4 libthai-data libthai0 libtiff4 netsurf-common sgml-base ttf-dejavu-core xml-core
    apt-get --yes purge --auto-remove xserver-common x11-xfs-utils x11-xserver-utils xinit libsmbclient blt gvfs gvfs-backends gvfs-daemons gvfs-fuse idle idle-python2.7 idle-python3.2 idle3 libaudio2 libice6 liblightdm-gobject-1-0 libobrender27 libpulse0 libqt4-svg libqtgui4 libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0-0 libsdl1.2debian libsm6 libsmpeg0 libwebkitgtk-1.0-0 libwebkitgtk-3.0-0 libxaw7 libxklavier16 libxmu6 libxss1 libxt6 libxtst6 lightdm lightdm-gtk-greeter lxde lxde-core midori nano obconf openbox python-pygame python-tk python3-tk  scratch tk8.5 wpagui x11-common x11-utils x11-xkb-utils xinit xserver-common xserver-xorg xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-evdev xserver-xorg-input-synaptics xserver-xorg-video-fbdev zenity xserver* x11-common x11-utils x11-xkb-utils x11-xserver-utils xarchiver xauth xkb-data console-setup xinit lightdm libx{composite,cb,cursor,damage,dmcp,ext,font,ft,i,inerama,kbfile,klavier,mu,pm,randr,render,res,t,xf86}* lxde* lx{input,menu-data,panel,polkit,randr,session,session-edit,shortcut,task,terminal} obconf openbox gtk* libgtk* alsa* nano python-pygame python-tk python3-tk scratch tsconf desktop-file-utils cifs-utils samba-common smbclient
    apt-get --yes purge --auto-remove python-rpi.gpio scratch debian-reference-en dillo idle3 python3-tk idle python-pygame python-tk lightdm gnome-themes-standard gnome-icon-theme raspberrypi-artwork gvfs-backends gvfs-fuse desktop-base lxpolkit netsurf-gtk zenity xdg-utils mupdf gtk2-engines alsa-utils  lxde lxtask menu-xdg gksu midori xserver-xorg xinit xserver-xorg-video-fbdev libraspberrypi-dev libraspberrypi-doc dbus-x11 libx11-6 libx11-data libx11-xcb1 x11-common x11-utils lxde-icon-theme gconf-service gconf2-common
    apt-get --yes purge --auto-remove bluez bluetooth bluez-firmware avahi-daemon raspi-config cups-browsed alsa-utils wolfram-engine console-setup triggerhappy anacron cups bluetooth rpcbind -y
    apt-get --yes purge --auto-remove rsh-client telnet xinetd needrestart
    apt-get --yes autoremove
    

    Actualizaremos el firmware

    rm -rf /boot/.firmware_revision /root/.firmware_revision
    apt-get --yes clean
    apt-get --yes update
    dpkg --configure -a
    PRUNE_MODULES=1 SKIP_WARNING=1 rpi-update
    apt --purge autoremove -y
    

    Actualizaremos el sistema

    apt-get --yes clean
    apt update --allow-releaseinfo-change
    apt list --upgradable
    apt-get --yes update
    apt-get --yes upgrade
    apt-get --yes dist-upgrade
    apt-get --yes --assume-yes full-upgrade
    apt-get --yes install raspberrypi-kernel-headers raspberrypi-kernel
    
    apt-get --yes autoremove
    apt-get --yes autoclean
    apt-get --yes clean
    

    En este punto, realizaremos un reinicio de la Raspberry

    Leave a Reply

    Your email address will not be published. Required fields are marked *