The tale of the broken hard drive
by Mats Hellman on 16.May, 2011 under Linux
About six months ago my trusted Linkstation Live had enough, since late 2008 it has been running without a hitch. The device started blinking red and rebooting it had the nice clicking sound of a broken hard drive.
Nothing was recoverable from the drive so I had to start from scratch, first I went to the local computer store and bought myself an Western Digital Caviar Green 1TB drive.
To get it up and running I had to go trough several pages and try some of the tips from one page and some from another. That’s why I decided to put together my own survival-guide here so I can find it the next time this thing goes south. This quick and dirty howto is for the LS-CHL only!!!
So here it goes:
1. Download the TFTP recovery software from ftp://24.153.165.234/array1/share/nas-recovery/ , if you have the LS-CHL device it’s the TFTP Boot Recovery LS-CHL 1.06 you want.
2. Download the latest firmware from Buffalo, the version 1.07 should be the latest one since they don’t develop it anymore.
3. Disassemble the device, here is a picture of the open device http://www.yamasita.jp/linkstation/2009/09/090912_4l.jpg
4. Next you need a computer running Windows XP, I tried Windows 7 but could not get it to work.
5. Insert the new hard-drive into the Linkstation, you should not partition it. Just put it in.
6. Shut down any firewall service on your Windows XP and set your local IP to 192.168.11.1 and subnet 255.255.255.0. The Linkstation should use 192.168.11.150 once in emergency mode.
7. Unpack the TFTP boot recovery file. And start TFTP Boot.exe file. This should fire up a commandprompt. Look for the line Listening on: 192.168.11.1:69, if it’s there everything should go smoothly from now on.
8. Start the Linkstation and wait for the red light to start flashing, now press the function key for a few seconds and release. The light should turn blue and in your command prompt window you should see the transfer starting.
9. Once the transfer is done start NasNavi.exe to see if your computer can find the device. If it can you can now set your computer to get it’s IP automatically and unpack the Buffalo stock firmware.
10. When you have unpacked the firmware edit the LSUpdater.ini, in the end add
[specialflags]
debug = 1
11. Save and close the LSUpdater.ini file
12. Start the LSUpdater.exe and right click the rings in the upper left corner. Select Debug.
13. Enable all options on the right side of the window and press ok.
14. Start the update.
Wait for a while, quite a while actually and you should have your stock Linkstation Live back. Mine set the language to Japanese but it’s really easy to find the language settings even in Japanese
If you can’t follow this try googling especially from nas-central.org, this is purely a note for myself in case I ever need to do this again.
Migrating from IMAP to Exchange 2010
by Mats Hellman on 02.Dec, 2010 under Exchange Server 2010, Linux, Windows
I know this is a challenge for many professionals out there. And while there are many third party applications to migrate users from old systems to Exchange 2010 they don’t come cheap. There is also the fact that most old Linux based email systems use databases for user/password storage so you will need to get into them to properly move accounts. Due to this we need to be able to customize the process.
This is a highly customized process for the migration. I suggest you test everything here in your test lab before you even attempt to run it in production. All advice is provided as is and if something goes wrong you are on your own.
Image 1 displays a simplified setup of an Exchange system where we have two client access servers in a simple cluster and three backend mailbox servers.
What this article does not discuss
I will not go into any email routing so you need to make sure the email is routed correctly to your backend servers. This article will only take a look at activating the user mailbox in Exchange 2010 and synchronizing the IMAP account from the Linux server to the Exchange server.
Software and information
To successfully follow this article you need to know how to reset the IMAP users passwords and you need to know their usernames. That’s not something I will go into here, we used scripts to reset the passwords but you might want to do it another way.
You also need to install IMAPSync on the Linux server, it doesn’t necessarily have to be the one hosting the mailboxes, it could be another server. We used a third server for this because it was easier to install IMAPSync on a fresh CentOS 5 server than getting it set up on the old Linux server. The IMAPSync .rpm is available in the rpmforge repository. More information on that here http://dag.wieers.com/rpm/.
Simple walkthrough of the process
The HUB servers have a common FQDN, like exchange.domain.com. The HUB servers need to have the IMAP service started since this is the interface for the transfer. Normally this service is stopped in Exchange servers.
Our Linux server is running IMAP so we can connect to it without making any changes to it.
The flowchart in image 2 shows us the process
As I said above, you need to take care of the email routing before you activate mailboxes. Once the mailbox is activated all internal email from other Exchange users will go to the Exchange mailbox.
So to prepare we need to file the users we want to move in tables to be exported to comma separated values. We used Excel but you may use whatever you want. The file was set up like this
| uname | alias | smtp |
| user1 | Fname.Sname | fname.sname@domain.com |
| user2 | Fname2.Sname2 | fname2.sname2@domain.com |
This table was collected from local support engineers so they were able to define the users they wanted us to move. This article assumes the username for the Linux server is the whole SMTP address. Yours might differ and you would have to adapt this to any of my simple scripts.
The files needed for the servers
For the Exchange Server we need all of the columns so export everything to a CSV file. After export the file should look something like this
uname,alias,smtp
user1,Fname.Sname,fname.sname@domain.com
user2,Fname2.Sname2,fname2.sname2@domain.com
Assuming your alias combined with the domain.com is the username on the Linux server you would only need to export the Alias column to a file which should look something like this
Fname.Sname
Fname2.Sname2
When you have the two files, for simplicity let’s call them Exchange.csv and Linux.txt, copy them to the servers. The Linux.txt file should locate on the server you want to run IMAPSync from.
Activating mailboxes and setting the permissions
To move email we are going to use one special purpose account created only to move other users email. So open up your Active Directory Users and Computers and create a simple domain user account. During this example I’ll call this user Exch_mig_user. You can call it anything, or if you really want to, you can use an existing account.
Once you have an suitable account to set the Full access permissions for we can go ahead and create some mailboxes. So log into your mailbox server and fire up Exchange management shell.
The Exchange.csv file should already be located on the server, let’s say it’s in C:\.
To activate the mailboxes we run the following PowerShell command
PS C:\>Import-CSV C:\Exchange.csv | foreach-object{Enable-Mailbox –Identity $_.uname –Alias $_.alias –PrimarySMTPAddress $_.smtp}
This imports our CSV file and uses the values from the file to fill in the blanks in our Enable-Mailbox command. If you want to see what this command would do before using it just ad –WhatIF after $_.smtp. –WhatIf can be used with any of the PowerShell commands here.
After this we need to set the permissions on the mailboxes so the Exch_mig_user account will be able to access the mailbox.
Once again using PowerShell we run
PS C:\>Import-CSV Exchange.csv |foreach-object{Add-MailBoxPermission $_.Alias –user Exch_mig_user –AccessRights FullAccess}
Again, using –WhatIf will show you what would be done.
After running this we will be able to access any of the user accounts defined in the Exchange.csv file using the Exch_mig_user account. This is done so we don’t have to reset any user passwords in Active directory.
After you’re done move over to the Linux server but do not delete the Exchange.csv file, we will use it again later.
Reset Linux passwords
Looking at the flowchart in Image 2 this is where we reset the passwords for the Linux email users so they wont be able to log into the old system anymore and so we can access their email data. As I said before every system here can be different so I’m going to leave this part to you. You can script it, do it manually or have someone else do it. Just set the password to something useful if the server will continue to be active so it wont get hacked.
Using IMAPSync
Now that we have our Exchange accounts active and our Linux account passwords changed we can start the sync process. Notice the word sync, as this will not remove any email from the old server. It will sync them and if you run it again only new items will be moved.
So in our Linux server we have our Linux.txt file containing the First name and Surname of the users we are going to move.
The simple bash script I used looks like this
#!/bin/bash
logfile="synclog.txt"
testlog="/tmp/testlog.txt"
host1=linuximap.domain.com
#host1 is Source
host2=exchange.domain.com
#host2 is Dest
domain=domain.com
#domain is where email account is #everything after @ symbol ######
Do not modify past here #######################################
date=`date +%X_-_%x`
echo "" >> $logfile echo "————————————" >> $logfile
echo "IMAPSync started.. $date" >> $logfile
echo "" >> $logfile
{ while IFS=’;’ read u1; do
user=$u1"@"$domain
echo "Syncing User $user"
date=`date +%X_-_%x`
echo "Start Syncing User $u1"
echo "Starting $u1 $date" >> $logfile
imapsync –buffersize 8192000 –nosyncacls –subscribe –syncinternaldates –noauthmd5 –host1 $host1 –user1 "$user" –password1 TheLinuxPassword –ssl1 –port1 993 –host2 $host2 –user2 AD_DOMAINNAME/Exch_mig_user/$u1 –password2 Exch_mig_user_PASSWORD
date=`date +%X_-_%x`
echo "User $user done" echo "Finished $user $date" >> $logfile
echo "" >> $logfile
done ; } < Linux.txt
date=`date +%X_-_%x`
echo "" >> $logfile echo "IMAPSync Finished.. $date" >> $logfile
echo "————————————" >> $logfile
As with any script downloaded from the internet, read it, understand it and use it at your own peril!
Since we have changed all Linux users passwords to a specific password we can use a static password. If you want to use different passwords for different accounts you need to modify the script and the Linux.txt file.
Also the user used to access the Exchange mailboxes is the same for every account so the password can be static there to.
You need to change the following in the script
- TheLinuxPassword
- AD_DOMAINNAME
- Exch_mig_user_PASSWORD
Once they are set to your private settings you can run the script and it will sync the users from the IMAP server to Exchange Server via IMAP. Every account synced will be logged to the synclog.txt file.
Once the synchronization is done it’s time to once again go over to the Exchange server and remove the Full Access Permissions for the Exch_mig_user account.
Removing the full access permissions
Now that we have synced the defined users mail from our old system to our new system it’s time to remove the full access permissions of the account we used while moving email.
Again open the Exchange Management shell and run the following
PS C:\>Import-CSV Exchange.csv | foreach-object{Remove-MailboxPermission $_.Alias –user Exch_mig_user –AccessRights FullAccess –confirm: $false}
The –confirm: $false statement is there so we don’t have to confirm every permission change. If you move hundreds of users a time you don’t want to confirm this for every mailbox.
Once the script is done you should be done.
Summary
This might not be the most effective or the best way to move users from IMAP to Exchange, but it works and it does not cost anything but time spent on it. One problem is that IMAP folders will be synced one-to-one so if you have subfolders etc. your Exchange mailbox might get a little cluttered. But users have a tendency to clean it up, and we see to it that they get everything with them from the old system.
If you do use this method I’d really like to hear about it and if you have any questions feel free to ask. You can use comments here or send me an message using the contact page.
Supporting family and friends
by Mats Hellman on 01.Dec, 2010 under Apple, Linux, Windows
As most readers here are quite technical I thought I’d share one little application with you. Some may already be using it and others will be using it in a moment.
Have you ever had a friend or family member call you because they have issues with their computer? I guess all of us have since we are the experts in this area. In a corporate world we fire up some remote assistance software to help the user with his/her issues if we can’t solve it over the phone. What do we do at home? Mostly try to explain where to find settings and when it won’t work we get in our car and go to fix the computer locally. Well not anymore.
TeamViewer to the rescue
This is just one wonderful piece of software, never again will I have to get away from the comfort of my home office to fix a friends computer. I use TeamViewer for every last one of these problems.
There are two reasons for this, the first one is in non-commercial use TeamViewer is free as in beer and the second is the variety of platforms you can run TeamViewer on. TeamViewer runs on Windows, Mac, Linux and mobile devices. Granted I wouldn’t use my iPhone to support someone on a 24″ monitor but it is be possible.
Using it is so easy even your 90-year old grandma can use it. Just have them download and start up the QuickSupport version of TeamViewer and you can install the All-In-One full version.
From your client you will get the sessionID and the password, tap them into your full client and you are connected to their screen.
I promise you will save a lot of time using this. What ever your personal support incidents might be. Just remember it wont work if their problem is the connection to the network ![]()
Stop hotlinking
by Mats Hellman on 29.Nov, 2010 under Linux
I was looking at my webserver logs tonight and saw that there where quite a few sites hotlinking some of our icons and buttons. Putting pictures on the web they are gone in a second but please people, use your OWN bandwidth, not mine. Anyway this made me decide I had to do some .htaccess magic and stop this bandwidth theft. And as always, I thought I’d document it here so someone else can use this if someone is linking in to use their pictures.
The new picture
First I created a new picture to be sent to the hotlinkers. And if they didn’t use image size properties I made it double the size of the old one so hopefully it might mess with their layout a little.
The image created looked like this
The .htaccess file
After the new nice image was done I just had to do some .htaccess magic to replace what was sent out to the requesters.
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?nixadmins\.net/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://image_dump_host.com/no_hotlink.gif [L]
That’s it. Now anyone linking in on images will only see the image from the image dump host. You could use imageshack or any other service for this.
Quick Tip: Installing Linux from USB-stick
by Mats Hellman on 25.Nov, 2009 under Linux
This is a short tip so I will remember how to do this the next time I need to. It’s not a lengthy article or in-depth howto. Anyway, today I wanted to try out the latest Ubuntu (9.10) on my Lenovo X200s and my docking station was at work so I had no access to a dvd drive.
Installing from a USB-stick should be trivial so I decided to try it out and googled around to find some information on how to put Ubuntu on my Kingston Datatraveler.
Googling I found this wonderful program that, if needed, even downloads the files for you. But since I already had the Ubuntu ISO I could just start up UNetBootin and have it set Ubuntu on my USB-stick.
To do this just download http://unetbootin.sourceforge.net/ and start it. Select your ISO and the destination drive and you’re done. After that you have a fully functional USB Linux.

