Sunday 29 November 2009

Cloning an Ubuntu Server

I recently needed to clone an Ubuntu 9.04 server to another machine for one of my customers thinking that it would be simple. It wasnt. But here's how I got it to work.

Firstly from searching the net it would seem that there are a lot of different ways of doing this. dd, ddrescue, partimage, ping. They did not work for me for various reasons. I ended up using the tar method.

You will need a LiveCD that you can boot on the machine that you are copying to. And your original Install CD of Ubuntu. Because my original was server which is not a live CD I used Minibuntu. You will also need a USB drive that is big enough to hold the image.

First log in to the machine that you are copying. cd to /. sudo su.
tar -cvpzf backup.tar.gz -–exclude=/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media /

Copy the backup.tar.gz to  a USB drive attached to the machine.

mkdir /mnt/usb


mount /dev/sdb1 /mnt/usb
(sdb1 may be different on your machine dmesg | grep -i "SCSI" should list it with sd?)

cp /backup.tar.gz /mnt/usb


Next install a basic Ubuntu Server on the new machine.  Reboot and plug in the USB drive. Mount it as before and copy the backup to the root directory of the new machine. Then extract the archive.
sudo tar -xvpzf backup.tar.gz -C /

Reboot but this time to the LiveCD. If you use Mini Buntu command line LiveCD you need to select another terminal after boot. Ctrl-Alt-F2.

Since you are running from a live cd you need to mount the HDD of the machine. Same way as mounting USB.

Then you need to install grub again to get the boot stuff correct.

sudo grub
will bring up the grub prompt if not
sudo apt-get update
and
sudo apt-get install grub
. Note that you will need the internet for that. If you can not connect to the net just make sure that the LiveCD you use has grub on it. Mine didnt.

at the prompt
find /boot/grub/stage1

root (hd0,0)
(Replace with whatever the find returned)
setup (hd0) 
(Again replace the hd0 with the results of the find)

quit


Now we need to fix up the UUIDs. These are identifiers from the HDD which you have just overwritten. To get the UUID of your drives

ls -l /dev/disk/by-uuid/


or

sudo vol_id /dev/sda1


Note them down and for which partition root and swap. Check them and then check them again.

now change the grub loader and fstab.

sudo nano /mn/etc/fstab
.

update the UUIDs

sudo nano /boot/grub/menu.lst


update the UUIDs


Reboot and you should be a go.

You may get an issue with networking. Because a new card is recognized the ethernet adapter name on my system changed from eth0 to eth1. I worked this out by dmesg | grep eth0. edit the /etc/network/interfaces file and change all instances of eth0 to eth1.

References
https://help.ubuntu.com/community/BackupYourSystem/TAR
http://linux.byexamples.com/archives/321/fstab-with-uuid/
http://stringofthoughts.wordpress.com/2009/05/25/grub-error-15-debianubuntu/

Saturday 21 November 2009

beware of moving Profiles and User data

In Vista (and Win7) beware of moving Profiles (and so) User data to another drive without doing some reading....

This used to work fine in XP with the standard My Document>Properties>Move>yes

UPDATE: Found MS knowledgebase on this where they say its possible,


BUT DON'T SUPPORT IT, OR RECOMMEND IT. Blah


http://support.microsoft.com/kb/949977



Various alternative methods are discussed in detail here http://joshmouch.wordpress.com/2007/04/07/change-user-profile-folder-location-in-vista/,  and I have quoted extensively from that article, but the outcome of this long discussion is that I would opt to only do this when rebuilding Vista.

As an aside, I learnt a useful tip from the thread - as well as the fact that MS has finally caught up with 'Nix and has symbolic links...

To get a CMD prompt with Administrative privileges, all you need to do is:
1, Click the Start Button
2, Type ‘CMD’ in the Start Search box
3, Press and hold down [Ctrl]+[Shift]+[Enter]
You should then be able to create the links you need (symbolic links)  such as:

http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista/



Or use the tool LINKD

Get the tool LINKD.exe from Windows Server 2003 Ressourcekit tools. Copy it to c:\
Start Vista from CD into repair mode Konsole window or you can use BartPE or a second Windows XP/Vista installation.
Now rename c:\users into c:\users.old
type LINKD c:\users D:\Users
Now copy all files from c:\users.old into c:\users Restart.


The thread starts back in 2007, and continues right to the present day. Some ppl have had success using mklink

