Category Archives: IT

Lessons Learned in VPN Networking Domain Controllers

I had to setup a 2nd domain controller at an offsite location this past week. I don’t have any good VPN-ing routing equipment so I was just going to use OpenVPN to create a tunnel between the two sites. I set up OpenVPN to work with site-to-site routing and everything seemed to work… I could browse the shares from both sides, everyone was happy and could ping each other. I was even able to successfully install the 2nd domain controller and join the Windows domain. But then, I started getting all these random issues:

I spent lots of time troubleshooting it and I realized the issue. I set up the 2 OpenVPN servers to Masquerade NAT between the 2 subnets so all the traffic looked like it was coming from the VPN server itself. All the RPC calls were failing presumably because the domain controller was trying to open ports to communicate on. Anyways, I fixed that by making the openVPN server properly route and then DFSR was able to properly sync and replicate the two domain controllers. Moral of the story – make sure you set up proper routing and not NAT between domain controllers!

If you were able to get DCs working using masquerading NAT, please let me know. I’d be interested if that was possible.

Removing old Linux Kernels In Ubuntu

Ever get this on linux?

$ df -h /boot/
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 228M 228M 0M 100% /boot

Looks like ubuntu has been updating the kernels without cleaning itself up. Bad ubuntu! And it is terrible that the default boot partition is only 230MB. A quick google search gives me this one-liner:

$ dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge

Thanks tuxtweats! http://tuxtweaks.com/2010/10/remove-old-kernels-in-ubuntu-with-one-command/

**UPDATE**: You don’t have to do this anymore… You can now just do:

1
$ sudo apt-get autoremove

This will clean up old kernels. The only way this won’t work is if you’re at 100%. Then you have to clear a few old kernels out manually and then resume installation of the latest kernel, then run the autoremove command.

Troubleshooting Windows Automatically Turning On At Night

Do you ever put your computer to sleep or hibernate only to find it mysteriously staring at you the next morning awake?? That certainly disturbed me and I tried many things to stop my computer from being a zombie and eating brains in the middle of the night. :) Here’s the steps to troubleshoot and nail it on the head exactly what is happening.

Modern computer BIOSes have a host of functions for waking up the computer when it is off. Among them are the Real Time Clock (RTC) alarm that can wake up the computer on a scheduled basis (wiki), Wake On LAN (WOL) which can wakeup based on a special packet (wiki), device wake-up, and of course, the old fashion power button. Windows has a few programs that allows you to control the different features. For device wake-up, you can follow the instructions here. The post below is focused on RTC alarm which was the issue I was having.

If you are interested in killing this behavior all together and do not want to bother with everything else, simply navigate to Control Panel -> Search for “Power Options” -> On the left sidebar, “Change when the computer sleeps” -> “Change Advanced power settings”. You will see the screen below. Simply disable “Allow Wake Timers” and your computer will never wake up again by the timer when you put it to sleep.

I

If you are interested like me to figure out what exactly is causing the computer to wakeup, we can dive deeper into the power management system. Open a cmd prompt as administrator.

1
2
3
4
5
C:\Windows\system32>powercfg -waketimers
Timer set by [PROCESS] \Device\HarddiskVolume4\Windows\System32\services.exe exp
ires at 2:59:29 AM on 3/16/2013.
Reason: Windows will execute 'NT TASK\Microsoft\Windows\TaskScheduler\Regular
Maintenance' scheduled task that requested waking the computer.

We can see it is a scheduled task that is causing the system to wakeup at 2:59 in the morning. I’m on Windows 8, I believe the name might be different for previous versions, but you can go to Control Panel -> Search for “Scheduled” -> Scheduled Tasks. Look for the task listed above, in my case it was “Regular Maintenance”. Open that task and go to the “Conditions” tab and deselect “Wake the computer to run this task”.

After disabling that, check back with your wake timers and you should see the following:

