Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Book for UNIX on Mac OSX

Book for UNIX on Mac OSX
Thread Tools
bruce0515
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
May 11, 2010, 12:06 PM
 
Can anyone recommend a good book dealing with the UNIX upon which OSX is built? I'm somewhat experienced with UNIX in general but I'm looking for specifics that would be found in "Apple" UNIX like mounting external firewire hard drives, transferring files along with their Apple specific information and so on.

My reason is that I have an iMac that went down last summer. I can get into the UNIX command environment but after many efforts I am now resolved to the fact that it will never boot into the graphical interface of OSX again. It appears that the data on the hard drive is all there and I want to put it on a firewire hard drive along with any permissioning.
     
turtle777
Clinically Insane
Join Date: Jun 2001
Location: planning a comeback !
Status: Offline
Reply With Quote
May 11, 2010, 12:24 PM
 
Uhm, yeah, if you just want to copy files, sudo cp should do the trick.

After you copied them, just use chmod and chown to change ownership and permissions.

Am I missing something ?

-t
     
Person Man
Professional Poster
Join Date: Jun 2001
Location: Northwest Ohio
Status: Offline
Reply With Quote
May 11, 2010, 01:04 PM
 
Originally Posted by bruce0515 View Post
Can anyone recommend a good book dealing with the UNIX upon which OSX is built? I'm somewhat experienced with UNIX in general but I'm looking for specifics that would be found in "Apple" UNIX like mounting external firewire hard drives, transferring files along with their Apple specific information and so on.

My reason is that I have an iMac that went down last summer. I can get into the UNIX command environment but after many efforts I am now resolved to the fact that it will never boot into the graphical interface of OSX again. It appears that the data on the hard drive is all there and I want to put it on a firewire hard drive along with any permissioning.
Are you saying that you can boot into Single User Mode (hold down Command-S during start up), but booting normally into the GUI won't work?

Do you have another Mac available that you can hook the iMac to? One with Firewire? Why not just use the "broken" iMac in Firewire Target Disk Mode? This turns the computer into what essentially looks like an external Firewire hard drive to other machines. You should be able to use it on the iMac if you can boot into Single User Mode. All iMacs after July 2000 can do it.

This Support Article explains how, but basically, you hold down "T" as you start up the machine. It will come on and display a giant Firewire logo that slowly moves around. Connect a Firewire cable between the Mac you want to copy from and the Mac you want to copy to. The hard drive will mount on the other computer, and you can copy your files.

Hope this helps.
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
May 11, 2010, 09:41 PM
 
Originally Posted by Person Man View Post
Are you saying that you can boot into Single User Mode (hold down Command-S during start up), but booting normally into the GUI won't work?

Do you have another Mac available that you can hook the iMac to? One with Firewire? Why not just use the "broken" iMac in Firewire Target Disk Mode? This turns the computer into what essentially looks like an external Firewire hard drive to other machines. You should be able to use it on the iMac if you can boot into Single User Mode. All iMacs after July 2000 can do it.

This Support Article explains how, but basically, you hold down "T" as you start up the machine. It will come on and display a giant Firewire logo that slowly moves around. Connect a Firewire cable between the Mac you want to copy from and the Mac you want to copy to. The hard drive will mount on the other computer, and you can copy your files.

Hope this helps.
I read about target disk mode but I still haven't picked up a new Mac yet. So since I have an external firewire hard drive sitting around and I can boot into single user mode, I figured I might as well try to copy my files somewhere before the hard drive crashes too. I thought a good book might cover mounting file systems, file copying, creating backup archives ... maybe using the old iMac as a print server, so on. But thanks for pointing me toward target disk mode. I think that's really what I'll end up doing.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 11, 2010, 10:44 PM
 
Originally Posted by turtle777 View Post
Uhm, yeah, if you just want to copy files, sudo cp should do the trick.

After you copied them, just use chmod and chown to change ownership and permissions.

Am I missing something ?

-t

Never do that, because the ownership and permissions vary. Use cp -a or rsync -a to preserve this information.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 11, 2010, 10:48 PM
 
