[[oktatas:operációs rendszerek:netbsd|< NetBSD]] ====== NetBSD ====== * **Szerző:** Sallai András * Copyright (c) Sallai András, 2009, 2010, 2011, 2012, 2015, 2018 * Licenc: GNU Free Documentation License 1.3 * Web: http://szit.hu ===== Telepítés ===== ==== Telepítő beszerzése ==== * http://www.netbsd.org/ A főoldalon a "Get NetBSD" linkre kattintunk. A "Downloading NetBSD 6.1.5" résznél kiválasztom a megfelelő letöltési formát. ==== Telepítés ==== Ha a telepítő elindul válasszuk a lehetőségek közül az "Install NetBSD" pontot. >> NetBSD/x86 BIOS Boot, Revision 5.10 (Tue Jul 17 14:59:51 UTC 2018) (from NetB SD 8.0 >> Memory: 639/1047552 k 1. Boot normally 2. Boot single user 3. Disable ACPI 4. Disable ACPI and SMP 5. Drop to boot prompt Choose an option; RETURN for default; SPACE to stop counddown. Option 1 will be chosen in 0 seconds. Option: [1]: NetBSD/amd64 8.0 This menu-driven tool is designed to help you install NetBSD to hard disk, or upgrade an existing NetBSD system, with a minimum of work. In the following menus type the reference letter (a, b, c, ...) to select an item, or type CTRL+N/CTRL+P to select the next/previous item. The arrow keys and Page-up/Page-down may also work. Activate the current selection from the menu by typing the enter key. >a: Installation messages in English b: Installation aut Deeutsch c: Mensajes de instalacion en castellano d: Messages d'installation en français e: Komunikaty instalacyjne w jezyku polskim Keyboard type [...] k: Greek >l: Hungarian <: page up, >: page down NetBSD/amd64 8.0 This menu-driven tool is designed to help you install NetBSD to hard disk, or upgrade an existing NetBSD system, with a minimum of work. In the following menus type the reference letter (a, b, c, ...) to select an item, or type CTRL+N/CTRL+P to select the next/previous item. The arrow keys and Page-up/Page-down may also work. Activate the current selection from the menu by typing the enter key. Thank you for using NetBSD! NetBSD-8.0 Install System >a: Install NetBSD to hard disk b: Upgrade NetBSD on hard disk c: Re-install sets or install additional sets d: Reboot the computer e: Utility menu f: Config menu x: Exit Install System Shall we continue? yes or no? a: No >b: Yes Available disks >a: wd0 (16G, VBOX HARDDISK) b: Extended partitioning x: Exit This disk matches the following BIOS disk: BIOS # cylinders heads sectors total sectors GB ------ --------- ----- ------- ------------- --- 0x80 1024 255 63 33554432 17 [...] >a: This is the correct geometry b: Set the geometry by hand We are now going to install NetBSD on the disk wd0. [...] Whick would you like to do? >a: Edit the MBR partition table b: Use the entire disk The Current MBR partition table is shown below. Flgs: a => Activate partition, d => bootselect default, I => Install here Select the partition you wish to change: Total disk size 16384 MB Start( MB) Size( MB) Flg Kind Bootmenu ---------- ---------- --- -------------------- -------- >a: unused b: unused c: unused d: unused e: Change input units (sectors/cylinders/MB) x: Partition table OK >a: type: unused b: start: 0 MB c: size: 0 MB d: end: 0 MB e: active: No f: install: No g: bootmenu: h: default: Yes i: Change input units (sectors/cylinders/MB) x: Partition OK >a: Don't change b: Delete partition c: NetBSD d: Extended partition, LBA e: FreeBSD/386BSD f: OpenBSD g: Linux native h: Linux swap i: DOS FAT12 j: DOS FAT16, <32M <: page up, >: page down A particionálás végén: The Current MBR partition table is shown below. Flgs: a => Activate partition, d => bootselect default, I => Install here Select the partition you wish to change: Total disk size 16384 MB Start( MB) Size( MB) Flg Kind Bootmenu ---------- ---------- --- -------------------- -------- >a: 0 15390 a I NetBSD b: 15390 994 Linux swap c: unused d: unused e: Change input units (sectors/cylinders/MB) x: Partition table OK The bootcode in the Master Boot Record does not appear to be valid. Do you want to install the NetBSD bootcode? yes or no? >a: Yes b: No [...] Choose your installation >a: Set sizes of NetBSD partitions b: Use existing partition sizes You can now change the sizes for the system partitons. The default is to allocate all the space to the root file system. However, you may wish to have separate /usr (additional system files), /var (log files) or /home (users' home directories) file systems. Free space will be added to the partiton marked with a '+'. MB Cylinders Sectors Filesystem >a: 2080 (14366) 4228 4261824 + / b: 1024 2081 2097648 swap c: 0 0 0 /tmp (tmpfs) d: 0 0 0 /usr e: 0 0 0 /var f: 0 0 0 /home g: Add a user defined partition h: Change input units (sectors/cylinders/MB x: Accept partition sizes. Free space 12285 MB, 12 free partitions. We now have your BSD disklabel partitions as: This is your last chance to change. Start MB End MB Size MB FS type Newfs Mount Mount point --------- --------- -------- ---------- ----- ----- ----------- a: 0 16364 14365 FFSv2 Yes Yes / b: 14365 15389 1024 swap c: 0 15389 15389 NetBSD partition d: 0 16383 16384 Whole disk e: 0 0 0 unused f: Show all unused partitions g: Change input units sectors/cylinders/MB) x: Partition size ok Please enter a name for your NetBSD disk [VBOX HARDDISK ]: ALAP Ok, we are now ready to install NetBSD on your hard disk (wd0). Nothing has been written yet. This is your last chance to quit this process before anything gets changed. Shall we continue? yes or no? >a: No b: Yes Would you like to install the normal set of bootblocks or serial bootblocks? Normal bootblocks use the BIOS console device as the console (usually the monitor and keyboard). Serial bootblocks use the first serial port as the console. Selected bootblock: BIOS console Bootblocks selection >a: Use BIOS console b: Use serial port com0 c: Use serial port com1 d: Use serial port com2 e: Use serial port com3 f: Set serial baud rate g: Use existing bootblocks x: Exit The NetBSD distribution is broken into a collection of distributin sets. There are some basic sets that are needed by all installations and there are some other sets that are optional. You may choose to install a core set (Minimal installation), all of them (Full installation), or a custom group of sets (Custom installation). Select your distribution a: Full installation >b: Installation without X11 c: Minimal installation d: Custom installation x: Abandon installation Your disk is now ready for installing the kernel and the distribution sets. As noted in your INSTALL notes, you have several options. For ftp or nfs, you must be connected to a network with access to the proper machines. Sets selected 10, processed 0, Next set kern-GENERIC. Install from >a: CD-ROM / DVD / install image media b: HTTP c: FTP d: NFS e: Floppy f: Unmounted fs g: Local directory h: Skip set i: Skip set group j: Abandon installation Status: Running Command: progress -zf /amd64/binary/sets/comp.tgz tar --chroot -xhepf - ------------------------------------------------------------------------------- 96% |******************************** | 809 MiB 57.75 MiB/s 00:00 ETA The extraction of the selected sets for NetBSD-8.0 is complete. The system is now able to boot from the selected hard disk. To complete the installation, sysinst will give you the opportunity to configure some essential things first. >Hit enter to continue Configure the additional items as needed. a: Configure network configure b: Timezone UTC c: Root shell /bin/sh d: Change root password ***EMPTY*** e: Enable installation of binary packages install f: Fetch and unpack pkgsrc for building from source install g: Enable sshd NO h: Enable ntpd NO i: Run ntpdate at boot NO j: Enable mdnsd NO k: Enable xdm NO l: Enable cgd YES m: Enable lvm NO n: Enable raidframe YES >x: Finished configuring The installation of NetBSD-8.0 is now complete. The system should boot from hard disk. Follow the instructions in the INSTALL document about final configuration of your system. We also recommend reading the afterboot(8) manpage; it contains a list of things to be checked after the first complete boot. At a minimum, you should edit /etc/rc.conf to match your needs. See /etc/defaults/rc.conf for the default values. >Hit enter to continue NetBSD/amd64 8.0 This menu-driven tool is designed to help you install NetBSD to hard disk, or upgrade an existing NetBSD system, with a minimum of work. In the following menus type the reference letter (a, b, c, ...) to select an item, or type CTRL+N/CTRL+P to select the next/previous item. The arrow keys and Page-up/Page-down may also work. Activate the current selection from the menu by typing the enter key. Thank you for using NetBSD! NetBSD-8.0 Install System a: Install NetBSD to hard disk b: Upgrade NetBSD on hard disk c: Re-install sets or install additional sets >d: Reboot the computer e: Utility menu f: Config menu x: Exit Install System A telepítés kész. Olvasni való: man 8 afterboot Érdemes szerkesztenivaló: /etc/rc.conf Az alapértelmezett beállítások itt vannak: /etc/defaults/rc.conf ===== Új felhasználó felvétele ===== useradd -m joe passwd joe ===== Csomagkezelés ===== Két csomagkezelő áll rendelkezésre: * pkg_add - régebbi * pkgin - aktuális ==== pkg rendszer ==== A pkg_add a PKG_PATH környezeti változóval dolgozik, azonban az nincs beállítva automatikusan. Beállítás: PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/OPSYS/ARCH/VERSIONS/All" export PKG_PATH A fenti OPSYS, ARCH és VERSION helyére be kell helyettesíteni a megfelelő értékeket. * OPSYS -> NetBSD * ARCH -> i386 vagy x86_64 * VERSIONS -> például: 8.0 Konkrét példa: PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/NetBSD/x86_64/8.0/All" export PKG_PATH Régebbi verziókban szükség volt még a /usr/pkg/sbin útvonalba helyezésére, de a legújabb NetBSD-ben már alapból be van állítva. További parancsok: * pkg_add * pkg_admin * pkg_create * pkg_delete * pkg_info ==== pkgin ==== A NetBSD legújabb csomagkezelője a pkgin. Képes függőségek kezelésére és internetes tárolókról telepíteni. vi /usr/pkg/etc/pkgin/repositories.conf ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/8.0/all A pkgin paranccsal a csomaginformációk frissítése után telepíthetünk: # pkgin update Hozzáférhető csomagok listázása: # pkgin avail Telepített csomagok listázása: # pkgin list Telepítsük például a Midnight Commander fájlkezelőt, amely csomag neve mc. Telepítés: # pkgin install mc Szerverhez néhány hasznos csomag: * mc * bash * apache * pure-ftpd * nmap * php-5 * mysql-server * dovecot * lsof Grafikus rendszerhez: * openbox * gedit * scite * firefox * libreoffice* * lxde Csomagok keresése: pkgin search ===== Funkció billentyűk ===== Alapértelmezett terminál típus vt100. A vt100 beállítás mellett viszont nem működnek a funkció billentyűk. Állítsuk be azokat a következő paranccsal: export TERM=wsvt25 Az export parancs Bourne-compatibilis shell-ek esetén használható, mint sh, ksh, stb. Régebben használtam a TERM=linux beállítást, de F1-F5-ig nem volt elérhető funkcióbillentyű. A C Shell esetén a setenv parancsot szoktuk használni: setenv TERM wsvt25 A beállítást felvehetjük a /etc/profile fájlban, így automatikusan beállításra kerül belépéskor. ===== Grafikus felület beállítása ===== Xorg -configure Azonnal indíthatunk egy grafikus felületen: X -config /root/xorg.conf.new Ha már elindítottunk egy grafikus felületet kapunk egy login és egy xterm nevű parancssoros terminált. A login feliratú parancssorba ha beírjuk exit parancsot, akkor kiléphetünk a grafikus felületről. Ha valódi számítógépre telepítettük, akkor az X-ből ki léthetünk a Ctrl+Alt+Backspace billentyűkombinációval. Virtualbox esetén, például a Ctrl + F3 billentyűvel lépjünk be egy új terminálon, majd a kill paranccsal lőjük ki a X programot. Hogy minden felhasználó használhassa a az X11 beállításait, másoljuk a helyére a konfigurációs fájlt: cp /root/xorg.conf.new /etc/X11/xorg.conf Ez után felhasználóként is indíthatjuk a grafikus felületet: startx Billentyűzet: A grafikus felület elindul a xorg.conf létrehozása nélkül is. A magyar billentyűzet beállításához viszont szükség van a /etc/X11/xorg.conf állományra. Az xorg.conf fájlban keressük meg az InputDevice szekciót, majd adjuk hozzá a következő Option sort: Section "InputDevice" Identifier "Keyboard0" Driver "kbd" Option "XkbLayout" "hu" EndSection A billentyűzet átállítható a setxkbmap paranccsal menet közben: setxkbmap hu ===== Ablakkezelő ===== Alapértelmezett ablakkezelő a twm. Ez megváltoztatható a következő állományban: /etc/X11/xinit/xinitrc Cseréljük le az ablakkezelőt openbox-ra. Ehhez előbb telepítsük azt. pkgin install openbox Ezek után a fent említett xinitrc fájlban cseréljük le a twm & a következőre: exec openbox Az XFCE4 telepítése, értelemszerűen: pkgin install xfce4 xinitrcben: exec xfce4-session LXDE telepítése indítása: pkgin install lxde vi /etc/X11/xinit/xinitrc exec lxsession Néhány beállítás: cp /usr/pkg/share/examples/rc.d/dbus /etc/rc.d/ echo rpcbind=YES >> /etc/rc.conf echo dbus=YES >> /etc/rc.conf /etc/rc.d/rpcbind start /etc/rc.d/dbus start ===== Bejelentkezés kezelő ===== Az alapértelmezett bejelentkezéskezelő a xdm. Engedélyezése tiltása a /etc/rc.conf fájlban lehetséges. xdm=YES # x11 display manager ===== Hálózat ===== ==== Hálózati eszközök ==== Hálózati eszközök listázása: ifconfig -l A hálózati eszköz, pcn0, bge0 vagy wm0 néven látjuk. A pcn0 hálózati eszköz beállításai: ifconfig pcn0 ==== Kapcsolat ==== Kapcsolat ellenőrzése: ping IP-cím ping hostnév ==== Gépnév ==== mcedit /etc/rc.conf hostname=iskolazo ==== Portok ==== Sokszor érdekes számunkra milyen portok vannak nyitva. === Netstat === netstat -a -f inet Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Adress State tcp 0 0 *.smtp *.* LISTEN udp 0 0 *.bootpc *.* === Lsof === pkg_add -v lsof lsof -i COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME dhclient 477 root 5u IPv4 0xc171df30 0t0 UDP *:bootpc master 1701 root 12u IPv4 0xc18869c4 0t0 TCP *:smtp (LISTEN) master 1701 root 13u IPv6 0xc1886dac 0t0 TCP *:smtp (LISTEN) ===== Bash ===== Az alapértelmezett shell a szimpla sh. Érdemes feltelepíteni a Bash shellt. Telepítés: pkgin install bash A telepítés helyét kérdezzük le: which bash A következőt kapjuk: /usr/pkg/bin/bash Az /etc/passwd és /etc/master.passwd fájlban beállíthatjuk alapértelmezett shellnek. ===== Midnight Commander ===== A **TERM** változó **wsvt25** értékre állítása nélkül NE indítsuk el a Midnight Commandert. Telepítés: pkgin install mc A MC használat során (például: F4), panaszkodik egy szintaktikai állomány hiányára. Az 1.6.x változatban nincs ilyen probléma. Másoljunk egyet a hiányolt helyre: cp /usr/pkg/etc/mc/syntax/Syntax /root/.mc/cedit/ ===== Postfix ===== A Postfix Fullinstall választva automatikusan telepszik. A 25-ös port azonban alapból nincs nyitva. Szerkesszük a /etc/postfix/master.cf állományt. Keressük meg a következő sort: #smtp inet n - n - - smtpd Vegyük ki a "#" karaktert a sor elől, majd indítsuk újra a postfixet: /etc/rc.d/postfix restart Állítsuk be postfixet, mert szinte semmi nincs beállítva. Például honnan fogadhat levelet: mydestination = gépnév, localhost ===== Apache ===== Telepítése: pkg_add -v apache A dokumentumok helye: /usr/pkg/share/httpd/htdocs/ Démonkezelő scriptet a helyére másoljuk: cp /usr/pkg/share/examples/rc.d/apache /etc/rc.d/ Utasítjuk a rendszert az apache elindítására, rendszerinduláskor: echo "apache=YES" >> /etc/rc.conf Állítsunk be egy szervernevet: echo "ServerName zold.and:80" >> /usr/pkg/etc/httpd/httpd.conf Az apache vezérlése ezek után: /etc/rc.d/apache start /etc/rc.d/apache stop /etc/rc.d/apache restart /etc/rc.d/apache status Így is újraindíthatjuk a szervert: kill -HUP `cat /var/run/httpd.pid` PHP pkg_add -v php-5.4.5 Vagy engedélyezem a PHP CGI-t: /usr/pkg/libexec/cgi-bin/php Vagy PHP modult. ===== Pure-FTPd ===== Telepítés: pkgin install pure-ftpd cp /usr/pkg/share/examples/rc.d/pure_ftpd /etc/rc.d/ echo "pure_ftpd=YES" >> /etc/rc.conf Vezérlés: /etc/rc.d/pure_ftpd start /etc/rc.d/pure_ftpd stop /etc/rc.d/pure_ftpd restart ===== Bind ===== Telepítés: pkgin install bind cp /usr/pkg/share/examples/rc.d/named9 /etc/rc.d/ chmod 0755 /etc/rc.d/named9 cp /usr/pkg/share/examples/rc.d/lwresd /etc/rc.d/ echo "named_chrootdir=/var/chroot/named" >> /etc/rc.conf ===== MySQL ===== Telepítés: pkgin install mysql-server Root jelszó: /usr/pkg/bin/mysqladmin -u root -p password 'titok' /usr/pkg/bin/mysqladmin -h 'hostname' -u root -p password 'titok' Indíthatóvá tétel: cp /usr/pkg/share/examples/rc.d/mysqld /etc/rc.d/ A rendszer újraindulása után is induljon: echo "mysqld=YES" >> /etc/rc.conf ===== MariaDB ===== pkgin install mariadb-server Rendszergazdai jelszó beállítása: /usr/pkg/bin/mysqladmin -u root -p password 'titok' /usr/pkg/bin/mysqladmin -h 'hostname' -u root -p password 'titok' cp /usr/pkg/share/examples/rc.d/mysqld /etc/rc.d/ echo "mysqld=YES" >> /etc/rc.conf (8.0-ban nem indul el) ===== Samba ===== pkgin install samba-4 A beállítások helye: /usr/pkg/etc/samba/smb.conf Az indításhoz másoljuk a helyére a init scripteket: cp /usr/pkg/share/examples/rc.d/nmbd /etc/rc.d/ cp /usr/pkg/share/examples/rc.d/smbd /etc/rc.d/ cp /usr/pkg/share/examples/rc.d/winbindd /etc/rc.d/ Ezek után már egyszer indítás/leállítás lehetséges: /etc/rc.d/nmbd onestart /etc/rc.d/winbindd onestart /etc/rc.d/smbd onestart /etc/rc.d/nmbd onestop /etc/rc.d/winbindd onestop /etc/rc.d/smbd onestop Ha újraindítás után is szeretnénk automatikusan indítani a szervert: nano /etc/rc.conf Írjuk a fájl végére: nmbd=YES winbindd=YES smbd=YES Ezek után használhatjuk a start, stop paramétereket: /etc/rc.d/nmbd start /etc/rc.d/winbindd start /etc/rc.d/smbd start /etc/rc.d/nmbd stop /etc/rc.d/winbindd stop /etc/rc.d/smbd stop Az ad/dc-hez szükséges: cp /usr/pkg/share/examples/rc.d/samba /etc/rc.d/ Az /etc/rc.conf végére: samba=YES Ezek után indítás: /etc/rc.d/nmbd start ==== AD/DC vagy szimpla megosztás ==== ActiveDirectory/Domain Controller használatához: /etc/rc.d/samba start Tradicionális egyszerű CIFS fájlmegosztás használatához: /etc/rc.d/nmbd start /etc/rc.d/winbindd start /etc/rc.d/smbd start ===== GUI ===== Billentyűzet kiosztás: setxkbmap hu Magyar ékezetes: pkgin install biznet-iso8859_2-1.0nb5 ===== Hasznos parancsok ===== A proctree fastruktúrában mutatja a folyamatokat szülő-gyermek viszonylatban: proctree Több információért használjuk a -h kapcsolót: proctree -h ===== Linkek ===== * http://www.netbsd.org/ (2015) * http://pkgin.net/ (2018; A pkgin csomagkezelő leírása) * https://www.netbsd.org/docs/guide/en/ (2018) * http://www.netbsd.org/docs/guide/en/netbsd.html (2018; Dokumentáció) * http://blog.netbsd.org/ (2018) * https://wiki.netbsd.org/the_netbsd_system_manager__39__s_manual/ (2018)