Visualizzazione post con etichetta os x. Mostra tutti i post
Visualizzazione post con etichetta os x. Mostra tutti i post

sabato 5 settembre 2015

Samsung Galaxy S6 + Android File Transfer + Mac OS X: device not found

In Italiano, l'errore è "impossibile collegarsi al dispositivo".

It means that you previously installed KIES and you didn't unistall it properly. KIES is not supported anymore.

From the terminal:

sudo rm -rf /System/Library/Extensions/ssuddrv.kext

lunedì 25 maggio 2015

[Mac OS X] The ultimate Mac OS X performance optimization (updated when needed)

In my 20 years experience with Mac OS X (starting from 7.3 to Yosemite 10.10) I frequently need to debug or at least to tune up the System. Here is my tips & tricks archive for the everyday survival. This archive is updated as soon as I have new tricks: I need to store them somewhere to share between my Macs and to build an history for disaster recovery purpose.

For debug I mostly use Activity Monitor to inspect the problems (you find it in Application / Utility), looking at the CPU Tab, where I added the memory column (right click on the columns and just mark it) to have all in one place.

For problem solving, if you see the courier font it means that you must copy / paste that command in the utility / terminal.

Enjoy.


discoveryd uses 100% CPU after 10.10.3 upgrade
http://masugadesign.com/blog/easy-temp-fix-discoveryd-100-cpu-osx-10-10-3

temporary solution, but it works since a couple of weeks right now and my macs fans don't fly away like airplanes anymore. You could perhaps save it as a bash script and run it with a weekly crontab.

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist

since the culprit could also be the bonjour service, it's better to flush all the DNS caches around your mac (I recently thrashed an airport express so it could have left traces on my Macs)
http://furbo.org/2015/05/05/discoveryd-clusterfuck/
http://osxdaily.com/2014/11/20/flush-dns-cache-mac-os-x/

sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;

mds and mds_stores (Spotlight) eating 50% and more CPU
http://9to5mac.com/2014/02/11/how-to-get-spotlight-processes-back-under-control-when-cpu-usage-goes-crazy/

Open Spotlight Preferences. As soon as I dropped my user/Library/Application Support folder it falled to 5%. You can also disable indexing daemon when you perform intensive works (then turn it back on!)

sudo mdutil -a -i off

But this will cause Spotlight to stop working. An application like the freeware AppPolice could help in other cases (a simple slider will let you choose the max percentage of CPU a process can use), but although it shows Spotlight, mds and mds_stores aren't shown and limiting Spotlight doesn't affect them in any way: they will keep on consuming 99% CPU. You can work around it with cputhrottle utility (it must be installed) or nice / renice (prebuilt in any unix system but not hard-limiting). Since Process Renicer by eosgarden is discontinued and Process Wizard by La Chose is stuck on Leopard, I gave a try to Appriority (free edition not available on the App Store, download it from the website) but no way to select mds_stores. I think the only way is to renice known useless processes with a bash script at login: given a loop containing all the PIDs to renice (e.g. mds, AirPlay and other stuff)

sudo cputhrottle PID_to_limit max_percentage_integer

I will post the bash script as soon as I will do one. Meanwhile read these articles:
http://nixsos.com/limit-application-cpu-usage-in-mac/
https://github.com/maumi/cputhrottle

preview panel RAM eater
I was wondering how my RAM was eated on my Mac Book Pro 2011 and Mac Mini late 2011 and I inspected it with the free app Memory Clean. I experienced problems like apps that refused to open, a whole system like XP pre-service pack 3 and the famed windowsupdate fix, no way to work with finder, too strange to be on a Mac.

No way to get rid of this problem... I also read that Yosemite doesn't leave free RAM since uses it for the file cache: too strange because this is an energy consuming strategy and it's really far from everything I experienced in the Apple world since 1996.

Ok, I admit that I had the standard 4GB on both the computers and perhaps it wasn't enough for Yosemite. I upgraded them respectively on 12GB and 16GB and... my RAM was eaten!!!

It was time for a deeper inspection and, after several days, I noticed that it happened if I selected a word document (the preview panel, which is default on OSX, tried to show the preview content) and double clicked on it to open. Obviously the finder stuff stood in place, so under my document window while I was editing it, the finder keep the file selected and the preview panel trying to make the preview from it. Some kinda bug looped the RAM to death on both my Macs, blame on you Apple!

http://osxdaily.com/2013/01/10/disable-finder-icon-thumbnails-previews-mac-os-x/

The temporary fix is to open the view options wherever you like, disable icon preview, disable preview column, make it as default view and have a fast performing computer despite the fact that it's a temporary solution. Do you still need to preview anything while you're working on the finder? No problem, select it and press space!

misc utilitie
Select - copy - paste text directly from the Finder's Quick Look:

defaults write com.apple.finder QLEnableTextSelection -bool TRUE; killall Finder

