Full bootable system on usb device (for virus/malware scanning and/or system recovery)?

My macbook has been acting a bit strange for the last three months (mostly semi-random system freezes and an odd 'allow' rule added to my firewall that I'm pretty sure I didn't add), so I wanted to install some Antivirus(AV) and malware scanners, but I don't really want to run these all the time, so I was hoping to create a bootable external disk with these tools so I could boot off them on occasion if anything seemed a bit strange, but creating a bootable external volume has been surprisingly difficult.

(quick sidenote: I'm aware of xprotect and while it's awesome and I'm glad to have it, it doesn't make logical sense to me that a sufficiently advanced virus/trojan couldn't patch/tweak any actively running protection software it was aware of. Therefore, it seems the only way to be sure is to boot off a "known clean" system (with both up-to-date versions of xprotect and any other AV/malware scanner you want to run), then mount the suspect system as an external drive and scan away).


Back to the core problem: I tried creating a bootable usb install stick, booted off of it, then used that usb stick to install to a different stick (single partition, osx extended journaled, guid partition table).


This "appeared" to be working (it went through the full install process, which initially appeared to go quickly, but then the last little bit took more than half an hour), but when I tried to boot off of said target stick (by holding option to get a list of choices), I wasn't given the option to boot off the target stick. Booting off the internal disk and taking a look at the target stick showed a pretty empty stick (I believe there was a folder with a handful of files).


I'd be fine with using the install disk if I could actually run anything on it. I did try copying one of the AV programs I was going to test to the install stick, rebooted off of the install stick, then ran the AV installer from the terminal, but it checks if the root drive has enough space (which it doesn't and also is read-only) and won't let me install anywhere else (like the writable partition on the 32gb sd card that I'm using for the install drive).


Any suggestions how to make a bootable system on an external disk, preferably with a writable root partition (or a way to get j.random.antivirus to let me install somewhere other than the root partition)?

MacBook, OS X Yosemite (10.10.2)

Posted on Apr 10, 2015 11:19 AM

Reply
12 replies

Apr 10, 2015 12:37 PM in response to Kappy

Just to verify, you're saying that it is indeed possible to run the yosemite installer off one flash drive to install a fully bootable system on a second flash drive (creating not just another bootable installer stick, but a stick with a complete OS install), yes?


