Próxima revisión | Revisión previaÚltima revisiónAmbos lados, revisión siguiente |
es:howtos:network_services:nfs_root [2019/02/11 12:16 (UTC)] – creado slackwarespanol | es:howtos:network_services:nfs_root [2019/02/22 21:46 (UTC)] – [Sources] slackwarespanol |
---|
| <note warning>En proceso de traducción. Victor</note> |
====== NFS Root ====== | ====== NFS Root ====== |
| |
==== Introduction ==== | ==== Introducción ==== |
| |
This HOWTO is about running your Slackware Linux system without any hard disk - or perhaps with a very small hard disk - accessing the network to retrieve all files except the kernel. If you want to go the whole hog you can PXE-boot the kernel too, however this HOWTO expects you to have somewhere local to store the kernel. We're going to use VirtualBox virtual machines to **simulate** a diskless client. We'll still use a full Linux install along with our trusty LILO to prepare and then boot that kernel. This may seem a bit pointless, as there is no use-case for exactly what I'm doing here, but it should at least educate as to how you go about getting NFS root, and some of the pitfalls and workarounds. | Este CÓMO trata de ejecutar su sistema Slackware Linux sin ningún disco duro, o quizás con un disco duro muy pequeño, accediendo a la red para recuperar todos los archivos excepto el kernel. Si desea ir por todo, también puede arrancar con PXE el kernel, sin embargo, este CÓMO espera que tenga un lugar local para almacenar el kernel. Vamos a utilizar máquinas virtuales (VirtualBox) para ** simular ** un cliente sin disco. Seguiremos usando una instalación completa de Linux junto con nuestro confiable LILO para preparar y luego arrancar ese kernel.Esto puede parecer un poco inútil, ya que no hay un caso de uso para exactamente lo que estoy haciendo aquí, pero al menos debería informar sobre cómo se obtiene la raíz NFS, y algunos de los escollos y soluciones alternativas. |
| ==== Ejecutando un servidor NFS ==== |
| |
==== Running an NFS server ==== | Por supuesto, necesita un servidor NFS para servir los archivos raíz. Voy a llamar a esto ** slack-nfs-server **. La dirección IP es ** 172.17.0.80 **. Hay [[nfs-quick_and_dirty_setup | un gran artículo]] sobre la configuración de un servidor NFS. A continuación, cree su servidor con Virtual Box (con redes puenteadas) y luego vuelva aquí para el siguiente paso. |
| |
Of course you need an NFS server to serve the root files from. I'm going to call this **slack-nfs-server**. The IP address is **172.17.0.80**. There is a [[nfs-quick_and_dirty_setup|a great article]] on setting up an NFS server. Following that, create your server using Virtual Box (with bridged networking), and then come back here for the next step. | El /etc/exports que estoy usando se ve así: |
| |
The /etc/exports I'm using looks like this: | |
| |
<code>/nfs_share 172.17.0.1/24(rw,sync,no_root_squash,no_subtree_check)</code> | <code>/nfs_share 172.17.0.1/24(rw,sync,no_root_squash,no_subtree_check)</code> |
| |
That's insecure but good enough for the setup, we can refine it later. In addition to that guide it's worth doing: | Eso es inseguro pero lo suficientemente bueno para la configuración, podemos refinarlo más tarde. Además de esa guía vale la pena hacer: |
| |
<code>chmod 777 /nfs_share</code> | <code>chmod 777 /nfs_share</code> |
| |
In order that we can be sure we can write to the root of our NFS share once it's mounted. | Para que podamos estar seguros de que podemos escribir en la raíz de nuestro recurso compartido NFS una vez que esté montado. |
| ==== Creando los rootfs ==== |
| |
==== Creating the rootfs ==== | Ahora cree otra máquina virtual para realizar la instalación (redes puenteadas nuevamente). Monte el disco de instalación de Slackware en esta máquina virtual. Si desea un rootfs de 32 bits, obviamente use el DVD de instalación de 32 bits, si desea un rootfs de 64 bits, use Slackware64. Si desea 32 bits (muy probablemente para un cliente sin disco) puede que necesite habilitar PAE en VirtualBox en Sistema -> Procesador para que Slack32 arranque. |
| |
Now create another virtual machine to do the install (bridged networking again). Mount the Slackware install disk on this virtual machine. If you want a 32-bit rootfs, obviously use the 32-bit install DVD, if you want a 64-bit rootfs, use Slackware64. If you do want 32-bit (quite likely for a diskless client) you may need to enable PAE in VirtualBox under System -> Processor to get Slack32 to boot. | Suponiendo que ahora haya arrancado el instalador de Slackware con el gran kernel predeterminado, ahora puede iniciar la instalación. Inicie sesión como root y obtenga su dirección IP: |
| |
Assuming you now have the Slackware installer booted using the default huge kernel you can now start the install. Login as root, and get your IP address: | |
| |
<code># dhcpcd eth0</code> | <code># dhcpcd eth0</code> |
| |
Mount the nfs share you previously created on /mnt: | Monte el nfs que creó previamente en /mnt: |
<code># mount -o rw,nolock slack-nfs-server:/nfs_server /mnt</code> | <code># mount -o rw,nolock slack-nfs-server:/nfs_server /mnt</code> |
| |
If you don't have DNS setup that's fine, just substitute the IP address of your server for slack-nfs-server, i.e. 172.17.0.80. | Si no tiene una configuración de DNS que esté bien, simplemente sustituya la dirección IP de su servidor por el servidor slack-nfs, es decir, 172.17.0.80. |
| |
Now we need to fudge something for the Slackware installer. Using fdisk, create a single partition on your hard disk (/dev/sda1). Unfortunately a valid partition on a drive connected to the system is a requirement for the installer to run. Don't worry, we'll just delete this entire virtual machine when we're done so it's no biggie. | Ahora necesitamos manipular algo para el instalador de Slackware. Con fdisk, cree una sola partición en su disco duro (/dev/sda1). Desafortunadamente, una partición válida en una unidad conectada al sistema es un requisito para que el instalador se ejecute. No se preocupe, solo eliminaremos toda esta máquina virtual cuando hayamos terminado, así que no hay problema. |
| |
Now run 'setup'. | Ahora ejecute 'setup'. |
| |
* Remap keyboard as you want | * Mapea el teclado como quieras |
* Don't configure any swap. | * No configurar ningún swap. |
* At the screen 'Select Linux installation partition' don't select /dev/sda1 just down-arrow and select '(done adding partitions, continue with setup)'. | * En la pantalla 'Select Linux installation partition' no seleccione /dev/sda1 solo la flecha hacia abajo y seleccione '(done adding partitions, continue with setup)'. |
* Install from the slackware cd/dvd | * Instalar desde el slackware cd / dvd |
* Select your packages as normal | * Seleccione sus paquetes como normal |
* Don't create a bootdisk | * No cree un bootdisk |
* Don't install LILO. | * No instale LILO. |
| Cuando termine, ahora debería encontrar una raíz fs 'instalada' en el directorio del servidor. Si planea usarlo con más de un cliente liviano, entonces sería un buen momento para realizar una copia de respaldo antes de iniciarlo. |
| |
When done you should now find a root fs 'installed' to the server directory. If you plan to use it with more than one thin client, then now would be a good time to take a backup copy before the first boot into it. | |
| |
| ==== Creando el kernel ==== |
| |
==== Creating the kernel ==== | El enorme kernel completo que viene con Slackware 14.2 está cerca de proporcionar todo lo que necesitamos, pero aún necesitamos recompilarlo. Recomendaría hacer la compilación en una máquina virtual de 32 bits si está apuntando a un cliente liviano de 32 bits, o de 64 bits si su cliente liviano es de 64 bits. Hay formas de evitar esto y compilar de forma cruzada los núcleos de 32-> 64 bits y viceversa, pero las máquinas virtuales son baratas y la vida es corta: |
| |
The full huge kernel that comes with Slackware 14.2 is close to providing everything we need, but we still need to recompile it. I'd recommend doing the compilation on a 32-bit virtual machine if you are targeting a 32-bit thin client, or 64-bit if your thin client is 64-bit. There are ways to avoid this and cross-compile kernels 32->64 bit and visa versa but virtual machines are cheap and life is short: | |
| |
<code># cd /usr/src/linux | <code># cd /usr/src/linux |
# make menuconfig</code> | # make menuconfig</code> |
| |
Configuration order is important, as selecting certain options makes others available. First off we will need a network driver compiled into the kernel for the NIC we're going to use. For VirtualBox the default NIC is PCnet32, an lspci will probably tell you yours: | El orden de configuración es importante, ya que la selección de ciertas opciones hace que otras estén disponibles. Primero, necesitaremos un controlador de red compilado en el kernel para la NIC que vamos a utilizar. Para VirtualBox, la NIC predeterminada es PCnet32, y lspci probablemente le dirá la suya: |
| |
<code>Device Drivers -> Network Device Support -> Ethernet driver support -> AMD PCnet32 PCI support <*></code> | <code>Device Drivers -> Network Device Support -> Ethernet driver support -> AMD PCnet32 PCI support <*></code> |
| |
Make sure this is compiled into the kernel (e.g. hitting 'y'). | Asegúrate de que esto esté compilado en el kernel (por ejemplo, presionando 'y'). |
| |
[OPTIONAL] We also need to tell the kernel which IP address to use, which can be set statically, but DHCP is much easier, so generally you will want to include these options: | [OPCIONAL] También debemos decirle al núcleo qué dirección IP usar, que se puede configurar de forma estática, pero DHCP es mucho más fácil, por lo que generalmente querrá incluir estas opciones: |
| |
<code>Networking support -> Networking options -> IP: kernel level autoconfiguration [*] | <code>Networking support -> Networking options -> IP: kernel level autoconfiguration [*] |
IP: DHCP support [*]</code> | IP: DHCP support [*]</code> |
| |
Finally, we absolutely need the support for Root FS on NFS: | Finalmente, absolutamente necesitamos el soporte para Root FS en NFS: |
| |
<code>File Systems -> Network File systems -> Root file system on NFS [*]</code> | <code>File Systems -> Network File systems -> Root file system on NFS [*]</code> |
| [OPCIONAL] Es bastante útil agregar una versión local a esta versión del kernel. Recomiendo hacer esto para diferenciarlo de su gran kernel estándar de Slackware y evitar sobrescribir los módulos por error. Solo podemos añadir '-nfsroot': |
[OPTIONAL] It's pretty useful to append a local version to this kernel release. I'd advise doing this to differentiate it from your standard Slackware huge kernel and avoid clobbering the modules from that by mistake. We can just add '-nfsroot': | |
| |
<code>(-nfsroot) General Setup -> Local version - append to kernel release</code> | <code>(-nfsroot) General Setup -> Local version - append to kernel release</code> |
| |
Save the configuration and then do a: | Guarde la configuración y luego haga un: |
| |
<code># make bzImage</code> | <code># make bzImage</code> |
| |
While that build is running, it's time to configure LILO. | Mientras se ejecuta esa compilación, es hora de configurar LILO. |
| |
| |
==== Configuring LILO ==== | ==== Configurando LILO ==== |
| |
Let's call the kernel /boot/vmlinuz-nfsroot. Add a section to the lilo.conf file: | Llamemos al kernel /boot/vmlinuz-nfsroot. Agregue una sección al archivo lilo.conf: |
| |
<code>image=/boot/vmlinuz-nfsroot | <code>image=/boot/vmlinuz-nfsroot |
append= "root=/dev/nfs ip=dhcp nfsroot=172.17.0.80:/nfs_share,v3 rw"</code> | append= "root=/dev/nfs ip=dhcp nfsroot=172.17.0.80:/nfs_share,v3 rw"</code> |
| |
If you didn't want to use dhcp you'll now need to have a read of | Si no desea utilizar dhcp, ahora tendrá que leer Documentation/filesystems/nfs/nfsroot.txt en las fuentes del kernel para descubrir las muchas opciones que puede |
Documentation/filesystems/nfs/nfsroot.txt in the kernel sources to figure out the many options that you can | incluir para ip= distinto de 'dhcp'. |
include for ip= other than 'dhcp'. | |
| |
Obviously keep your default linux kernel in another image= section so you can switch between booting the nfsroot and the normal kernel to play around with this stuff. | Obviamente, mantenga su kernel de Linux predeterminado en otra sección image = para que pueda cambiar entre el arranque de nfsroot y el kernel normal para jugar con estas cosas. |
| |
You cannot specify a normal root= entry in this section because LILO doesn't recognise /dev/nfs for root (the device doesn't actually exist to LILO). So instead just specify it in the append= line which LILO doesn't try to interpret, and LILO will include this extra nfsroot image without error. | No puede especificar una entrada normal de root= en esta sección porque LILO no reconoce /dev/nfs para root (el dispositivo no existe realmente para LILO). Entonces, en lugar de eso, simplemente especifíquelo en la línea append= que LILO no intenta interpretar, y LILO incluirá esta imagen nfsroot adicional sin error. |
| |
The v3 seems to be really important in making anything at all happen on boot. If that isn't set, no communication seems to occur. | La v3 parece ser realmente importante para hacer que suceda algo en el arranque. Si eso no está establecido, ninguna comunocación ocurrirá. |
| |
The 'rw' is also important. It prevents the fsck of the root fs. because root is NFS and can't be checked. Slackware won't boot properly if we give 'ro'. Instead of using 'rw' you could optionally hack fsck out of the Slackware startup scripts on your NFS root, however simply using 'rw' is quicker (albeit dirtier). | El 'rw' también es importante. Previene el fsck de la raíz fs. porque la raíz es NFS y no se puede verificar. Slackware no arranca correctamente si damos 'ro'. En lugar de usar 'rw', opcionalmente podría hackear fsck de los scripts de inicio de Slackware en su raíz NFS, sin embargo, usar 'rw' es más rápido (aunque más sucio). |
| |
With the kernel compilation finished, copy the kernel into the /boot directory and rename it: | Con la compilación del kernel terminada, copie el kernel en el directorio /boot y renómbrelo: |
| |
<code>cp /usr/src/linux/arch/x86/boot/bzImage /boot/vmlinuz-nfsroot</code> | <code>cp /usr/src/linux/arch/x86/boot/bzImage /boot/vmlinuz-nfsroot</code> |
| |
It may be created elsewhere than arch/x86 depending on your architecture, e.g. x64, arm. | Puede crearse en otro lugar que no sea arch/x86 dependiendo de su arquitectura, por ejemplo. x64, arm. |
| |
Don't forget to run LILO: | No se olvide de ejecutar LILO: |
| |
<code># lilo</code> | <code># lilo</code> |
| |
==== First Boot ==== | ==== Primer arranque ==== |
| |
The above is enough to get you a booting Slackware system, or should be. There are some additional steps that you may wish to now do. | Lo anterior es suficiente para obtener un sistema Slackware de arranque, o debería serlo. Hay algunos pasos adicionales que quizás desee hacer ahora. |
| |
=== Modules === | === Módulos === |
| |
None of the modules have been installed, let's add them. Shutting down the nfsroot system and booting back into the Slackware kernel compilation virtual machine we can now compile the missing modules. First we will mount the rootfs, just as we did from the installer virtual machine: | Ninguno de los módulos ha sido instalado, vamos a agregarlos. Al apagar el sistema nfsroot y volver a arrancar en la máquina virtual de compilación del kernel de Slackware, ahora puede compilar los módulos que faltan. Primero montará los rootfs, tal como lo hicimos desde la máquina virtual del instalador: |
| |
<code>mount -o rw,nolock slack-nfs-server:/nfs_share /mnt/tmp</code> | <code>mount -o rw,nolock slack-nfs-server:/nfs_share /mnt/tmp</code> |
| |
Then we can compile and install the modules: | Luego pude compilar e instalar los módulos: |
| |
<code># cd /usr/src/linux | <code># cd /usr/src/linux |
# make modules_install INSTALL_MOD_PATH=/mnt/tmp</code> | # make modules_install INSTALL_MOD_PATH=/mnt/tmp</code> |
| |
For the last command, avoid adding a trailing slash to /mnt/tmp, and try not to forget the INSTALL_MOD_PATH, otherwise you may have just clobbered your system modules. If you gave your kernel a local suffix (e.g. -nfsroot) you'd have been protected against that. | Para el último comando, evite agregar una barra diagonal final a /mnt/tmp, e intente no olvidar la INSTALL_MOD_PATH, de lo contrario, puede que solo haya sobrescrito los módulos de su sistema. Si le hubiera dado a u kernel un sufijo local (por ejemplo, -nfsroot), habría sido protegido contra eso. |
| |
=== Swap on NFS === | === Swap en NFS === |
| |
You can create a swap file on your NFS share somewhere like this: | Puede crear un archivo swap en su recurso compartido NFS en algún lugar como este: |
| |
<code># dd if=/dev/zero of=/nfs_share/swapfile bs=1024 count=64k</code> | <code># dd if=/dev/zero of=/nfs_share/swapfile bs=1024 count=64k</code> |
| |
Then format it for swap: | Luego formatearlo para swap: |
| |
<code># mkswap /nfs_share/swapfile</code> | <code># mkswap /nfs_share/swapfile</code> |
| |
Then on the client you associate a loopback device with the file: | Luego, en el cliente asocie un dispositivo de bucle invertido con el archivo: |
| |
<code># losetup /dev/loop0 /swapfile</code> | <code># losetup /dev/loop0 /swapfile</code> |
| |
Then start using the loopback device for swap: | Entonces comience a usar el dispositivo de bucle invertido para swap: |
| |
<code># swapon /dev/loop0</code> | <code># swapon /dev/loop0</code> |
| |
Obviously you need to add the last two commands to /etc/rc.d/rc.local or another startup script to run on each boot. | Obviamente, debe agregar los dos últimos comandos a /etc/rc.d/rc.local u otro script de inicio para ejecutar en cada arranque. |
| |
=== Locking down /etc/exports === | === Bloqueo de / etc / exports === |
| Suponiendo que su cliente liviano se conecte desde una dirección predecible, ahora que ha instalado los módulos, finalmente puede bloquear el acceso solo al cliente liviano (/etc/exports en el servidor): |
Assuming your thin client connects from a predictable address, now that we've installed the modules we can finally lock down access to only the thin client (/etc/exports on the server): | |
| |
<code>/nfs_share 172.17.0.81/32(rw,sync,no_root_squash,no_subtree_check)</code> | <code>/nfs_share 172.17.0.81/32(rw,sync,no_root_squash,no_subtree_check)</code> |
| |
And we presumably don't want all-and-sundry using our newly prepared rootfs directory, so drop it down a level and qualify it by IP address (on the server): | Y es de suponer que no queremos que todos y cada uno utilicen nuestro directorio rootfs recién preparado, así que bájelo y califíquelo por dirección IP (en el servidor): |
| |
<code># cd / | <code># cd / |
# mv 172.17.0.81 nfs_share</code> | # mv 172.17.0.81 nfs_share</code> |
| |
Now over on the client machine, configure LILO so nfsroot | Ahora en la máquina cliente, configure LILO para que nfsroot solicite el recurso compartido nfs basado en la dirección IP del cliente con '% s': |
requests the nfs share based on the client's IP address with '%s': | |
| |
<code>image=/boot/vmlinuz-nfsroot | <code>image=/boot/vmlinuz-nfsroot |
append= "root=/dev/nfs ip=dhcp nfsroot=172.17.0.80:/nfs_share/%s,v3 rw"</code> | append= "root=/dev/nfs ip=dhcp nfsroot=172.17.0.80:/nfs_share/%s,v3 rw"</code> |
| |
NFS Root is never going to be considered secure, but at least this makes cross-contamination of nfsroots less likely. | La raíz NFS nunca se considerará segura, pero al menos esto hace que la contaminación cruzada de nfsroots sea menos probable. |
| |
Note that I am using dhcp in the above example, but I've added an entry to /etc/dnsmasq.conf on my router mapping the thin client MAC address to the IP address 172.17.0.81 so the client always gets that address. | |
| |
====== Sources ====== | Tenga en cuenta que estoy usando dhcp en el ejemplo anterior, pero agregué una entrada a /etc/dnsmasq.conf en mi enrutador que asigna la dirección MAC del cliente liviano a la dirección IP 172.17.0.81 para que el cliente siempre obtenga esa dirección. |
* Originally written by [[wiki:user:bifferos | User bifferos]] | ====== Fuentes ====== |
| * Escrito originalmente por [[[wiki:user:bifferos | User bifferos]] |
| * Traducido por: [[wiki:user: slackwarespanol | Victor]] 2019/02/22 21:41 (UTC) |
| |
{{tag>howtos nfs author_bifferos}} | {{tag>howtos nfs author_bifferos}} |