So, I have linux installed in a VM running under Parallels. This has been good. For a long time, I edited everything by shelling into the linux VM and using vi. This was cool for awhile. I like vi, vi rules. Working remotely on a machine (aka ssh) is how I've always worked.
I was looking around during the time that the MacHeist hype thing was going on. Most of those programs were shit, IMO. I took a look at serveral of them, including Textmate. One of the other guys here uses Textmate, and it's seriously nice. It has code-folding, which I really like, and it supports tons of languages. It does this thru its bundles capability, which I believe lets end users add new language support to it as needed. It has cool templating, and snippets (of code) that can be tab-completed, which is really freaking great. The snippets let you define different tab stops in the snippet so you can fill out the code. I really like this, as I can define snippets for this XML format we use.
I also wanted to give Textmate a try because, well, as great as vi is, sometimes I just like a GUI based editor more. After about 1 week of the 30 day trial, I bought Textmate, alone, not in that lame Macheist bundle.
Ok, so back to Parallels. For a long time, I was editing on the Mac, commiting to the code repository, checking out on the linux VM, and testing the code. This was like 4 different kinds of suck. So I was now doing everything in the VM. Once I decided on Textmate, I needed a way to edit on the VM from Textmate. NFS seemed like a good choice. I guess I could have done a few different ways, but I liked NFS for some stupid reason.
Parallels lets you have a few different types of networking; bridged, NAT (shared), and host-only. Since this VM is used for (aside from development) testing of exploit code, which means running vulnerable versions of software on it, I don't want the machine to be accessible from the local network. This rules out bridged mode. I also need to be able to do repository check-ins/outs, so this rules out host-only mode. So I'm using Parallels NAT mode, which seems to be fine. I guess I should ideally sandbox this VM, but whatever.
So, I setup NFS on the linux VM. (This is where this blog just becomes a place I can remember things I will forget). I setup NFS on linux (if memory serves) just by editing the exports file thusly:
/home 10.211.55.2(rw,insecure,async)Yeah, I just export my /home. I've seen worse. Muuuch worse. How about exporting '/' with no authentication, completely wide open? Yeah, that's pretty bad, so I hope I'm doing a little better than that.
So, on /home, the directory I access is owned by macosxuser:macosxuser, whose UID matches the UID of my account on the Mac. That's just how NFS expects things to be. This lets me save files from within Textmate on the NFS server.
Ok, so that's all working. Greatness. On the Mac, I didn't want to have to manually mount that filesystem when I need to work, because that's oh, basically everyday. Mac OS lets you setup automounting. This rules. So I look around and try a few things and finally arrive at:
- Open up netinfo manager
- Create a new node called /mounts (should already be there)
- Create a node for the mount
- Type nfs
- dir /Network/Servers
- create a new node for opts
- add values for (in my case):nfsv2, -i, net
- Name it
My exported entry looks like
Once you save that, you killall -HUP automount. Cool thing is now this will be mounted by Mac OS when you access this directory thru things like applications and the finder. Shells in terminal seem not to cause automounting to occur, so if I wanna access the files on cmdline, I need to cause the automount to occur first. Sometimes you get into a weird state where the automount doesn't occur. Ususally the kill HUP fixes this for me. I've gotten into weird places where it doesn't.
"name" = ( "mounts" );
CHILDREN = (
{
"type" = ( "nfs" );
"dir" = ( "/Network/Servers/" );
"opts" = ( "nfsv2", "-i", "net" );
"name" = ( "servername:/home" );
}
)
}
Also, I've accidentally done kill TERM, which of course isn't good. And I can't ever remember what the command line args to automount are. I found that this script is where it gets started, so this is an alternate way to start or restart automount on Mac OS X:
/System/Library/StartupItems/NFS start
Hopefully that saves someone some looking. 99% of the time, 'someone' will be me.
This setup is nice because when the VM isn't running, no problem. When I start Parallels, I can then just open Textmate and get at the files I need. I also like that Textmate works with my source control, so I really don't have to get into the VM except to run the code to test. So weee that's great.
I also have tons of pcap files I look at. On the Mac I use Ethereal for this. I do captures from our product, captures from exploit code, captures of just whatever. I have them strewn across multiple machines, including the Mac and linux. I used to do some painful copy thing (scp, nc, rsync) from linux into the mac to view the pcaps in ethereal. Now, I just open them on the NFS, which is great.
What else... there's tons of stuff with Parallels; I use it daily. I'm using one of the betas, 3120. There's 3150 out, which I hope fixes some of my problems. I get random crashes a bunch, which of course sucks. Oh yeah, if you have files opened over NFS when this happens, make sure you restart the VM before switching to those programs, or you'll get the beachball death spiral, which isn't fun.
Here's some of the things to watch out for with Parallels: if you're a windows user, DO NOT ENABLE GLOBAL DRAG&DROP. This is very bad, because it opens up a share to your entire host OS disk. That's a really bad thing to do; Shame, shame Parallels. ;) I'm sure they'll fix this eventually. I'd just stick to using the shared folders. Yeah, dragging a file from the mac desktop to windows is neat, but just stay away.
The full screen mode of Parallels is great. I like that. Nice in conjunction with VirtueDesktops so you have windows on its own desktop.
Hopefully I'll remember something else about Parallels that will be helpful to someone. Again, mostly me, but still.
Update:
Found this link, wanted to save it for myself in case I ever need it:
http://www.behanna.org/osx/nfs/howto1.html
Update 2:
Another link I'd like to remember. This is using OSX as the NFS server
http://www.qsyssoft.com/machaxor/?p=8
No comments:
Post a Comment