(ps, for any future reader who found this thread through a search engine and is wondering why the sudo command above doesn't work for you: The command is using the developer preview, but you've got the general release version of the yosemite installer. I'd give the corrected command, but IMHO if you can't fix it yourself, you really shouldn't be running sudo commands. Have solid backups if you decide to ignore this warning).

Apr 13, 2015 11:02 AM in response to Leo41

Use the Yosemite installer application to install a system on a 16 GB flash drive prepped for OS X. I've done this numerous times. Do not attempt to install something else on the flash drive before installing OS X.


If you want to create a bootable installer:


Make your own Yosemite flash drive installer using the Yosemite tool:


You can create a Yosemite flash drive installer via the Terminal. Yosemite has its own built-in installer maker you use via the Terminal:


You will need a freshly partitioned and formatted USB flash drive with at least 8GBs. Leave the name of the flash drive at the system default, "Untitled." Do not change this name. Wait for the process to complete which will take quite some time.


Open the Terminal in the Utilities folder. Copy and paste the following command line in its entirety into the Terminal window.


sudo /Applications/Install\ OS\ X\ Yosemite\ Developer\ Preview.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Yosemite\ Developer\ Preview.app --nointeraction


Press RETURN, enter admin password (will not echo to the window) then press RETURN again.


You need to have the installer in your Applications folder or change the paths in the above command line.

Apr 10, 2015 12:58 PM in response to Leo41

To further clarify:


  1. Run createinstallmedia to create bootable installer on stick A.
  2. Boot from stick A into bootable installer.
  3. Go through normal 'os install' process using stick B as target (aka, not createinstallmedia).
  4. Reboot using stick B into a normal instance of OSX Yosemite without the internal hard disk mounted.
  5. Install anti-virus on the running OS on stick B (not the internal hard drive).


Assuming I can do all of the above, I know how to mount the internal drive with hdiutil, so I should be good to go. So far, step 4 hasn't worked as expected, but you (Kappy) are saying you have indeed done this (not step 5, but step 4)?

Apr 10, 2015 12:59 PM in response to Leo41

Thank you for noticing that error. I need to change that command line. The sudo is still required.


To clarify: You can use the downloaded Yosemite installer to install OS X on a flash drive; you can also create a bootable flash drive installer. You can boot from that flash drive and install OS X on another flash drive. Both methods work, but the latter will be a bit slow, so I wouldn't recommend it unless necessary.


If you have a bootable OS X drive (flash or otherwise) that doesn't have more space in use than the target device, then you can clone one to the other using Disk Utility.

Apr 13, 2015 11:02 AM in response to Leo41

First, regarding the install of Yosemite, you'll probably need more space in order to do anything meaningful with it. OS X gets cranky without enough free disk space to play with. A small portable hard drive would probably be a better choice than a flash drive.


As to the necessity of doing this, though... there really is none. There's no currently known malware capable of infecting Yosemite, and the last new Mac malware appeared back in November. Nothing new since then.


At some point in the future, there undoubtedly will be some new Mac malware. When that happens, Mac OS X will not protect you against it... but neither will any anti-virus software. So running anti-virus software won't give you any kind of benefit there.


Finally, it's important to understand that if you did happen to get infected with something, anti-virus software will not be a cure. In the case of real malware, in most cases, an infection means you'd better erase the hard drive and reinstall everything from scratch, or restore from a prior backup. You should never let anti-virus software "remove" the malware and assume that's good enough. It might be, but there could be an awful lot riding on that "might."


If you do decide to install anti-virus software in a clean system on an external drive, the only one that I would recommend using at this time is ClamXav.

Apr 10, 2015 11:14 PM in response to Leo41

As long as you have been keeping your software fully up-to-date and have not disabled XProtect or Gatekeeper, then there is no known malware that has been able to "patch/tweak any actively running protection software it was aware of." If I recall correctly, the last time anything close to doing something like that was Flashback in 2011 which would simply give up if it observed firewall or virus protection processes active.


I have always been able to install a complete OS X on a 64 GB USB thumb drive or Secure Digital Memory Card by simply using a full installer from my hard drive, but I see it only takes up about 20GB, so a 32GB should work just fine. You should not need to create an separate Installer USB drive first unless you want one for other purposes (which I have always done).


I know there is a smaller version that has been made available to developers for products such as DiskWarrior, TechTool Pro, Drive Genius and Data Rescue, but I suspect it's not available to users.

Apr 13, 2015 11:12 AM in response to Kappy

Retrying the process did indeed work this time. I used the same card adapters, but a different memory card, so I'm assuming a problem with the other card was the core issue (I did notice that the first time around, it felt like it stayed on "about a minute remaining" for a full half out, but this time around, I started a timer and while the initial install to the SD card took just over an hour, I never noticed the "about a minute remaining", and the machine rebooted off the new sd card on it's own (the "phase 2" part of the install). I expected to have to hit 'option' to get it to boot off the new device, so I'm assuming there's a 'boot from' setting in the nvram. As a side note, I was also surprised that my non-standard keyboard preference seems to go into nvram as well).

Apr 13, 2015 2:55 PM in response to thomas_r.

Short version: This all started because I noticed an 'allow' rule in my software firewall allowing connections to the ssh port from a single ip in china, which is on a number of "banned hacker ip" lists.



Long version:


First, regarding the install of Yosemite, you'll probably need more space in order to do anything meaningful with it. OS X gets cranky without enough free disk space to play with. A small portable hard drive would probably be a better choice than a flash drive.


So far, it's working ok with a 32gb card (obscenely slow, as expected).


As to the necessity of doing this, though... there really is none. There's no currently known malware capable of infecting Yosemite, and the last new Mac malware appeared back in November. Nothing new since then.


