[OpenIndiana-discuss] Relocated root home directory

Sašo Kiselkov skiselkov.ml at gmail.com
Sat Feb 9 12:14:49 UTC 2013


On 02/09/2013 01:02 PM, Jim Klimov wrote:
> On 2013-02-09 12:44, Sašo Kiselkov wrote:
>> On 02/09/2013 02:52 AM, Jim Klimov wrote:
>>> 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
> 
>>> Thanks, and hope this trick helps others,
>>
>> What's with all the black magic?
>>
>> Why couldn't you simply do:
>>
>> # mv /root /root-old
>> # zfs create -o mountpoint=/root rpool/export/home/root
>> # chmod 700 /root
>> # /usr/gnu/bin/cp -ar /root2/* /root/
> 
> In fact, no I could not (and you're inconsistent with root2
> and root-old :) ).

Meh.

> Here's why: there are cases where the OS
> does use the nominal home for actual work - such as repairs
> and other single-user works, as well as cases where the home
> is on another pool and can't be mounted.

Worst thing is you won't get your precious home directory.

> As a result, the OS
> will work with /root and place some files there, rendering
> it an unviable mountpoint for ZFS auto-mounter for the actual
> relocated home - at least as long as there is no analog for
> "mount -O" enforcement via dataset properties to do overlay
> mounts over non-empty directories. And failure of dataset
> automounter leads to single-user mode and lack of service.

# umount /root
# chmod 500 /root
# zfs mount rpool/export/home/root

> Workarounds are still possible, such as setting rootfs's /root
> directory immutable,

Bingo.

> but I am not sure it would work under
> Solaris - (almost certainly) not in sol10u8.

Couldn't be bothered to test (my S10 boxes are running in production).

> Also, you might
> indeed want some files to be in the "repair-time" root home,
> such as some SSH keys

Why exactly would I want ssh keys in single user?

> or your bash aliases and history of repair commands, etc.

# mkdir /tmp/whatever
# zfs set mountpoint=/tmp/whatever rpool/export/home/root
# zfs mount rpool/export/home/root

If filesystems on your rpool are unmountable (and yet the system
booted), then you have a whole different heap of problems than "I want
my bash history". And locating /root on anything other than rpool is a
"Bad Idea(tm)".

Cheers,
--
Saso



More information about the OpenIndiana-discuss mailing list