I have an external audio card and I always get an annoying message on my audio app every time my HDMA screen wakes up after sleep: "Logic Pro is scanning your system for audio devices, and has detected a device named “DisplayPort”. You need to unload default audio drivers

sudo kextunload /System/Library/Extensions/AppleHDA.kext


mercoledì 18 febbraio 2015

[Mac OS X] keep a shared disk mounted after a network failure

I have several WD NAS with several shares. And I just need them mounted!

Have them available on system startup is pretty easy:

  • mount them on the Finder with different flavors
    • via sidebar
    • via CMD+K
      • smb://192.168.1.101 or better cifs://192.168.1.101
      • afp://192.168.1.101
      • ftp://192.168.1.101
  • open you SYSTEM PREFERENCES (apple menu on the left upper corner)
  • open your USERS PREFERENCES and go to the LOGIN ITEMS tab
  • drag and drop your mounted drives
  • don't forget to check the checkbox on the left where your drives are listed
But what if you have a network failure, wake on sleep etc?
  • Go to / HARD DISK / Applications / Utilities
  • you find the "AppleScript Editor" or "Script Editor" for the most recent systems like Yosemite
  • paste this:
on idle 
  tell application "Finder" 
    set isConnected to disk "FILM" exists 
    set isConnected2 to disk "MP3" exists 
  end tell 
  if isConnected = false then 
    try 
mount volume "FILM" on server "192.168.1.101" 
    end try 
  end if 
  if isConnected2 = false then 
try 
mount volume "FILM" on server "192.168.1.102"
    end try 
end if 
  return 5 
end idle

  • Make sure to edit the IPs and network share names according to yours, I just left you a couple of sample folders and IPs
  • Save as application naming it "checkshares" wherever you like and check the checkbox "leave it opened"
  • Open the terminal and drag & drop your "checkshares" application in order to determine the exact path e.g. /Users/testuser/Desktop/checkshares.app
  • copy the path in the clipboard and delete all
  • from the terminal type "nano Desktop/checkshares.sh", in my example I put all on the user Desktop
  • paste this adapting to your paths and users:
#!/bin/sh
echo 'open /Users/testuser/Desktop/checkshares.app/' | /bin/sh
  • press CTRL+O and CTRL+X to save and quit
  • paste this to the terminal in order to make the script executable:
  • chmod u+x /Users/testuser/Desktop/checkshares.sh
  • paste this to the terminal in order to run checkshares.sh every 5 mins:
  • crontab -e
    */5 * * * * /bin/bash /Users/testuser/Desktop/checkshares.sh
  • press CTRL+O and CTRL+X to save and quit

You can check after 5-6 minutes if you got a new system mail with the command "mail", just to check that everything went fine or if the system generated some alert message. You shouldn't find any email. Everything is ok, so we can reedit crontab:
    crontab -e
    */5 * * * * /bin/bash /Users/testuser/Desktop/checkshares.sh >> /dev/null 2>&1
This command will prevent your crontab line to flood your system mailbox by simply redirecting any output message to NULL device. I rather prefer to add the appended line to a new line and comment out the first line, since I could need to debug something later on.

#########################
UPDATE ON open COMMAND ISSUE

After a while I had the error
LSOpenURLsWithRole() failed with error -600 for the file /Users/testuser/Desktop/checkshares.app

It happened randomically and then generated me thousand messages (one every 60 seconds in my case) until I rebooted the Mac. Infact the "open" command and a bunch of other commands have a long historical issues with the WindowsServer binding: checks after executions, maintaining a resilient session keeping, etc etc.

Googling around didn't help but gave me the inspiration to find this issue and a proper solution.
According to Apple, the 2 schedulers are crontab and launchd, but the second is the preferred one:
https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html

Starting from 2 nice posts and a little app, which consistently helped me to write a syntactically correct file, I wrote my own PLIST and everything was fine.

Create this file (remember that the name NetworkShares must be unique):
/Users/lost/Library/LaunchAgents/NetworkShares.plist

Paste this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>NetworkShares</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/bin/open</string>
                <string>/Users/testuser/Desktop/checkshares.app</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>StartInterval</key>
        <integer>60</integer>
</dict>

</plist>

I also made use of this app http://www.soma-zone.com/LaunchControl/ which enabled me to discover that the minimum seconds are 10 and not the 5 I initially put. I opted for 60 in order to stay safe.

The useful posts are these:

venerdì 4 aprile 2014

Split Tunneling + VPN + VMware (Windows, Mac OS X, Linux)