The file systems should mount on their own unless they are corrupt, in which case you can attempt a repair with a fsck -y. If you need to manually mount a volume you can do so with diskUtil.

You can also try booting from your OS X install CD and accessing the Terminal there so that you can start your copy, backup.

I would go with a:

cp -av / /Volumes/yourdrive
     
Simon
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status: Offline
Reply With Quote
May 12, 2010, 03:16 AM
 
Why don't you just clone the disk of the broken Mac to another disk?

Boot from the install DVD (insert disk, boot holding c), in the Utilities menu select Disk Utility > Restore. Drag the broken Mac's HDD to source, drag your external storage to destination, select erase destination, and click 'restore'. Done. All files will be backed up including all permissions, dates, symlinks, etc.
     
turtle777
Clinically Insane
Join Date: Jun 2001
Location: planning a comeback !
Status: Offline
Reply With Quote
May 12, 2010, 07:23 AM
 
Originally Posted by besson3c View Post
Never do that, because the ownership and permissions vary. Use cp -a or rsync -a to preserve this information.
I agree, for system files, that's not a good idea.

But for personal files (movies, music, documents), it should be ok.
He'd be later copying it back to a working OS install.

The issue I see with preserving the ownership and right sis that he runs into trouble accessing some files later on.

-t
     
Simon
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status: Offline
Reply With Quote
May 12, 2010, 08:06 AM
 
The problem with your suggestion, turtle, is that it's just plain and simple cp. Symlinks for example won't be preserved. Same goes for dates. The flags Besson uses make more sense.

That said, I still don't see why the OP should be forced to screw around on the CLI interface when all he needs to do is boot from the install DVD so he can use familiar and convenient GUI tools.
( Last edited by Simon; May 12, 2010 at 08:36 AM. Reason: typo)
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 12, 2010, 08:27 AM
 
Originally Posted by Simon View Post
Why don't you just clone the disk of the broken Mac to another disk?

Boot from the install DVD (insert disk, boot holding c), in the Utilities menu select Disk Utility > Restore. Drag the broken Mac's HDD to source, drag your external storage to destination, select erase destination, and click 'restore'. Done. All files will be backed up including all permissions, dates, symlinks, etc.

Definitely worth a try, but won't the entire imaging operation crap out once/if it hits some unreadable sectors?
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
May 12, 2010, 09:17 AM
 
Originally Posted by Simon View Post
The problem with your suggestion, turtle, is that it's just plain and simple cp. Symlinks for example won't be preserved. Same goes for dates. The flags Besson uses make more sense.

That said, I still don't see why the OP should be forced to screw around on the CLI interface when all he needs to do is boot from the install DVD so he can use familiar and convenient GUI tools.
I can't boot to the GUI even from the install disk. It just stalls out at the grey screen. Something in one of the chips must have gotten fried. What started all this was a power surge before a blackout. I was connected to a battery backup surge protector. The computer did not go down. I wasn't home at the time and my son thought it would be wise to shut it down .... never to boot normally again.
     
Simon
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status: Offline
Reply With Quote
May 12, 2010, 01:19 PM
 
So you claim you can't get past the gray startup screen regardless of boot partition but you can access your Mac through the CLI in single-user mode?
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
May 12, 2010, 04:16 PM
 
Originally Posted by Simon View Post
So you claim you can't get past the gray startup screen regardless of boot partition but you can access your Mac through the CLI in single-user mode?
I presume its single-user mode. During the boot process I press cmd-option .. something (sorry, I'm at work right now and don't have any notes to look at). I definitely get into UNIX. I can list directories and cat files so I don't think anything happened to the hard drive. I think something happened to the ROM involved in the whole boot process. If I try to boot from the install disk, I can hear that its going to the CD drive and reading but I never get past the grey screen.
     
Simon
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status: Offline
Reply With Quote
May 13, 2010, 03:56 AM
 
Does FW TDM work?
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
May 13, 2010, 08:29 PM
 
Originally Posted by Simon View Post
Does FW TDM work?
I have to get another Mac to use as the host. That's why for now I just wanted to backup to a hard drive from the command line environment.
     
