OS X Users Folder On A Separate Partition Using bash Scripts and Casper Imaging

Keep user’s home folders separated from the system so a re-image will not destroy their data.

Requirements For This Walkthrough


  1. Users Icon


Why Do This?

Re-imaging a computer is often the fastest recovery method, but it is destructive because it erases everything.  Mounting the /Users  folder on a separate partition allows you to re-image a computer without destroying the user data.  This allows you to deploy the System partition without worrying about user settings.

Likewise, end-users can set things the way they want.  They can even keep their own ~/Applications  folder.  This separation or User and System integrates well with Apple’s methodology of resource domains.


  • Increased complexity because two partitions need to be managed
  • Users may run out of space based on what sizes were chosen for the partition
  • The System partition may run out of space based on what sizes were chosen for the partition



Marko Jung presented The College Challenge at the 2012 JNUC (and the similar presentation The Egg of Columbus in 2013).  I loved the concept but was not versed in Perl (language used for partitioning the disk), so I decided to try to make a bash version of the workflow.  It is not nearly as advanced and does not have a lot of error-checking, but I plan to improve this over time.

Conceptual Overview

  1. Erase/partition the disk with a bash script
  2. Deploy an /etc/fstab  file at imaging time
  3. Modify /etc/fstab  on the first boot after imaging with another bash script
  4. Change the icon to look like the normal /Users  folder so end-users don’t really know anything is different



Create the partition-disk.sh  Script

Below is the script to run before deploying the image.  It will partition the disk into three partitions: Macintosh HD, Users HD, and Recovery HD.  Adjust the disk sizes per your environment.

Create /etc/fstab

Using Casper Composer, capture a new package to capture the /etc/fstab  file as well as the /Users  folder icon, which will both be deployed at imaging time.  Use vifs  to edit /etc/fstab  with the following line:

LABEL=Users\040HD /Users hfs rw

This will mount the /Users  folder to a partition named exactly Users HD using HFS+ and making it read/write.  This file needs to be deployed before the image is applied.

Install the New /Users Icon

For the second part of the package, create a new folder to store the icon: /usr/local/imaging/users.icns .  Copy the icon into this folder.  This will be applied to the /Users  partition on first boot so that it looks like a regular folder. The icon I created just uses the normal icon with a little disk-slice badge on the bottom right.  From a distance, this looks like a normal folder to an end-user, but an admin will easily notice the badge, which will be an indicator that the workflow worked properly. usersicon

Create the package with Composer and save it as a .pkg.

Create A Script to Modify /etc/fstab

This script will tell the system to mount /Users  to the UUID of the Users HD partition.

Create A Script to Change the /Users Icon

This script will copy the icon deployed from the previous .pkg to the root of the /Users  partition.  This command works because it is a Volume and not a folder.  If it was just a folder, the process to change the icon is different.

Create the Workflow

This is what the Casper Imaging workflow looks like without any additional packages.