My original question was boiled down to the core issue I was trying to solve (building a usb boot device with 10.10, which I'm doing on a 2008 macbook running 10.10.2), but the actual laptop I'm concerned about is a 2011 macbook air running 10.9.5 (and, to be honest, even the security updates take way too long for me to install because having to reboot incurs a massive personal performance hit as I have to reopen everything I was working on (aka, a bunch of terminal and "screen" (the terminal multiplexer, like tmux) sessions)).


Quick preface to the event that made me nervous: I'm using an outbound firewall on all my macs called LittleSnitch (technically, it handles both directions, but it's raison d'etre is that it's a firewall that allows you to set rules on a per-program basis instead of per-host. For example, I can allow any of the osx core software (ex: apsd, assistantd, etc) to talk to anything in the apple.com domain, and block other programs from doing so). This allows me to see what software is trying to connect where outside of my laptop (because it pops up an allow/deny alert when something occurs that doesn't match an existing rule).

This is useful because while I do outbound filtering of most ports on the firewall between my lan and the internet, I leave 80 and 443 (and a few others) wide open because I have no choice. I'm concerned about any virus/trojan using 80/443 to call home, so LittleSnitch allows me both to watch for that, and restrict those ports to my browsers. So I'll get an alert if j.random.program tries to hit somedomain:80, which is great as long as said virus/trojan doesn't burrow into my browser and use the browser to make outbound connections.

But here's the event that really bothered me: I have LittleSnitch setup to auto-block any connection attempt made if I don't acknowledge it within 3 minutes. I recently noticed in my "unapproved rules" section (aka, rules that have hit this 3min limit and used my default block rule) that there was an 'allow' rule. Also, it was for an incoming port (also odd). The target port is 22, and it allows a single ip address. Of all my computers, this is the only one not running sshd, so the rule itself didn't have a negative effect on my security, but it raises a number of troubling questions:

  1. How was it added?
  2. Why is it marked 'allow'?

I suppose I should point out that the single ip this rule allows is in china and if you google that ip, it shows up on a number of "banned hacker ip" lists (including abuseipdb.com). I should also mention that I've never been to china, nor do I work with anyone in china, so I can't find a legitimate reason for this rule to exist.

At best, it's "possible" that, while attending a unix conference AND while my laptop was booting (the other way a rule will make it into the 'unacknowledged' section: if it occurs before you've logged in, so it can't show an alert) that my laptop was port scanned by said ip. The problem is that there's a lot of unlikeliness here, and it STILL should have shown up as a 'deny' rule instead of an 'allow'.


Finally, it's important to understand that if you did happen to get infected with something, anti-virus software will not be a cure. In the case of real malware, in most cases, an infection means you'd better erase the hard drive and reinstall everything from scratch, or restore from a prior backup. You should never let anti-virus software "remove" the malware and assume that's good enough. It might be, but there could be an awful lot riding on that "might."


Which is the core problem. On one hand, I do have backups of this laptop, but I can't point to a specific date when this may have occurred. Also, they're timemachine backups to a local NAS which is always on, so one assumes that if the laptop is infected, it's possible that said infection has added itself to any/all checkpoint timemachine backups as well. Speaking of the NAS, I have two NAS devices but their only backup is that each one contains two disks in a raid1 configuration, so even if I restore the laptop from the timemachine backups, there's potential that the NAS also contains the infection (though, I also suppose that everything outside of timemachine on both NAS devices are purely data, so barring software bugs that allow a machine to be infected by reading a jpg/nef/(ad nauseam video formats) that has been infected; the chance of infection of those is probably lower than I had originally anticipated).


I suppose this is very much a never ending rabbit hole of paranoia.


At this point, I really just want something to verify that I'm not crazy and there is indeed "something" bad that has gotten into that machine or provide me some small peace of mind by giving an all clear.

Aside from anti-virus and malware scanning, the only other method I've been able to come up with is letting the laptop sit and logging all traffic between it and the internet on the border firewall with tcpdump. I'm not generating any traffic from that laptop on my own which should make sifting through it easier, but may also reduce the amount of callbacks it's making to "home base", etc. I'm expecting software update, apsd and the like to be making calls to apple, ntpd and a few other programs making their own software update checks, and either some connections that I can't account for, or everything looking on the up and up.


I should also point out that I do not engage in any "at-risk behavior" (installing random (or worse, illegal/stolen) software, installing "browser bar" plugins)) . In fact, I've setup the browser to disable plugins by default and only run them when I specifically request (visible elements are replaced by the gray 'plugin missing' box, but will load/run said plugin (aka, flash) if clicked), so I've done my best to limit attack vectors, but this tweak to the software firewall is disconcerting (especially because LS also does it's best to watch for/avoid such things).


All of this suggests either a very sophisticated attack or I missed something and am being overly paranoid.



If you do decide to install anti-virus software in a clean system on an external drive, the only one that I would recommend using at this time is ClamXav.


I was surprised by this since I'd have thought a scanner that does "on-access" type scanning would be better for this purpose (ie, I don't want to go through all the trouble of setting up this recovery boot system, only to have it infected after a external disk that I'd like to scan is mounted (aka, you mount a disk to scan, and before you start the scanning process (or before it reaches an infected file) something silly happens like spotlight or finder reads the file and the infected file uses some bug in one or the other to infect the supposed clean boot stick).


IE, as far as I can tell, clamXav doesn't have on-access scanning so there is a slim chance of something bad happening prior to executing the scan (especially given how slow everything is running because I'm running all of this of a usb device).


