{"id":149,"date":"2016-12-18T12:14:44","date_gmt":"2016-12-18T11:14:44","guid":{"rendered":"http:\/\/maciejpiasecki.info\/blog\/?p=149"},"modified":"2017-01-11T18:19:14","modified_gmt":"2017-01-11T17:19:14","slug":"wielka-siec-w-miniaturce","status":"publish","type":"post","link":"https:\/\/maciejpiasecki.info\/blog\/wielka-siec-w-miniaturce\/","title":{"rendered":"Wielka sie\u0107 w miniaturce"},"content":{"rendered":"<p>Nie raz si\u0119 zdarza\u0142o \u017ce mia\u0142em problem bo komputer zajmowa\u0142 za du\u017co miejsca, jeszcze cz\u0119\u015bciej problemem jest ha\u0142as i temperatura.<\/p>\n<p>Oczywi\u015bcie nie ma nic za darmo, ale wszystko zale\u017cy od tego co chcemy uzyska\u0107. Podstawowym kryterium jest internet, poczta, dokumenty i \u0142\u0105czno\u015b\u0107. Jest mo\u017cliwo\u015b\u0107 grania ale to niej est g\u0142\u00f3wne kryterium, ale o tym na ko\u0144cu.<\/p>\n<p>Celem samym w sobie jest zrobi\u0107 ma\u0142e dzia\u0142aj\u0105ce stanowiska dla dorastaj\u0105cych domownik\u00f3w.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Materia\u0142 w trakcie testowania i uzupe\u0142niania<\/p>\n<p>&nbsp;<\/p>\n<h2 class=\"post-title\">Diskless Debian Linux booting via dhcp\/pxe\/nfs\/tftp\/aufs<\/h2>\n<div class=\"postmeta\"><span class=\"meta-date\"><a href=\"http:\/\/debianaddict.com\/2012\/06\/19\/diskless-debian-linux-booting-via-dhcppxenfstftp\/\">June 19, 2012<\/a><\/span> <span class=\"meta-category\"><a title=\"View all posts in Linux\" href=\"http:\/\/debianaddict.com\/category\/linux\/\" rel=\"category tag\">Linux<\/a><\/span> <span class=\"meta-comments\"><a title=\"Comment on Diskless Debian Linux booting via dhcp\/pxe\/nfs\/tftp\/aufs\" href=\"http:\/\/debianaddict.com\/2012\/06\/19\/diskless-debian-linux-booting-via-dhcppxenfstftp\/#respond\">No comments<\/a><\/span><\/div>\n<div class=\"entry\">\n<p>Want to boot a (possibly minimal) installation of Debian off the network using a read-only NFS share as the root filesystem, such that each netbooted machine has \/ mounted read-only over NFS and all writes are done to memory? Read on!<\/p>\n<p>This assumes you are using a Linux computer as your router, which will be running Debian and hosting the local version of Debian we will be serving to clients which are PXE booting. This could be seen as a second part of my <a title=\"Linux as a router with iptables, bind9, and dhcpd\" href=\"http:\/\/debianaddict.com\/2012\/06\/19\/linux-as-a-router-with-iptables-bind9-and-dhcpd\/\">tutorial on making a Debian box a router<\/a> , as it assumes your local network is still 10.0.0.0\/24 and the dhcp\/nfs\/tftp server\u2019s IP is 10.0.0.1<\/p>\n<p>First off, we\u2019ll need deboostrap, nfs, tftpd, and\u00a0syslinux. Install them:<\/p>\n<pre>apt-get install tftp-hpa nfs-kernel-server debootstrap syslinux<\/pre>\n<p>We will store our initrd and boot loader under \/srv\/tftp and our NFS root filesystem under \/srv\/nfsroot<\/p>\n<pre>mkdir -p \/srv\/tftp \/srv\/nfsroot<\/pre>\n<p>Our nfsroot needs to be mountable via NFS. Export it read-only to our local network by putting the following in \/etc\/exports<\/p>\n<pre>\/srv\/nfsroot 10.0.0.0\/24(ro,no_root_squash,no_subtree_check)<\/pre>\n<p>We will be booting to a custom Debian install. Install it in \/srv\/nfsroot using <a href=\"http:\/\/wiki.debian.org\/Debootstrap\">Debootstrap<\/a>:<\/p>\n<pre>debootstrap stable \/srv\/nfsroot http:\/\/ftp.us.debian.org\/debian<\/pre>\n<p>Now we need to install some packages in the NFS installation of Debian:<\/p>\n<pre>chroot \/srv\/nfsroot apt-get update\r\nchroot \/srv\/nfsroot apt-get install initramfs-tools linux-image-2.6.32-5-amd64<\/pre>\n<p>Configure its initramfs to generate NFS-booting initrd\u2019s<\/p>\n<pre>sed 's\/BOOT=local\/BOOT=nfs\/' -i \/srv\/nfsroot\/etc\/initramfs-tools\/initramfs.conf<\/pre>\n<p>We\u2019ll need the aufs module<\/p>\n<pre>echo aufs &gt;&gt; \/srv\/nfsroot\/etc\/initramfs-tools\/modules<\/pre>\n<p>Create the file \/srv\/nfsroot\/etc\/initramfs-tools\/scripts\/init-bottom\/aufs give it executable permissions and fill it with the following<\/p>\n<pre>modprobe aufs\r\nmkdir \/ro \/rw \/aufs\r\nmount -t tmpfs tmpfs \/rw -o noatime,mode=0755\r\nmount --move $rootmnt \/ro\r\nmount -t aufs aufs \/aufs -o noatime,dirs=\/rw:\/ro=ro\r\nmkdir -p \/aufs\/rw \/aufs\/ro\r\nmount --move \/ro \/aufs\/ro\r\nmount --move \/rw \/aufs\/rw\r\nmount --move \/aufs \/root\r\nexit 0<\/pre>\n<p>Generate initrd<\/p>\n<pre>update-initramfs -k<\/pre>\n<p>Copy generated initrd, kernel image, and pxe bootloader to tftp root and create folder for pxe config<\/p>\n<pre>cp \/srv\/nfsroot\/boot\/initrd.img-2.6.32-5-amd64 \/srv\/tftp\/\r\ncp \/srv\/nfsroot\/boot\/vmlinuz-2.6.32-5-amd64 \/srv\/tftp\/\r\ncp \/usr\/lib\/syslinux\/pxelinux.0 \/srv\/tftp\r\nmkdir \/srv\/tftp\/pxelinux.cfg<\/pre>\n<p>Configure boot loader. Put the following into \/srv\/tftp\/pxelinux.cfg\/default<\/p>\n<pre>default Debian\r\nprompt 1\r\ntimeout 10\r\nlabel Debian\r\nkernel vmlinuz-2.6.32-5-amd64\r\nappend ro initrd=initrd.img-2.6.32-5-amd64 root=\/dev\/nfs ip=dhcp nfsroot=10.0.0.1:\/srv\/nfsroot<\/pre>\n<p>Configure tftp\u2019s \/etc\/default\/tftpd-hpa<\/p>\n<pre>TFTP_USERNAME=\"tftp\"\r\nTFTP_DIRECTORY=\"\/srv\/tftp\"\r\nTFTP_ADDRESS=\"0.0.0.0:69\"\r\nTFTP_OPTIONS=\"--secure\"<\/pre>\n<p>Add these lines to your dhcp config file \/etc\/dhcp\/dhcpd.conf<\/p>\n<pre>next-server 10.0.0.1;\r\nallow bootp;\r\nallow booting;<\/pre>\n<p>Restart some services:<\/p>\n<pre>\/etc\/init.d\/isc-dhcp-server restart\r\n\/etc\/init.d\/tftpd-hpa restart\r\nexportfs -ra<\/pre>\n<p>At this point, configuration is done and you should be good to go. You might want to reset the root password on the nfs debian install:<\/p>\n<pre>chroot \/srv\/nfsroot passwd root<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Nie raz si\u0119 zdarza\u0142o \u017ce mia\u0142em problem bo komputer zajmowa\u0142 za du\u017co miejsca, jeszcze cz\u0119\u015bciej problemem jest ha\u0142as i temperatura. Oczywi\u015bcie nie ma nic za darmo, ale&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,5],"tags":[63],"class_list":["post-149","post","type-post","status-publish","format-standard","hentry","category-bez-kategorii","category-it","tag-diskless-debian-siec-pxe-pxeboot"],"_links":{"self":[{"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/posts\/149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/comments?post=149"}],"version-history":[{"count":2,"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/posts\/149\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/posts\/149\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/media?parent=149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/categories?post=149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/maciejpiasecki.info\/blog\/wp-json\/wp\/v2\/tags?post=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}