Hello all,

  I found it not very convenient to have root's home directory
as a part of rootfs - if I switch between different BEs, the
homedir changes back and forth. It also consumes space in the
snapshots, if a BE is cloned from a variant which had some
junk in this path.

  I know this is less relevant by default now that root is a
role, but it is still used as a user account by some, and it's
used as a user during repairs/single-user mode in particular.
The latter usage breaks if the home path defined in /etc/passwd
is not available (i.e. relocated to a pool that's not available
during single-user admin works).

  My shot at fixing the situation was this:

1) created dedicated dataset, i.e. rpool/export/home/root
   and transferred all contents of /root into it

2) created /root/.profile with this text:

# === /root/.profile
if [ x"$_SLASH_PROFILE" = x ]; then
        _SLASH_PROFILE=Y
        export _SLASH_PROFILE
        if [ -d /export/home/root ]; then
                HOME=/export/home/root
                cd $HOME
                export HOME
                /bin/test -s ./.profile && . ./.profile
        fi
        unset _SLASH_PROFILE
fi
# === /root/.profile

   The idea is that interactive shells would first interpret
   ~/.profile - and in case of the relocated home, switch
   into it transparently. Just in case, I tried to protect
   against loops such as including the /root/.profile from
   other profiles again - I've seen such practices in life :)

   This is hopefully portable across various shells, does
   work with bash and old Bourne Shell.

3) The entry in /etc/passwd still points to /root. The repair
   modes - if they don't mount the ZFS path with root's new
   home - can use /root/ to lay their little waste such as
   .bash_history; however for usual interactive use of root
   as a user account the home is persistent across all BEs.

Are there any fundamental drawbacks to such a tweak?
Any more variables to set/export when switching $HOME? ;)

Thanks, and hope this trick helps others,
//Jim


_______________________________________________
OpenIndiana-discuss mailing list
[email protected]
http://openindiana.org/mailman/listinfo/openindiana-discuss

Reply via email to