jmiddel
Grizzled Veteran
Join Date: Dec 2001
Location: Land of Enchantment
Status: Offline
Reply With Quote
May 14, 2010, 04:10 PM
 
The OPs initial request was for a book he could use to figure this out, intrigued, I went to Amazon and found this book, which I promptly ordered.

Mac OS X for Unix Geeks (Leopard)"
Ernest E. Rothman; Paperback; $23.09 Amazon.com: Mac OS X for Unix Geeks (Leopard) (9780596520625): Ernest E. Rothman, Brian Jepson…
     
slferris
Fresh-Faced Recruit
Join Date: May 2010
Status: Offline
Reply With Quote
May 14, 2010, 04:47 PM
 
A favorite of mine is "The Mac OS X Command Line: Unix Under the Hood" by Kirk McElhearn
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
May 17, 2010, 10:32 AM
 
Originally Posted by slferris View Post
A favorite of mine is "The Mac OS X Command Line: Unix Under the Hood" by Kirk McElhearn
Does it have a lot of OSX specific techniques and examples?
     
Big Mac
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
May 17, 2010, 10:49 AM
 
If you can boot into single user mode, your Mac isn't that borked. Have you tried reinstalling OS X on a new hard drive?

Regardless, there's no mystery to getting your old hard drive in a firewire case. Buy one, install your drive in it, then connect to it another Mac and you're done. Permissions won't matter because you won't want to transplant the whole system from that old disk to the other Mac anyway, you just want the home folder(s). You don't need a Unix book for this kind of issue.

"The natural progress of things is for liberty to yield and government to gain ground." TJ
     
Simon
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status: Offline
Reply With Quote
May 17, 2010, 12:17 PM
 
Originally Posted by Big Mac View Post
If you can boot into single user mode, your Mac isn't that borked.
That's what I was thinking...
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
Aug 15, 2010, 06:33 PM
 
Finally picked up a new iMac, 3.06 i3. Decided to try the target mode idea with my old iMac. The old iMac goes into target disk mode but its icon doesn't show up on my new iMac. I can see it with diskutil, though and but it won't mount it. Obviously errors and I afraid that running fsck on it will make me lose my data.

So I'm trying to mount a 500 Gb usb external drive to my old iMac in single-user mode. I keep getting closer and closer to mounting it but I can't seem to get beyond an error that says Incorrect super block. There's nothing on my external drive so I can format it any which way I want. How do I get beyond the Incorrect super block?
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Aug 15, 2010, 10:04 PM
 
You're getting that error message mounting the external drive? What do you hope to do with the external drive, use it to shuttle data between the two machines? What have you done in attempt to format the external drive that has no data on it?

Sorry, I'm a little bit confused as to what you are trying to do here...
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
Aug 15, 2010, 11:35 PM
 
Yes. I want to shuttle data between the two machines. Using Disk Utility on my new iMac I formatted the external drive with one partition and formatted that partition as a Mac OS extended (journaled) partition. When mounting it from my old iMac, in single user mode, I get the Incorrect super block error. I tried again, this time formatting the external drive as a FAT partition and got the same error. I tried again, this time formatting the external drive as an eFAT partition and got the same error again.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Aug 15, 2010, 11:46 PM
 
Is the old iMac a PowerPC based iMac? If so, you will have to format the drive using the older partition map ("Apple Partition Map"), the newer partition map ("GUID") will not work on PowerPC based Macs. The partition map option is one of the format options within Disk Utility.
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
Aug 15, 2010, 11:52 PM
 
Yes its an old powerpc model and i did use the Apple Partition option.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Aug 16, 2010, 12:00 AM
 
Do you have an OS X DVD? You might want to try booting off of something else, just as a test. Your OS X install could be corrupt enough that some functionality is not possible in single user mode? I'm sort of grasping at straws here, but this would still probably be a worthwhile test unless somebody can think of something better...
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
Aug 16, 2010, 12:06 AM
 
I can't boot it off the CD. It tries to read from the drive but I just get the grey screen with the little spinning icon and it never gets any further
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Aug 16, 2010, 12:14 AM
 
