Why are my VM’s custom attributes not backed up? Work around with PowerCLI

This posting is for those that might want to backup a VM on one vCenter and restore it in another vCenter, but seeing that the custom attributes are not copied over. For now, this is a workaround. Moving forward, VMware is deprecating custom attributes in favor of tags. For tagging, it makes sense because if you’re searching for a particular VM, that’s how you do it, but custom attributes are key-valued pairs. I’m not sure how that makes sense with tags.

First off, you will need PowerShell and PowerCLI both installed on your machine. You can do this from any Windows host that can talk to vCenter. If you’re using Windows 7 or above, you should not need to download PowerShell, but you can download it here if necessary: http://www.microsoft.com/en-us/download/details.aspx?id=34595. You can get the VMware PowerCLI here: https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI501. There’s an access restriction in PowerShell by default that will not allow PowerCLI commands to run if it’s turned on. The installer will ask if you want to turn it off – you can have the installer do it for you. After it’s all installed, you can move onto the next step.

The first thing we need to do is to authenticate against vCenter. You can do this with:
We’ll need to find out what the custom attributes are. You can get them by running:
Connect-VIServer -user -pass for example:
Connect-VIServer 10.5.10.204 -user domain\administrator -pass P@SSw0RD!

Before we do any backup, we need to find out what the custom attributes are. You can do this by running
$vm=get-vm

If you want to read the custom fields, you can type:
$vm.Customfields

You can output those custom fields into a file or whatever you want. When you want to write those field back into a VM, you would do it this way:

After registering the VM, you can run this to assign the new vm:
$newvm = get-vm

Then loop through the custom fields and set them
foreach ($field in $vm.Customfields) {set-annotation -Entity $newvm -customattribute $field.Key -Value $field.Value }

This should set the custom fields that you will need.

How to backup your iPhoto pictures and videos to a NAS w/ rsync

This is how I backup my iPhoto stuff. I know that Apple has tools to do this, but I don’t use TimeMachine and keep most of my backups on my NAS.

I also keep my iPhoto Library on an external drive (to save space on my local SSD drive).

This is the simple script that I run in the Terminal:

#!/bin/bash
    if [ -d /Volumes/Monster/Private/iphoto_pictures ]; then
    if [ -f lock ]; then
exit 1
    fi
      touch lock
rsync -av /Volumes/Fujin/iPhoto\ Library.photolibrary/ /Volumes/Monster/Private/iphoto_pictures/iPhoto\ Library
   rm -rf lock
     fi;

What I’m doing here is first off, checking to see if the NAS is mounted. In my case, my mount name is “Monster” and the directory were I put my pictures is /Private/iphoto_pictures, so I check to see if the directory exists. If it does, I proceed to check if a lock exists. The reason I create a lock is so that I don’t have more than 1 backup job running at once. I keep this script running in my crontab, so that if the NAS is mounted and there is no lock, it will call rsync to copy all of the files in my iPhoto library into the one on the NAS.

I’ve had no issues with restoring so far – to restore, just need to rsync the other way.

Hope this helps.

Wait … before you move to Tomato from DD-WRT!

If you’re reading this, it’s probably too late. You’re probably already running into this issue:

401

and it’s probably driving you nuts!

If you haven’t done the move yet, good. Telnet into the router and run:

nvram get http_username

and

nvram get http_passwd

The way that Tomato and DD-WRT store passwords usernames and passwords is different – DD-WRT stores them encrypted whereas Tomato doesn’t, so with this, you can use it to log into Tomato after you’ve done the move. I call it a move and would hate to call it an upgrade, because some hardcore DD-WRT users might be offended.

Now, if you haven’t done this already and are seeing the error, this will be interesting. With the ASUS router, I think I was able to just do a 30-30-30 reset and it took care of it. Unfortunately with Shibby’s implementation of Tomato, they don’t implement the reset button, so you can press the reset button until you’re blue in the face and it won’t do a thing. On other routers, you may need to press the SES/AOSS button. On the Netgear Nighthawk, it’s the WIFI on/off button. You can hold it down and it will start a password-less telnet daemon at port 233 if held for 20+ seconds. So, when you’re booted into Tomato (the web login will still say DD-WRT) and you can’t log in, hold the button down for 20+ seconds and then go to the command prompt and run:

