解决Solaris下的/home问题

本文讨论了在OpenSolaris系统中如何正确配置用户目录映射的问题。通过使用automounter,可以实现在/export/home下的用户目录能够被正确地映射到/home下,解决了由于默认用户目录位置不同而引起的应用程序兼容性问题。
Hi.

We have many scripts which are hardcoded to use /home/httpd. This
folder have a svn-checkout, the scripts are executed as another user.
Coming from a FreeBSD background this is not a problem since all users
(except for root) by default are located beneath /home.

Ie. user foo relies on /home/httpd/bar to find fonts etc.

On solaris the default is to create an /export/home and then
dynamically locate the username relative to /home during login. But
this will not work since the files will be at /export/home/httpd
instead.

Can I circumvent this on opensolaris?

 ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

If I remember correctly, as long as automounter is running an entry in /etc/auto_home (before +auto_home) like

* localhost:/export/home/&

should do the trick.

×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

There are several different solutions to this.  Here's one discussion
that is on the first page of a google.com search:

  http://www.voiceworks.pl/cypromis/2007/06/10/the-magic-of-automounting-user-homedirectories-on-solaris/

It essentially suggests adding this to /etc/auto_home:

       httpd   localhost:/export/home/httpd

There are other ways to do this, though.  One is to remove the
auto_home references from /etc/auto_master and then either mount a new
file system directly over /home or use lofs to mount in a lower level
directory.


××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Thank you for yor reply. I added the entry to /etc/auto_home but it
did not do the trick unfortunately. /etc/auto_home looks like this:

+auto_home
* localhost:/export/home/&

I also switched those two entries, and rebooted each time. I'm running
opensolaris b70b.

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Did you restart the automounter ?

svcadm restart autofs

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Thank you for your reply. I also tried that as well as the other
suggestion that was posted to this thread. But httpd does not show up
in /home.

I added the entries to another test server and rebooted. These are the entries:

kilaasi 127.0.0.1:/export/home/kilaasi
claus 127.0.0.1:/export/home/claus

rozetta~%>pwd
/export/home/kilaasi

I'm using opensolaris b70b.

> There are other ways to do this, though.  One is to remove the
> auto_home references from /etc/auto_master and then either mount a new
> file system directly over /home or use lofs to mount in a lower level
> directory.

I will try that instead.

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Just tried but unfortunately it did not help.

rozetta~#>svcadm restart autofs
rozetta~#>ls -l /home
total 0

rozetta~#>ls -l /export/home
total 20
drwxr-x---   6 claus    staff        512 Oct 10 16:24 claus
drwxr-xr-x  16 kilaasi  staff       1024 Oct 10 16:41 kilaasi
drwx------   2 root     root        8192 Oct  4 10:58 lost+found

/etc/auto_master:
+auto_master
/net            -hosts          -nosuid,nobrowse
/home           auto_home       -nobrowse

/etc/auto_home:
+auto_home
kilaasi 127.0.0.1:/export/home/kilaasi
claus 127.0.0.1:/export/home/claus

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Hi Claus,

you have the "nobrowse" option to /home - which means ls /home will give nothing
(i.e. you can't browse it)  - you probably need to try /home/claus or
/home/kilaasi to see anything in /home.

HTH,

×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Nothing is supposed to show up; it's all on demand.

Try: ls -l /home/clause

×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

Thank you! :-)  You're right. So if I change /etc/auto_home to

+auto_home
* localhost:/export/home/&

I get

tape~#>ls -l /home
ls: error reading directory /home: No such file or directory
total 4

whenever I restart autofs. Doing a 'ls /home/claus' works. And adding
the entries one by one as 'claus localhost:/export/home/claus' also
works.

**************************************************************************************

Thank you for all who helped me in this matter.

The /home-mapping is in place, I have to manually to type 'ls
/home/foo'  to make it visible beneath /home. But as long as the
scripts work it will work out just fine.


**************************************************************************************


* localhost:/export/home/&
+auto_home

does the trick,  no reboot needed.
just restart the automounter after editing /etc/auto_home with

svcadm restart autofs
arvin@ubuntu:/home/tplink/PLATFORM$ git status On branch vine Your branch is up to date with 'origin/vine'. nothing to commit, working tree clean arvin@ubuntu:/home/tplink/PLATFORM$ df -h Filesystem Size Used Avail Use% Mounted on udev 5.8G 0 5.8G 0% /dev tmpfs 1.2G 3.2M 1.2G 1% /run /dev/sda5 393G 162G 211G 44% / tmpfs 5.9G 0 5.9G 0% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 5.9G 0 5.9G 0% /sys/fs/cgroup /dev/sda1 511M 4.0K 511M 1% /boot/efi tmpfs 1.2G 32K 1.2G 1% /run/user/1000 /dev/sr0 100M 100M 0 100% /media/arvin/CDROM /dev/sr1 2.6G 2.6G 0 100% /media/arvin/Ubuntu 20.04 LTS amd64 /dev/sda4 354G 140G 197G 42% /data arvin@ubuntu:/home/tplink/PLATFORM$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 800G 0 disk ├─sda1 8:1 0 512M 0 part /boot/efi ├─sda2 8:2 0 1K 0 part ├─sda3 8:3 0 32G 0 part [SWAP] ├─sda4 8:4 0 360G 0 part /data └─sda5 8:5 0 399.5G 0 part / sr0 11:0 1 99M 0 rom /media/arvin/CDROM sr1 11:1 1 2.5G 0 rom /media/arvin/Ubuntu 20.04 LTS amd64 arvin@ubuntu:/home/tplink/PLATFORM$ sudo fdisk -l /dev/sda Disk /dev/sda: 800 GiB, 858993459200 bytes, 1677721600 sectors Disk model: VMware Virtual S Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xab47bd6d Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 1050623 1048576 512M b W95 FAT32 /dev/sda2 1052670 838858751 837806082 399.5G 5 Extended /dev/sda3 838858752 905967615 67108864 32G 82 Linux swap / Solaris /dev/sda4 905967616 1660942335 754974720 360G 83 Linux /dev/sda5 1052672 838858751 837806080 399.5G 83 Linux Partition table entries are not in disk order. 为什么home目录迁移以后,没有节省根目录空间
最新发布
11-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值