1) Created a new partition (“d”) for my data.
2) Backed up up my drive (just in case).
3) Loaded the Windows Vista installation disk and got to the command prompt.
4) Once at the command prompt, I entered the following commands:
robocopy C:\Users D:\Users /MIR /E /XJ [Enter]
rmdir /S /Q C:\Users [Enter]
rmdir “C:\Documents and Settings” [Enter]
mklink /J C:\Users D:\Users [Enter]
mklink /J “C:\Documents and Settings” D:\Users [Enter]
The robocopy took about 15 minuted for 5 gigs worth of data. The other commands took no time at all.
5)I exited and rebooted.
6)Voila. I was good to go.




When I look in my c partition, I see “junction pointers” for c:\Users and c:\Documents and Settings both pointing to d:\Users.
Everything seems smooth and I haven’t noticed any slow down.
Then some success:

Richard on January 22, 2009


I think you guys all think Vista is a real new OS. It is much more simple than any of the above optiosn to move a profile directory and maintain its rights.


First I did as others mentioned. I changed the default location of users in the registry (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList). I set the Default, ProfilesDirectory and Public keys to point at a seperate volume. (in my case D:\Users}. I then copied the C:\Users\Default and C:\Users\Public directories to the target (D:\Users in this case).


Then I created a dummy admin, and logged in as my dummy admin, confirmed the location of the new admin profile in the secondary volume (i.e. D:\Users\Dummy)


Now the trick: I first set my file view to allow my dummy admin to see invisible, hidden and system files. Then I right-click the Computer icon (or go to System in the Control Panel), select Properties and then choose Advanced System Properties. In the Advanced tab is a User Profiles section. Click the Settings button and you can move each profile right there, Be sure to move the profile to the same folder name. So if you are moving user JDoe and his profile is C:\Users\JDoe then make sure to move it to the same folder (i.e. d:\Users\JDoe). This will move the whole profile and keep the same user rights! No screwing around with command line or anything. In the registry make sure all your user profiles point to the right folders now. The user profiles will start with S-1-5-21-(lots of numbers) usually. If you see Short names like S-1-15-18, those are Service profiles, leave those be, only edit your user profile paths. Now log back in a your migrated user and enjoy.


Caveat: Because you did not change the rights of the original C:\Users\profile directory you will not be able to rename or remove C:\Users. This isn’t a big deal as you are not using it anyway.


Richard on January 22, 2009



Actually a correction to the above. You can actually log in as the migrated user and delete the old C:\User\ profile of that specific user, since they still own the folder.
I menation that for the guy who had a 100 gig profile above. And sorry this still requires a copy.

Some arguments continues as to whether symbolic link should or should not be used, and success with Win7 has been reported:

cdr on October 2, 2009




In our school we have dual boot xp/vista computers.
This is how we move the entire Vista User profiles folder to a different partition
(E: in our case).
First we do a regular Vista installation.
Then we run the following startup script:
REM robocopy the user profiles folder to E:
robocopy C:\Users E:\Users /MIR /E /XJ /COPYALL /DCOPY:T
REM remove user profiles folders/link from C:
rmdir /S /Q C:\Users
rmdir “C:\Documents and Settings”
REM create on C: symbolic links that refer to E:
mklink /J C:\Users E:\Users
mklink /J C:\Documents and Settings” E:\Users
We activate this script with a local policy (gpedit.msc): Computer configuration – Windows settings
– Scripts – Startup. We also enable two other options: Computer configuration – Administrative
Templates\System\Scripts\Run startup scripts asynchronously and Run startup scripts visible.
The script has to be a computer startup script in order to run it before any profile is loaded.
After we reboot the pc and the script has run once, we remove all previously mentioned settings.
We’ve been doing this for some time and until now everything seems to work fine.



Friday 20 November 2009

Service Packs and Updates keeping us in bacon

To apply, or not to apply.

Until this week, I have been advocating customers to apply any and all Microsoft updates that are available.

I was surprised (but not shocked), that a routine SP1 on Vista Home Basic went up the creek.

I was also surprised that more of a fuss had not been made of it at the time (mid 2008). Judging by the number of similar reports, it was obviously a widespread problem.

In summary, if SP1 was applied whilst the antivirus was not disabled, the file $TxfLog was corrupted and Windows simply got into a reboot loop.

Booting to Linux (Ubuntu 9.04 did it for me), mounting the drive using the third generation ntfs-3g allowed me to delete the file.  Bingo.  Fixed.

