Posted 19 September 2010 - 04:31 PM
Recently I had a situation where I couldn’t get into the GUI (even with safe mode –x). I knew I had to replace a certain file on the root with a file I had stored on another drive. Now if this was DOS, it would be trivial to copy the file over – not so in OS X.
In order to use the mount command, we first need to know three pieces of information.
1. The name of the drive we want to mount (what do we call it?)
2. The type of file system that drive uses.
3. The folder we are going to mount the drive in.
First we need to enter Single User Mode. For Chameleon-type hackintosh bootloaders, hit any key then type –s enter. For legit Mac users I think you hold Apple and s key as you boot.
After booting, somewhere on the screen, you should see a line similar to this:
BSD root: disk0s1, major 14, minor 1
This tells us that we are currently on disk 0, partition 1 (ignore the major, minor).
You can now go ahead and enter the two commands listed on the screen.
mount –uw /
The first command will check your disk for errors and the second will give you write access to the root. You now need to be EXTREMELY CAREFUL about making inadvertent or damaging changes to root.
We need to know what the computer has called our drives and partitions. We use the ls command (similar to dir in DOS).
ls –l /dev/disk*
We get some output which contains something like this:
/dev/disk0s1 <-- we know we are on this partition
/dev/disk1s2 <-- the file we want is here (we think)
Note this list seems to change and there is no guarantee that partitions named in the GUI using diskutil will have the same names here. Also CD’s and DVD’s take a while to show up sometimes so just repeat the command (use up arrow) until they do.
Check the file system used by the drive we want to mount. In my example it is a Windows NTFS partition.
ntfs <-- ok that’s what we expected
Now we create a folder to mount the drive to. For easy access let’s make a folder on the root called “drive2”.
Now it’s time to use all this information in the mount command
mount –t ntfs /dev/disk1s2 /drive2
With some luck it worked. We check to see if our files and folders are there.
ls –l /drive2
If the device was a HFS/HFS+ volume (Mac OS) then we would use this command:
mount –t hfs /dev/disk1s2 /drive2
USB hard drives and flash drives would use similar syntax depending on what file system the device was formatted with eg. NTFS (windows), HFS (mac), MSDOS (older / smaller usb sticks).
For a CD…
mount –t cd9660 /dev/disk1s2 /drive2
For a DVD…
mount –t udf /dev/disk1s2 /drive2
if this doesn’t work then try the cd9660 switch as if it was a CD.
Mounting a Samba network share does not seem to work in Snow Leopard 10.6.4.
At this point you should be able to do the things you wanted to do (cp files etc.). Note, HFS drives are mounted with WRITE ACCESS by default even if the root is read-only (use -r switch if you want to mount read-only). NTFS drives are mounted as read-only and there is no native support for write access.
We can unmount the device using this command (note spelling of “umount”):
When you are finished, use the reboot or shutdown command. DO NOT use the exit command which will continue booting into GUI.
NOTE: Please do not reply to this thread to troubleshoot your problems. I'm not an expert, I just taught myself what I needed to know to get the job done. Single User Mode has an excellent man command (short for manual). This is the best way to teach yourself. Also look in the /sbin folder for variations of the mount command for other file systems.
If you have something useful to add, for example you know how to get SMB shares to mount, then please contribute.
Posted 21 October 2010 - 02:12 AM
Somehow I messed up my install and needed to backup before reinstalling.
Posted 15 October 2012 - 05:08 PM
Posted 28 August 2014 - 06:39 AM
Could you tell me how can I repair disk permission in -s mode?
After usage over time, If Mac performance has degraded, any important data is missing or you need an ordinary regular maintenance. Then, it is good to repair disk in Safe mode. Please backup before you attempt all these. Launch Disk Utility and find these 2 commands
"Verify Disk Permissions' and 'Repair Disk Permissions' in the Left pane.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users