telnet <router IP> 223

There, you should be able to run the 2 ‘nvram get’ commands and use that info to log into the router and do a reset from there.

Hope this helps!

Why I choose TomatoUSB over DD-WRT

I recently bought a Netgear Nighthawk R7000 for my home router. I figured it would be a good time to get a new router, so I was debating between this on and the ASUS (RT-AC68U). I chose the Nighthawk purely based on price. It was 10% off at Target. 🙂 When I shop for a router, I normally try to get open-source. The reason for this is so that I can hack it as I enjoy doing things like that and I like to use features that are not designed the original product. Why companies build routers and put their own firmware on it is beside me. I really wonder why they don’t just use the open-source stuff since it’s so good. If you look at my blog, you’ll see that I have run DD-WRT on my older routers as well.

The reason I decided to go with Tomato instead of DD-WRT is because of a couple of features that I like in Tomato. The first feature is the QOS transfer rates.

Screen Shot 2014-06-11 at 10.59.05 PM

I haven’t found where I can easily do this in DD-WRT. The reason I like this feature is because I can instantly know who is using up my bandwidth.

Another feature I like that unfortunately does not work on this router yet is A feature where I could see all of the URLs that I’ve visited and searches that I’ve done. I hope that Shibby fixes this in the 121 build.

Screen Shot 2014-06-11 at 11.01.41 PM

These are the two major reasons why I decided to use Tomato over DD-WRT. I’ve also run into issues with using the wireless bridge feature in DD-WRT where Tomato worked very easily.

I would love for some DD-WRT hardcore fans to debate with me. I’ve used DD-WRT firmware for a long time and just switched to Tomato very recently. The main reason I switched to Tomato was back in the days when I had the ASUS RT-N16 router. DD-WRT had Wi-Fi that kept dropping off almost daily and I had to find something better and Tomato was the answer at the time.

Please post your comments! Thanks!

P.S. Here‘s a good link on how to set up DD-WRT with a VPN.

 

 

NFS is better than CIFS (at least for streaming video) or How and why to use NFS instead of CIFS on Mac OS X

For the longest time, I thought that my wifi connection was just too slow. Trying to play a movie with VLC player was just painful! I was trying to play movies and it would buffer for a long time and while it was playing, would stop for a little while, pixelate, and play again. I just finished gave up on it for a long time. I bought a new router, a Netgear Nighthawk 802.11ac router that was supposed to be much faster. Unfortunately I didn’t look at my MacBook Pro specs and see that my wireless on the laptop didn’t support 802.11ac! No problem though – still keeping the router. The range on the router is much better than my old Belkin Play N600.

Just for the heck of it yesterday I decided that maybe NFS would be better than CIFS. I worked at Sun Microsystems for 4 1/2 years. I should’ve known this!

I think I tried using NFS on Mac a while back and it didn’t work and I just gave up. The error I got was this one:

Screen Shot 2014-06-09 at 12.35.19 PM

 

I’m glad I revisited this. Because of this error, I just figured that Finder didn’t mount NFS. Since Mac OS X does include showmount however, I thought maybe it does it via command line.

Doing a quick google search, I found that to mount NFS, because Linux wants the server to use ports <1024 and Mac OS X wants >1024, you need to use the ” -o resvport” option when doing the mount via command line.

sudo mount -t nfs -o resvport 192.168.0.11:/home/Monster /s

You don’t need to do it that way. Finder works just just fine. All you need to do is on the server side, add insecure as an option into /etc/exports like this:

/home/Monster *(rw,sync,no_subtree_check,insecure)

Then in Finder, you can use the familiar  ⌘K and give

nfs://192.168.0.11/home/Monster