(Most posts point back to http://www.delmartian.com/workaround-for-stop-0x0000c1f5-0xc1f5-c1f5-bsod-clfssys-kb946084.html so kudos there.)

Problem solved? You'd think.

Up till then I didn't know which update had been the cause, so I ran SP1.

This time I came up with another unusable Vista system, telling me usefully:
!! 0xc0000034 !! 250/53007 (_0000000000000000.cdf-ms)

Fortunately, this too was fairly simply resolved using a Vista Recovery Disc and going back to the last Restore Point, summarised well here: http://ezinearticles.com/?Error:-0xc0000034-While-Installing-Windows-Vista-SP1-Or-SP2&id=2580302


OOPS, spoke too soon, restore shows the point that I wanted (immediately prior to SP1), but never completes.


I ended up backing up (via F11 and saving to a USB disk) and reinstalling ("recovering").






A few things occur to me.

1 How did we fix these sorts of things before we could search (and find) the exact error message, and find multiple hits and usually a solution, or at least a hint which direction to go, thus saving hours of trial and error in getting it fixed.


2 Does Microsoft specifically say that we need to disable antimalware when applying major (or even minor) patches? They probably do somewhere in the never-read "I agree" screens...


3 A new refreshed OS is a good idea occasionally, but only when I choose it, and not on a customer's beloved tweaked and data-laden dust-collector.



4 Restore points are REALLY useful, and we should use them more routinely. (Perhaps we are guilty of jumping to conclusions that fixes should be harder than that, whereas we should be covering off the simplest, built-in methods first).


5 In Vista there are a lot more built-in options to try and fix things at boot time, but the terminology is obtuse and each of the methods seems to confuse the matter further!



For a good run down of the Vista recovery process, see http://neosmart.net/blog/2008/windows-vista-recovery-disc-download/


And lastly, a knowledge of Linux is absolutely essentials these days to fix Windows!




Wednesday 18 November 2009

What's in a name

We were going to call ourselves HAH – but that’s a bit close to HAHA, although if the domain was still available for that [does quick lookup on the side], it might have been a good idea!

(and yes, is still available at time of writing).

One would think that hha.co.nz would be simple and easy and hard to get wrong.

Wrong. Try saying that to the “representative” on the other end of an 0800 in outer Siberia.

…..”was that “Haitch Haitch ‘ay”, or ‘aitch ‘aitch ‘ey (hey?)”  Eh? Grrrrr

Oh well, what’s branding anyway but a big old con.

It’s our intellect, drive and ambition that count, oh, and being able to get to the phone before it stops ringing ;)

Still, that’s us. Three hard-working boys enjoying making a GO of it

Monday 16 November 2009

Go

Google have just released a new programming language called go that on the face of it is another 'me too' programming language but I think it could be a real game changer.

In the good ol' days computers used to double in speed every 18 months along with Moore's Law.  For nerds like me this was great. If you got a new PC and your nemesis had one that was a year or more  old you could invite them round for coffee and ritual humiliation. Ahhh good times.

But then Moore's Law ran out. There was no mention on the 6 O'clock news. No funeral. No old Arab women slapping their foreheads and screaming at the sky. Now when I drop $2000 on a new laptop the only thing that it does different to my 3 year old laptop is Bluetooth so it can talk to my cellphone. I am not even sure what they say too each other.

Although some CPU's are in the 3+GHz range most are 2 something and the cheapies are 1.6. To sell more computers the manufacturers are adding processors. Dual core, Quad Core etc. The only problem with that is that it has no wow factor. When you get a new machine it doesn't feel any faster than you old one and certainly wont be scaring your nemesis. The reason for this is that even though the computers have more procs the software that runs on them is still designed for single procs.

Developing software for multi proc systems is fundamentally different and most modern languages are woefully ill equipped to handle it in such a way that moronic developers like me can understand. There have been attempts but they have just not got off the ground.

Then along comes GO.

  • GO from the ground up is designed for multi processor and distributed processing systems.

  • It creates extremely fast executables.

  • It has kept the syntax simple and easy to understand.

  • It is open source.


All that means nothing if nobody uses it but this language is released by Google. I am not completely sure but I think Google owns the internet. If they don't own it they must be pretty close. In Nerdville (where I live) Google has the greatest market share by a mile and the fate of this language will be decided in Nerdville.

If it does take off and desktop software and OS  is written in it then it will no longer be the GHz of your CPU but how many CPUs you have that matter. Twice as many CPU's = twice the speed. Three cheers for conspicuous consumption.