30.4.12

How to re-load/re-index with (or disable) Spotlight in Mac OS X Lion

How to Disable (or Enable) Spotlight in Mac OS X Lion


Disable Spotlight in OS X Lion

Completely disabling and reenabling Spotlight in Mac OS X Lion can be done with the help of the Terminal. The following command unloads the Spotlight mds agent from launchd, preventing the daemon from running or indexing any drives entirely.

Open up the Terminal (found in /Applications/Utilities/) and enter the following commands based on the need to either disable or reenable Spotlight indexing. This will effect indexing on all drives connected to the Mac.

Disable Spotlight

The primary method is using launchctl, this will require the administrative password:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
Another approach is to use the older indexing method of “sudo mdutil -a -i off” which turns off indexing only, but more on that in a minute.

Re-enable Spotlight

The guaranteed way to reenable Spotlight is to reload it into launchd using launchctl:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
Again, the alternate approach is the indexing related “sudo mdutil -a -i on” command, but that method can throw the “Spotlight server is disabled” error and not allow you to turn it back on. If you run into that problem, use the sudo launchctl load command instead to enable both indexing and Spotlight.

With Spotlight reloaded launchd, the mds agent will immediately start running again to reindex the filesystem. Depending on the amount of changes and new files since the last time MDS ran, this can take a while. You can verify that MDS is running through Activity Monitor or by pulling down the Spotlight menu to see an “Indexing Drive Name” progress bar.

Enable Spotlight in OS X Lion

Spotlight tips - mac os x

Spotlight tips

Spotlight tips

This FAQ, derived from information in the "Spotlight" chapters of our book Troubleshooting Mac OS X, addresses the following topics related to Spotlight® in Mac OS X:
A comprehensive treatment of Spotlight, including extensive troubleshooting information, can be found in the "Spotlight" chapters of our Troubleshooting Mac OS X e-books.

A brief tutorial on Spotlight

  • Spotlight was introduced in Mac OS X 10.4 and significantly improved in later versions of Mac OS X.
  • Spotlight will begin indexing any volume as soon as it is mounted, with certain exceptions: CDs, DVDs, disk images, and shared network volumes are not indexed when mounted. By volume we mean either a hard drive with a single partition, or a specific partition on a hard drive with multiple partitions.
  • By default, Spotlight indexes and searches a limited number of folders, specifically those listed in the AppleCare® Knowledge Base document "Mac OS X 10.4: Where does Spotlight search?"
  • Furthermore, Spotlight will neither index nor search:
    • Hidden files: Files whose names begin with a period (.).
    • Invisible files: Files whose invisible file-system attribute has been enabled.
    • Files within hidden or invisible folders.
    • Under Mac OS X 10.4, System-related files or folders. These are indexed and can be searched under Mac OS X 10.5 and later.
  • Spotlight saves all its index-related files in the .Spotlight-V100 directory at the root level of a volume it has indexed.
  • If you open Activity Monitor, the process mds is active when Spotlight is either indexing or searching. The mdimport process is also active during indexing. Under Mac OS X 10.5 or later , the mdworker process is also active during indexing.
  • Under Mac OS X 10.4, Spotlight is disabled in Safe Mode. Under Mac OS X 10.5 and later, Spotlight is available in Safe Mode.
  • Spotlight employs Search Kit for content indexing and finding files by their content. SearchKit was first introduced in Mac OS X 10.3 for content indexing and Find By Content. However, Spotlight does not remove content indices created under previous versions of Mac OS X, which can consume considerable space on the hard drive.
  • Removing these indices is especially tedious since Spotlight will not find hidden files whose names begin with a period (.) and index files created under Mac OS X 10.3 and earlier have file names beginning with .FBC .
  • As a result, you must use a utility like DEVONtechnologies EasyFind to locate and remove index files created under Mac OS X 10.3 and earlier.
  • See our "Troubleshooting a failed indexing operation" FAQ for information about index files created by ContentIndexing under earlier versions of Mac OS X.
  • A number of Terminal commands are available for working with Spotlight:
    • mdfind : Search Spotlight metadata indices.
    • mdimport : Force Spotlight to import metadata for a specific directory.
    • mdls : List the metadata attributes of a specific file.
    • mdutil : A utility for managing Spotlight indices.
  • You can find a variety of hints for manipulating the Spotlight index files, overcoming some of Spotlight's default limitations, and for using the Spotlight-specific Terminal commands by searching the Mac OS X Hints site for spotlight.
  • Additional information about Spotlight can be found by reviewing the documents listed in the Related links section of this FAQ.

Rebuilding Spotlight indices

There are two approaches to rebuilding the Spotlight indices on a given volume:
Via Privacy: Add, then remove, the volume whose Spotlight indices you wish to rebuild to the System Preferences > Spotlight > Privacy tab (hereafter abbreviated as "Privacy"). See the AppleCare Knowledge Base document "Spotlight: How to re-index files and folders."
Via Terminal: Assuming indexing is enabled on the volume in question:
1.
Open Terminal, located in the Macintosh HD > Applications > Utilities folder.
2.
At the Terminal prompt, type the following command:
  • sudo mdutil -E /path_to_volume
where /path_to_volume is the path of the volume whose Spotlight indices you wish to rebuild. [1]
For example, to rebuild the Spotlight indices for your Mac OS X startup disk, the command is:
  • sudo mdutil -E /
3. Press Return. You will receive a confirmation message based on the version of Mac OS X you are using:

Mac OS X Confirmation Message
10.5 and later Indexing enabled.
10.4 Volume index removed.

Indexing will begin shortly thereafter.
4. At the Terminal prompt, type exit and press Return.
5. Quit (Command-Q) Terminal.

Stopping Spotlight indexing