Mi è capitata l'esigenza di monitorare intere classi di apparati tramite VPN (in questo caso erano Cisco, ma è indifferente).
Purtroppo il router aziendale non supportava il Cisco Client, in quanto si trattava di una customizzazione di linux in cui il client vpnc si rifiutava di funzionare, ma forse il problema era il concentratore, antichissimo e in gestione a terzi. Per farla breve, l'unico apparato in grado di connettersi era una macchina Windows con a bordo XP o 2003 Server, tramite l'ordinario Cisco VPN Client o addirittura il VPN client integrato. Questo però mi impediva di svolgere operazioni che potevo compiere solo tramite server linux, ma ho trovato la soluzione forzando il 2003 Server (o XP... non avrebbe fatto differenza) a fare da gateway a una pletora di macchine virtuali linux.
192.168.101.0 è la LAN dell'ufficio
192.168.101.1 è il router di connettività
192.168.101.19 è il server WIndows 2003 Server che useremo come gateway VPN per via di RAM e CPU abbondanti (serve a ospitare le virtual machines)
VMware VIRTUAL MACHINE (NO PLAYER, es. VMware Workstation, Fusion, etc)
VMware Player non permette di editare il Virtual Networking, quindi non è adatto.
Concettualmente il VPN client di Microsoft permette di fare da gateway di connessione, sia per le VM ospitate al suo interno (VMware Workstation, Fusion ed altri futuri paritetici), ma anche per tutte le macchine della LAN.

WINDOWS CON CLIENT VPN E VMWARE WORKSTATION GIA' INSTALLATO
START / ESEGUI / regedit HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Linkage\Bind sposta in alto \Device\NdisWanIp riavvia
Connessione VPN / Proprietà / Rete / TCPIP / Proprietà:
  • DNS server remoto (es. 10.0.0.101)
  • Avanzate lascia flag gateway predefinito
Connessione VPN / Proprietà / Avanzate:
  • consenti ad altri utenti
  • scegli VMnet8 (è l'interfaccia di NAT di VMware)
  • il sistema automaticamente imposta VMnet8 a 192.168.0.1, se è un secondo gateway (es. ridondante) metti un indirizzo diverso es. 192.168.0.2
Connetti la VPN e controlla quale indirizzo abbia il gateway, es.172.16.1.1.
VMware Workstation / Edit / Virtual Network Editor, sostituisci VMnet8 "Use local DHCP" il default 192.168.137.0 con 192.168.0.0.
START / ESEGUI / cmd
  • route print (in basso non ci sono rotte statiche)
  • route -p add 172.16.0.0 mask 255.255.0.0 172.16.1.1 metric 1
  • (route -p sta per "persistent", cioè statica, si conserva al riavvio)
  • ping 10.0.0.101 e anche ping google.it
  • se non pinga google:
    • route delete 0.0.0.0
    • route add 0.0.0.0 mask 0.0.0.0 192.168.1001.1 metric 0
LINUX NELLA VM (usa la classe della VMnet8)
Le Virtual Machines devono avere 2 interfacce di rete (/etc/network/interfaces): eth0 è su VMnet8, eth1 invece in è bridge su VMnet1

sudo -i
nano /etc/networking/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

#QUESTA E' LA LAN TRA MACCHINE VMWARE
auto eth0
iface eth0 inet static
   address 192.168.0.20
   netmask 255.255.255.0
   gateway 192.168.0.1
   dns-nameservers 10.0.0.101 10.0.0.102

#ATTENZIONE! QUESTA E' LA LAN ORDINARIA DELLE MACCHINE DELL'UFFICIO
auto eth1
iface eth1 inet static
   address 192.168.101.20
   netmask 255.255.255.0
   gateway 192.168.101.1
   dns-nameservers 192.168.101.1 208.67.222.222


/etc/init.d/networking restart

Considerati alcuni problemi di rotte di default (0.0.0.0 / 0) che ritornano, preferisco fare un cronjob di questo tipo:

# m h  dom mon dow   command
*/1 * * * * /home/conf/network_fab.sh

#!/bin/bash
sudo /sbin/route del -net 10.0.0.0/8 gw 192.168.0.1 dev eth0
sudo /sbin/route del -net 172.16.0.0/12 gw 192.168.0.1 dev eth0
sudo /sbin/route add -net 10.0.0.0/8 gw 192.168.0.1 dev eth0
sudo /sbin/route add -net 172.16.0.0/12 gw 192.168.0.1 dev eth0
sudo /sbin/route delete default dev eth0

e ci puoi infilare tutte le reti raggiungibili dal gateway remoto che ora raggiungi via VPN

OSX (ricorda di usare l'IP di Windows nella LAN come gateway)
sudo route -n add 10.0.0.0/8 192.168.101.19
sudo route -n add 172.16.0.0/12 192.168.101.19
Windows XP e 2003 (ricorda di usare l'IP di Windows nella LAN come gateway)

route -p add 10.0.0.0 mask 255.0.0.0 192.168.101.19 metric 1
route -p add 172.16.0.0 mask 255.255.0.0 192.168.101.19 metric 1