X

News, tips, partners, and perspectives for the Oracle Solaris operating system

Automounted Home Directory

Guest Author

If you're running a fresh installation of Solaris 11 Express (as opposed to an upgrade from OpenSolaris), you'll notice your home directory is now at the more appropriate /home/<username>, instead of /export/home/<username>.

bleonard@solaris:~$ pwd
/home/bleonard
bleonard@solaris:~$ grep bleonard /etc/passwd
bleonard:x:54324:1::/home/bleonard:/usr/bin/bash

In reality, the data for your home directory still resides at /export/home/<username>, it's just that the directory has been automounted for you at /home/<username>. This is configured in the file /etc/auto_home:

oracle@solaris:~$ cat /etc/auto_home 
#
# <license text removed>
#
# Home directory map for automounter
#
oracle  

localhost:/export/home/&
bleonard

localhost:/export/home/&
+auto_home

A big benefit of automating your home directory is that it now becomes very easy to relocate the location of the storage behind the directory. Say, for example, the rpool, in which the home directory is stored by default, starts running out of space. By changing the automount location, we can relocate our home directory to another disk, or even network attached storage (which would make it accessible from any instance of Solaris).

For this example I'm simply going to relocate my home directory to another disk I have available on the machine.

bleonard@solaris:~$ sudo format < /dev/null
Password:
Searching for disks...
Failed to inquiry this logical diskFailed to inquiry this logical diskdone
AVAILABLE DISK SELECTIONS:
0. c7d0 <ئ���Pp�nD ����pȅ��ئ���pp�n4"��� cyl 2607 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
1. c8d0 <ئ���Pp�nD ����pȅ��ئ���pp�n4"��� cyl 33416 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@1/cmdk@0,0
Specify disk (enter its number):

The new disk is c8d0 (I forget the reason why the output is messed up, but it gives me the information I need).

I'll create a new zpool using that disk:

bleonard@solaris:~$ sudo zpool create newpool c8d0
Password:

And then create a new file system for my home directory:

bleonard@solaris:~$ sudo zfs create -p newpool/home/bleonard 

Then copy my current home directory to its new location:

bleonard@solaris:~$ sudo cp -rp /export/home/bleonard /newpool/home 

The next step is to tell the automounter to use the new location as the backing store for my home directory by updating /etc/auto_home as follows:

bleonard@solaris:~$ grep bleonard /etc/auto_home 
bleonard

localhost:/newpool/home/&
 

Then reboot to re-establish the home directory at its new location:

bleonard@solaris:~$ sudo reboot
Password:

Now you can delete the old home directory in rpool, freeing up space:

bleonard@solaris:~$ sudo zfs destroy rpool/export/home/bleonard
Password:

For more information on the automounter, see the Task Overview for Autofs Administration.

Join the discussion

Comments ( 2 )
  • Mark J Musante Monday, February 14, 2011

    Better yet, rather than doing a zfs create/cp -rp operation, you can use zfs send | zfs recv


  • Bert JW Regeer Monday, February 14, 2011

    After the copying of the data, zfs unmount rpool/export/home/username, zfs set mountpoint=/export/home/username newpool/home/username, make sure everything is working correctly, then zfs destroy rpool/export/home/username.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.