Then, your network share should be mounted and you should have access to it. That said, you now are subject to POSIX file permissions.

Hope this helps!

Drobo connected to Asus router running TomatoUSB

Simple – Don’t do it! This was from a couple of years ago when running TomatoUSB on an ASUS RT-N16 router. DD-WRT had issues where the wifi would drop off periodically. I found that TomatoUSB (Shibby or Toastman) were both very good alternatives. So good that I’ve since moved onto Tomato for almost all of my routers.

Anyways, some of the issues I ran into were:

Value too large for defined data type …

Sep 24 00:01:08 unknown daemon.err smbd[1539]: disk_free: sys_fsusage() failed.
Error was : Value too large for defined data type
Sep 24 00:01:08 unknown daemon.err smbd[1539]: disk_free: sys_fsusage() failed.
Error was : Value too large for defined data type

root@unknown:/tmp/etc# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 5.6M 5.6M 0 100% /
tmpfs 62.0M 400.0K 61.6M 1% /tmp
devfs 62.0M 0 62.0M 0% /dev
df: /tmp/mnt/Monster: Value too large for defined data type

Along with this, the CPU on that router just couldn’t handle NTFS-3G well – CPU utilization was going through the roof on writes. I think reads were okay.

It would be better to just build a cheap NAS.

A relatively easy/inexpensive way to speed up your old desktop or laptop for ~$100

REQUIREMENTS:
Ghost binaries on bootable CD/DVD or USB thumb drive
Windows 7 installation DVD or USB thumb drive

There are several ways to speed up some old computers. Sometimes, they might not even be old – they’re just slow.

My mother’s laptop was crawling. It had a dual-core 2ghz chip, 4gb ram. Why was it slow? I figured, 4gb ram is enough to run Windows 7 – I’m running a bunch of VMs and I only have 5gb ram on the server. So, it had to be i/o. Since I had an old 128gb SSD from a laptop I had before, I put it in. The problem was, the laptop had a 320gb hd. Clonezilla wouldn’t clone it – gave me some issues with partimage. I remember that the old Ghost 2003 would do a bigger to smaller disk. So, I tried that. Ghost gave me other issues. I tried ghost.exe -fdsp because this is Windows 7. Vista changed some things with NTFS or something that made Ghost stop working with the default settings. The first time I tried Ghost, it ran for 90 minutes and ran into a bad sector. 🙁 It failed. So I tried bypassing it. I ran ghost with the -BSC -FRO switches. It then ran into some issue with a big file or something and told me to pass the -NTC- switch. Well, that failed and told me the same thing, so I just decided to abandon the ghost idea and start fresh.

Since I had the idea of upgrading my mom’s hd, I did the same with a couple of other computers, so my process has been repeated. On the other machines, I got 1tb Seagate ssd hybrid desktop drives (sshd) for $80 each. Ghost 2003 or 8.0 both work for Windows 7. The first thing I did was put the SSD in along with the disk I wanted to clone. I booted from one of my old Ghost DVD archives, but on one machine, there was only 2 SATA ports, so I had to figure out a way to build a bootable USB thumb drive. The one I ended up using was UNetbootin – with that, I created a FreeDOS bootable thumb drive and copied the ghost.exe binary there. Since the stupid Ghost DVD archive only had .GHO files on it and I could access the DOS partition, I ended up copying ghost.exe by extracting it from an old Hiren’s Boot CD. With that, I was able to boot from USB. You can copy ghost.exe onto the USB drive, but FreeDOS boots in it’s own jail or something. The ghost.exe actually ends up on b:\. You should be able to then do the clone using ghost.exe -FDSP -BSC -FRO. After a successful clone, since this is Windows 7, we’re not exactly done yet. The disk will not boot – will give
Windows failed to start. A recent hardware or software change might be the cause. To fix the problem:

1.Insert your Windows installation disc and restart your computer.
2.Choose your language settings, and then click “Next.”
3.Click “Repair you computer.” If you do not have this disc, contact your system administrator or computer manufacturer for assistance.

Status: 0xc0000225