Do you have access to another Mac you can use to install OS X to a partition of your external HD so that you can reattempt single user mode? It could be that there is enough severe physical damage to the drive that regardless it will cause OS X to wig out. Another option might be to remove the damaged drive so that it isn't present at boot time, and try a variety of tools to try to salvage data from it.

Just thinking out loud here...
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
Aug 16, 2010, 08:55 AM
 
The external drive is USB so I don't think its bootable from my old iMac. I guess I can buy a firewire external. Is it possible to reformat an old iPod and put OS X on it. Its firewire but only 10 Gb (its old -- 2nd generation iPod).
     
King Bob On The Cob
Mac Elite
Join Date: Apr 2002
Location: Illinois
Status: Offline
Reply With Quote
Aug 16, 2010, 05:48 PM
 
Bad superblock makes me think the drive is formatted as UFS. There is a backup superblock though and you may be able to use FSCK to fix it (provided the disk isn't dead).

Try running:

fsck -b 32

Once you get past that, the proper duplication command you want if you want to preserve all meta-data is "ditto"

Use "man ditto" and read up on it. It's the best duplication command you can find on Mac OS X.
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
Aug 16, 2010, 10:12 PM
 
Running fsck -b 32 /dev/disk1s3 returns:

Alternate super block location: 32
** /dev/rdisk1s3
BAD SUPER BLOCK: MAGIC NUMBER WRONG
     
bruce0515  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Location: Wrightstown, NJ
Status: Offline
Reply With Quote
Aug 17, 2010, 03:37 PM
 
Finally got my external drive mounted and was able to copy all my user files to it except for three.

Bits and pieces from everyone here helped in the solution plus a couple things from the Apple Discussion group. As you would expect it wasn’t really that complicated. Here are some notes for reference.

My external USB drive came out of the box formatted for Windows. Make sure you create a partition that is Mac OS extended. Whether its journaled or not depends on how you intend to use it. I used NOT journaled because I was only copying files. I also chose to create one big partition for simplicity. When creating the partition, go into options and select either GUID Partition Table or Apple Partition Map. I used Apple Partition Map since I was working with an old iMac. Run the verify utility just to make sure everything is OK with the drive.

I booted the old iMac into single-user mode and issued a “ls –lias /dev/disk*” command to see what disk devices were there. Then I plugged in my USB external and after some spinning and buzzing I issued the “ls –lias /dev/disk*” command again to see what was different. My external had been recognized as /dev/disk1s0 and /dev/disk1s3. I took a chance that s3 was what I wanted. This is where the “great revelation” came. I had been trying to mount with "/sbin/mount". I had read somewhere that there was a /sbin/mount_hfs but it was not found on my old iMac. I had also read that if you want to run fsck on an hfs+ drive then use fsck_hfs not fsck. I also read that there was a "mount" command as opposed to the "/sbin/mount" command. So as I was reading the man pages on “mount” I saw the post from King Bob on the Cob about the drive appearing to be formatted as UFS. As I’m looking at the mount documentation I see a –t hfs option. The light went off that I have an hfs file system and I’m using a mount command that is expecting a UFS file system and when it doesn’t find a Magic Number that confirms a UFS file system, it gives me an error. I need to inform this mount command that its an hfs drive.

So I created my mount point /Volumes/SimpleDrive and did a chmod 777 (probably not necessary). I mounted with “mount –t hfs /dev/disk1s3 /Volumes/SimpleDrive” and it mounted with no error. I used King Bob’s suggestion to copy with “ditto”, simply “ditto /Users /Volumes/SimpleDrive” and all the sub-folders and files under /Users were copied along with their meta data to the external drive. It took about 45 minutes or more (I didn’t really time it).

I unmounted the external with “umount /dev/disk1s3” and got rid of the directory with “rmdir /Volumes/SimpleDrive”. I plugged the external into my new iMac and there were all my files. Now I’m a happy camper. The only glitch so far is that I forgot the password for some old Audio Books and I can’t import them into iTunes.

Thanks so much to all who have contributed to this thread over the several months and hopefully my summary will be helpful to someone else.
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:26 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,