C:\Windows\system32>powercfg -waketimers
There are no active wake timers in the system.

Now you can still have wakeup timers that go off when you want them while not having the daily 3AM alarm go off. :)

Windows Master Installer

I got tired of having to have different media for installing the various versions of Windows 7 and Win 2k8 so I put together a master install disk. The procedure on how to do so has been around for a long time on the net, but I decided to automate it so I can repeat this in the future if I wanted to add other versions of Windows (say Win 8?).

Credit goes to “Explicit” for his original guide.

Without Further to do, here’s the batch script.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@echo off
 
set IMAGEXBIN="C:\Program Files\Windows AIK\Tools\amd64\imagex.exe"
set SEVENZIPBIN="C:\Program Files\7-Zip\7z.exe"
set OSCDIMGBIN="C:\Program Files\Windows AIK\Tools\amd64\oscdimg.exe"
 
set WIN7X86ISO="..\en_windows_7_ultimate_with_sp1_x86_dvd_u_677460.iso"
set WIN7X64ISO="..\en_windows_7_ultimate_with_sp1_x64_dvd_u_677332.iso"
set WIN2K8ISO="..\en_windows_server_2008_r2_with_sp1_x64_dvd_617601.iso"

rem extract everything from the ISOs
%SEVENZIPBIN% x -ox64 %WIN7X64ISO%
%SEVENZIPBIN% x -ox86 %WIN7X86ISO%
%SEVENZIPBIN% x -oServer %WIN2K8ISO%

rem let's gather the win7 64bit installers
 
%IMAGEXBIN% /export x64\sources\install.wim 2 x86\sources\install.wim "Windows 7 HOMEPREMIUM x64"
%IMAGEXBIN% /export x64\sources\install.wim 3 x86\sources\install.wim "Windows 7 PROFESSIONAL x64"
%IMAGEXBIN% /export x64\sources\install.wim 4 x86\sources\install.wim "Windows 7 ULTIMATE x64"

rem let's gather the win server 2k8 installers
 
%IMAGEXBIN% /export Server\sources\install.wim 1 x86\sources\install.wim "Windows Server 2008 R2 SERVERSTANDARD"
%IMAGEXBIN% /export Server\sources\install.wim 2 x86\sources\install.wim "Windows Server 2008 R2 SERVERSTANDARDCORE"
%IMAGEXBIN% /export Server\sources\install.wim 3 x86\sources\install.wim "Windows Server 2008 R2 SERVERENTERPRISE"
%IMAGEXBIN% /export Server\sources\install.wim 4 x86\sources\install.wim "Windows Server 2008 R2 SERVERENTERPRISECORE"
%IMAGEXBIN% /export Server\sources\install.wim 5 x86\sources\install.wim "Windows Server 2008 R2 SERVERDATACENTER"
%IMAGEXBIN% /export Server\sources\install.wim 6 x86\sources\install.wim "Windows Server 2008 R2 SERVERDATACENTERCORE"
%IMAGEXBIN% /export Server\sources\install.wim 7 x86\sources\install.wim "Windows Server 2008 R2 SERVERWEB"
%IMAGEXBIN% /export Server\sources\install.wim 8 x86\sources\install.wim "Windows Server 2008 R2 SERVERWEBCORE"

rem copy the EULA for boot.wim
 
mkdir serverMount
%IMAGEXBIN% /mountrw Server\sources\boot.wim 2 serverMount
 
mkdir win7Mount
%IMAGEXBIN% /mountrw x86\sources\boot.wim 2 win7Mount
 
xcopy /E serverMount\sources\License win7Mount\sources\License
 
%IMAGEXBIN% /unmount /commit win7Mount
 
%IMAGEXBIN% /unmount serverMount
 
rmdir serverMount
rmdir win7Mount

rem copy the EULA for installing from within windows.
 
xcopy /E Server\sources\License x86\sources\License
 
copy Server\sources\install*.clg x86\sources\
 
