ðŸ Archived View for technicalsuwako.moe ⺠blog ⺠nfsnetworksetup.gmi captured on 2024-08-31 at 12:32:12. Gemini links have been rewritten to link to archived content
â¬ ïž Previous capture (2024-08-18)
-=-=-=-=-=-=-
æçš¿æ¥ïŒ2024-08-16
2幎åãããããµãŒãã§ã©ãã©ãLinuxããOpenBSDã«ä¹ãæãå§ããæã«ãNFSãšãããã¡ã€ã«ã·ã¹ãã ãèŠã€ããŸããã
ãã£ãšãã®ããã°ãèªãã ããNFSã倧奜ããšç¥ã£ãŠããããããã
ä»æ¥ã®æçš¿ã§ã¯ãNFSãµãŒããšã¯ã©ã€ãšã³ãã®èšçœ®æ¹æ³ãæãæ§ãšæããŸãã
NFSãNetwork File SystemãïŒãããã¯ãŒã¯ãã¡ã€ã«ã·ã¹ãã ïŒã¯ãååã®éããããã¯ãŒã¯äžã§äœ¿çšåºæ¥ããã¡ã€ã«ã·ã¹ãã ã§ãã
ãããã¯ãŒã¯å ã®äžå°ããµãŒããšããŠæ©èœããä»ã®äžå°ãã¯ã©ã€ã¢ã³ããšããŠèšå®ããäºãåºæ¥ãŸãã
ããã«ãããUSBã¡ã¢ãªã䜿çšããããæ©å¯ææžãã¡ãŒã«ãã¯ã©ãŠãã¹ãã¬ãŒãžãåã¯ã€ã³ã¹ã¿ã³ãã¡ãã»ãŒãžã§éä¿¡ããçã®å±éºãªæ¹æ³ã䜿ããã«ãæ©æ¢°éã§ãã¡ã€ã«ããã€ãã£ãé床ã§éä¿¡ããäºãå¯èœã«ãªããŸãã
ããïŒïŒïŒã§ã¯ã8 TiBã®SSDãè€æ°æèŒããFreeBSDã®ã¯ãŒã¯ã¹ããŒã·ã§ã³ãNASãšããŠèšå®ãã次ã®æ§ãªéèŠãªããŒã¿ãä¿åããŠããŸãïŒ
ä¿åãµã€ãã§äœ¿ã£ãŠã¢ãŒã«ã€ããããŠã§ãããŒãž
ãããã®ãµãŒãã¹ã¯å šãŠè€æ°ã®OpenBSDãµãŒãã§çšŒåããŠããããããã®ãµãŒããåãNATå ã«ååšããçºãNASã«ã€ã³ã¿ãŒãããã¢ã¯ã»ã¹ãä»äžããäºãªããFreeBSDäžã®ãã£ã¬ã¯ããªãOpenBSDãµãŒãã«ç°¡åã«ããŠã³ãããäºãåºæ¥ãŸãã
ãã®çµæãFreeBSDäžã®ZFSã®ããã©ãŒãã³ã¹ãšããã¯ã¢ããæ©èœæ§ã®å©ç¹ã享åããªãããOpenBSDäžã®relaydãšhttpdã®ã»ãã¥ãªãã£ãšå®å®æ§ã確ä¿åºæ¥ããšãããæ£ã«çŸããç¶æ³ã§ãïŒ
ãããŠãå©çãçãŸãªãå人ãšããŠå€§éã®ããŒã¿ãä¿ååºæ¥ãçç±ã¯ãã©ãã ãããŒã¿ãä¿åããŠããæ¯æãã®ã¯é»æ°ä»£ãISP代ãåã³åºå®IP代ã ãã§ããããã®éé¡ã¯æ¯æåãã§ããçºã§ãã
Linuxã§ã¯ã«ãŒãã«ã§NFS察å¿ãæ瀺çã«æå¹ã«ããå¿ èŠãããïŒåã¯ããã±ãŒãžãããŒãžã£ãéããŠã«ãŒãã«ã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ããå¿ èŠãããïŒã®ã«å¯ŸããBSDç³»OSã§ã¯ããã©ã«ãã§å«ãŸããŠããçºããã®ã¬ã€ãã®çºã«äœããã€ã³ã¹ããŒã«ããå¿ èŠã¯ãããŸããã
ããããNASã«FreeBSDã䜿çšããçç±ã¯ãZFSãæšæºã§å¯Ÿå¿ãããŠããããã§ãã
ããFreeBSDã奜ãã§ãªããã°ãåãæ§ã«ZFSãããã©ã«ãã§ä»ããŠããIllumosç³»ã®ãã£ã¹ããªãã¥ãŒã·ã§ã³ã䜿ãäºãåºæ¥ãŸãã
Dragonfly BSDãšããéžæè¢ãããããã¡ãã¯HAMMER2ãæèŒãããŠããŠãHAMMER2ã察å¿ããå¯äžã®OSã§ããããŸãã
LinuxãNetBSDã«ãZFSã®å£åçãã€ã³ã¹ããŒã«åºæ¥ãŸããããã€ãã£ãã§ã¯ãªãã®ã§ãããŸãå§ãåºæ¥ãŸããã
Linuxã«ã¯BtrfsããããŸãããããã¯ZFSãåçŸããããšããå£åçã§ãCDDLã©ã€ã»ã³ã¹ã§ã¯ãªãã®ãç¹åŸŽã§ãã
CDDLããããIllumosãFreeBSD以å€ã§ã¯æ¡çšããã«ãã倧ããªçç±ã§ãã
äœããBtrfsã¯Red Hat補åã§ãããéå»ã«ãäœåºŠãèŠãããæ§ã«ãRed HatããåºãŠãããã®ã¯Linuxå šäœã«ãšã£ãŠçœé£ãšãªãäºãå€ãã§ãã
NFSãµãŒããèšå®ããåã«ãNFSããŒãã£ã·ã§ã³ã䜿çšããå šãŠã®ãŠãŒã¶ãŒãäœæãããŠãŒã¶ãŒåãUIDãGIDããŠã§ããµãŒããšäžèŽããäºã確èªããŠäžããã
äŸãã°ããŠã§ããµãŒãäžã§UIDãšGIDã1001ã®ãsuwakoããšãããŠãŒã¶ãŒãããŠãNASäžã§ãsuwakoããšãããŠãŒã¶ãŒã®UIDãšGIDã1002ã§ããå Žåãåã¯äž¡æ¹ã§UIDã1001ã§ããNASäžã§GIDã1002ã§ãŠã§ããµãŒããŒäžã§GIDã1001ã®å Žåãã¢ã¯ã»ã¹æš©éãšã©ãŒãçºçããŸãã®ã§ããã®ç¹ã«æ³šæããŠäžããïŒ
åãã«ãŒã¿ãèšå®ããŠãEthernetã«æ¥ç¶ãããåæ©æ¢°ã«åºå®ã®ããŒã«ã«IPã¢ãã¬ã¹ãå²ãåœãŠãæ§ã«ããŠäžããã
ã«ãŒã¿ã®DHCPãµãŒããIPã¢ãã¬ã¹ãå€æŽãããšããäºãã«æ¥ç¶ã§ããªããªãããŠã§ããµãŒããèªåããŠã³ããããŠããå ŽåãèŠã€ãããªãããŒãã£ã·ã§ã³ãæ¢ãããšããŠèµ·åãæ®ã©åºæ¥ãªããªããŸãã
ãããéåžžã«éèŠã§ãïŒ
ãŠãŒã¶ãŒãæ£ããäœæããã«ã¯ã次ã®ã³ãã³ãã䜿çšããŸãïŒ
$ pw groupadd suwako -g 1001 $ pw useradd suwako -g suwako -s /bin/csh -m -u 1001 -c "NFS User"
äœåŠãã®ãã£ã¬ã¯ããªãäœæããŸãïŒ
$ mkdir /zroot/www_data $ chown -R suwako:suwako /zroot/www_data
次ã«ããã£ã¬ã¯ããªã/etc/exportsãã¡ã€ã«ã«è¿œå ããŸãã
ãŠã§ããµãŒãã®IPã¢ãã¬ã¹ã192.168.0.106ã§ãããšä»®å®ããŸãã
åãè€æ°ã®æ©æ¢°ããããŠã³ãåºæ¥ãäºã瀺ãçºã«ãããŒãããœã³ã³ãè¿œå ããŸãããã
ããã§ã¯ãããŒãããœã³ã³ã®IPã¢ãã¬ã¹ã192.168.0.125ãšä»®å®ããŸãã
/zroot/www -alldirs -maproot=suwako:suwako 192.168.0.106 /zroot/www -alldirs -maproot=suwako:suwako 192.168.0.125
次ã«ã/etc/rc.confã§ãµãŒãã¹ãæå¹ã«ããŸãã
zfs_enable="YES" rpcbind_enable="YES" nfs_server_enable="YES" nfsd_flags="-u -t -n 6" mountd_enable="YES"
`nfsd_flags`ã®èª¬æã§ããã`-u`ã¯ãUDPã§æäŸãã`-t`ã¯ãTCPã§æäŸãã`-n 6`ã¯ã6ã€ã®ããŒã¢ã³ã䜿çšããããšããæå³ã§ãã
ãããã®ãã©ã°ãéžãã çç±ã¯ãåçŽã«ãã³ããŒãžã§äŸãšããŠäœ¿çšãããŠããããã§ãããå¿ èŠã«å¿ããŠãã©ã°ã調æŽããŠäžããã
次ã«ããµãŒãã¹ãèµ·åããŸãïŒ
$ service rpcbind start $ service nfsd start $ service mountd start $ service nfsd restart $ service mountd restart
ãµãŒãã¹ãèµ·ååŸã«nfsdãšmountdãåèµ·åããçç±ã¯ãæ£ããèµ·åé åºããŸã ããããªãçºãåäœç¢ºèªã®çºã«è¡ã£ãŠããŸãã
äœããrpcbindã¯èšå®å€æŽæã«åèµ·åããå¿ èŠã¯ãªããnfsdãšmountdã®ã¿åèµ·åãå¿ èŠã§ãã
次ã«ãåäœç¢ºèªãè¡ããŸãïŒ
$ showmount -e Exports list on localhost: /zroot/www 192.168.0.106 192.168.0.125
IPã¢ãã¬ã¹ã®é åºã¯é¢ä¿ãããŸããã
ãªã¹ãã«è¡šç€ºãããŠããã°ãããŒãã£ã·ã§ã³ã®ããŠã³ããæ©èœããäºã確èªåºæ¥ãŸãã
次ã¯ããŠã§ããµãŒãã§ããŠã³ããæ©èœããã楜ããéšåã§ãã
ãŸãã¯ãåãååãUIDãGIDãæã€æ°ãããŠãŒã¶ãŒãäœæããŸãã
$ groupadd -g 1001 suwako $ useradd -u 1001 -g 1001 -m -s /bin/ksh suwako
次ã«ããŠã§ããµãŒãäžã«ãã£ã¬ã¯ããªãäœæããŸãã
ããã¯ãŠã§ããµãŒããªã®ã§ã/var/www/htdocsã®äžã«çœ®ãã®ãæãçã«ããªã£ãŠããŸãã
$ mkdir -p /var/www/htdocs/076.moe/website_data $ chown -R suwako:suwako /var/www/htdocs/076.moe
次ã«ããã®æ°ãããã£ã¬ã¯ããªã«NFSããŒãã£ã·ã§ã³ãããŠã³ãããŸãããã
NASã®IPã¢ãã¬ã¹ã192.168.0.143ã§ãããšä»®å®ããŸãã
$ mount_nfs 192.168.0.143:/zroot/www /var/www/htdocs/076.moe/website_data
ããã§ãããŠã§ããµãŒãã§ã¯ãã®çºã«ãµãŒãã¹ãæå¹ã«ãããèµ·åãããããå¿ èŠã¯ãããŸããã
ãŠã§ããµãŒãã¯NASã®ã¯ã©ã€ã¢ã³ãã ããã§ãã
ãšã©ãŒãåºãªããã°ãããŠã³ãã¯æåããŠããŸãã
ãŠã§ããµãŒãã«ãã¡ã€ã«ã眮ãããããNASã«ãååšããããåã¯ãã®éã確èªããäºã§ç¢ºèªåºæ¥ãŸãã
ä»åŸãèªåããŠã³ããããå Žåã¯ã/etc/fstabãã¡ã€ã«ãç·šéããŸãããã
# ãã¡ã€ã«ã·ã¹ãã ããŠã³ããã€ã³ã FSé¡ RWãªãã·ã§ã³ <dump> <pass> 86c58f108204433b.b none swap sw 86c58f108204433b.a / ffs rw,wxallowed 1 1 192.168.0.143:/zroot/www /var/www/htdocs/076.moe/website_data nfs rw 0 0
ãã®ã¹ãããã¯å®å šã«ä»»æã§ãããå¥ã®OSãå¥ã®äœ¿çšäŸã説æããçºã«ç€ºããŠãããŸãã
ãŸããèªåã®ããŒãããœã³ã³äžã§HTMLããŒãžãçŽæ¥ç·šéããå€æŽãå³åº§ã«ãŠã§ããµã€ãã«åæ ãããã®ã«äŸ¿å©ã ãšæããããããã
ãããã®ããŒãããœã³ã³ã¯å®éã«ã¯OpenBSDãåãããŠããŸããããã®æçš¿ã®ç®çã®çºã«ã代ããã«Void LinuxãåäœããŠãããšä»®å®ããŸãã
é©ãäºã«ãAppleã®macOSã¯BSDç³»OSãšåæ§ã«ãããã©ã«ãã§NFSãå«ãŸããŠããŸãã
ãã®çºã貎æ¹ã®ãŠã§ããã¶ã€ããŒã3Dã¢ãŒãã£ã¹ãã®ååããLinuxãšåãæé ã«åŸãäºãåºæ¥ãŸãã
äœããäœãã€ã³ã¹ããŒã«ãããæå¹ã«ãããããå¿ èŠã¯ãããŸããã
å¯äžã®éãã¯ãmacOSã§ã¯OpenBSDãšåæ§ã«`mount_nfs`ã䜿çšåºæ¥ãŸãããLinuxã§ã¯`mount -t nfs`ã䜿çšããå¿ èŠãããç¹ã§ãã
`mount_nfs`ã¯ãUnixã§`mount -t nfs`ãšæžã代ããã«ãççž®ããæ¹æ³ã«éããŸããã
ããã¯ããŒãããœã³ã³ãªã®ã§ãUID 1001ããã³GID 1001ã®ãŠãŒã¶ãŒãšã°ã«ãŒããsuwakoããæ¢ã«ååšããŠãããšä»®å®ããŸãã
ååšããªãå Žåã¯ãOpenBSDãšåãã³ãã³ãã§ãŠãŒã¶ãŒãäœæåºæ¥ãŸãã
$ groupadd -g 1001 suwako $ useradd -u 1001 -g 1001 -m -s /bin/bash suwako
BSDç³»ã®OSãšã¯ç°ãªããæ®ã©ã®Linuxãã£ã¹ããã§ã¯NFS察å¿ãå¥éã€ã³ã¹ããŒã«ããããã«ãŒãã«ã§æå¹ã«ããå¿ èŠããããŸãã
Void Linuxã®å Žåã2ã€ã®ããã±ãŒãžãã€ã³ã¹ããŒã«åºæ¥ãŸãããäŸãã°CRUXã®å Žåã¯ãã«ãŒãã«ã§æåã§æå¹ã«ããŠããã³ã³ãã€ã«ããå¿ èŠããããŸãã
$ xbps-install nfs-utils sv-netmount
åèµ·åãå¿ èŠã«ãªãå¯èœæ§ãããã®ã§ããã®ç¹ã«æ³šæããŠäžããã
äœæ ãåãããŸããããOpenBSDãFreeBSDãmacOSãšã¯ç°ãªããLinuxã§ã¯NFSãåäœãããçºã«3ã€ã®ãµãŒãããŒã¢ã³ãæå¹ã«ããå¿ èŠããããŸãã
ãããããããçŸä»£ã®Linuxã§ã15幎åçšè¯ãã¯ãããŸããã
ã§ã¯ããµãŒãã¹ãæå¹ã«ããŸãããã
Void Linuxã¯runitã䜿çšããŠããã®ã§ããã®å Žåã¯æ¬¡ã®æ§ã«ããŸãã
$ ln -s /etc/sv/rpcbind /var/service $ ln -s /etc/sv/statd /var/service $ ln -s /etc/sv/netmount /var/service $ sv start statd rpcbind netmount
ããã§ããŠã³ãåºæ¥ãŸãã
$ mkdir -p /mnt/website $ chown -R suwako:suwako /mnt/website $ mount -t nfs 192.168.0.143:/zroot/www /mnt/website
èªåããŠã³ãããã«ã¯ãOpenBSDãŠã§ããµãŒããšåã/etc/fstabæ§é ã䜿çšåºæ¥ãŸãã
以äž