This shows you the differences between two versions of the page.
autofs [2017/08/10 21:46] |
autofs [2022/04/16 12:22] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | * http://en.wikipedia.org/wiki/Automounter | ||
+ | |||
+ | ===== AUTOFS ===== | ||
+ | |||
+ | <code> | ||
+ | host=nas | ||
+ | host=$(hostname) | ||
+ | host=$host.lan | ||
+ | dir=/local | ||
+ | |||
+ | |||
+ | # check working nfs setup | ||
+ | dpkg -L nfs-kernel-server || sudo apt-get install nfs-kernel-server nfs-common sudo | ||
+ | |||
+ | grep $host /etc/hosts || sudo $EDITOR /etc/hosts | ||
+ | |||
+ | grep $dir /etc/exports \ | ||
+ | || echo "$dir 192.0.0.0/255.0.0.0(rw,sync,no_root_squash,no_subtree_check)" | sudo tee -a "/etc/exports" | ||
+ | |||
+ | sudo exportfs -rv | ||
+ | # exporting 192.0.0.0/255.0.0.0:/local | ||
+ | |||
+ | sudo service nfs-kernel-server restart | ||
+ | |||
+ | ping -c 1 "$host" && sudo showmount -e $host && sudo showmount -a $host | ||
+ | |||
+ | sudo mkdir -p /mnt/tmp /etc/local/ | ||
+ | sudo mount -o nolock $host:$dir /mnt/tmp # TODO host.lan | ||
+ | sudo mount -o nolock $host:/mnt/host-$host-local /mnt/tmp # TODO | ||
+ | |||
+ | |||
+ | # install | ||
+ | dpkg -L autofs || sudo apt-get install autofs | ||
+ | sudo mkdir -p /etc/auto.master.d /mnt/nfs | ||
+ | echo "/mnt/nfs /etc/local/auto.nfs --ghost, --timeout=60" | sudo tee -a /etc/auto.master.d/nfs.autofs | ||
+ | |||
+ | # configure | ||
+ | cat<<EOF | sudo tee -a "/etc/local/auto.nfs" | ||
+ | |||
+ | #host-$host-local $host:/mnt/host-$host-local | ||
+ | host-$host-home -fstype=nfs,rw,intr $host:/mnt/host-$host-home | ||
+ | host-$host-local -fstype=nfs,rw,intr $host:/mnt/host-$host-local | ||
+ | host-$host-dir -fstype=nfs,rw,intr $host:$dir | ||
+ | |||
+ | EOF | ||
+ | |||
+ | # cd /mnt/nfs && ln -fs . mnt | ||
+ | |||
+ | sort /etc/local/auto.nfs | cut -d: -f 2 | sort | uniq | xargs -n 1 sudo mkdir -pv | ||
+ | |||
+ | # cd /mnt/nfs | ||
+ | # sort /etc/local/auto.nfs | grep -v '^#' | cut -d' ' -f 1 | sort | uniq \ | ||
+ | # | xargs sudo mkdir -p | ||
+ | |||
+ | |||
+ | sudo /etc/init.d/autofs restart | ||
+ | cd /mnt/nfs && ls | while read t ; do sudo rmdir -v /mnt/$t ; sudo ln -fsv "nfs/$t" "/mnt/$t" ; done | ||
+ | |||
+ | time ls /mnt/nfs/*/ | ||
+ | |||
+ | dmesg | ||
+ | |||
+ | root 26112 0.1 0.8 15664 1644 ? Ssl 14:45 0:00 /usr/sbin/automount --pid-file /var/run/autofs.pid | ||
+ | root 26282 0.0 0.4 4252 816 ? S 14:46 0:00 \_ /bin/mount -n -t nfs nas:/mnt/host-nas-local /mnt/nfs/host-nas-local | ||
+ | root 26283 0.0 0.9 3644 1712 ? S 14:46 0:00 \_ /sbin/mount.nfs nas:/mnt/host-nas-local /mnt/nfs/host-nas-local -n -o rw | ||
+ | root 26311 0.0 0.2 2260 556 ? S 14:46 0:00 \_ rpc.statd --no-notify | ||
+ | root 26322 0.0 0.7 2952 1452 ? Ss 14:46 0:00 \_ rpc.statd --no-notify | ||
+ | |||
+ | |||
+ | # TODO : check | ||
+ | model=$(sudo udevadm info /dev/sda | grep 'E: ID_MODEL=' | cut -d= -f2) | ||
+ | label=$model # TODO | ||
+ | |||
+ | cat<<EOF | sudo tee -a /etc/auto.master.d/ext-usb.autofs | ||
+ | /media/ /etc/local/auto.ext-usb --timeout=10,defaults,user,exec,uid=1000 | ||
+ | EOF | ||
+ | |||
+ | cat<<EOF | sudo tee -a /etc/local/auto.ext-usb | ||
+ | $label -fstype=auto :/dev/disk/by-label/$label | ||
+ | EOF | ||
+ | |||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
+ | ===== AUTOFS : YP ===== | ||
+ | |||
+ | echo $USER@$HOSTNAME | ||
+ | myuser@myhost | ||
+ | |||
+ | showmount -e nfsserver | grep myuser | ||
+ | /users/myuser myhost | ||
+ | |||
+ | dmesg | grep automount | ||
+ | |||
+ | Nov 22 14:14:31 localhost automount[[1022]]: >> | ||
+ | mount: nfsserver:/users/myuser failed, | ||
+ | reason given by server: Permission denied | ||
+ | Nov 22 14:14:31 localhost automount[[1022]]: | ||
+ | mount(nfs): nfs: mount failure nfsserver:/users/myuser on /home/myuser | ||
+ | Nov 22 14:14:31 localhost automount[[1022]]: failed to mount /home/myuser | ||
+ | |||
+ | cat /etc/auto.master | ||
+ | /home yp:auto.home | ||
+ | |||
+ | Problem was in [[DHCP]] and [[DNS]] . | ||
+ | |||
+ | |||
+ | ===== MORE ===== | ||
+ | |||
+ | @TaG: [[FS]] [[NFS]] [[mount]] [[SMB]] FusE FileSystem | ||
+ | |||
+ | {{https://i.chzbgr.com/completestore/12/10/3/QJa9c46YjUGGxc36uBeIZg2.jpg}} | ||
+ | |||
+ | <html> | ||
+ | <iframe width="560" height="315" src="https://www.youtube.com/embed/tdYbtidCYHM" frameborder="0" allowfullscreen></iframe> | ||
+ | </html> | ||