A common practice to stop Spotlight from indexing volumes is to add the volume to the Privacy while the volume is being indexed.

Under Mac OS X 10.4, using Privacy to stop indexing can cause a variety of anomalous behaviors which are the result of inconsistencies in how the Privacy tab works vs. certain functions of the mdutil command.

These anomalies have been corrected in Mac OS X 10.5 and later . Nevertheless, using Privacy to stop indexing on a volume works best in Mac OS X 10.6 and later: it is sometimes problematic under Mac OS X 10.5, especially when used for external hard drives that are moved between different Macs.

Disabling Spotlight indexing while indexing is in progress

Adding a volume to Privacy while it is being indexed is not the best method for stopping the indexing of that volume. Instead, we recommend the following:
1. Let indexing begin on the volume.
2. Open Terminal, located in the Macintosh HD > Applications > Utilities folder.
3. At the Terminal prompt, type the following command, exactly as written:
  • sudo mdutil -i off /path_to_volume
where /path_to_volume is the path of the volume being indexed. [1]
4. Press Return.
5. If prompted for a Password, type your Admin password, then press Return.
You will receive the response:
  • /path_to_volume/: Indexing disabled for volume.
under Mac OS X 10.4 or
  • /path_to_volume: Indexing disabled.
under Mac OS X 10.5 or later.
Spotlight will immediately cease to index the specified volume.
6. If you are using Mac OS X 10.5 or later, skip to step 9.
Otherwise, erase the partial index created by Spotlight under Mac OS X 10.4 . At the Terminal prompt, type the following command, exactly as written:
  • sudo mdutil -E /path_to_volume
where /path_to_volume is the path of the volume being indexed. [1]
7. Press Return.
8. If prompted for a Password, type your Admin password, then press Return.
You will receive the response:
  • /path_to_volume/: Volume index removed.
9. At the Terminal prompt, type exit then press Return.
10. Quit (Command-Q) Terminal.

Preventing Spotlight from indexing backup volumes

If you use a backup or synchronization utility to duplicate one volume on your Mac — the source volume — to another volume, such as a FireWire drive — the destination volume, you may notice that Spotlight will index the destination volume even though you previously disabled indexing on such. This is especially true if:
  • Your backup utility performs either:
    • An incremental duplicate, copying only new or changed files from the source volume to the destination volume.
    • A full duplicate, copying all files from the source volume to the destination volume, replacing the contents of the destination volume.
  • Spotlight indexing is enabled on the source volume.
As part of the duplication, your backup utility may copy the .Spotlight-V100 directory from the source volume to the destination volume. If Spotlight is enabled on the source volume, then it will be enabled on the destination volume after the .Spotlight-V100 directory is copied to such from the source volume.

The information Spotlight uses to ascertain if indexing is enabled on a volume is saved in the .Spotlight-V100 directory at the root level of that volume. Therefore, if you backup a volume on which indexing is permitted, after the /.Spotlight-V100 directory is copied from the source volume to the destination volume, indexing will be enabled on the destination volume.
Additionally, Spotlight may begin to index the destination volume while the backup is in progress. This can slow the backup process considerably: in our tests, this has caused backups to require up to 150% of their normal time, i.e. a one-hour backup could require 1.5 hours due to Spotlight indexing the destination volume.

The latest versions of the backup and recovery applications recommended in our "Backup and Recovery" FAQ will respect the state of Spotlight indexing on the destination volume. If you use one of the recommended applications, you can avoid the problem of Spotlight indexing backup volumes while the backup is in progress by simply disabling Spotlight indexing on the destination volume before performing the first backup.

Related links

How to install Mac OS X Lion on your Hackintosh with Unibeast

How to install Mac OS X Lion on your Hackintosh with Unibeast

 
If you're interested in running Mac OS X, but you don't want to pay ridiculous prices for a normal Mac, then a Hackintosh just might be for you. Right now, the newest iteration of Mac OS X is 10.7, known as Lion. We've already covered installing Mac OS X 10.6 (Snow Leopard), but unlike Snow Leopard, Lion doesn't include an installation DVD, which complicates matters. While tonymacx86's guide on installing Lion is very good, it's also very basic, just like his Snow Leopard guide. This guide follows tonymacx86's method, but it also attempts to explain every part of the process in detail, from start to finish (with pictures, thanks to Virtualbox). 

NOTE: Mac OS X Lion has several new hardware requirements, compared to Snow Leopard. Lion is a 64-bit operating system, meaning that old 32-bit processors like Intel Pentium no longer work. Additionally, AMD processors do not work with Lion because there is no legacy kernel.


.....more: How to install Mac OS X Lion on your Hackintosh with Unibeast

Use Lion's FileVault 2 to encrypt your Mac's internal drive | Macworld

Use Lion's FileVault 2 to encrypt your Mac's internal drive | Macworld

Apple latest Mac operating system, OS X 10.7 Lion includes FileVault 2, the latest version of Apple’s method of file encryption. In this how-to, we'll go through the steps on activating FileVault 2 for your Mac's internal startup drive. 

Step 1: Proper partitioning 

Before we begin the encryption process, your Mac’s internal startup drive must have Lion’s Recovery HD partition, which appears if you formatted your drive using the GUID partition scheme, as well as a single partition or multiple partitions created with Boot Camp Assistant. If you’ve partitioned your drive in a different way, you need to back up your data, erase and repartition your drive, and then re-install Lion, restoring your files, apps, and data afterwards.
To verify that the Recovery HD partition is on your Lion startup drive, restart your Mac and hold down the Option key. This will launch Startup Manager (pictured, top), where Recovery HD will appear if it is installed. You can also launch the Terminal, type diskutil list and press Return. A list (pictured, bottom) of your hard drives and partitions will appear.

Learn more about Lion Recovery and Recovery HD.