26 Replies to “OS X Users Folder On A Separate Partition Using bash Scripts and Casper Imaging”

  1. how do i edit the fstab file? I went to the location and its says fstab.hd. IS that the same? what program should i use?

        1. I suggest creating the file using sudo vi /etc/fstab (or whatever other command line text editor you like)–this will reduce the chance of extra information or weird characters from being added to the file Just ignore the fstab.hd file,

  2. I’m trying this out. I think I might be making a mess of things somewhere. My partitions are created and seem to be working ok. The icon does not change. And Users HD shows up where Users should be without being renamed and with a regular Hard Disk icon. Should the Recovery HD and Users HD be hidden from the desktop if this process runs correctly?

    1. I ran into this a lot when trying to figure it out. You need to have that initial /etc/fstab file deployed at imaging time. And then create it again with the first boot script.

      If run properly, the Users HD drive will not appear because it will be mounted to /Users. So if this part is not working, it would also explain why the icon is not changing. Also, to hide the Recovery HD, you will need to run a script like this:

      RecoveryHDName="Recovery HD"
      RecoveryHDID=`/usr/sbin/diskutil list | grep disk0 | grep "$RecoveryHDName" | awk 'END { print $NF }'`

      /usr/sbin/diskutil unmount /dev/"$RecoveryHDID"
      /usr/sbin/asr adjust -target /dev/"$RecoveryHDID" -settype Apple_Boot
      /usr/sbin/diskutil info /dev/"$RecoveryHDID"

  3. Thanks for your reply. That snippet of code hid the Recovery partition for me.

    The fstab is being deployed. Here is what the file looks like after booting up.

    UUID=48055134-FF83-3C84-9E81-8DF4FBEE669D /Users hfs rw 0 0

    and here is the diskutil info on the /Users Partition

    diskutil info /Users
    Device Identifier: disk0s3
    Device Node: /dev/disk0s3
    Part of Whole: disk0
    Device / Media Name: Users HD

    Volume Name: Users HD
    Escaped with Unicode: Users%FF%FE%20%00HD

    Mounted: Yes
    Mount Point: /Users
    Escaped with Unicode: /Users

    File System Personality: Journaled HFS+
    Type (Bundle): hfs
    Name (User Visible): Mac OS Extended (Journaled)
    Journal: Journal size 24576 KB at offset 0x657000
    Owners: Enabled

    Partition Type: Apple_HFS
    OS Can Be Installed: Yes
    Media Type: Generic
    Protocol: SATA
    SMART Status: Verified
    Volume UUID: 48055134-FF83-3C84-9E81-8DF4FBEE669D

    Total Size: 217.5 GB (217515376640 Bytes) (exactly 424834720 512-Byte-Blocks)
    Volume Free Space: 217.1 GB (217053548544 Bytes) (exactly 423932712 512-Byte-Blocks)
    Device Block Size: 512 Bytes

    Read-Only Media: No
    Read-Only Volume: No
    Ejectable: No

    Whole: No
    Internal: Yes
    Solid State: No

    It shows up in the Finder as Users HD inside the Macintosh HD window.

    Stumped but still trying

    1. So everything looks good there. But I think you might be missing the step where you deploy the original /etc/fstab file. Using Composer, capture the file as you make it. It should contain this content exactly:

      LABEL=Users40HD /Users hfs rw

      You should edit it using vifs to make sure it is error-free. Then, that file needs to be deployed immediately after deploying the base OS. Take a look at the Casper Imaging workflow screenshots to see what I mean.

  4. This still doesn’t work for me. I’m using Casper Imaging 9.3.2 . I’ve attempted this as part of a 10.8.5 and 10.7.5 workflow with the same results. The workflow order is the same as you show above with a 4th script to hide the recovery partition.I hope you could take a quick look Jacob and telling me if everything looks ok.

    My deploy fstab package looks like the image below fstab_pacifist

    My fstab file has the text as shown in the attached image fstab_text

    I’ve used the scripts directly from your github. https://github.com/jacobsalmela/users-folder-on-separate-partition

    And my end result is as shown below with a Users HD in the location where the Users folder should be end_result

    1. Did you see my last response to make sure your package with the file contains only this:

      LABEL=Users40HD /Users hfs rw

      That needs to be deployed first, and then you use the script to write to the same file again.

      Also, from your screenshot, I see that /usr (and maybe other files) are in your package. Those should be removed. The only thing in the package should be the /etc/fstab with the line mentioned above.

      Finally, you will want to make sure Casper is not partition the drive because we do this in the script.

  5. It doesn’t fit in with your bash philosophy, but OSX has a hidden setting for mounting a user’s directory on a different partition without using fstab. Go to System Preferences -> Users & Groups. Click on the lock icon and enter password. Right-click on a user’s name and select “Advanced Options”. You can now change the user’s home directory, login shell and other things. I’m sure there is a way to execute this via bash if the right file is found with the config.

    1. I have never tried, but I believe you can do this via dscl, but you are correct that it doesn’t fit the philosophy:

      dscl . -change Users/-- USERNAME NFSHomeDirectory CURRENTFOLDER NEWFOLDER

      The advantage of the fstab is that your new users will get created on the partition without any extra legwork.

      Thanks for the note!

  6. Hi Jacob,

    Do you know why, when re-imaging, the previous user accounts don’t import? Everything with fstab is working really well, but I’m missing this step. New accounts get created in the right place but kind of defeats the purpose if the old accounts don’t appear in Sys Prefs > Users. Thanks!!

    1. That is a good question. What versions of Imaging and OS X are you using? It’s been a while since I have done this, so I don’t quite recall…

      1. We’re on 9.65 for Imaging/JSS, using the latest build of OS X 10.10.3. Using AutoDMG and AutoCasper NBI. Thanks for the response!

        1. I last used it on 10.7, but just tried it out on 10.9.5 using 9.72 and it seemed to work.

          Are you using AD/OD accounts, or local ones? I looked at my old setup and I was just manually making the new user (use it mostly for staff computers). But I tried it out and you can use the jamf binary in a post-imaging script:

          jamf createAccount -username "biff_henderson" -realname "Biff Henderson" -password "password"

          Even though the command returns “directory already exists,” the user gets made appropriately and uses the existing home folder. You could also create a new user via bash:

          dscl . create /Users/biff_henderson
          dscl . create /Users/biff_henderson UserShell /bin/bash
          dscl . create /Users/biff_henderson RealName "Biff Henderson"
          dscl . create /Users/biff_henderson UniqueID 503
          dscl . create /Users/biff_henderson PrimaryGroupID 1000
          dscl . create /Users/biff_henderson NFSHomeDirectory /Users/biff_henderson
          dscl . passwd /Users/biff_henderson PASSWORD
          dscl . append /Groups/admin GroupMembership biff_henderson

          The line where you set the NFSHomeDirectory would be the user’s home folder.

          1. Just what I needed! We’re using local accounts until we transition fully to AD. Thanks!!!

  7. so i have a different use case and am wondering how much of any of this i need. We have loaner machines at our library and they are frozen with Deepfreeze. I want to be able to have users login and save data without losing anything. I cant use symlinks or hard links. So if i have another partition created that is visible how hard would it be to use your idea for mine?

    1. I haven’t used DeepFreeze, but from what I understand, it prevents modification to a disk or partiton, so in theory, you could use it as described in this post, and only freeze the System partition, leaving the User’s partition alone.

  8. Hi Jacob, I have been using this workflow in Casper very successfully for a year now. Thank you. I have been thinking recently about modifying the process for brand new macs and following a thin imaging rather than modular imaging path. Do you think it would be possible to start with a single partition > resize (shrink) that non-destructively > add the Users partition into the space created > make the fstab and icon changes > deploy apps and configuration changes ?? Any ideas how to modify your existing bash scripts to accomplish this? Any help at all would be much appreciated.

    1. I’m glad to hear it is still working!

      There is a diskutil command with a similar syntax to the commands in the scripts. Something like this:

      diskutil resizeVolume disk2s2 50G JHFS+ "Users HD" 450G

      would split the existing disk into two partitions–50GB for the System and then 450GB for the Users HD. I haven’t actually done this and the only hurdle I see would have to do with CoreStorage/Fusion drives as they add some technical roadblocks to the process. But it sure would be nice. I will definitely look into it more and let you know what I come up with.

Leave a Reply