In any case, thank you all for your help.

Apr 13, 2015 4:26 PM in response to Leo41

You've managed to hit me at the busiest part of my day job with a discussion that is rapidly drifting away from the initial topic, so you may not have all the right help participating right now, but I suspect between thomas_r. and I we can adequately cover all this given some time to dissect it.


I'll start by saying that I was only drawn here by the mention of ClamXav since (full disclosure) I do uncompensated tech support on the ClamXav Forum and dropped by just to see if you needed help with that, so I may be slightly biased in that respect, but I don't think so. My hobby is Mac Malware in general and I have over half a dozen different A-V scanners currently installed for testing and just in case I ever feel like I need such protection. None are actively involved in real-time/on-access scanning as I don't find that to be currently needed based on my computing habits.

Leo41 wrote:


So far, it's working ok with a 32gb card (obscenely slow, as expected).

I'd have to guess that your MacBook uses a USB 2.0 buss for that SD card (I know that's what my iMac uses) so yes, it's going to be painfully slow. If you have FireWire ports that would be another reason to consider the use of an external drive for all this.

the actual laptop I'm concerned about is a 2011 macbook air running 10.9.5 (and, to be honest, even the security updates take way too long for me to install because having to reboot incurs a massive personal performance hit as I have to reopen everything I was working on (aka, a bunch of terminal and "screen" (the terminal multiplexer, like tmux) sessions)).

You didn't say how much RAM you have, but in general, Mavericks requires more for many users. Yosemite makes that even more important for speed related issues. Apple says you can get by with 2GB and it will let you install with such a small amount, but anybody trying to run as many apps at the same time as you indicate will need at least 4GB. Unfortunately, you won't be able to upgrade a MBA if you have less.

But here's the event that really bothered me: I have LittleSnitch setup to auto-block any connection attempt made if I don't acknowledge it within 3 minutes. I recently noticed in my "unapproved rules" section (aka, rules that have hit this 3min limit and used my default block rule) that there was an 'allow' rule. Also, it was for an incoming port (also odd). The target port is 22, and it allows a single ip address. Of all my computers, this is the only one not running sshd, so the rule itself didn't have a negative effect on my security, but it raises a number of troubling questions:

  1. How was it added?
  2. Why is it marked 'allow'?

I suppose I should point out that the single ip this rule allows is in china and if you google that ip, it shows up on a number of "banned hacker ip" lists (including abuseipdb.com). I should also mention that I've never been to china, nor do I work with anyone in china, so I can't find a legitimate reason for this rule to exist.