del x86\sources\ei.cfg

rem create bootable disk
 
%OSCDIMGBIN% -lGRMCULFRER_EN_DVD -m -u2 -o -h -bx86\boot\etfsboot.com x86 Windows7and2008R2AIO.iso

rem cleanup afterwards, uncomment to run

rem rmdir /s x86
rem rmdir /s server
rem rmdir /s x64

Recovering Data from a corrupt RapidDrive Partition

I had a Lenovo Y570 I recently had to repair. It seemed like a straightforward job to mount the HDD using my favorite LiveCD and copy the data to a secondary hard drive. I quickly found out it wasn’t that straightforward. On this model, there was a 750GB hard drive with a 64GB SSD that was hybridly merged together using something called RapidDrive. The technology dynamically copies data between the HDD and SSD so that you can get the best of both worlds in terms of performance and space. Unfortunately, recovery of such systems when the drive is unbootable is almost impossible.

I booted up to my favorite live CD to find two partitions on the SSD, 1 spanning 750 GB. cfdisk would not even run because it said that this partition ends after size of the drive. The 750GB HD had several partitions on it, the largest 700GB one with all the data on it would not mount either… (probably because half of it was on the SSD!)

I could not find any information on the internet on how to mount the hard drives or recover the data. Lenovo was unhelpful and wanted to take the laptop and probably wipe it and give it back to me. I noticed though that when you run the “OneKey Recovery System” that the virus scanner was able to read the hybrid partition of data. There was hope of recovering the data.

Unfortunately though, OneKey Recovery gives you only 2 options, scan for viruses or wipe the hard drive and restore. I wish they would give me a command prompt or something. I tried numerous things such as booting OneKey Recovery System in safe mode and other things like that. Nothing worked. I finally dived into the internals and forced a command prompt to load up.

Here’s how.

UPDATE Thanks to reader RM, you can skip the steps in modifying the lrs.wim file and just try using his pre-modified lrs.wim file. No guarantees that it will work though – there may be specific drivers for each Lenovo laptop model that may make them incompatible. As always, backup your own lrs.wim file before using his just in case it doesn’t work.

RM’s lrs.wim file

Items Needed:

  • Favorite LiveCD that can mount ntfs drives
  • External drive to backup and copy data
  • Windows AIK
  • 2nd Windows 7 Computer

Steps:

  1. Boot off your live CD. Identify the recovery partition. On my system, the SSD was /dev/sda and the HDD was /dev/sdb. The recovery system was on /dev/sdb3.
    1
    2
    
    $ mount /dev/sdb3 /mnt/local
    $ mount /dev/sdc1 /mnt/usb # storage drive


  2. Make a backup, then copy off the wim file off the recovery partition.
    1
    2
    3
    
    # the filenames may be off since I am writing this from memory
    $ cp /mnt/local/Onekey/PE/lrs.wim /mnt/local/Onekey/PE/lrs.wim.original
    $ cp /mnt/local/Onekey/PE/lrs.wim /mnt/usb/


  3. Unmount your external drive and bring it to your windows machine with AIK installed on it. Mount the wim and update the boot loader file. You must run all the following commands as administrator (right click on cmd.exe and click “run as administrator”)
    1
    2
    3
    
    mkdir lrs-mount
    "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" /mountrw lrs.wim 1 lrs-mount
    notepad lrs-mount\windows\system32\winpeshl.ini

    winpeshl.ini should be changed to:

    1
    2
    
    [LaunchApps]
    %SYSTEMDRIVE%\windows\system32\cmd.exe
    1
    2
    
    "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" /commit lrs-mount
    "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" /unmount lrs-mount
  4. Copy the lrs.wim back to the original location and shutdown and restart using the “OneKey” button. When you startup, you should get a command prompt instead of the one click install. On my computer, e: was the hard drive. There seems to be 3-4 drives, c:, d:, e:, x:, perhaps even more. You’ll have to search.