computer architecture – Michmutters
Categories
Technology

Use This Terminal Command to Force Eject a Stubborn Disk From Your Mac

Image for article titled Use This Terminal Command to Force Eject a Stubborn Disk From Your Mac

photo: The Image Party (Shutterstock)

We’ve all been there: You have an external hard drive or USB thumb stick plugged into your Mac, and you’re ready to part ways. You drag it to the the Trash, or right-click to eject it, only to be greeted by the infamous, “The disk wasn’t ejected because one or more programs may be using it.” You look around your Mac: No app is open, no program is running. Whatever is causing the ejection delays certainly isn’t your fault. In the wise words of Peter Parker“I missed the part where that’s my problem.”

Unfortunately, macOS has made it your problem. There could be multiple reasons why your computer won’t let go of your disk (we’ve run through them before), but often, the main issue is this: macOS is running a process accessing a file on the disk you can’t see. That’s why, even though everything is shut down and closed as far as you can see, your Mac insist the disk is in use. We all have trouble letting go sometimes.

That said, your Mac doesn’t always leave you hanging out to dry: Occasionally, you’ll see the option to Force Eject the disk, but even that solution comes with a caveat: How do you really know your Mac isn’t currently writing something to the disk? If you force eject it, either with software or by unplugging the disk from your Mac, you could damage your data.

Luckily, there’s a simple solution, so long as you’re OK usingTerminal. in to Reddit thread musing on this subjectone user suggested the following command to quickly end any unknown processes running between macOS and your hard drive:

sudo lsof /Volumes/{Name of the disk}

The “lsof” command, which stands for “list open files,” does exactly what is says: It’s a command meant to list all open files in your system, and dish on the processes that opened them in the first place. Because of this, it’s often used when users cannot unmount (or eject) disks—the command tells you which process is using which file, something you wouldn’t see just by using surface-level macOS. As long as you’ve stopped using the hard drive yourself, you should only see whatever process is holding things up on macOS’ end.

Once you know the process in question, you can terminate it, and safely eject the disk without worry. To do so, you’ll need to open Activity Monitor (press Command + Space then search “Activity Monitor”). Switch to the Disk tab, then scroll through the “Process Name” list until you see the one out in Terminal. Click on it, then click the (X) at the top of the menu bar. Finally, choose “Quit” on the pop-up to end the process. Now, try ejecting your disk: It should leave your computer right away.

As pointed out by another user in that Reddit thread, the culprit in many cases—at least on macOS—is Quick Look. Quick Look is the feature that allows you to peek at documents, images, and other files without needing to actually open those files first. If Quick Look pops up for you after running this Terminal command, this user recommends you try using Quick Look on another file not on your external disk. For example, open your Mac’s main disk and Quick Look a file there: That process can shake things loose, and allow you to eject your disk without issue.

.

Categories
Technology

The Hidden Way to Monitor Your Mac’s Temperature for Free

Image for article titled The Hidden Way to Monitor Your Mac's Temperature for Free

photo: pisaphotography (Shutterstock)

Apple silicon—including the M1 and new M2 chips—has a reputation for staying cool even under intense workloads. Intel Macs, on the other hand, run notoriously hot. They’re still capable computers, but they heat up fast, which, in turn, slows things down. If you have an Intel-based Mac, you’ve probably experienced this computational heatwave for yourself. Rather than guessing how hot your computer is getting, however, there’s a hidden monitor built into every Intel-based Mac that lets you know exactly what the internal temperature is.

Why your Mac overheats (and why it’s bad)

I talked about this subject beforewhen I mostly focused on laptops. Whether you have a MacBook or an iMac, however, the general principle is the same: You don’t want your machine to overheat.

Computers heat up because the internal components, namely the CPU and GPU, generate heat as they work. Depending on your computer, you might not notice it while performing light tasks. Once you start pushing the machine, however, you’ll feel the temperature ramping up.

It’s not that this heat will damage or break your computer. I mean, it absolutely could, but manufacturers make sure that will never happen. A little heat is okay; the parts are designed to operate normally within a wide range of temperatures. However, when the chips start to get too hot—usually around 90 degrees FAhrenheityour computer will slow down its processing speed in order to cool things down, a process referred to as “throttling.”

Throttling sucks, because it means you’re not getting the performance you expect from your machine. Truea slow machine is better than a burnt and broken one, but avoiding the overheating problem in the first place can help you prevent throttling before it kicks inand push your Mac to its maximum potential.

While there are many ways to combat overheating, one is to keep tabs on your Mac’s temperature. And if you have an Intel Mac, you already have a monitor built right into macOS.

macOS’ hidden temperature monitors for Intel Macs

You won’t find these temperature monitors by searching through the apps installed on your Mac. You won’t even find them in Activity Monitor, as useful a utility as it is. Rather, your Mac’s temperature monitor is found in Terminal. Using Terminal likely seems intimidating to many users, because it allows you to control your Mac using only text-based commands. But you don’t actually need to memorize any of thosee commands to use Terminal; a copied and pasted command works just as well.

There are plenty of useful Terminal commands everyone can use (we covered many of them in this piece) but we’re focusing on the temperature monitors this time. There are two commands you can use here. The first lets you see temperature stats for your Mac’s CPU. Copy and paste the following command exactly as-is into a new Terminal window (quotation marks and all):

sudo powermetrics —samplers smc |grep -i “CPU die temperature”

If done right, Terminal will ask for your password. Enter it (you won’t be able to see what you’re typing, unfortunately), then press the return key. After a moment, you’ll begin seeing temperature readings, updating roughly every five seconds. The temperatures are written in Celsius, so you’ll need to convert to Fahrenheit on your own, but, after a while, you start to pick up which temperatures are cool, warm, hot, and too hot.

Speaking of which, you will also get access to one of my favorite data points in macOS: When things start to get too hot and your Mac decides it needs to cool things down, you’ll see (fan) written next to the temperatures (if your Mac has fans, that is). That lets you know the fans are starting to work harder to move hot air out of your machine. Fans are obviously a good tool for cooling computers, but they aren’t perfect: If your CPU is still heating up to unsafe levels—usually 98 degrees Fahrenheit, going by my experience in Terminal—you’ll start to see (power) instead. When this reading appears, it means macOS is throttling your CPU to keep the temperature from going overboard.

You can also check your GPU temperatures with the following command:

sudo powermetrics –samplers smc |grep -i “GPU die temperature”

Notice that you won’t see (fan) or (power) appear on this Terminal windowonly temperature readings.

Options for Apple silicone

While Apple’s suite of silicon chips don’t face as many heat ramps as Intel-based Macs, they can still overheat and throttle like any other chip. Unfortunately this built-in Terminal command won’t work on M1 and newer, since those chips are designed differently than Intel chips in how they handle heat.

The only solid temperature monitor for Apple silicon available rright now is TG-Prowhich comes at a cost. It’s usually $20, though at the time of this writingit’s on sale for $10. If you’re looking for a temporary solution, the app offers a two-week free trial, so you can monitor your temperatures on M1, M2, or any other Apple silicon variant for 14 days free of charge.

Hopefully, as Apple silicon is adopted by more and more of the Mac user base, developers will write more temperature monitoring apps for the platform. Hey, maybe Apple will even make their own—for free.

.