Migrating from Linux to Windows

Five years ago, I setup a home server on Debian 5. Since then it’s been upgraded to Debian 6, then Debian 7, been ported to newer hardware and had drives added. Today I migrated it to Windows Server 2012 R2. After five years running on Linux, I had simply had enough. I’ll get into the why in a little bit, but first some how.

 

I didn’t have enough space anywhere to backup everything to external storage, so I did it on the same disk. The basic process was as follows:

  • Boot a Knoppix live DVD and use GNU Parted to resize the partition to make room for Windows
  • Install Windows, then install ext2fsd so I could mount the Linux partition
  • Move as much as I could from the Linux partition to Windows
  • Boot off Knoppix, shrink the Linux partition as much as possible
  • Boot back into Windows and expand that partition into the reclaimed space
  • Repeat until there was no EXT3 left

Needless to say it took a while, but it worked pretty well. Ext2fsd is pretty slick, I use it when I have to dual-boot as well, along with the ntfs driver Linux to access my Windows partitions.

 

So now on to the why. Why would someone ever stop using Linux, when Linux is obviously “better” right? The fact is, Linux hasn’t really matured in 5 years. Debian (and it’s illegitimate child, Ubuntu), is a major distro, but still there are no good remote/central management or instrumentation tools, file system ACLs are kludgy and not enabled by default, single-sign-on and integrated authentication is non-existent or randomly implemented, distros still can’t agree on fundamental things like how to configure the network. It’s basically a mess and I got tired of battling with it. Some of my specific beefs are:

  • VBox remote management is junk, Hyper-V is better in that space. VBox has a very low footprint and excellent memory management, but remote administering it is not a strength.
  • Remote administration in general is better in Windows. An SSH prompt is not remote administration, being able to command a farm of web servers to restart in sequence, waiting for one to finish before starting the next, that is remote administration. Cobbling something together in perl/python/bash/whatever to do it is not the same. Also nagios is terrible. Yes, really, it is. Yes it is.
  • Linux printing is pretty terrible. I had CUPS setup, had to use it in raw mode with the Windows driver on my laptop. Luckily Windows supports IPP, I never got print sharing going with Samba
  • Just a general feeling of things being half finished and broken. Even gparted, you have to click out of a text box before the ok prompt will be enabled. Windows GUIs are better, and if you’re a keyboard jockey like me, you can actually navigate the GUI really easily with some well established keyboard shortcuts (except for Chrome, which is it’s own special piece of abhorrent garbage).

Linux is a tool, and like any tool it has it’s uses. I still run Debian VMs in Hyper-V for playing with PHP and Python, but even then after development I would probably run these apps on Windows servers.

 

Advertisements

Custom Debian live environment

I’ve been working with live CDs and netbooting Debian. There are a lot of common elements, so this covers how to do a basic framework for either system. In this demo, I’ll create a system called “default” which is the bare minimum bootable system.

The host system

The host system is the life support for the chroot. I think it’s a good idea to use a VM.

Debootstrap

Debootstrap will install a Debian base system in a directory. I like to create my images in /usr/src.
You only need to install it once.

apt-get install debootstrap

But you use it for every chroot you want to make:

debootstrap --arch=amd64 --variant=minbase wheezy /usr/src/default http://ftp.us.debian.org/debian/

In this case I’m using the amd64 architecture but you can also use i386. Man debootstrap for (a little) more information.

Enter the environment

I use a script called “readyroot” to get the chroot environment ready and to enter it. The script is at the bottom of this post. I just save it as /usr/src/readyroot, so I execute

/usr/src/readyroot /usr/src/default open

This will take care of mounting dev, sys and proc, and enter the chroot.

Updating the environment

There are a few things to do now

Set a root password

passwd root

Set a hostname

echo "my-chroot" > /etc/hostname

Update apt

apt-get update

Generate a machine ID

apt-get install dialog dbus --yes && 
dbus-uuidgen > /var/lib/dbus/machine-id

Install a kernel

apt-get install linux-image-amd64

This installs the new kernel meta package, and makes you a little more version independent. It’s going to be something else on x86 systems (486-pae maybe?), so do  apt-cache search linux-image to see what’s available.

Leave the environment

Believe it or not, you now have the absolute bare minimum Debian system. From here you

exit

Then

/usr/src/readyroot /usr/src/default close

And that’s it. From here you can use it for:

  • Creating a custom LiveCD
  • Creating a diskless VM

Readyroot

The readyroot script helps ease into and out of chroot environments. I’ve been playing with diskless systems and LiveCDs lately and cobbled this together to simplify the process. It’s written for Debian 7 systems. The first time you get into your chroot, you should

apt-get install dialog dbus --yes && 
dbus-uuidgen > /var/lib/dbus/machine-id

After that it will just work automatically.

#!/bin/bash
case $2 in
        open)
                echo opening chroot $1
                if [ ! -d $1 ]; then
                        echo specified root $1 does not exist
                        exit 1
                fi
                echo mounting evnironment
                mount none -t proc $1/proc
                mount none -t sysfs $1/sys
                mount -o bind /dev $1/dev
                mount none -t devpts $1/dev/pts
                chroot $1 /bin/bash -c "export HOME=/root; export LC_ALL=C; dbus-uuidgen > /var/lib/dbus/machine-id; exec bash"
        ;;
        close)
                echo closing chroot $1
                umount -lf $1/dev/pts
                umount -lf $1/sys
                umount -lf $1/dev
                umount -lf $1/proc
                rm -rf $1/tmp/*
                rm -f $1/var/lib/dbus/machine-id
                if [ ! -d $1 ]; then
                        echo specified root $1 does not exist
                        exit 1
                fi
        ;;
        *)
                echo usage: readyroot [path] [open/close]
        ;;
esac