[SOLVED] netfs fails to mount samba mountpoint in fstab

Answer:  netfs fails to mount my samba mountpoint because eventhough
network is before netfs, and network is not started in the background, it
still seems to take a while to complete, but it doesn't block netfs from running.
If I put some stalling code in /etc/rc.d/network, and make it wait, then netfs
will mount the shares, because network was allowed to start and netfs can
it can find the servers.
Now, what I want to know is why my network starts up so slowly.
----------------------- Read thread for details ----------------------
This similar setup is working on my old Gentoo setup.
fstab
//tib/public /mnt/network/tib smbfs rw,user,auto,guest 0 0
tib resolves to a server on my LAN.
When I boot my ARCH system, it gets to netfs daemon, and times out trying to
access the server.  I get the message
5711: Connection to tib failed
SMB connection failed
The boot completes, and I log in and get the following
$ ping tib
PING tiburon.mill (192.168.0.36) 56(84) bytes of data.
64 bytes from tiburon.mill (192.168.0.36): icmp_seq=1 ttl=64 time=0.354 ms
64 bytes from tiburon.mill (192.168.0.36): icmp_seq=2 ttl=64 time=0.371 ms
and, I can mount it like this (which reads /etc/fstab)
$ mount //tib/public
$ ls /mnt/network/tib/ | wc -l
11
It seems like ARCH isn't able to use the network until sometime after this point in the boot.  Here's my rc.conf daemons
DAEMONS=(syslog-ng network netfs crond sshd alsa)
I tried putting netfs last, but that made no difference.  I also tried to load netfs in the background without benefit.
Note:  cifs doesn't work either; and I get more descriptive errors
:: Mounting Network Filesystems
mount error: count not find target server. TCP name tib/public not found
No ip address specified and hostname not found.
OK, that clear enough.  But, the hostname is found right when the boot process finishes and I get a prompt.
And, I've tried the ip address, and FQDN too.
Any ideas?
Last edited by ristretto (2007-07-24 05:04:57)

ok, gave it a try.
//tib/public /mnt/network/tib cifs rw,user,noauto,guest 0 0
$ cat /etc/rc.d/local
#!/bin/bash
mount //tib/public
$ grep DAE /etc/rc.conf
# DAEMONS
DAEMONS=(syslog-ng network netfs crond sshd alsa local)
Note local at the end.
Now, all the daemons load up quick, and then local goes and times out, and I
get the same error.
mount error: count not find target server. TCP name tib/public not found
No ip address specified and hostname not found.
putting mount in .bash_profile is a bit of a security issue (though not really on my setup)
but, more importantly, it mounts each time I log in to that account (say each ssh window to the box.)
I'm thinking it's a bug in the initialization process somewhere?  I've never had this problem on other distros.
What thinks you?

