大网数据广告活动
服务器运维问答

NFS home for multiple computers

· 52CE 我爱测

I'm here to ask something that is taking me a lot of time and now I don' t know how to continue, and this is a really big(and awesome) community. Well, the problem is that I'm trying to do a distributed Linux system for schools a…

问题原文

原帖链接 · Brokes · CC BY-SA 3.0

I'm here to ask something that is taking me a lot of time and now I don' t know how to continue, and this is a really big(and awesome) community.

Well, the problem is that I'm trying to do a distributed Linux system for schools and universities, It takes the SquashFS from an Apache server, the initrd and kernel loaded via TFTP and when it starts, it loads all the system in the RAM. The idea is to make as secure as possible, and when the computer turns off, all the data of the system is clean, but the problem is with the home folder...

The home folder is in a NFS server, and I'm trying to make different folder for each user, using the MAC address of the computer to create a folder in the NFS server and connect to it, but i don't know how to pass the MAC address on boot-time to create the folder in first time, and if the home folder of this MAC exists, connect to it, using fstab like now with a user-proof folder.

Thanks in advance!

已采纳解答

原帖链接 · user394646 · CC BY-SA 3.0

I've done a very similar thing for a MythTV system. Each diskless frontend machine netboots using DHCP PXE and TFTP. System is running Ubuntu 16.04 LTS. (IP 1.1.1.1 is the client machine and 2.2.2.2 is the server)

In /etc/dhcp/dhcpd.conf IP and hostname is assigned based on MAC:

group {
    use-host-decl-names on;  #forces hostname to host
    host bedroom {
        hardware ethernet 00:00:00:00:00:00;
        fixed-address 1.1.1.1;
    }
}

TFTP calls a mount script upon boot init, which mounts an NFS home based on the hostname. I used hostname for readability when browsing the folder structure; you could parse the MAC and use it for the folder name. TFTP pxelinux.cfg default file:

LABEL linux
  DEFAULT vmlinuz-4.4.0-53-generic root=/dev/nfs initrd=initrd.img-4.4.0-53-generic nfsroot=2.2.2.2:/pxeroot init=/boot/mountscript.sh ip=dhcp rw

mountscript.sh:

#!/bin/bash
HOSTNAME=`hostname`
MOUNT_OPTS="rw,intr,async,bg,tcp"
mount -t nfs 2.2.2.2:/path/to/homes/home-${HOSTNAME} /home -O MOUNT_OPTS

exec /sbin/init </dev/console >/dev/console 2>&1

Also, /etc/exports has NFS export settings which map the required home folder to the unique static IP address:

/path/to/homes/home-bedroom 1.1.1.1(rw,async,insecure)

New homes folder and the NFS export entries for each new machine must be added manually.

Please note: this example applies to single-use, single-user machines that store some unique configuration info (IR commands for the TV it's attached to, mostly) in the home folder. It achieves your stated goal of a home folder per MAC, but I suspect that home folder per user is what you're actually looking for as joeqwerty mentions. This solution would not allow a user to log into any machine, and would require home folders to be created per-user, per-machine. That also means that without a messy web of symlinks, there'd be no easy way to access the same files on different computers.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。