At best, it's "possible" that, while attending a unix conference AND while my laptop was booting (the other way a rule will make it into the 'unacknowledged' section: if it occurs before you've logged in, so it can't show an alert) that my laptop was port scanned by said ip. The problem is that there's a lot of unlikeliness here, and it STILL should have shown up as a 'deny' rule instead of an 'allow'.

I'm a long time Little Snitch user, very familiar with it's use and seem to have the same approach as you outlined.


I'll start by saying that being probed by an incoming request for Port 22 (ftp) from China is an extremely common thing for virtually all users. It's the holy grail of ports since it allows pretty much unlimited access to all your drives for harvesting or installing any file in any location. What I don't quite understand is how it could penetrate you MBA firewall if you had it turned on at the time and did not have file sharing enabled.


Sorry, but I have no idea beyond what you have already discovered about LS, how it could have been added as allowed.


What I can tell you is that there is no currently known malware capable of doing this, so if it's something the community is unaware of, you are unlikely to find it with any A-V scanner available today.

On one hand, I do have backups of this laptop, but I can't point to a specific date when this may have occurred. Also, they're timemachine backups to a local NAS which is always on, so one assumes that if the laptop is infected, it's possible that said infection has added itself to any/all checkpoint timemachine backups as well.

Again, that is not a currently known capability of an OS X malware. Only backups after an infection occurs would be infected, nothing before that.

Aside from anti-virus and malware scanning, the only other method I've been able to come up with is letting the laptop sit and logging all traffic between it and the internet on the border firewall with tcpdump.

You might want to take a look at WireShark to see if it would make that any easier. I had it installed for awhile, but never could find anything useful so have not used it since Leopard.


as far as I can tell, clamXav doesn't have on-access scanning so there is a slim chance of something bad happening prior to executing the scan (especially given how slow everything is running because I'm running all of this of a usb device).

ClamXav from the web site has a real-time scan capability called Sentry (which watches whatever you tell it to for any new or changed files), but you are correct that it does not perform on-access scanning. That's actually the main reason for it's being recommended by thomas_r. and others. Such activity is the primary cause of slow downs which are deemed unacceptably by many users. Again I may be biased, but I never really saw the point in scanning the same files over and over each time they were touched by a process or application. The only advantage I can see is that if a new signature is received after a new/modified file is scanned, it would then be recognized as infected. Since the time between discovery of new malware and therefore new signature production averages several weeks or possibly months, that seems a big price to pay for such a slim possibility. I have the advantage of reading almost all of the OS X related malware blogs at least daily, so if there's anything new I'll almost certainly know about it before any of my signature databases have been updated, but since OS X malware is still relatively rare, most users will have read or heard about it in the news soon after discovery.

Apr 13, 2015 5:03 PM in response to Leo41

I think MadMacs0 has answered everything quite well. There's just one thing I'd add:


you mount a disk to scan, and before you start the scanning process (or before it reaches an infected file) something silly happens like spotlight or finder reads the file and the infected file uses some bug in one or the other to infect the supposed clean boot stick


The problem with that reasoning is that there is no known method by which this could be made to happen. At this time, in order for malware to be installed, you've got to be tricked into opening it yourself. It doesn't happen by just connecting a drive.


Now, I'm not going to say it couldn't happen at some point in the future, with new malware exploiting an unknown vulnerability. However, if you had been infected with such a beast, there would be no easy way to know about it. A real security expert could probably track it down, given time and physical access to your computer, if there were anything to be found. Anti-virus software certainly wouldn't do the trick.


I can't explain the IP address you describe in Little Snitch. I think it's unlikely to be related to malware, but I certainly cannot say that with certainty. So, you've got a couple options:


1) Remove that entry from Little Snitch and keep a close eye on the connections your computer is making. If you don't see anything weird, you're probably fine... malware isn't much of a threat if it's not trying to call home.


2) Erase the hard drive and reinstall everything from scratch.


My recommendation would be to start with #1, and save #2 for if you see something concerning. However, if you really need the peace of mind, you could just skip straight to #2.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Full bootable system on usb device (for virus/malware scanning and/or system recovery)?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.