Similar Messages

  • [SOLVED] Arch failed to mount /boot

    Hey there,
    after my btrfs filesystem somehow got corrupted, so it would only mount my "/"-filesystem as read-only, I backed it up with rsync, recreated the partition and then transfered the data back. After that, I was unable to boot anymore with this error:
    [1.593560] systemd-fsck[306]: fsck.fat 3.0.27 (2014-11-12)
    [1.594292] systemd-fsck[306] /dev/sda1: 98 files, 43105/98304 clusters
    Mounting boot...
    [FAILED]Failed to mount /boot.
    See "systemctl status boot.mount" for details
    SystemD the prompted me with it's emergency mode, but this didn't react to any keyboard presses, so I couldn't check the exact error with sth. like journalctl -xb. I then booted a, today downloaded, Arch Live-CD and tried to access the logs via journalctl -b -D /var/log/journal/ didn't work out: It only had the logs from before the boot problem.
    With a bit of googling I figured a way of fixing this could be chrooting in and reinstalling initramfs, typing chroot errored out with:
    chroot: failed to run command /usr/bin/zsh: No such file or directory
    I tried commenting out /boot in fstab, but at booting something [FAILED] with Load Kernel Modules and I instantly got prompted with a blank, black screen with a "_" blinking in the top left corner, like a normal console, expect any prompt of any kind was missing and it didn't react to my keystrokes, similiar to SystemD's emergency mode
    So essentially two smaller problems with few google results are hindering me from solving my big problem.
    Thanks for any help in advance,
    Quanttek
    Last edited by Quanttek (2015-05-26 09:48:21)

    Head_on_a_Stick wrote:
    Quanttek wrote:I use plain "chroot". "chroot --help" works, but not chroot itself. I also tried to rebuild the symbolic link from the normal lib -> /usr/lib to /lib/* -> /usr/lib/* and it didnt work
    https://wiki.archlinux.org/index.php/Ch … ing_chroot
    Probably easier to use `arch-chroot` though:
    https://wiki.archlinux.org/index.php/Ch … rch-chroot
    Thanks. Using arch-chroot worked out. It is/was certainly no environment issue, I even tested it with both i386 and x86_64.
    I used it to reinstall mkinitcpio and to update my system, so now on boot I dont get a failure on mounting /boot anymore, but I still have problems with Load Kernel Modules.
    My screen now looks something like this: http://m.imgur.com/ATWHJoq
    Again it's not reacting to any keystrokes. I'll get some sleep now and will look tomorrow into getting some information from the journal logs.

  • [SOLVED]eCryptfs fails with mount: mount(2) failed: No such file or d

    Since some weeks back I cant seem to mount my eCryptfs stuff.
    Usually I just mounted my lvmdrive and did a:
    sudo mount /dev/sda1 /media/Olddrive;sudo ecryptfs-recover-private /media/Olddrive/home/.ecryptfs/user/.Private;sudo ecryptfs-recover-private /run/media/user/lvmdriveid/.ecryptfs/user/.Private
    Hit y,y [password] repeat and there it was, truly bob was my uncle.
    However, These days I get a:
    Inserted auth tok with sig [key] into the user session keyring
    mount: mount(2) failed: No such file or directory
    What have changed?
    *disclaimer: I might not be supersure about the exact " /media/Olddrive/home/.ecryptfs/user/.Private " as I fiddled a bit with it before I rebooted earlier today after a -Suy.
    Last edited by danielpublic (2014-11-01 10:23:35)

    Forgot to update, in any case I managed to access my data through the old manual way.
    cd /run/media/user/harddrive/.ecryptfs/user/.encryptfs
    sudo ecryptfs-unwrap-passphrase ./wrapped-passphrase
    sudo ecryptfs-add-passphrase --fnek
    Inserted auth tok with sig [aaaaaaaaaaaaaaaa] into the user session keyring
    Inserted auth tok with sig [bbbbbbbbbbbbbbbb] into the user session keyring
    sudo mount -t ecryptfs /run/media/user/harddrive/home/.ecryptfs/user/.Private /media/mountdir
    Used default settings execpt for:
    Enable filename encryption (y/n) [n]: y
    and of course inserted [bbbbbbbbbbbbbbbb] when asked:
    Filename Encryption Key (FNEK) Signature [aaaaaaaaaaaaaaaa]: bbbbbbbbbbbbbbbb

  • [SOLVED] Suddenly unable to mount samba share using cifs

    I have a home server running ArchLinux, hosting an SMB share. My client box is also ArchLinux, both are up to date, running Linux-ck 3.9.2-2-ck. Prior to rebooting both machines around twenty minutes ago, the share mounted fine for months.
    Here is the extent of the "verbosity" I receive from mount:
    mount error(13): Permission denied
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
    Here is my fstab:
    # /etc/fstab: static file system information
    # <file system> <dir> <type> <options> <dump> <pass>
    tmpfs /tmp tmpfs nodev,nosuid 0 0
    # UUID=71066ae2-40ec-4125-9db7-d04b6a04f712
    UUID=71066ae2-40ec-4125-9db7-d04b6a04f712 / ext4 rw,relatime,data=ordered 0 2
    # UUID=172faa6a-9cca-4d9e-a0b9-a5da3ea81922
    UUID=172faa6a-9cca-4d9e-a0b9-a5da3ea81922 /boot ext2 rw,relatime 0 2
    # UUID=65023815-33fc-4ebd-b245-65683201fbcf
    UUID=65023815-33fc-4ebd-b245-65683201fbcf /home ext4 rw,relatime,data=ordered 0 2
    UUID=1a23d461-fa2b-4ea4-8e58-e7efba3f3bed /media/Storage ext3 rw 0 2
    //ARRAY/Array /media/Array cifs credentials=/home/xaero/.smbpasswd,iocharset=utf8,uid=1000,gid=1000,nounix,sec=ntlm 0 0
    I have tried any number of different options on that final line defining this share now:
    I have tried //array/array (which is what it was originally) and //ARRAY/Array (which is case-sensitive) as well as any combination of using my credentials file (which used to work) or user=,pass= as well changing my credentials file to use quotation marks around my password as it has special characters. I've also read of using sec=ntlm fixing mount issues, but in my case it did not. I'm kind of scratching my head here as passing --verbose to mount yields zero additional information... the uid and gid entries were necessary in the past to mount this share, however I have tried both with and without them, to no avail.
    I rely on SMB in lieu of sshfs as there isn't a stable sshfs implementation for Windows users, which there are some on my network; I also find for whatever reason SMB happens to be faster.
    Last edited by Xaero252 (2013-05-19 21:45:30)

    I'm not exactly sure what fixed this... I looked at the configuration file to make sure I hadn't missed it being updated, and it was in the new format; everything setup correctly (I remember having to edit it not long ago to fix something, probably for the update which you mentioned) I reverted my fstab back to the way it was before (making backups is good) and restarted the smbd on the server numerous times... at some point it just started working again. I wish I had a more concrete answer for documentation sake, but I was literally just rebooting/restarting services in desperation with little to no config hacking between and suddenly things clicked. I'm also no longer running the sec=ntlm option..
    Thanks for reminding me to check my config though, when I updated I had forgotten to enable user restriction (guest was enabled, and certain directories weren't user-specific)

  • [SOLVED]dual boot-Failed to mount real root device

    Hello,
    Here is my drives partition info:
    /dev/sda1       2,949,122,048 3,907,028,991   957,906,944   7 NTFS / exFAT / HPFS
    /dev/sda2               2,048   901,117,951   901,115,904  83 Linux
    /dev/sda3    *    901,117,952 1,925,115,903 1,023,997,952   f W95 Extended (LBA)
    /dev/sda5         901,120,000   901,439,487       319,488  83 Linux
    /dev/sda6         901,441,536   905,648,127     4,206,592  82 Linux swap / Solaris
    /dev/sda7         905,650,176 1,925,115,903 1,019,465,728  83 Linux
    /dev/sda4       1,925,115,904 2,949,122,047 1,024,006,144   7 NTFS / exFAT / HPFS
    /dev/sdb1               2,048     2,099,199     2,097,152  83 Linux
    /dev/sdb2           2,099,200    53,299,199    51,200,000  83 Linux
    /dev/sdb3          53,299,200    73,779,199    20,480,000  83 Linux
    /dev/sdb4          73,779,200   224,673,791   150,894,592   7 NTFS / exFAT / HPFS
    I installed Opensuse 12.1 on /dev/sda5. It is booting with Grub, working with no problems. The computer boots directly to Grub menu.
    THEN, I installed Arch linux (last release) on both sda and sdb following these mounting points:
    /dev/sdb1 mounted as /boot  Ext2
    /dev/sdb2 mounted as /   BTRFS
    /dev/sdb3 mounted as /usr  BTRFS
    /dev/sda2 mounted as /home  BTRFS
    Intstallation went smooth until the end. Installed the bootloader.
    Now, I am trying to configure GRUB to boot Arch.
    Here is what I added on /boot/grub/menu.lst, in sda5 under Opensuse:
    title Arch Linux  [/boot/vmlinuz-linux]
        root (hd1,0)
        kernel /vmlinuz-linux root=/dev/sdb1 ro
        initrd /initramfs-linux.img
    In Opensuse, i can check that vmlinux and grub/menu.lst are indeed in /dev/sdb1
    My /etc/fstab is on /dev/sdb2
    =============================== sdb2/etc/fstab: ==========
    # /etc/fstab: static file system information
    # <file system>    <dir>    <type>    <options>    <dump>    <pass>
    tmpfs        /tmp    tmpfs    nodev,nosuid    0    0
    /dev/sda2 /home btrfs defaults 0 1
    /dev/sdb1 /boot ext2 defaults 0 1
    /dev/sdb2 / btrfs defaults 0 1
    /dev/sdb3 /usr btrfs defaults 0 1
    With this parameters, i got an message error when booting Arch:
    Mounting /dev/sdb1 on /new_root failed: no such device.
    Error : failed to mount the real root device.
    So, at busybox prompt, I tried this command line :
    ramfs # mount -t ext2 /dev/sdb1
    Got an error : Can't read /etc/fstab
    I tried too to give a uuid adress to sdb1 in my menu.lst file, but it didn't change anything, so I am sure partition number is correct.
    It seems to me in fact that GRUB can't find fstab.
    Two questions :
    -Would it be better in fact to use only 1 GRUB file for both systems? If yes, shall I keep only the grub config from Opensuse?
    -What do I wrong with Arch booting? Why can't I boot Arch?
    EDIT :1- just realised there is no BOOT flag in my partiton table on /dev/sdb.
                2- root is on /dev/sdb2, not sdb1.
    1-I toggled my first partition bootable using fdisk
    2-changed root to point to /dev/sdb2
    Now booting into Arch login
    Last edited by gabx (2011-11-22 22:33:09)

    It was a very simple problem. I used the wrong uuid for my /
    Correct entry in 40_custom is:
    #!/bin/sh
    exec tail -n +3 $0
    # This file provides an easy way to add custom menu entries. Simply type the
    # menu entries you want to add after this comment. Be careful not to change
    # the 'exec tail' line above.
    menuentry "Arch Linux uuid" {
    insmod part_msdos
    insmod ext2
    search --fs-uuid --no-floppy --set=root 8516fa60-0d45-4f33-b269-817c5290f6cc
    linux /vmlinuz26 root=/dev/disk/by-uuid/9f32e668-2548-4ed4-a10b-3fbea66a6d95 ro vga=775
    initrd /kernel26.img
    Now the boot is working great. Next thing was that my /home and swap was not detected.
    That was simply because /etc/fstab was still using /dev/sda etc naming. changing  that to uuid solved that part as well.
    To use uuid all the way and of cause the correct one solved everything
    /Christer
    Last edited by agkbill (2011-07-15 16:00:30)

  • [solved] netfs/sshfs failing on boot

    ok I seem to have a very weird problem and I can not for the life of me figure out a solution.
    I have ssh setup with rsa authentication, I am mounting the sshfs share in fstab according to the wiki.
    [email protected]:torrents/ /mnt/desktop fuse defaults,users,port=22000,reconnect,allow_other 0 0
    On boot netfs fails with the error
    Connection reset by peer.
    But if I let kde finish loading and start a terminal and type in
    /etc/rc.d/netfs start
    it mounts just fine. This is where I don't understand why it will not mount when booting. Because I can not replicate the error once the machine is fully booted. I even tried the sleep 20 trick in netfs.
    my daemon array looks like this.
    DAEMONS=(syslog-ng acpid cpufreq crond hal !net-profiles net-auto-wireless rpcbind nfs-common oss fam sshd ntpd !avahi-daemon netfs)
    Any idea is worth a shot so please amuse me
    Solution: Delete the /root/.ssh/known_hosts file and then re-authenticate the host machine for root user locally. My known_hosts had two entries and the first entry was not available on the network. I assume this is the reason why netfs was failing. The rsa key of the only working host was the exact same before and after in the known_hosts file.
    Last edited by jacko (2009-12-29 16:16:56)

    After booting "swapon -s" give me:
    Filename Type Size Used Priority
    /dev/sda3 partition 8388604 0 -1
    So I assume that the swap partition is actually mounted and activated. However, resuming from hibernation always results in output which says "clearing orphan nodes." I know it has something to do with the swap because I was able to get resume to work by activating swap after I manually mounted swap after booting. I can't remember the exact process I used, whether it be through systemctl or swapon. I will see if I can get figure it out again.

  • [SOLVED] Initramfs fails to properly mount luks partition

    Hello All,
    As I foreshadowed in my intro, I'm having trouble getting encrypted Archlinux to work on my Acer Aspire 5750. I've previously had encrypted Debian Netinst and encrypted Aptosid working on this device. The arch iso I'm using is 2011.08.19-core-i686.
    https://bbs.archlinux.org/viewtopic.php?id=124415 appears similar and Tallahassee offers a workaround, but it doesn't work for me (unless I'm doing something wrong?)
    I suspect there is a bug in the init scripts used by the initramfs. I would like to first of all determine whether I really should file a bug report (and if so where), and secondly whether we can find a workaround to get things up and running in the meantime.
    Now for the meaty bits.
    Old grub doesn't appear to support lvm or luks, so I first of all prepare for grub 2 by installing the gptfdisk package into the iso environment. I use gdisk to set up a 1 or 2 mb bios boot partition at the start of /dev/sda, followed by a 256mb partition (/dev/sda2) for /boot, with the rest of the drive given to the partition intended for the encrypted root partition (/dev/sda3).
    I use cfdisk to toggle the partition type for /dev/sda3 to 8e (Linux LVM).
    Run the following commands, with credits to Aptosid: Installing to a Cryptroot:
    pvcreate /dev/sda3
    vgcreate vg /dev/sda3
    lvcreate -n crypt --extents 100%FREE vg
    cryptsetup --verify-passphrase -c aes-xts-plain:sha512 luksFormat /dev/mapper/vg-crypt
    cryptsetup luksOpen /dev/mapper/vg-crypt cryptroot
    pvcreate /dev/mapper/cryptroot
    vgcreate cryptvg /dev/mapper/cryptroot
    lvcreate -n swap --size 2g cryptvg
    lvcreate -n root --extents 25%FREE cryptvg
    lvcreate -n home --extents 100%FREE cryptvg
    /arch/setup
    Go through the arch setup as normal. At the bit where you configure hard-drives, you'll find all your encrypted partitions ready waiting to be labelled and formatted. Stop after installing packages.
    After installing packages, press CTL-ALT-F2 and log in. Edit /mnt/etc/rc.conf and /mnt/etc/mkinitcpio.conf. CTL-ALT-F1 and reinstall packages. Proceed with the configure step.
    Don't install a boot loader; just quit after configuring everything.
    Follow the steps here: Grub 2 During Archlinux Installation.
    The automatically generated grub.cfg doesn't include things necessary to lvm and luks. Before running grub_bios-install, I edit the grub.cfg to insmod lvm and flag the kernel with cryptdevice=/dev/mapper/vg-crypt:cryptvg-root and rootfstype=ext4 (because that is the encrypted root's filesystem).
    At this point, I would expect the system to be bootable, so reboot.
    Grub2 loads up. I can verify the changes I made to grub.cfg by pressing `e'. So boot and see the messages,
    Loading Linux linux ...
    Loading initial ramdisk ...
    A password is required to access the cryptvg-root volume:
    Enter passphrase for /dev/mapper/vg-crypt:
    So far so good. I enter my passphrase. The following messages ensue:
    vgscan: unrecognized option '--sysinit'
    Error during parsing of command line.
    device-mapper: create ioctl failed: Device or resource busy
    mount: mounting /dev/mapper/cryptvg-root on /new_root failed: Device or resource busy
    ERROR: Failed to mount he real root device.
    Bailing out, you are on your own. Good luck.
    So I get dumped into the ramfs. That ain't much fun.
    Does anyone have some ideas on things to try next? Should I file a bug report?
    Last edited by /dev/zero (2011-10-22 00:28:52)

    Not sure what you mean by difficult and buggy to work with... at this low level, if a VM is having issues replicating this sort if thing, it's not a very useful VM. Find one that doesn't suck. I tend to use KVM because it's terminal friendly via emulation of a serial console.
    Anyways, I can reproduce your issue and fix it. There's 2 things you'll need to change:
    1) You're naming your unlocked cryptdevice the same thing as your root. That's creating a clash with the name you've given your root logical volume. Since the name isn't really important, just change your cryptdevice declare to "cryptdevice=/dev/mapper/vg-crypt:root"
    2) Since you're doing the xzibit thing and nesting lvm inside of the crypt device (i still think its really bizzare to do this, but it looks like mkinitcpio supports it anyways), you'll need to add the lvm2 hook a second time to HOOKS in /etc/mkinitcpio.conf after the encrypt hook.
    Last edited by falconindy (2011-10-22 00:19:10)

  • [Solved] Failed to mount /boot/efi

    Hi,
    Recently I've been having a lot of trouble starting Arch Linux. As in I can't. It starts off fine, but then whike it tries to mount my disks I get this problem:
    systemd-fsck[159]: fsck.fat 3.0.23 (2013-10-15)
    systemd-fsck[159]: /dev/sda5: 111 files, 6783/130048 clusters
    [ OK ] Started File System Check on /dev/disk/by-uuid/6AE1-65C8.
    Mounting /boot/efi...
    [ FAILED ] Failed to mount /boot/efi.
    See 'systemctl status boot-efi.mount' for details.
    [ DEPEND ] Dependency failed for Local File Systems.
    Welcome to emergency mode! After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" to try again
    to boot into default mode.
    This is the output of systemctl status boot-efi.mount:
    boot-efi.mount - /boot/efi
    Loaded: loaded (/etc/fstab)
    Active: failed (Result: exit-code) since Sun 2013-12-01 17:40:58 EST; 4min 16s ago
    Where: /boot/efi
    What: /dev/disk/by-uuid/6AE1-65C8
    Process: 179 ExecMount=/bin/mount /dev/disk/by-uuid/6AE1-65C8 /boot/efi -t vfat -o rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro (code=exited, status=32)
    Dec 01 17:40:58 jay-archlinux systemd[1]: boot-efi.mount mount process exited, code=exited status=32
    Dec 01 17:40:58 jay-archlinux systemd[1]: Failed to mount /boot/efi
    Dec 01 17:40:58 jay-archlinux systemd[1]: Unit boot-efi.mount entered failed state.
    The output of mount /dev/disk/by-uuid/6AE1-65C8 /boot/efi -t vfat:
    mount: unknown filesystem type: 'vfat'
    (When I first started getting this it told me dosfstools wasn't installed. However I've since installed the latest version and it's made no difference.
    I dual boot Arch Linux and Windows 8 on a laptop under UEFI, and have had this setup for about a year now. This problem seems like it may be associated with recent problems I've been having with windows 8 (Spontaneously restarting itself 2 or 3 times a day with a BSoD and "Kernel Data Inpage Error".) One time after such a restart I went to boot Arch Linux after the restart rather than Windows and got errors similar to the one I first posted, except that they were occurring with my Windows NTFS partitions which I mount in Arch Linux. After booting into Windows and restarting manually, the error just became what it is now. However I'm not sure if this was where the problem first began or not as I haven't used Arch Linux very often over the past few months.
    Does anyone have any idea what's going on or how to fix it?
    Thanks.
    Last edited by jdgordon01 (2013-12-01 14:05:59)

    pacman -Q linux
    linux 3.11.6-1
    uname -a
    3.9.9-1-ARCH #1 SMP PREEMPT Wed Jul 3 22:45:16 CEST 2013 x86_64 GNU/Linux
    No idea how that's happened... I initially tried 'mkinitcpio -p linux' but it also did nothing.
    EDIT: Turns out I must have updated at some point and forgotten a crucial step in manually copying the new files in /boot/ to /boot/efi/EFI/arch/ which is necessary when updating under UEFI systems. I updated again using the live USB/chrooting, manually copied everything that was needed and everything's working again!
    Last edited by jdgordon01 (2013-12-01 14:05:35)

  • System Image Utility "volume on diskxsx failed to mount"

    I've been trying to create a NetRestore image using System Image Utility (SIU) for the past couple of days, but no matter what I do it fails.  I was oringally using OSX 10.8.4, but have now upgraded to 10.8.5.
    After reading through the logs, I can see SIU fails whilst it's trying to mount the volume.  Has anyone else had this issue, and if so, were you able to fix it?
    I also noticed the "Create image of /Volume/Macintosh HD/" function stops at 48% instead of 100%.  Is that normal?
    Below is a copy of the log that SIU produced.
    Starting image creation.
    Workflow Started (2013-09-24 08:41:36 +0100)
    OS X Server 10.8.5 (12F37), System Image Utility 10.8.3 (624)
    Starting action: Define Image Source (1.4)
    Finished running action: Define Image Source
    Starting action: Create Image (1.7.2)
    Starting image creation process...
    Create NetRestore Image
    Initiating NetRestore from installed volume.
    progressPrefix="_progress"
    ++ progressPrefix=_progress
    scriptsDebugKey="DEBUG"
    ++ scriptsDebugKey=DEBUG
    imageIsUDIFKey="1"
    ++ imageIsUDIFKey=1
    imageFormatKey="UDZO"
    ++ imageFormatKey=UDZO
    mountPoint=""
    ++ mountPoint=
    ownershipInfoKey="501:20"
    ++ ownershipInfoKey=501:20
    blockCopyDeviceKey="0"
    ++ blockCopyDeviceKey=0
    dmgTarget="NetInstall"
    ++ dmgTarget=NetInstall
    potentialRecoveryDevice="disk4s3"
    ++ potentialRecoveryDevice=disk4s3
    asrSource="ASRInstall.pkg"
    ++ asrSource=ASRInstall.pkg
    destPath="/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi"
    ++ destPath='/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi'
    skipReorderingKey="0"
    ++ skipReorderingKey=0
    sourceVol="/Volumes/Macintosh HD"
    ++ sourceVol='/Volumes/Macintosh HD'
    postInstallHelperKey="1"
    ++ postInstallHelperKey=1
    . "${1}/createCommon.sh"
    + . /tmp/niutemp.rDvE48RI/createCommon.sh
    # createCommon.sh
    # Common functionality for the Image creation process.
    # sourced in by the various SIU scripts
    # Copyright © 2007-2012 Apple Inc. All rights reserved.
    # Using dscl, create a user account
    AddLocalUser()
    # $1 volume whose local node database to modify
    # $2 long name
    # $3 short name
    # $4 isAdminUser key
    # $5 password data
    # $6 password hint
    # $7 user picture path
    # $8 Language string
    local databasePath="/Local/Default/Users/${3}"
    local targetVol="${1}"
    # Find a free UID between 501 and 599
    for ((i=501; i<600; i++)); do
    output=`/usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -search /Local/Default/Users UniqueID $i`
    # If there is already an account dscl returns it, so we're looking for an empty return value.
    if [ "$output" == "" ]; then
    break
    fi
    done
    # Create the user record
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -create $databasePath
    if [ $? != 0 ]; then
    echo "Failed to create '${databasePath}'."
    return 1
    fi
    # Add long name
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath RealName "${2}"
    if [ $? != 0 ]; then
    echo "Failed to set the RealName."
    return 1
    fi
    # Set up the users group information
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath PrimaryGroupID 20
    if [ $? != 0 ]; then
    echo "Failed to set the PrimaryGroupID."
    return 1
    fi
    # Add some additional stuff if the user is an admin
    if [ "${4}" == 1 ]; then
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append "/Local/Default/Groups/admin" GroupMembership "${3}"
    if [ $? != 0 ]; then
    echo "Failed to add the user to the admin group."
    return 1
    fi
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append "/Local/Default/Groups/_appserveradm" GroupMembership "${3}"
    if [ $? != 0 ]; then
    echo "Failed to add the user to the _appserveradm group."
    return 1
    fi
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append "/Local/Default/Groups/_appserverusr" GroupMembership "${3}"
    if [ $? != 0 ]; then
    echo "Failed to add the user to the _appserverusr group."
    return 1
    fi
    fi
    # Add UniqueID
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath UniqueID ${i}
    if [ $? != 0 ]; then
    echo "Failed to set the UniqueID."
    return 1
    fi
    # Add Home Directory entry
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath NFSHomeDirectory /Users/${3}
    if [ $? != 0 ]; then
    echo "Failed to set the NFSHomeDirectory."
    fi
    if [ "${6}" != "" ]; then
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath AuthenticationHint "${6}"
    if [ $? != 0 ]; then
    echo "Failed to set the AuthenticationHint."
    return 1
    fi
    fi
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath picture "${7}"
    if [ $? != 0 ]; then
    echo "Failed to set the picture."
    return 1
    fi
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -passwd $databasePath "${5}"
    if [ $? != 0 ]; then
    echo "Failed to set the passwd."
    return 1
    fi
    # Add shell
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath UserShell "/bin/bash"
    if [ $? != 0 ]; then
    echo "Failed to set the UserShell."
    return 1
    fi
    # Create Home directory
    if [ -e "/System/Library/User Template/${8}.lproj/" ]; then
    /usr/bin/ditto "/System/Library/User Template/${8}.lproj/" "${targetVol}/Users/${3}"
    else
    /usr/bin/ditto "/System/Library/User Template/English.lproj/" "${targetVol}/Users/${3}"
    fi
    if [ $? != 0 ]; then
    echo "Failed to copy the User Template."
    return 1
    fi
    /usr/sbin/chown -R $i:$i "${targetVol}/Users/${3}"
    if [ $? != 0 ]; then
    echo "Failed to set ownership on the User folder."
    return 1
    fi
    # Copies a list of files (full paths contained in the file at $1) from source to the path specified in $2
    CopyEntriesFromFileToPath()
    local theFile="$1"
    local theDest="$2"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    while read FILE
    do
    if [ -e "${FILE}" ]; then
    local leafName=`basename "${FILE}"`
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Copying ${FILE}."
    fi
    /usr/bin/ditto $opt "${FILE}" "${theDest}/${leafName}" || return 1
    fi
    done < "${theFile}"
    return 0
    # Copies a list of packages (full path, destination pairs contained in the file at $1) from source to .../System/Installation/Packages/
    CopyPackagesWithDestinationsFromFile()
    local theFile="$1"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    while read FILE
    do
    if [ -e "${FILE}" ]; then
    local leafName=`basename "${FILE}"`
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Copying ${FILE}."
    fi
    read SUB_PATH
    /usr/bin/ditto $opt "${FILE}" "${mountPoint}/Packages/${SUB_PATH}${leafName}" || return 1
    fi
    done < "${theFile}"
    return 0
    # Create an installer package in ${1} wrapping the supplied script ${2}
    CreateInstallPackageForScript()
    local tempDir="$1"
    local scriptPath="$2"
    local scriptName=`basename "${scriptPath}"`
    local entryDir=`pwd`
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Create installer for script ${scriptName}"
    opt="-v"
    fi
    # shouldn't exist on entry...
    if [ -e "${tempDir}/emptyDir" ]; then
    /bin/rm -rf "${tempDir}/emptyDir"
    fi
    # make some directories to work in
    /bin/mkdir $opt -p "${tempDir}/${scriptName}.pkg/Contents/Resources" || return 1
    /bin/mkdir $opt "${tempDir}/emptyDir" || return 1
    # Create Archive.pax.gz
    cd "${tempDir}/emptyDir"
    /bin/pax -w -x cpio -f "${tempDir}/${scriptName}.pkg/Contents/Archive.pax" .
    /usr/bin/gzip "${tempDir}/${scriptName}.pkg/Contents/Archive.pax"
    cd "${entryDir}"
    # Create the Archive.bom file
    /usr/bin/mkbom "${tempDir}/emptyDir/" "${tempDir}/${scriptName}.pkg/Contents/Archive.bom" || return 1
    # Create the Info.plist
    /bin/cat > "${tempDir}/${scriptName}.pkg/Contents/Info.plist" << END
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>CFBundleIdentifier</key>
    <string>com.apple.SystemImageUtility.${scriptName}</string>
    <key>CFBundleShortVersionString</key>
    <string>1</string>
    <key>IFMajorVersion</key>
    <integer>1</integer>
    <key>IFMinorVersion</key>
    <integer>0</integer>
    <key>IFPkgFlagDefaultLocation</key>
    <string>/tmp</string>
    <key>IFPkgFlagInstallFat</key>
    <false/>
    <key>IFPkgFlagIsRequired</key>
    <false/>
    <key>IFPkgFormatVersion</key>
    <real>0.10000000149011612</real>
    </dict>
    </plist>
    END
    echo "pkmkrpkg1" > "${tempDir}/${scriptName}.pkg/Contents/PkgInfo"
    echo "major: 1\nminor: 0" > "${tempDir}/${scriptName}.pkg/Contents/Resources/package_version"
    # Copy the script
    /bin/cp "$scriptPath" "${tempDir}/${scriptName}.pkg/Contents/Resources/postflight"
    # clean up
    /bin/rm -r "${tempDir}/emptyDir"
    return 0
    # Validate or create the requested directory
    CreateOrValidatePath()
    local targetDir="$1"
    if [ ! -d "${targetDir}" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Creating working path at ${targetDir}"
    fi
    /bin/mkdir -p "${targetDir}" || return 1
    fi
    # If any exist, apply any user accounts
    CreateUserAccounts()
    # $1 volume whose local node database to modify
    local count="${#userFullName[*]}"
    local targetVol="${1}"
    if [ $count -gt 0 ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Adding $count user account(s) to the image"
    fi
    for ((index=0; index<$count; index++)); do
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Adding user ${userFullName[$index]}"
    fi
    #lay down user here
    AddLocalUser "${targetVol}" "${userFullName[$index]}" "${userUnixName[$index]}" "${userIsAdmin[$index]}" "${userPassword[$index]}" "${userPassHint[$index]}" "${userImagePath[$index]}" "${userLanguage[$index]}"
    if [ $? != 0 ]; then
    echo "Failed to create the User '${userUnixName[$index]}'."
    return 1
    fi
    #suppress the Apple ID request
    DisableAppleIDRequestForUser "${targetVol}" "${userUnixName[$index]}"
    done
    # "touch"
    /usr/bin/touch "${targetVol}/private/var/db/.AppleSetupDone"
    /usr/bin/touch "${targetVol}/Library/Receipts/.SetupRegComplete"
    fi
    # retry the hdiutil detach until we either time out or it succeeds
    retry_hdiutil_detach()
    local mount_point="${1}"
    local tries=0
    local forceAt=0
    local limit=24
    local opt=""
    forceAt=$(($limit - 1))
    while [ $tries -lt $limit ]; do
    tries=$(( tries + 1 ))
    /bin/sleep 5
    echo "Attempting to detach the disk image again..."
    /usr/bin/hdiutil detach "${mount_point}" $opt
    if [ $? -ne 0 ]; then
    # Dump a list of any still open files on the mountPoint
    if [ "${scriptsDebugKey}" == "DEBUG" ]; then
    /usr/sbin/lsof +fg "${mount_point}"
    fi
    if [ $tries -eq $forceAt ]; then
    echo "Failed to detach disk image at '${mount_point}' normally, adding -force."
    opt="-force"
    fi
    if [ $tries -eq $limit ]; then
    echo "Failed to detach disk image at '${mount_point}'."
    exit 1
    fi
    else
    tries=$limit
    fi
    done
    # Create the dyld shared cache files
    DetachAndRemoveMount()
    local theMount="${1}"
    local mountLoc=`mount | grep "${theMount}"`
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Detaching disk image"
    # Dump a list of any still open files on the mountPoint
    if [ "${scriptsDebugKey}" == "DEBUG" ]; then
    /usr/sbin/lsof +fg "${theMount}"
    fi
    fi
    # Finally detach the mount (if it's actually mounted) and dispose the mountPoint directory
    if [ "${mountLoc}" != "" ]; then
    /usr/bin/hdiutil detach "${theMount}" || retry_hdiutil_detach "${theMount}" || return 1
    fi
    /bin/rmdir "${theMount}" || return 1
    return 0
    # Turn off the Apple ID request that happens on first boot after installing the OS
    DisableAppleIDRequestForUser()
    local targetUserLib="${1}/Users/${2}/Library"
    # Only do this if the file doesn't exist
    if [ ! -e "${targetUserLib}/Preferences/com.apple.SetupAssistant.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Disabling Apple ID request for user '${2}'"
    fi
    /usr/libexec/PlistBuddy -c "Add :DidSeeCloudSetup bool 1" "${targetUserLib}/Preferences/com.apple.SetupAssistant.plist" > /dev/null 2>&1
    /usr/libexec/PlistBuddy -c "Add :LastSeenCloudProductVersion string 10.8" "${targetUserLib}/Preferences/com.apple.SetupAssistant.plist" > /dev/null 2>&1
    fi
    return 0
    # If the pieces exist, enable remote access for the shell image
    EnableRemoteAccess()
    local srcVol="${1}"
    local opt=""
    if [ -e "${srcVol}/usr/lib/pam/pam_serialnumber.so.2" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Enabling shell image remote access support"
    opt="-v"
    fi
    # install some things (again which aren't part of BaseSystem) needed for remote ASR installs
    /usr/bin/ditto $opt "${srcVol}/usr/lib/pam/pam_serialnumber.so.2" "${mountPoint}/usr/lib/pam/pam_serialnumber.so.2" || return 1
    if [ -e "${srcVol}/usr/sbin/installer" ]; then
    /usr/bin/ditto $opt "${srcVol}/usr/sbin/installer" "${mountPoint}/usr/sbin/installer" || return 1
    fi
    # copy the sshd config and add our keys to the end of it
    if [ -e "${srcVol}/etc/sshd_config" ]; then
    /bin/cat "${srcVol}/etc/sshd_config" - > "${mountPoint}/etc/sshd_config" << END
    HostKey /private/var/tmp/ssh_host_key
    HostKey /private/var/tmp/ssh_host_rsa_key
    HostKey /private/var/tmp/ssh_host_dsa_key
    END
    fi
    fi
    return 0
    # If it exists, install the sharing names and/or directory binding support to the install image
    HandleNetBootClientHelper()
    local tempDir="${1}"
    local targetVol="${2}"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    if [ -e  "${tempDir}/bindingNames.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Directory Service binding information"
    fi
    /usr/bin/ditto $opt "${tempDir}/bindingNames.plist" "${targetVol}/etc/bindingNames.plist" || return 1
    /usr/sbin/chown root:wheel "${targetVol}/etc/bindingNames.plist"
    /bin/chmod 644 "${targetVol}/etc/bindingNames.plist"
    fi
    if [ -e  "${tempDir}/sharingNames.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Sharing Names support"
    fi
    /usr/bin/ditto $opt "${tempDir}/sharingNames.plist" "${targetVol}/etc/sharingNames.plist" || return 1
    /usr/sbin/chown root:wheel "${targetVol}/etc/sharingNames.plist"
    /bin/chmod 644 "${targetVol}/etc/sharingNames.plist"
    fi
    if [ -e  "${tempDir}/NetBootClientHelper" ]; then
    /usr/bin/ditto $opt "${tempDir}/NetBootClientHelper" "${targetVol}/usr/sbin/NetBootClientHelper" || return 1
    /usr/sbin/chown root:wheel "${targetVol}/usr/sbin/NetBootClientHelper"
    /bin/chmod 555 "${targetVol}/usr/sbin/NetBootClientHelper"
    /usr/bin/ditto $opt "${tempDir}/com.apple.NetBootClientHelper.plist" "${targetVol}/System/Library/LaunchDaemons/com.apple.NetBootClientHelper.plist" || return 1
    /usr/sbin/chown root:wheel "${targetVol}/System/Library/LaunchDaemons/com.apple.NetBootClientHelper.plist"
    /bin/chmod 644 "${targetVol}/System/Library/LaunchDaemons/com.apple.NetBootClientHelper.plist"
    # finally, make sure it isn't disabled...
    /usr/libexec/PlistBuddy -c "Delete :com.apple.NetBootClientHelper" "${targetVol}/var/db/launchd.db/com.apple.launchd/overrides.plist" > /dev/null 2>&1
    fi
    return 0
    # If any exist, install configuration profiles to the install image
    InstallConfigurationProfiles()
    local tempDir="${1}"
    local targetVol="${2}"
    local profilesDir="${targetVol}/var/db/ConfigurationProfiles"
    if [ -e  "${tempDir}/configProfiles.txt" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Configuration Profiles"
    fi
    /bin/mkdir -p "${profilesDir}/Setup" || return 1
    # Make sure the perms are correct
    /usr/sbin/chown root:wheel "${profilesDir}"
    /bin/chmod 755 "${profilesDir}"
    /usr/sbin/chown root:wheel "${profilesDir}/Setup"
    /bin/chmod 755 "${profilesDir}/Setup"
    /usr/bin/touch "${profilesDir}/.profilesAreInstalled"
    CopyEntriesFromFileToPath "${tempDir}/configProfiles.txt" "${profilesDir}/Setup" || return 1
    # Enable MCX debugging
    if [ 1 == 1 ]; then
    if [ -e  "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" ]; then
    /usr/libexec/PlistBuddy -c "Delete :debugOutput" "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" > /dev/null 2>&1
    /usr/libexec/PlistBuddy -c "Delete :collateLogs" "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" > /dev/null 2>&1
    fi
    /usr/libexec/PlistBuddy -c "Add :debugOutput string -2" "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" > /dev/null 2>&1
    /usr/libexec/PlistBuddy -c "Add :collateLogs string 1" "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" > /dev/null 2>&1
    fi
    fi
    # Converts a list of scripts (full paths contained in the file at $1) into packages in $3
    InstallScriptsFromFile()
    local tempDir="${1}"
    local theFile="${2}"
    local targetDir="${3}"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Converting scripts into install packages"
    opt="-v"
    fi
    while read FILE
    do
    if [ -e "${FILE}" ]; then
    # make an installer package out of the script
    CreateInstallPackageForScript "$tempDir" "${FILE}" || return 1
    # copy the resulting package to the Packages directory
    local leafName=`basename "${FILE}"`
    /usr/bin/ditto $opt "${tempDir}/${leafName}.pkg" "${targetDir}/${leafName}.pkg" || return 1
    # clean up
    /bin/rm -r "${tempDir}/${leafName}.pkg"
    fi
    done < "${theFile}"
    return 0
    # Prepare the source by deleting stuff we don't want to copy if sourcing a volume
    PostFlightDestination()
    local tempDir="${1}"
    local destDir="${2}"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Performing post install cleanup"
    opt="-v"
    fi
    # delete the DS indices to force reindexing...
    if [ -e "${mountPoint}/var/db/dslocal/indices/Default/index" ]; then
    /bin/rm $opt "${mountPoint}/var/db/dslocal/indices/Default/index"
    fi
    # detach the disk and remove the mount folder
    DetachAndRemoveMount "${mountPoint}"
    if [ $? != 0 ]; then
    echo "Failed to detach and clean up the mount at '${mountPoint}'."
    return 1
    fi
    echo "Correcting permissions. ${ownershipInfoKey} $destDir"
    /usr/sbin/chown -R "${ownershipInfoKey}" "$destDir"
    # Prepare the source by deleting stuff we don't want to copy if sourcing a volume
    PreCleanSource()
    local srcVol="$1"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    if [ -e "$srcVol/private/var/vm/swapfile*" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Removing swapfiles on $1"
    fi
    /bin/rm $opt "$srcVol/private/var/vm/swapfile*"
    fi
    if [ -e "$srcVol/private/var/vm/sleepimage" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Removing sleepimage on $1"
    fi
    /bin/rm $opt "$srcVol/private/var/vm/sleepimage"
    fi
    if [ -d "$srcVol/private/tmp" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Cleaning out /private/tmp on $1"
    fi
    /bin/rm -r $opt "$srcVol/private/tmp/*" > /dev/null 2>&1
    fi
    if [ -d "$srcVol/private/var/tmp" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Cleaning out /private/var/tmp on $1"
    fi
    /bin/rm -r $opt "$srcVol/private/var/tmp/*" > /dev/null 2>&1
    fi
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Cleaning out devices and volumes on $1"
    fi
    if [ -d "$srcVol/Volumes" ]; then
    /bin/rm -r $opt "$srcVol/Volumes/*" > /dev/null 2>&1
    fi
    if [ -d "$srcVol/dev" ]; then
    /bin/rm $opt "$srcVol/dev/*" > /dev/null 2>&1
    fi
    if [ -d "$srcVol/private/var/run" ]; then
    /bin/rm -r $opt "$srcVol/private/var/run/*" > /dev/null 2>&1
    fi
    # Copy kernel and build the kext cache on the boot image
    PrepareKernelAndKextCache()
    local srcDir="$1"
    local destDir="$2"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Preparing the kernel and kext cache for the boot image"
    opt="-v"
    fi
    # Insure the kext cache on our source volume (the boot shell) is up to date
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Updating kext cache on source volume"
    fi
    /usr/sbin/kextcache -update-volume "${srcDir}" || return 1
    # Copy the i386 and, if it exists, the x86_64 architecture
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing the kext cache to the boot image"
    fi
    # make sure this doesn't exist
    if [ -e "${destDir}/i386" ]; then
    /bin/rm -rf "${destDir}/i386"
    fi
    # Install kextcaches to the nbi folder
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Creating a kernelcache for the boot shell"
    fi
    /bin/mkdir -p $opt "${destDir}/i386/x86_64" || return 1
    /usr/sbin/kextcache -arch x86_64 -L -N -S -z -K "${srcDir}/mach_kernel" -c "${destDir}/i386/x86_64/kernelcache" "${srcDir}/System/Library/Extensions" || return 1
    # Create the i386 and x86_64 boot loaders on the boot image
    PrepareBootLoader()
    local srcVol="$1"
    local destDir="$2"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Preparing boot loader"
    opt="-v"
    fi
    # Copy the boot.efi to the booter shell
    if [ -e "${mountPoint}/System/Library/CoreServices/boot.efi" ]; then
    /usr/bin/ditto $opt "${mountPoint}/System/Library/CoreServices/boot.efi" "${destDir}/i386/booter" || return 1
    else
    /usr/bin/ditto $opt "${srcVol}/System/Library/CoreServices/boot.efi" "${destDir}/i386/booter" || return 1
    fi
    # Unlock the file so we can change its owner later
    chflags nouchg "${destDir}/i386/booter"
    # Copy the PlatformSupport.plist file
    if [ -e "${mountPoint}/System/Library/CoreServices/PlatformSupport.plist" ]; then
    /usr/bin/ditto $opt "${mountPoint}/System/Library/CoreServices/PlatformSupport.plist" "${destDir}/i386/PlatformSupport.plist" || return 1
    else
    /usr/bin/ditto $opt "${srcVol}/System/Library/CoreServices/PlatformSupport.plist" "${destDir}/i386/PlatformSupport.plist" || return 1
    fi
    # If it exists, install the partitioning application and data onto the install image
    ProcessAutoPartition()
    local tempDir="$1"
    local opt=""
    local targetDir=""
    if [ -e "$tempDir/PartitionInfo.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    # Determine if this is an install source, or a restore source
    if [ -d "${mountPoint}/Packages" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Partitioning application and data to install image"
    fi
    targetDir="${mountPoint}/Packages"
    elif [ -d "${mountPoint}/System/Installation/Packages" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Partitioning application and data to restore image"
    fi
    targetDir="${mountPoint}/System/Installation/Packages"
    else
    echo "There doesn't appear to be either an install or restore source mounted at ${mountPoint}"
    return 1
    fi
    # Create the Extras directory if it doesn't exist
    if [ ! -d "${targetDir}/Extras" ]; then
    /bin/mkdir "${targetDir}/Extras"
    fi
    targetDir="${targetDir}/Extras"
    /usr/bin/ditto $opt "$tempDir/PartitionInfo.plist" "${targetDir}/PartitionInfo.plist" || return 1
    /usr/bin/ditto $opt "$tempDir/AutoPartition.app" "${targetDir}/AutoPartition.app" || return 1
    fi
    return 0
    # If it exists, install the minstallconfig.xml onto the install image
    ProcessMinInstall()
    local tempDir="$1"
    local opt=""
    local targetDir="${mountPoint}/Packages/Extras"
    if [ -e "$tempDir/minstallconfig.xml" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing minstallconfig.xml to install image"
    opt="-v"
    fi
    /usr/bin/ditto $opt "$tempDir/minstallconfig.xml" "${targetDir}/minstallconfig.xml" || return 1
    /usr/sbin/chown root:wheel "${targetDir}/minstallconfig.xml"
    /bin/chmod 644 "${targetDir}/minstallconfig.xml"
    fi
    return 0
    # untar the OSInstall.mpkg so it can be modified
    untarOSInstallMpkg()
    local tempDir="$1"
    local opt=""
    # we might have already done this, so check for it first
    if [ ! -d "${tempDir}/OSInstall_pkg" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "uncompressing OSInstall.mpkg"
    opt="-v"
    fi
    /bin/mkdir "${tempDir}/OSInstall_pkg"
    cd "${tempDir}/OSInstall_pkg"
    /usr/bin/xar $opt -xf "${mountPoint}/System/Installation/Packages/OSInstall.mpkg"
    # make Distribution writeable
    /bin/chmod 777 "${tempDir}/OSInstall_pkg"
    /bin/chmod 666 "${tempDir}/OSInstall_pkg/Distribution"
    fi
    # Make a tempdir to mount the image on
    mountPoint=`mktemp -d "/tmp/mnt.XXXXXXXX"`
    mktemp -d "/tmp/mnt.XXXXXXXX"
    ++ mktemp -d /tmp/mnt.XXXXXXXX
    + mountPoint=/tmp/mnt.7E4iD6mQ
    sourceMount=""
    + sourceMount=
    crfsErrExit()
    echo "Execution of '`basename \"${0}\"`' failed. Cleaning up."
    # detach the disk and remove the mount folder
    DetachAndRemoveMount "${mountPoint}"
    # detach the mounted source, if necessary
    if [ "${sourceMount}" != "" ] ; then
    DetachAndRemoveMount "${sourceMount}"
    fi
    # Remove the items we created
    /bin/rm -r "$destPath/i386" > /dev/null 2>&1
    /bin/rm "$destPath/$dmgTarget.dmg" > /dev/null 2>&1
    /bin/rm "$destPath/System.dmg" > /dev/null 2>&1
    # Finally, remove the directory IF empty
    /bin/rmdir "$destPath"
    exit 1
    InstallNetBootClientHelper()
    local tempDir="${1}"
    local destDir="${mountPoint}/Packages/Extras"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    if [ -e "${tempDir}/bindingNames.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Directory Service binding information"
    fi
    /usr/bin/ditto $opt "${tempDir}/bindingNames.plist" "${destDir}/bindingNames.plist" || return 1
    /usr/sbin/chown root:wheel "${destDir}/bindingNames.plist"
    /bin/chmod 644 "${destDir}/bindingNames.plist"
    fi
    if [ -e "${tempDir}/sharingNames.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Sharing Names support"
    fi
    /usr/bin/ditto $opt "${tempDir}/sharingNames.plist" "${destDir}/sharingNames.plist" || return 1
    /usr/sbin/chown root:wheel "${destDir}/sharingNames.plist"
    /bin/chmod 644 "${destDir}/sharingNames.plist"
    fi
    # This is required, make sure it's here
    /usr/bin/ditto $opt "${tempDir}/NetBootClientHelper" "${destDir}/NetBootClientHelper" || return 1
    /usr/sbin/chown root:wheel "${destDir}/NetBootClientHelper"
    /bin/chmod 555 "${destDir}/NetBootClientHelper"
    /usr/bin/ditto $opt "${tempDir}/com.apple.NetBootClientHelper.plist" "${destDir}/com.apple.NetBootClientHelper.plist" || return 1
    /usr/sbin/chown root:wheel "${destDir}/com.apple.NetBootClientHelper.plist"
    /bin/chmod 644 "${destDir}/com.apple.NetBootClientHelper.plist"
    /usr/bin/ditto $opt "${tempDir}/installClientHelper.sh" "${mountPoint}/var/tmp/niu/postinstall/installClientHelper.sh" || return 1
    /usr/sbin/chown root:wheel "${mountPoint}/var/tmp/niu/postinstall/installClientHelper.sh"
    /bin/chmod 555 "${mountPoint}/var/tmp/niu/postinstall/installClientHelper.sh"
    return 0
    InstallBaseSystemToShell()
    local baseSystemDMG="${1}"
    local shellMount="${2}"
    local tempDir=`/usr/bin/dirname "${1}"`
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ] ; then
    opt="-v"
    echo "Copying Base System bits to the boot shell image"
    fi
    baseMount=`mktemp -d "/tmp/mnt_bs.XXXXXXXX"`
    /usr/bin/hdiutil attach "${baseSystemDMG}" -noverify -owners on -nobrowse -noautoopen -mountpoint "${baseMount}" -quiet || return 1
    # Copy the boot.efi and SystemVersion.plist out to the shell dmg
    /usr/bin/ditto $opt "${baseMount}/System/Library/CoreServices/boot.efi" "${shellMount}/boot.efi" || return 1
    chflags nouchg "${shellMount}/boot.efi"
    /bin/mkdir -p "${shellMount}/usr/standalone/i386" || return 1
    /bin/ln "${shellMount}/boot.efi" "${shellMount}/usr/standalone/i386/boot.efi" || return 1
    /bin/mkdir -p "${shellMount}/System/Library/CoreServices" || return 1
    /bin/ln "${shellMount}/boot.efi" "${shellMount}/System/Library/CoreServices/boot.efi" || return 1
    /usr/bin/ditto $opt "${baseMount}/System/Library/CoreServices/SystemVersion.plist" "${shellMount}/System/Library/CoreServices/SystemVersion.plist" || return 1
    # stash some things we need for later
    /usr/bin/ditto $opt "${baseMount}/System/Library/Caches/com.apple.kext.caches/Startup/kernelcache" "${tempDir}/kernelcache" || return 1
    /usr/bin/ditto $opt "${baseMount}/System/Library/CoreServices/com.apple.recovery.boot/PlatformSuppo rt.plist" "${tempDir}/PlatformSupport.plist" || return 1
    # Clean up
    /usr/bin/hdiutil detach "${baseMount}" || retry_hdiutil_detach "${baseMount}" || return 1
    /bin/rmdir "${baseMount}"
    theDmg=`basename "${baseSystemDMG}"`
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ] ; then
    echo "Copying ${theDmg} to the boot shell."
    fi
    /usr/bin/ditto $debug_opt "${baseSystemDMG}" "${shellMount}/${theDmg}"
    return 0
    # Set up for script debugging
    debug_opt=""
    + debug_opt=
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ] ; then
    debug_opt="-v"
    fi
    + '[' DEBUG == VERBOSE -o DEBUG == DEBUG ']'
    + debug_opt=-v
    # Prepare the destination
    CreateOrValidatePath "${destPath}" || crfsErrExit
    + CreateOrValidatePath '/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi'
    + local 'targetDir=/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi'
    + '[' '!' -d '/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi' ']'
    + '[' DEBUG == VERBOSE -o DEBUG == DEBUG ']'
    + echo 'Creating working path at /Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi'
    Creating working path at /Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi
    + /bin/mkdir -p '/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi'
    # Source in our image building commands
    . "${1}/buildCommands.sh"
    + . /tmp/niutemp.rDvE48RI/buildCommands.sh
    '/System/Library/CoreServices/System Image Utility.app/Contents/Library/Automator/Create Image.action/Contents/Resources/asrFromVolume.sh' "/tmp/niutemp.rDvE48RI" "/Volumes/Macintosh HD" "System" || exit 1
    ++ '/System/Library/CoreServices/System Image Utility.app/Contents/Library/Automator/Create Image.action/Contents/Resources/asrFromVolume.sh' /tmp/niutemp.rDvE48RI '/Volumes/Macintosh HD' System
    progressPrefix="_progress"
    ++ progressPrefix=_progress
    scriptsDebugKey="DEBUG"
    ++ scriptsDebugKey=DEBUG
    imageIsUDIFKey="1"
    ++ imageIsUDIFKey=1
    imageFormatKey="UDZO"
    ++ imageFormatKey=UDZO
    mountPoint=""
    ++ mountPoint=
    ownershipInfoKey="501:20"
    ++ ownershipInfoKey=501:20
    blockCopyDeviceKey="0"
    ++ blockCopyDeviceKey=0
    dmgTarget="NetInstall"
    ++ dmgTarget=NetInstall
    potentialRecoveryDevice="disk4s3"
    ++ potentialRecoveryDevice=disk4s3
    asrSource="ASRInstall.pkg"
    ++ asrSource=ASRInstall.pkg
    destPath="/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi"
    ++ destPath='/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi'
    skipReorderingKey="0"
    ++ skipReorderingKey=0
    sourceVol="/Volumes/Macintosh HD"
    ++ sourceVol='/Volumes/Macintosh HD'
    postInstallHelperKey="1"
    ++ postInstallHelperKey=1
    # variables we will need
    created_dest="NO"
    + created_dest=NO
    afvErrExit()
    echo "Execution of '`basename \"${0}\"`' failed. Cleaning up."
    # detach the disk and remove the mount folder
    if [ "${created_dest}" == "YES" ]; then
    /bin/rm -r "${destPath}"
    fi
    exit 1
    retrieveBaseSystemDMG()
    local tempDir="${1}"
    local opt=""
    if [ "${potentialRecoveryDevice}" != "" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ] ; then
    echo "Retrieving BaseSystem bits from Recovery HD"
    opt="-v"
    fi
    recoveryMount=`mktemp -d "/tmp/mnt_rp.XXXXXXXX"`
    /usr/sbin/diskutil mount readOnly -mountPoint "${recoveryMount}" "${potentialRecoveryDevice}" || return 1
    # Now make sure this is what was expected
    if [ -e "${recoveryMount}/com.apple.recovery.boot/BaseSystem.dmg" ]; then
    /usr/bin/ditto $opt "${recoveryMount}/com.apple.recovery.boot/BaseSystem.dmg" "${tempDir}/BaseSystem.dmg" || return 1
    /usr/bin/ditto $opt "${recoveryMount}/com.apple.recovery.boot/BaseSystem.chunklist" "${tempDir}/BaseSystem.chunklist"
    fi
    /usr/sbin/diskutil unmount "${potentialRecoveryDevice}" || return 1
    /bin/rmdir "${recoveryMount}"
    fi
    return 0
    # Insure the working path (dmg destination) exists
    if [ ! -d "${destPath}" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Creating working path at ${destPath}"
    fi
    /bin/mkdir -p "${destPath}" || afvErrExit
    created_dest="YES"
    fi
    + '[' '!' -d '/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi' ']'
    # If the volume source is the boot drive we have an asr:// type source
    if [ "${2}" == "/" ]; then
    # Create an empty image to skip the ASR volume creation
    /usr/bin/touch "${destPath}/${3}.dmg"
    # Set aside the needed BaseSystem.dmg
    retrieveBaseSystemDMG "${1}" || afvErrExit
    fi
    + '[' '/Volumes/Macintosh HD' == / ']'
    # Look for an existing System.dmg
    if [ ! -e "${destPath}/${3}.dmg" ]; then
    # Didn't find one, so create it from volume source
    ${1}/makeNetRestoreFromItem.sh "${1}" "${2}" "${3}" || afvErrExit
    fi
    + '[' '!' -e '/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi/System.dmg' ']'
    + /tmp/niutemp.rDvE48RI/makeNetRestoreFromItem.sh /tmp/niutemp.rDvE48RI '/Volumes/Macintosh HD' System
    progressPrefix="_progress"
    ++ progressPrefix=_progress
    scriptsDebugKey="DEBUG"
    ++ scriptsDebugKey=DEBUG
    imageIsUDIFKey="1"
    ++ imageIsUDIFKey=1
    imageFormatKey="UDZO"
    ++ imageFormatKey=UDZO
    mountPoint=""
    ++ mountPoint=
    ownershipInfoKey="501:20"
    ++ ownershipInfoKey=501:20
    blockCopyDeviceKey="0"
    ++ blockCopyDeviceKey=0
    dmgTarget="NetInstall"
    ++ dmgTarget=NetInstall
    potentialRecoveryDevice="disk4s3"
    ++ potentialRecoveryDevice=disk4s3
    asrSource="ASRInstall.pkg"
    ++ asrSource=ASRInstall.pkg
    destPath="/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi"
    ++ destPath='/Users/morgan/Desktop/NetRestore of Macintosh HD_2.nbi'
    skipReorderingKey="0"
    ++ skipReorderingKey=0
    sourceVol="/Volumes/Macintosh HD"
    ++ sourceVol='/Volumes/Macintosh HD'
    postInstallHelperKey="1"
    ++ postInstallHelperKey=1
    . "${1}/createCommon.sh"
    + . /tmp/niutemp.rDvE48RI/createCommon.sh
    # createCommon.sh
    # Common functionality for the Image creation process.
    # sourced in by the various SIU scripts
    # Copyright © 2007-2012 Apple Inc. All rights reserved.
    # Using dscl, create a user account
    AddLocalUser()
    # $1 volume whose local node database to modify
    # $2 long name
    # $3 short name
    # $4 isAdminUser key
    # $5 password data
    # $6 password hint
    # $7 user picture path
    # $8 Language string
    local databasePath="/Local/Default/Users/${3}"
    local targetVol="${1}"
    # Find a free UID between 501 and 599
    for ((i=501; i<600; i++)); do
    output=`/usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -search /Local/Default/Users UniqueID $i`
    # If there is already an account dscl returns it, so we're looking for an empty return value.
    if [ "$output" == "" ]; then
    break
    fi
    done
    # Create the user record
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -create $databasePath
    if [ $? != 0 ]; then
    echo "Failed to create '${databasePath}'."
    return 1
    fi
    # Add long name
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath RealName "${2}"
    if [ $? != 0 ]; then
    echo "Failed to set the RealName."
    return 1
    fi
    # Set up the users group information
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath PrimaryGroupID 20
    if [ $? != 0 ]; then
    echo "Failed to set the PrimaryGroupID."
    return 1
    fi
    # Add some additional stuff if the user is an admin
    if [ "${4}" == 1 ]; then
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append "/Local/Default/Groups/admin" GroupMembership "${3}"
    if [ $? != 0 ]; then
    echo "Failed to add the user to the admin group."
    return 1
    fi
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append "/Local/Default/Groups/_appserveradm" GroupMembership "${3}"
    if [ $? != 0 ]; then
    echo "Failed to add the user to the _appserveradm group."
    return 1
    fi
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append "/Local/Default/Groups/_appserverusr" GroupMembership "${3}"
    if [ $? != 0 ]; then
    echo "Failed to add the user to the _appserverusr group."
    return 1
    fi
    fi
    # Add UniqueID
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath UniqueID ${i}
    if [ $? != 0 ]; then
    echo "Failed to set the UniqueID."
    return 1
    fi
    # Add Home Directory entry
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath NFSHomeDirectory /Users/${3}
    if [ $? != 0 ]; then
    echo "Failed to set the NFSHomeDirectory."
    fi
    if [ "${6}" != "" ]; then
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath AuthenticationHint "${6}"
    if [ $? != 0 ]; then
    echo "Failed to set the AuthenticationHint."
    return 1
    fi
    fi
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath picture "${7}"
    if [ $? != 0 ]; then
    echo "Failed to set the picture."
    return 1
    fi
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -passwd $databasePath "${5}"
    if [ $? != 0 ]; then
    echo "Failed to set the passwd."
    return 1
    fi
    # Add shell
    /usr/bin/dscl -f "${targetVol}/var/db/dslocal/nodes/Default" localonly -append $databasePath UserShell "/bin/bash"
    if [ $? != 0 ]; then
    echo "Failed to set the UserShell."
    return 1
    fi
    # Create Home directory
    if [ -e "/System/Library/User Template/${8}.lproj/" ]; then
    /usr/bin/ditto "/System/Library/User Template/${8}.lproj/" "${targetVol}/Users/${3}"
    else
    /usr/bin/ditto "/System/Library/User Template/English.lproj/" "${targetVol}/Users/${3}"
    fi
    if [ $? != 0 ]; then
    echo "Failed to copy the User Template."
    return 1
    fi
    /usr/sbin/chown -R $i:$i "${targetVol}/Users/${3}"
    if [ $? != 0 ]; then
    echo "Failed to set ownership on the User folder."
    return 1
    fi
    # Copies a list of files (full paths contained in the file at $1) from source to the path specified in $2
    CopyEntriesFromFileToPath()
    local theFile="$1"
    local theDest="$2"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    while read FILE
    do
    if [ -e "${FILE}" ]; then
    local leafName=`basename "${FILE}"`
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Copying ${FILE}."
    fi
    /usr/bin/ditto $opt "${FILE}" "${theDest}/${leafName}" || return 1
    fi
    done < "${theFile}"
    return 0
    # Copies a list of packages (full path, destination pairs contained in the file at $1) from source to .../System/Installation/Packages/
    CopyPackagesWithDestinationsFromFile()
    local theFile="$1"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    while read FILE
    do
    if [ -e "${FILE}" ]; then
    local leafName=`basename "${FILE}"`
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Copying ${FILE}."
    fi
    read SUB_PATH
    /usr/bin/ditto $opt "${FILE}" "${mountPoint}/Packages/${SUB_PATH}${leafName}" || return 1
    fi
    done < "${theFile}"
    return 0
    # Create an installer package in ${1} wrapping the supplied script ${2}
    CreateInstallPackageForScript()
    local tempDir="$1"
    local scriptPath="$2"
    local scriptName=`basename "${scriptPath}"`
    local entryDir=`pwd`
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Create installer for script ${scriptName}"
    opt="-v"
    fi
    # shouldn't exist on entry...
    if [ -e "${tempDir}/emptyDir" ]; then
    /bin/rm -rf "${tempDir}/emptyDir"
    fi
    # make some directories to work in
    /bin/mkdir $opt -p "${tempDir}/${scriptName}.pkg/Contents/Resources" || return 1
    /bin/mkdir $opt "${tempDir}/emptyDir" || return 1
    # Create Archive.pax.gz
    cd "${tempDir}/emptyDir"
    /bin/pax -w -x cpio -f "${tempDir}/${scriptName}.pkg/Contents/Archive.pax" .
    /usr/bin/gzip "${tempDir}/${scriptName}.pkg/Contents/Archive.pax"
    cd "${entryDir}"
    # Create the Archive.bom file
    /usr/bin/mkbom "${tempDir}/emptyDir/" "${tempDir}/${scriptName}.pkg/Contents/Archive.bom" || return 1
    # Create the Info.plist
    /bin/cat > "${tempDir}/${scriptName}.pkg/Contents/Info.plist" << END
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>CFBundleIdentifier</key>
    <string>com.apple.SystemImageUtility.${scriptName}</string>
    <key>CFBundleShortVersionString</key>
    <string>1</string>
    <key>IFMajorVersion</key>
    <integer>1</integer>
    <key>IFMinorVersion</key>
    <integer>0</integer>
    <key>IFPkgFlagDefaultLocation</key>
    <string>/tmp</string>
    <key>IFPkgFlagInstallFat</key>
    <false/>
    <key>IFPkgFlagIsRequired</key>
    <false/>
    <key>IFPkgFormatVersion</key>
    <real>0.10000000149011612</real>
    </dict>
    </plist>
    END
    echo "pkmkrpkg1" > "${tempDir}/${scriptName}.pkg/Contents/PkgInfo"
    echo "major: 1\nminor: 0" > "${tempDir}/${scriptName}.pkg/Contents/Resources/package_version"
    # Copy the script
    /bin/cp "$scriptPath" "${tempDir}/${scriptName}.pkg/Contents/Resources/postflight"
    # clean up
    /bin/rm -r "${tempDir}/emptyDir"
    return 0
    # Validate or create the requested directory
    CreateOrValidatePath()
    local targetDir="$1"
    if [ ! -d "${targetDir}" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Creating working path at ${targetDir}"
    fi
    /bin/mkdir -p "${targetDir}" || return 1
    fi
    # If any exist, apply any user accounts
    CreateUserAccounts()
    # $1 volume whose local node database to modify
    local count="${#userFullName[*]}"
    local targetVol="${1}"
    if [ $count -gt 0 ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Adding $count user account(s) to the image"
    fi
    for ((index=0; index<$count; index++)); do
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Adding user ${userFullName[$index]}"
    fi
    #lay down user here
    AddLocalUser "${targetVol}" "${userFullName[$index]}" "${userUnixName[$index]}" "${userIsAdmin[$index]}" "${userPassword[$index]}" "${userPassHint[$index]}" "${userImagePath[$index]}" "${userLanguage[$index]}"
    if [ $? != 0 ]; then
    echo "Failed to create the User '${userUnixName[$index]}'."
    return 1
    fi
    #suppress the Apple ID request
    DisableAppleIDRequestForUser "${targetVol}" "${userUnixName[$index]}"
    done
    # "touch"
    /usr/bin/touch "${targetVol}/private/var/db/.AppleSetupDone"
    /usr/bin/touch "${targetVol}/Library/Receipts/.SetupRegComplete"
    fi
    # retry the hdiutil detach until we either time out or it succeeds
    retry_hdiutil_detach()
    local mount_point="${1}"
    local tries=0
    local forceAt=0
    local limit=24
    local opt=""
    forceAt=$(($limit - 1))
    while [ $tries -lt $limit ]; do
    tries=$(( tries + 1 ))
    /bin/sleep 5
    echo "Attempting to detach the disk image again..."
    /usr/bin/hdiutil detach "${mount_point}" $opt
    if [ $? -ne 0 ]; then
    # Dump a list of any still open files on the mountPoint
    if [ "${scriptsDebugKey}" == "DEBUG" ]; then
    /usr/sbin/lsof +fg "${mount_point}"
    fi
    if [ $tries -eq $forceAt ]; then
    echo "Failed to detach disk image at '${mount_point}' normally, adding -force."
    opt="-force"
    fi
    if [ $tries -eq $limit ]; then
    echo "Failed to detach disk image at '${mount_point}'."
    exit 1
    fi
    else
    tries=$limit
    fi
    done
    # Create the dyld shared cache files
    DetachAndRemoveMount()
    local theMount="${1}"
    local mountLoc=`mount | grep "${theMount}"`
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Detaching disk image"
    # Dump a list of any still open files on the mountPoint
    if [ "${scriptsDebugKey}" == "DEBUG" ]; then
    /usr/sbin/lsof +fg "${theMount}"
    fi
    fi
    # Finally detach the mount (if it's actually mounted) and dispose the mountPoint directory
    if [ "${mountLoc}" != "" ]; then
    /usr/bin/hdiutil detach "${theMount}" || retry_hdiutil_detach "${theMount}" || return 1
    fi
    /bin/rmdir "${theMount}" || return 1
    return 0
    # Turn off the Apple ID request that happens on first boot after installing the OS
    DisableAppleIDRequestForUser()
    local targetUserLib="${1}/Users/${2}/Library"
    # Only do this if the file doesn't exist
    if [ ! -e "${targetUserLib}/Preferences/com.apple.SetupAssistant.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Disabling Apple ID request for user '${2}'"
    fi
    /usr/libexec/PlistBuddy -c "Add :DidSeeCloudSetup bool 1" "${targetUserLib}/Preferences/com.apple.SetupAssistant.plist" > /dev/null 2>&1
    /usr/libexec/PlistBuddy -c "Add :LastSeenCloudProductVersion string 10.8" "${targetUserLib}/Preferences/com.apple.SetupAssistant.plist" > /dev/null 2>&1
    fi
    return 0
    # If the pieces exist, enable remote access for the shell image
    EnableRemoteAccess()
    local srcVol="${1}"
    local opt=""
    if [ -e "${srcVol}/usr/lib/pam/pam_serialnumber.so.2" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Enabling shell image remote access support"
    opt="-v"
    fi
    # install some things (again which aren't part of BaseSystem) needed for remote ASR installs
    /usr/bin/ditto $opt "${srcVol}/usr/lib/pam/pam_serialnumber.so.2" "${mountPoint}/usr/lib/pam/pam_serialnumber.so.2" || return 1
    if [ -e "${srcVol}/usr/sbin/installer" ]; then
    /usr/bin/ditto $opt "${srcVol}/usr/sbin/installer" "${mountPoint}/usr/sbin/installer" || return 1
    fi
    # copy the sshd config and add our keys to the end of it
    if [ -e "${srcVol}/etc/sshd_config" ]; then
    /bin/cat "${srcVol}/etc/sshd_config" - > "${mountPoint}/etc/sshd_config" << END
    HostKey /private/var/tmp/ssh_host_key
    HostKey /private/var/tmp/ssh_host_rsa_key
    HostKey /private/var/tmp/ssh_host_dsa_key
    END
    fi
    fi
    return 0
    # If it exists, install the sharing names and/or directory binding support to the install image
    HandleNetBootClientHelper()
    local tempDir="${1}"
    local targetVol="${2}"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    if [ -e  "${tempDir}/bindingNames.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Directory Service binding information"
    fi
    /usr/bin/ditto $opt "${tempDir}/bindingNames.plist" "${targetVol}/etc/bindingNames.plist" || return 1
    /usr/sbin/chown root:wheel "${targetVol}/etc/bindingNames.plist"
    /bin/chmod 644 "${targetVol}/etc/bindingNames.plist"
    fi
    if [ -e  "${tempDir}/sharingNames.plist" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Sharing Names support"
    fi
    /usr/bin/ditto $opt "${tempDir}/sharingNames.plist" "${targetVol}/etc/sharingNames.plist" || return 1
    /usr/sbin/chown root:wheel "${targetVol}/etc/sharingNames.plist"
    /bin/chmod 644 "${targetVol}/etc/sharingNames.plist"
    fi
    if [ -e  "${tempDir}/NetBootClientHelper" ]; then
    /usr/bin/ditto $opt "${tempDir}/NetBootClientHelper" "${targetVol}/usr/sbin/NetBootClientHelper" || return 1
    /usr/sbin/chown root:wheel "${targetVol}/usr/sbin/NetBootClientHelper"
    /bin/chmod 555 "${targetVol}/usr/sbin/NetBootClientHelper"
    /usr/bin/ditto $opt "${tempDir}/com.apple.NetBootClientHelper.plist" "${targetVol}/System/Library/LaunchDaemons/com.apple.NetBootClientHelper.plist" || return 1
    /usr/sbin/chown root:wheel "${targetVol}/System/Library/LaunchDaemons/com.apple.NetBootClientHelper.plist"
    /bin/chmod 644 "${targetVol}/System/Library/LaunchDaemons/com.apple.NetBootClientHelper.plist"
    # finally, make sure it isn't disabled...
    /usr/libexec/PlistBuddy -c "Delete :com.apple.NetBootClientHelper" "${targetVol}/var/db/launchd.db/com.apple.launchd/overrides.plist" > /dev/null 2>&1
    fi
    return 0
    # If any exist, install configuration profiles to the install image
    InstallConfigurationProfiles()
    local tempDir="${1}"
    local targetVol="${2}"
    local profilesDir="${targetVol}/var/db/ConfigurationProfiles"
    if [ -e  "${tempDir}/configProfiles.txt" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing Configuration Profiles"
    fi
    /bin/mkdir -p "${profilesDir}/Setup" || return 1
    # Make sure the perms are correct
    /usr/sbin/chown root:wheel "${profilesDir}"
    /bin/chmod 755 "${profilesDir}"
    /usr/sbin/chown root:wheel "${profilesDir}/Setup"
    /bin/chmod 755 "${profilesDir}/Setup"
    /usr/bin/touch "${profilesDir}/.profilesAreInstalled"
    CopyEntriesFromFileToPath "${tempDir}/configProfiles.txt" "${profilesDir}/Setup" || return 1
    # Enable MCX debugging
    if [ 1 == 1 ]; then
    if [ -e  "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" ]; then
    /usr/libexec/PlistBuddy -c "Delete :debugOutput" "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" > /dev/null 2>&1
    /usr/libexec/PlistBuddy -c "Delete :collateLogs" "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" > /dev/null 2>&1
    fi
    /usr/libexec/PlistBuddy -c "Add :debugOutput string -2" "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" > /dev/null 2>&1
    /usr/libexec/PlistBuddy -c "Add :collateLogs string 1" "${targetVol}/Library/Preferences/com.apple.MCXDebug.plist" > /dev/null 2>&1
    fi
    fi
    # Converts a list of scripts (full paths contained in the file at $1) into packages in $3
    InstallScriptsFromFile()
    local tempDir="${1}"
    local theFile="${2}"
    local targetDir="${3}"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Converting scripts into install packages"
    opt="-v"
    fi
    while read FILE
    do
    if [ -e "${FILE}" ]; then
    # make an installer package out of the script
    CreateInstallPackageForScript "$tempDir" "${FILE}" || return 1
    # copy the resulting package to the Packages directory
    local leafName=`basename "${FILE}"`
    /usr/bin/ditto $opt "${tempDir}/${leafName}.pkg" "${targetDir}/${leafName}.pkg" || return 1
    # clean up
    /bin/rm -r "${tempDir}/${leafName}.pkg"
    fi
    done < "${theFile}"
    return 0
    # Prepare the source by deleting stuff we don't want to copy if sourcing a volume
    PostFlightDestination()
    local tempDir="${1}"
    local destDir="${2}"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Performing post install cleanup"
    opt="-v"
    fi
    # delete the DS indices to force reindexing...
    if [ -e "${mountPoint}/var/db/dslocal/indices/Default/index" ]; then
    /bin/rm $opt "${mountPoint}/var/db/dslocal/indices/Default/index"
    fi
    # detach the disk and remove the mount folder
    DetachAndRemoveMount "${mountPoint}"
    if [ $? != 0 ]; then
    echo "Failed to detach and clean up the mount at '${mountPoint}'."
    return 1
    fi
    echo "Correcting permissions. ${ownershipInfoKey} $destDir"
    /usr/sbin/chown -R "${ownershipInfoKey}" "$destDir"
    # Prepare the source by deleting stuff we don't want to copy if sourcing a volume
    PreCleanSource()
    local srcVol="$1"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    opt="-v"
    fi
    if [ -e "$srcVol/private/var/vm/swapfile*" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Removing swapfiles on $1"
    fi
    /bin/rm $opt "$srcVol/private/var/vm/swapfile*"
    fi
    if [ -e "$srcVol/private/var/vm/sleepimage" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Removing sleepimage on $1"
    fi
    /bin/rm $opt "$srcVol/private/var/vm/sleepimage"
    fi
    if [ -d "$srcVol/private/tmp" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Cleaning out /private/tmp on $1"
    fi
    /bin/rm -r $opt "$srcVol/private/tmp/*" > /dev/null 2>&1
    fi
    if [ -d "$srcVol/private/var/tmp" ]; then
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Cleaning out /private/var/tmp on $1"
    fi
    /bin/rm -r $opt "$srcVol/private/var/tmp/*" > /dev/null 2>&1
    fi
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Cleaning out devices and volumes on $1"
    fi
    if [ -d "$srcVol/Volumes" ]; then
    /bin/rm -r $opt "$srcVol/Volumes/*" > /dev/null 2>&1
    fi
    if [ -d "$srcVol/dev" ]; then
    /bin/rm $opt "$srcVol/dev/*" > /dev/null 2>&1
    fi
    if [ -d "$srcVol/private/var/run" ]; then
    /bin/rm -r $opt "$srcVol/private/var/run/*" > /dev/null 2>&1
    fi
    # Copy kernel and build the kext cache on the boot image
    PrepareKernelAndKextCache()
    local srcDir="$1"
    local destDir="$2"
    local opt=""
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Preparing the kernel and kext cache for the boot image"
    opt="-v"
    fi
    # Insure the kext cache on our source volume (the boot shell) is up to date
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Updating kext cache on source volume"
    fi
    /usr/sbin/kextcache -update-volume "${srcDir}" || return 1
    # Copy the i386 and, if it exists, the x86_64 architecture
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ]; then
    echo "Installing the kext cache to the boot image"
    fi
    # make sure this doesn't exist
    if [ -e "${destDir}/i386" ]; then
    /bin/rm -rf "${destDir}/i386"
    fi
    # Install kextcaches to the nbi folder

    After running your command, and using the mounted image as my source for creating the NetRestore image, SIU was able to complete the first two steps, but failed on the rest.  It was able to complete "Creating Image From Source", and "Preparing Image For Restore", but it fails on "Creating Bootable System".
    I've copied and pasted the end of the error log.  Any idea what caused the Bootable System from successfully being created?
    PERCENT:-1.000000
    Finalizing disk image.
    created: /Users/morgan/Desktop/30sept.nbi/System.dmg
    # Set aside the needed BaseSystem.dmg
    retrieveBaseSystemDMG "${1}" || mnrfiErrExit
    + retrieveBaseSystemDMG /tmp/niutemp.3PZq4yzF
    + local tempDir=/tmp/niutemp.3PZq4yzF
    + local opt=
    + '[' disk2s3 '!=' '' ']'
    + '[' DEBUG == VERBOSE -o DEBUG == DEBUG ']'
    + opt=-v
    + echo 'Retrieving BaseSystem bits from Recovery HD'
    Retrieving BaseSystem bits from Recovery HD
    mktemp -d "/tmp/mnt_rp.XXXXXXXX"
    ++ mktemp -d /tmp/mnt_rp.XXXXXXXX
    + recoveryMount=/tmp/mnt_rp.75pVTRHs
    + /usr/sbin/diskutil mount readOnly -mountPoint /tmp/mnt_rp.75pVTRHs disk2s3
    Volume Recovery HD on disk2s3 mounted
    + '[' -e /tmp/mnt_rp.75pVTRHs/com.apple.recovery.boot/BaseSystem.dmg ']'
    + /usr/sbin/diskutil unmount disk2s3
    Volume Recovery HD on disk2s3 unmounted
    + /bin/rmdir /tmp/mnt_rp.75pVTRHs
    + return 0
    # update progress information
    echo "${progressPrefix}_preparingASR_"
    + echo _progress_preparingASR_
    # "Scan the image for restore"
    asr_opt=""
    + asr_opt=
    if [ "${skipReorderingKey}" == 1 ] ; then
    asr_opt="--nostream"
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ] ; then
    echo "Preparing image for restore without multicast reordering"
    fi
    else
    if [ "${scriptsDebugKey}" == "VERBOSE" -o "${scriptsDebugKey}" == "DEBUG" ] ; then
    echo "Preparing image for restore"
    fi
    fi
    + '[' 0 == 1 ']'
    + '[' DEBUG == VERBOSE -o DEBUG == DEBUG ']'
    + echo 'Preparing image for restore'
    Preparing image for restore
    /usr/sbin/asr imagescan --source "${destPath}/${dmgContainer}.dmg" $asr_opt || mnrfiErrExit
    + /usr/sbin/asr imagescan --source /Users/morgan/Desktop/30sept.nbi/System.dmg
    Checksumming partition of size 63 blocks...done
    Block checksum: ....10....20....30....40....50....60....70....80....90....100
    Reordering:     ....10....20....30....40....50....60....70....80....90....100asr: successfully scanned image "/Users/morgan/Desktop/30sept.nbi/System.dmg"
    # update progress information
    echo "${progressPrefix}_creatingInstallSystem_"
    + echo _progress_creatingInstallSystem_
    restoreSource="${sourceVol}"
    + restoreSource='/Volumes/Macintosh HD'
    # If this is a restore from install media, mount that as our source
    if [ "${restoreSource}" == "(installMedia)" ] ; then
    sourceMount=`mktemp -d "/tmp/mnt_src.XXXXXXXX"`
    /usr/bin/hdiutil attach "${destPath}/System.dmg" -noverify -owners on -nobrowse -noautoopen -mountpoint "${sourceMount}" -quiet || crfsErrExit
    restoreSource="${sourceMount}"
    fi
    + '[' '/Volumes/Macintosh HD' == '(installMedia)' ']'
    # If we don't have a BaseSystem.dmg available to us fail now.
    if [ ! -e "${1}/BaseSystem.dmg" ]; then
    echo "There is no BaseSystem.dmg (Recovery HD) associated with the source ${restoreSource}."
    crfsErrExit
    fi
    + '[' '!' -e /tmp/niutemp.3PZq4yzF/BaseSystem.dmg ']'
    + echo 'There is no BaseSystem.dmg (Recovery HD) associated with the source /Volumes/Macintosh HD.'
    There is no BaseSystem.dmg (Recovery HD) associated with the source /Volumes/Macintosh HD.
    + crfsErrExit
    basename "${0}"
    ++ basename '/System/Library/CoreServices/System Image Utility.app/Contents/Library/Automator/Create Image.action/Contents/Resources/createRestoreFromSources.sh'
    + echo 'Execution of '\''createRestoreFromSources.sh'\'' failed. Cleaning up.'
    Execution of 'createRestoreFromSources.sh' failed. Cleaning up.
    + DetachAndRemoveMount /tmp/mnt.nfN5nVgM
    + local theMount=/tmp/mnt.nfN5nVgM
    mount | grep "${theMount}"
    ++ mount
    ++ grep /tmp/mnt.nfN5nVgM
    + local mountLoc=
    + '[' DEBUG == VERBOSE -o DEBUG == DEBUG ']'
    + echo 'Detaching disk image'
    Detaching disk image
    + '[' DEBUG == DEBUG ']'
    + /usr/sbin/lsof +fg /tmp/mnt.nfN5nVgM
    + '[' '' '!=' '' ']'
    + /bin/rmdir /tmp/mnt.nfN5nVgM
    + return 0
    + '[' '' '!=' '' ']'
    + /bin/rm -r /Users/morgan/Desktop/30sept.nbi/i386
    + /bin/rm /Users/morgan/Desktop/30sept.nbi/NetInstall.dmg
    + /bin/rm /Users/morgan/Desktop/30sept.nbi/System.dmg
    + /bin/rmdir /Users/morgan/Desktop/30sept.nbi
    + exit 1
    Script is done.
    Bridge exited with status 256
    Failed to create image from restore source.
    An unknown error has occurred.
    An unknown error has occurred.
    Image creation process finished...
    Stopping image creation.
    Image creation failed.
    Thanks.

  • Fix - Journaled partition fails to mount (journal magic error)

    Before trying to repair or recover a 'Mac OS Extended (Journaled)' disk or partition that fails to mount in the Finder, check whether it is just the journal file that is corrupted. If the partition appears in Disk Utility, the fix is to turn off Journaling. If the partition can now be mounted and your files are present, the problem is solved and journaling can be reenabled.
    To confirm a problem with the journal search for console error messages with "journal magic" that occur when tring to mount the partition.
    In Disk Utility select the partition that will not mount, hold the Option key and select 'Disable Journaling' in the File menu drop down. It will take a few seconds to complete. Now mount the partition using the Mount button or the File menu. To turn journaling back on (recreating a clean journal file), select Enable Journaling from the File menu or the green toolbar button. (This can also be done through Terminal with the diskutil command. See https://discussions.apple.com/message/12838806#12838806 and search on "journal magic" for details.)
    I spent two days trying to recover my data from an external drive. Neither Disk Utility or Disk Warrior 4.4 was able to repair this problem. DU said the partition could not be repaired and DW failed with an "insufficient memory error (2154)". Of course your problem could be a more sever corruption, or the disk does not appear at all in DU, but this is easy to try first.
    Hope this is helpful.

    Let me be more specific
    W2000 SP4 server, MacBook client, trying to mount shared volume thru SMB
    -on the same subnet (i.e. lappy next to the server on the same switch) both mount_smbfs and smbclient work OK
    -from home smbclient is working, mount_smbfs does not (Err -36)
    -from home my wife can mount the shared volume thru Network Neighbours on her XP notebook
    -it does not seem to be TCP/IP related - all comp can make FTP or VNC to the server verywhere
    -err log of mount_smbfs is "negotiate phase failed: syserr Operation timed out in the console", no idea is there a way to verbose mount_smbfs
    -smb.conf looks basic...secure passwords=enable, no nsmb.conf
    -W2000 SP4 sever is all default secure policies, running FTP server w/o any issues.
    So is there a key on server...or the client which I have to tweak?
    Thank you.
    MB 2.0   Mac OS X (10.4.9)  
    MB 2.0   Mac OS X (10.4.9)  

  • Error message E: failed to mount /cache (invalid argument) message

    Charged my Thrive today first time in a couple months and it was stuck on the initial Toshiba logo startup screen..
    I attempted to wipe the cache as suggested in a lot of other posts on this forum, but Its  showing error messages..
      for examples
    Failed to mount Cache
    E: can't open cache/recovery/ log
    e: failed to mount /cache /recovery/ log
    e: failed closing /dev block platform etc etc etc
    please help, Im trying to figure this out but haven't noticed anything other than the reset option  (power button + volume up).
    Is it possible to update using external storage (USB/SD card)?  What are my options?

    Hello, and Welcome to the HP Support Community!
    Why are you trying to enter recovery mode?
    If you are sure you have followed the directions carefully, if still under warranty contact HP directly.
    To contact HP directly, click this link: http://h22207.www2.hp.com/us-en/contact-hp/
    Outside the USA:
    http://www8.hp.com/us/en/contact-hp/ww-phone-assis​t.html
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • Disk images failed to mount - codec overrun

    Hi,
    So after searching through the related posts I have been unable to correct my probelm, which is:
    I am unable to open some .dmg files. I have tried to open three different .dmg files from a variety of sources and they all return the same error:
    disk images failed to mount - codec overrun
    However, I was able to update my system to 10.4.7 using the updater. This did not solve the problem. I then tried load the combo version of 10.4.7 as suggested in a different post and while it didn't load (I accidentally grabbed the powerPC version) it was able to open the .dmg and look in them.
    Disk Utility is unable to attach the three that won't open. The first two Disk Utility was unable to verify or repair. The last (a cars game demo) was successfully verified but still came up with the codec overrun error when I tried to attach it. Finally I have tried removing the following two files and then restarting, to no effect.
    /System/Library/Extension.kextcache
    /System/Library/Caches/com.apple.kernalcaches/
    I'd appreciate any help offered. A search on codec overrun was of no use. I searched for "mount failed disk images" and variations of that to find what I have already tried.
    Thanks
    Pete

    I am havin the same problems. codec overrun
    I am trying to download stuffit from their site so I can open a program for school.
    I tried to download the dmg file from the apple site but was given the same error. Codec overrun
    Also I attempted to get the updates from the Apple site.......same error.
    So far this computer will not download much of anything without some kind of an error. Essentially this Imac is a $2000 jukebox. It does play music wonderfully.
    My roommate was able to downlad easily from the same internet connection with no problem the windows version of the program from te same site.
    This is a brand new out of the box iMac. 20" 1 gig 250 GB machine. First Mac for me and it is turning into a real headache.
    Any help with the codec overrun would be appreciated.

  • Slave drive, CDs, USB drives, Disk Images and FW drives fail to mount

    Hi. I have two Maxtor internal hard drives (6Y160P0 and 6Y120P0), the second of which (6Y120P0) all of a sudden will not mount on the desktop. When I reboot my Mac, I get two identical error windows that state, “The disk you inserted was not readable by this computer”, with options to initialize, ignore, or eject. (There are no other drives of any type connected to the computer).
    Within Disk Utility (when run from the primary hard drive), the slave drive shows up, but its icon is dimmed. Clicking the “Mount” button does nothing. Disk First Aid does not allow one to “Repair Permissions” nor “Repair Disk”, presumably since it won’t mount (eg, these options are dimmed). One odd aspect about Disk Utility is that the master and slave drive are listed as “disk0s10” and “disk1s10”, respectively, rather than the way they usually show up with the names I’ve given them. Yet on the desktop the working master drive shows up with its given name.
    When I run Disk Itility from a CD, both internal drives look fine, accept repairs, and the drives are listed by their proper names.
    As another interesting clue, all of the Disk Images (stored on the working master internal hard drive) that I have attempted to mount fail to open as well. When I doubleclick them, I get an error that reads, “The following disk images failed to mount: Reason: No mountable file systems”.
    Two different USB keychains fail to mount; my FW drive fails to mount.
    I’ve run Applejack Auto Restart without any difficulty several times.
    Apple's Hardware check CD says all is AOK.
    I’ve rebuilt this problematic disk (and the master) several times with Disk Warrior 3.03 and all is supposedly AOK.
    SmartReporter says both disks are fine.
    TechTool Pro 4.1.2 has run the following checks on the problem disk and these are AOK: Disk Controller, SMART, Read/Write.
    All of this makes me wonder if the issue is with my system software, rather than the slave disk??? Interestingly, CDs refuse to mount as well when I've booted from the primary hard drive (but I don't think it is the CD drive itself since I can boot from the CD drive). This, coupled with the fact that disk images won't mount, makes me now think it is an OS issue rather than hardware.
    Any suggestions about what I can do to salvage and fix this problem would be greatly appreciated!
    G4/867MHz running OS 10.4.8

    If anyone else is having this problem, check out the totally awesome post by GNJ to my similar query on the MacFixIt forums:
    Drives and Disk Images refuse to mount
    http://www.macfixitforums.com/showflat.php?Cat=&Board=tiger&Number=791320&Forum= &Words=CharPatton&Match=Username&Searchpage=0&Limit=25&Old=6months&Main=791320&S earch=true#Post791320
    His suggestion to run the 10.4.8 combined PPC update worked like a charm and solved the problem perfectly!
    PS If you are having the same issue, there is the problem that one can't use a USB/FW drive to get the combo updater onto the problematic hard drive, and even if you can, the faulty software won't allow one to mount a .dmg image. This can be solved by using "Target" mode, eg connect the problematic CPU to a working CPU (in this case, my PowerBook) via a FW cable, then boot up the problem CPU while holding down the letter "t". One can then drag the combined updater unstuffed file (eg, not the .dmg) directly to the problematic disk from the working CPU. Then, when I booted in the problematic disk/CPU, all it took was a doubleclick on the unstuffed updater and all was fine.

  • CDs and dmg files failing to mount on an eMac; any suggestions?

    Dear all,
    I have not posted here before and hope someone can assist please; I'm a long-time Apple user, having started with the Apple II and currently owning an iMac G5 and PowerBook G4.
    Having obtained a G4 eMac, I discovered a serious software/hardware for which I can't find a solution. It is running OS X.2.8 which has an issue mounting .dmg and CDs. When I attempt to mount .dmg files, it reports the error message:
    "FILE NAME failed to mount due to error 95. (no mountable file systems)"
    All CDs will not appear on the desktop with the exception of the Apple Hardware Test CD. They do appear through Disk Utility but can't be mounted. I have tried apps such as "Mount" without success.
    Apple has recognised this problem:
    http://docs.info.apple.com/article.html?artnum=106345
    http://docs.info.apple.com/article.html?artnum=107288
    but none of the suggested remedies have worked for me. Various forums suggest solutions, a summary of which may be found here:
    http://www.macattorney.com/tutorial.html#anchor-diskimage
    but none worked.
    I have also tried holding the "c" key with the Install CD but it won't mount.
    Any suggestions please? I can boot with System 9 - as a last resort would it be possible to then delete key files from the OS X's "System" folder, following which I might be able to boot from the "Install" CD?
    Many thanks,
    Peter

    They sometimes say you're better helping yourself!
    I seem to have solved this after many hours of experimentation. I decided to hook up my iMac G5 (running 10.4.11) via a firewire cable. Having started the iMac, I followed the instructions for a target disk, connected the cable and fired up the eMac (hold "T" etc). Within minutes the eMac with its inserted CD could be seen on my iMac's desktop. However, I now needed to see if it worked the other way around - if I could somehow boot up with the eMac and use the iMac as the target disk, putting the CD into the iMac.
    The eMac read the iMac's drive but unfortunately I could not see the inserted CD. Having then turned off the iMac, I left the firewire cable plugged in and then inserted the eMac's Install disk - to my great surprise the Install disk suddenly appeared on the eMac's desktop for the first time! I clicked the Installer which then announced it would start up from the CD. It duly did - and I managed to revert back to System 10.2, rather than the problematic Apple upgrade 10.2.8 which had been installed (and apparently caused the problems).
    I'm trying to obtain a copy of 10.3 Panther, simply to run the excellent Elgato EyeTV.
    Fingers crossed!
    PJD.

  • A volume failed to mount/Operation cannot be completed

    We bought a MacBook on the weekend. Our Apple concierge insisted that we can keep our music, videos and photos on our Windows XP desktop and "share" the files on the Mac--in other words, we can pull down what we need to edit or save on the Mac as need be.
    We've set up the shared directories on the Windows machine, renamed the Workgroup to match the Mac and disabled the firewall. We've "connected to server" using Finder and can see the two shared directories we've set up.
    But when I click on either one of them, I get an error message: "A volume failed to mount. The volume "Mac" could not be mounted."
    After some time of being on the network, I see a Shared directory in Finder with my PC. If I click on the icon, the title bar says: "Connected as: Guest". The window displays the same two directories as above but when I click on one or the other I get an error message: "The operation cannot be completed because the original item for "Mac" cannot be found."
    I've called Apple technical support and the agent's response was: I don't think you can do that. Just copy your files to the Mac using DVDs.
    Any ideas? We don't want to have to transfer a lifetime of photos, video and music to our laptop--we want to use the XP desktop as our hub.

    I'm having the same trouble. From an Intel Mac Mini running 10.5.3 I've been able to access smb shares fine on an old PC running XP pro. These are shared volumes on external drives on the PC. I can still access them fine from an old PowerBook G4 running 10.5.3, but while I can see computers on the network, if I try to connect to a share on the computer I get the message "the operation cannot be completed because the original item for <share name> cannot be found". If I try to mount it via a shortcut, I get the message "A volume failed to mount. The volume <share name> could not be mounted.
    In the console, I'm seeing things like:
    6/2/08 10:45:01 PM com.apple.coreservicesd[58] NOTE: Using non-mach-based version of client -> server communication, via direct function calls.
    but I don't know if that has anything to do with this or not.
    Has anyone heard of a fix for this?
    Thanks,
    Mark

Maybe you are looking for