Posted on 04-12-2012 12:11 PM
Anyone got a script that will create an FSTAB file from UUID at imaging?
Or any hints on how to target the volume being imaged via script to write a file to it?
Solved! Go to Solution.
Posted on 12-13-2013 01:51 PM
Posted on 04-12-2012 12:45 PM
A little background?
Posted on 04-12-2012 01:05 PM
Sure.. kinda like the last 2 posts: https://jamfnation.jamfsoftware.com/discussion.html?id=78
i have this so far but am unsure how to get it to work at imaging:
#!/bin/sh
usersUUID=`diskutil info Users HD | grep Volume UUID: | awk '{print $3}'`
echo >> /private/etc/fstab "UUID=$usersUUID /Users hfs rw"
chown root /private/etc/fstab
chmod 755 /private/etc/fstab
Posted on 04-12-2012 01:11 PM
if you use your diskutil command to also find the /dev/disk0s? number of the disk
umount -f thefounddevice
diskutil mount thefounddevice and it should then use the fstab to mount at the new mount point
but... if you had stuff written to /Users or /Users/Shared you might want to rsync that to the other partition and clean it up before unmounting and mounting over the /Users directory.
Posted on 04-12-2012 01:39 PM
Hi Todd.. what??
I'd like this to run at imaging.. via the casper imaging app, any pointers?
Posted on 04-12-2012 02:40 PM
well if you make a script and put it in your configuration for your image, it will run whenever you tell it to.
expand on the script that bentoms put up get the device, rsync any data off the existing users directory to the other partition, unmount, remount and you should have it the way you want it.
I personally use the label to mount so when the computer boots it mounts the disk the first time at the right place and put the fstab file on the computer to start with. but that does create some problems when you target disk mode another computer with a userdata partition, it mounts right on top of the one you really want mounted so you have to think a little if using the label method.
Posted on 04-12-2012 03:12 PM
thanks Todd.. i am running the script at post 3 at imaging, the partitions exist yet it doesn't seem to work..
Do i need to to target the drive using $1 or something?
Like you mentioned about the the label name.. it's an issue we've come across. I'm not looking to rsync the data at this stage either.. just wishing to find a way to create the stab using us UUID via a script.
Posted on 04-12-2012 03:23 PM
well the script that you posted is right except you have to write to the disk you are imaging, not sure what the variable would be, if its in a package its $3
sorry i was not catching on that it was your script. if it were me it would probably be in a systemsetup package and then when it installed you would use $3 for sure.
and then your script would look like
#!/bin/sh
usersUUID=diskutil info Users HD | grep Volume UUID: | awk '{print $3}'
echo >> ${3}/private/etc/fstab "UUID=$usersUUID /Users hfs rw"
chown root ${3}/private/etc/fstab
chmod 755 ${3}/private/etc/fstab
Posted on 04-12-2012 03:26 PM
and you know i think fstab needs tabs between the elements...
so echo >> ${3}/private/etc/fstab "UUID=$usersUUID /Users hfs rw"
should be this:
echo >> ${3}/private/etc/fstab "UUID=$usersUUID /Users hfs rw"
Posted on 04-12-2012 03:30 PM
maybe the tabs is all i'm missing?.. cheers will test tomorrow.
Posted on 04-20-2012 02:25 PM
sadly, still not working.. it doesn't even seem that the script is writing the file to the right location... hmmm..
Script below, $1 variable comes from: https://jamfnation.jamfsoftware.com/article.html?id=146
#!/bin/sh
usersUUID=`diskutil info Users HD | grep Volume UUID: | awk '{print $3}'`
echo >> $1/private/etc/fstab "UUID=$usersUUID /Users hfs rw"
chown root $1/private/etc/fstab
chmod 755 $1/private/etc/fstab
Posted on 04-20-2012 04:37 PM
nvm.. looks like it's an order issue.. will try again monday..
Posted on 04-26-2012 08:37 AM
Think we needd that script promised by Oxford Uni at the user conf in London!
Posted on 05-04-2012 06:33 AM
i tried the script to run it with a launch daemon because my script does some stuff that root needs to do. Sadly it does tab correctly and looks like this
UUID=54AAB218-961C-300B-8CF0-E7ACD503A40B /Users hfs rw
But... if i delete the fstab and run the script manually, then everything works as expected.
Any ideas?
Posted on 05-04-2012 06:59 AM
a thought might be to put a default fstab file in your image with a package that has a line similar to this
UUID=XXXUUIDXXX /Users hfs rw
assuming those are tabs between the elements
then in your script
sed -i .bak -e "s/XXXUUIDXXX/$usersUUID/" /private/etc/fstab
Posted on 05-04-2012 07:07 AM
I've actually fudged it, just haven't posted yet!
Bascially, @ imaging i deploy a fstab that has the following:
LABEL=UsersHD /Users hfs rw
So on 1st boot all the Users HD partition gets mounted at /Users.
My post install policy contains the below which then updates the stab file with the UUID.
#!/bin/sh
usersUUID=`diskutil info Users HD | grep Volume UUID: | awk '{print $3}'`
echo >> /private/etc/fstab "UUID=$usersUUID /Users hfs rw"
chown root /private/etc/fstab
chmod 755 /private/etc/fstab
Seems ok after 10 macs :)
Posted on 05-04-2012 07:11 AM
cheers Ben i'll give it a go. Im really looking forward to this awesome masterpeace
Posted on 05-04-2012 08:43 AM
Hi Ben, please can you clarify if you run the script as a policy or as part of the first run script or do you add a post install script to the packaged fstab?
Posted on 05-04-2012 09:17 AM
Thanks guys you are utter utter geniuses. I can't thank you ever enough!
Posted on 05-06-2012 03:04 AM
Thanks guys this is what i started using below.
I needed some condition checks to make sure its a MacPro, with a Volume called RLUSERS and already has a fstab (from imaging).
Hope someone finds it useful
#!/bin/bash
# This script is used to make sure the users data is set to a separate HDD on a partition called RLUSERS for Mac Pro machines ONLY.
# This is to make things easier for machine rebuilds and disaster recovery. The user will not need to back up their data prior to a machine rebuild if this is in place.
# This works only with an existing fstab in the imaging process
############ Hardcoded variables are set here ##################
file=ls /etc/fstab
model=system_profiler | egrep Model Identifier | grep MacPro
hdd=system_profiler SPSerialATADataType | grep RLUSERS | cut -d: -f1
############ Do Not Modify Below This Line #####################
# Check to see if its a MacPro and fstab exists
if [ "${file}" ] && [ "${model}" ] && [ "${hdd}" ] ; then
# Move the Shared folder to RLUSERS
mv /Users/Shared/ /Volumes/"${hdd}"/Shared/
# Pause 10 seconds
sleep 10
# Make sure the volume RLUSERS is hidden
/usr/bin/SetFile -a V /Volumes/"${hdd}"
# Get the UUID of the Volume RLUSERS
usersUUID=diskutil info "${hdd}" | grep Volume UUID: | awk '{print $3}'
# Output the UUID to the fstab file
echo >> $1/private/etc/fstab "UUID=$usersUUID /Users hfs rw"
# Change the ownership of the file
chown root:wheel $1/private/etc/fstab
chmod 755 $1/private/etc/fstab
# Otherwise don't do anything
else
echo "Don't do anything conditions not met!"
fi
exit 0
Posted on 06-25-2012 07:39 AM
I agree it would be nice if the Oxford University guys posted their case study, as they did say that they would, and I'm sure it would be beneficial to many people. However, I reckon they are more likely to if you call them Oxford instead of Cambridge! I'll mail them and see if I can prompt a response on this.
'echo' is a little confusing on macs. Linux man pages will inform you of a '-e' option for including extended characters, which does actually work on macs even though it isn't mentioned in the mac man pages. Weirdly though, at least this is my experience, the 'root' account has '-e' by default, whilst other accounts don't!!!
So, if you aren't root, then
echo -e "Tab here" > /tmp/tabtest
otherwise if you are root, then
echo "Tab here" > /tmp/tabtest
Kinda odd!
Posted on 06-25-2012 09:48 AM
...However, this is better than relying on echo. Let the shell pass the tab to echo
echo "hello"$' '"jamfnation" > /tmp/tabtest
This means that it wont matter what version of echo you are using, who is logged in, etc. It will matter what shell type you are using though, for example this wont work in tcsh, but then neither will echo with or without a '-e' option!!!
But everyone uses bash....right! :)
Posted on 06-03-2013 10:52 AM
Rumors are that Apple may screw us over to not have any other internal drives in the new Mac Pros!
https://m.facebook.com/#!/story.php?story_fbid=618830514796717&id=432763186736785&__user=765435081
After everything everyone has done to do this as well! Bye bye redundancy, convenient lunchtime imaging without losing any user data!
Posted on 06-10-2013 01:49 PM
Sorry where was Cambridge mentioned?
Anyway all irrelevant now. Apple screwed us over with the new Mac Pros zero extra internal storage.
Bye bye fstab :(
http://www.apple.com/mac-pro/index1.html
Posted on 06-10-2013 02:11 PM
It's possible now and will still be possible in the future to create home directories on external storage without editing fstab.
Posted on 06-10-2013 08:29 PM
I can only see this a viable option now by having some kind of fixed and locked storage to desks. Just what I thought, more costs!
Also the whole point about the fstab is to trick the operating system in the event the machine needs a rebuild. The user comes back from lunch and its done, all automatically with no fiddling about.
I don't see how it is going to work now.
Posted on 06-10-2013 08:35 PM
Oh and because of our client security requirements we cannot and do not allow access to external media. Kinda screwed with the new model now!
Posted on 12-13-2013 01:51 PM
Posted on 12-13-2013 01:54 PM
@gregneagle How are you doing this? CoreStorage trickery? I know you can change a users folder location after the fact but it's a manual procedure in the user advanced options.