Info: The boot selection failed because a required device is inaccessible.

This is an easy fix. Just follow the directions. Boot with the Windows 7 install DVD or USB thumb drive and go to repair and it’s done almost automatically. On one host, it asked to run CHKDSK afterwards. I let it run and everything was dandy as well. But if all else fails you could buy one of the best budget gaming laptops that is guaranteed to run great.

Postfix queue management

Haven’t touched Postfix in a long time since I do very little administration work anymore, but recently found a server that had a ton of mail queued up.

The way I used to manage it was with qvmenu.pl. You could find it here – http://taz.net.au/postfix/scripts/qvmenu.pl – it shows a graphical (curses based) user interface that allows you to select messages, read them, delete them, etc.

What if I wanted to really delete a ton of messages though? I did a quick search and found http://www.howtoforge.com/delete-mails-to-or-from-a-specific-email-address-from-postfix-mail-queue and modified the command to work for me. I decided to run these commands:
mailq | tail +2 | awk ‘BEGIN { RS = “” } / MAILER-DAEMON*/ { print $1 }’ | tr -d ‘*!’ | postsuper -d –
mailq | tail +2 | awk ‘BEGIN { RS = “” } / root@wuhan\.shocknetwork\.com$/ { print $1 }’ | tr -d ‘*!’ | postsuper -d –

This way, I’m getting rid of all of the bounce and double bounce messages and also the ones from root that probably aren’t important.

if vCenter Server Heartbeat or Neverfail Heartbeat failover appears to be not working or taking a long time …

The main symptom of this problem would be that the vCenter Server Heartbeat console or Neverfail Management Client console would show that the services had failed over, but if you were to try to ping it, it wouldn’t respond.
Logically, there there are some hypotheses you could come up with:

1) Network packet filter isn’t revealed on the active server, so we can’t connect to it.
2) Something wrong w/ the service.
3) The console is wrong and on the backend, nothing failed over.

These would be all wrong.

What we found was that it was an issue with ARP caching on the switches. Because the VM or host abruptly fell off the network, the switches hadn’t expired the ARP entries and that they were stale. You would think that it would be fixed in a minute after the ARP entries expired, but I guess the chain could take a little longer.

Probably the best way to troubleshoot this would be to get on a host on the same network segment and try a ping. If that fails, you could run “arp -a” and check to see if you indeed have the right mac address of the host you want to connect to. If not, you could probably log into the switch to delete the entry or you can create a task to run the command during switchover:

“C:\Program Files\VMware\VMware vCenter Server Heartbeat\R2\bin>nfpktfltr.exe arp”

You should then see the switchover happen without the long delay.

What in the world is irlwinning.com? DDOS?

Recently, I set up my own DNS server. I hadn’t run a public DNS server in years. Since the tvpads recently had some DNS issues, I thought maybe I could help eliminate some support calls by running my own DNS server, pointing to the right servers. Boy was I wrong! For some reason, even though some others on comcast would point to my server as a DNS server, they would still get answers that were not the answers given from my server! It was so bizarre! I had never seen it before. If they ran nslookup and used “server <DNS Server IP>” and typed in the name they wanted to resolve, it’s almost as if the server statement prior was ignored and they were getting the IP that the ISP wanted to give them.

Anyways, that’s not the problem I’m writing about here. Surfing some websites became slow for some reason and I thought I would investigate. The first thing I went to see was what connections I had to the outside world. I went to the router and looked at the traffic. Here’s what I saw:
dns
Obviously, that’s DNS traffic. Well, go to the DNS server and what do I see? This:

10-Oct-2013 15:34:14.228 queries: client 54.252.236.155#58070: query: irlwinning.com IN ANY +E
10-Oct-2013 15:34:14.670 queries: client 206.220.43.92#26073: query: irlwinning.com IN ANY +E

Many different lines of the same exact query. What is it? I have no idea. I’ve decided just to shut down DNS queries for now, but if anyone knows anything about this, I’d be happy to hear from you.

Thanks!