Friday, December 19, 2014

Random acts of math!

Hi all,

Hope you are having a splendid Friday!

Just a quick note to let you know about a new blog started by yours truly.

Random Acts of Math is a fun little place to share some peculiar or interesting things from the world of math. I wanted some practice writing with the digitizer on my Galaxy Note Pro and thought posting some writings to a blog would be constructive and might help a few people.

Disclaimer: I'm not a math expert, nor do I have a math degree (I did take some math courses in university). Given my amature status, always consult a professional before using anything you read on this blog for something important!

What about Jay's Desktop?

It hasn't been forgotten! Jay's Desktop will still be a place for me to write about things I find interesting  ("a place for my stuff") when the mood strikes me. Think of Random Acts of Math as a "subset" of Jay's Desktop - specifically for math-related items and writing from my tablet :)


Tuesday, March 18, 2014

Ubuntu 12.04 Tips: Clearing out old kernels & SSD Trim


I've recently come across two Ubuntu/Linux tips that I wanted to share (and document). They are particularly import if you run Ubuntu on machine with not a lot of extra hard disk space. In my case, I have a hybrid hard drive with a 24 GB SSD partition, and a 750 GB data partition (Ubuntu is installed on the SSD partition of obvious reasons, while most of /home uses symbolic links to the data partition). Over the last year or so, I've noticed my SSD partition steadily increase is size, from about 40% to 73%. Fearing I would run out of room soon, I did some research on if this was merely from system updates and installed software, or if it was something else. I also noticed my machine seemed to be responding much more slowly then it had been when I first set it up a year ago, and tried several things to improve performance without much result. I feared this might be related to the lack of disk space on the SSD partition as well, and I was sort of right.

These tips might be application to other Linux distributions as well. As always, use at your own risk!

1) Clearing out old kernel versions

Ubuntu keeps old kernels hanging around after you install new ones via auto-update. They can take up quite a bit of room. There are some good reasons for keeping old kernels around (e.g. reverting if a kernel update breaks something). But it's unlikely you'll need all of them.

Here's a simple little command line to clear out the old ones.

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

It worked for me, and cleared out a good 6 GB or so of old kernel files, which made a big difference on my 24GB SSD (I went from 73% full to 45% full). I'd recommend only doing this after you've confirmed that the newest kernel works, and even then, you might want to modify it slightly to keep the second last kernel just in case.

This also made a big difference in my /boot partition, which is about 500 MB. This is in fact what led me to find this, as I'd been getting error messages upon boot about /boot being nearly full and went to investigate. After removing the extra kernels, I'm back down only 29 MB full on /boot. Nice!


2) SSD Trim

If you ever use Ubuntu on an SSD drive (as I do), your performance will slow overtime unless you periodically run the 'fstrim' command (e.g. in a daily cron job) to send SSD delete commands for removed files. I definitely noticed a drop in performance over the last year, and have been trying to diagnose why when I came across this little gem.

Since then I've started running fstrim, I've definitely noticed an improvement. The first time I ran it, it sent about 7GB worth of "deletes". They are supposed to add this in 14.04, but it's not in as of 13.10 (or 12.04, which is what I use).

Full instructions and information are in the link below. Enjoy!


Friday, March 7, 2014

Linux Conversion for ASUS S56C (Part 1 - Windows 8 Backup)

Hello everyone!

This post was a long time in coming. I started it last April, but got distracted with life and happiness (you know, those non-computer related things). Anyway, last April I picked up an "Ultrabook-style" laptop to serve as my daily machine (a snazzy Asus S56C). The blog post chronicles transferring the machine to a Linux-based one, and what steps I had to go through to do so as well as any Tips and Tricks I discovered along the way. Note that I was using Windows 8.0 at the time, so the newer update, 8.1, might have some of the issues I ran into fixed.

Backing up Windows 8

I knew from the beginning that this would be a dedicated Linux machine. My first impressions on trying to use Windows 8 was basically that it was a pile of insanity served in a bowl of nonsense (I'm not biased or anything I swear :)). I'm sure I could get used to Windows 8 eventually, if I had to, but I would probably do some tweaks to get a more traditional desktop feel.

But since I knew Windows wouldn't be staying, I didn't invest too much time in that. However, I felt it was important to protect my investment by making sure I had a backup of the pre-installed Windows, in case I ever needed to restore it.

Sadly, even this was more complicated them I'm used too, so I thought it prudent to start the conversion blog with some helpful tips on backing up the original system.

Recovery Discs

I'm very used to making recovery discs on older systems, in fact I encourage everybody using computers to have some sort of disaster-recovery mechanism in place (including, but not limited to, recovery discs).

Normally, these recovery disc tools are provided by the computer manufacturer. They also take the form of a "recovery partition" on your hard drive, although in my experience, you can also make recovery discs in case the partition gets removed (or corrupted). These discs usually server to restore the partition in that case.

That's all fine and dandy, but I had a hard time finding the mechanism to create recovery discs. There didn't seem to be a manufacturer provided tool, and indeed there wasn't. However, with some Googling, I found how to create a create a recover drive from within Windows 8. That's right, you don't seem to be able to use discs any more, instead you create a recovery flash drive.

To get to the tool, open your "Charms" bar (move the cursor to one of the screens four corners), and select the "Search" option (it looks like a magnifying glass). In the Search Bar, type "recovery".

You might be surprised, as I was, to find zero results. That's because things are partitioned into categories in the search results. By default, you are only searching the "Apps" category. To find the recovery drive tool, you need to search the "Settings" category. Do that by clicking the "Settings" button. Personally, I would consider the tool an "App" and not a "Setting", but what do I know? :)

Once you search for "recovery" in Settings, you should find a link called "Create a recovery drive". You'll need a minimum 16GB Flash Drive to use. Thankfully, these aren't too expensive now-a-days (around $9.99 CDN here).

After that, follow the instructions to create the recovery drive. NOTE: You sadly won't be able to boot the recovery drive without doing some additional steps, but we'll get to in Part 2.

Create a System Image

If you are familiar with Windows 7, you know that you can create a complete Windows 7 system image to restore to an alternate drive (for example, if you suffer a hard drive malfunction).

This tool still exists in Windows 8, but it's hidden in an even more obscure location. Like before, go to the search menu and type "recovery" (in the Settings category). Look for an option called "Windows 7 File Recovery". "Windows 7??", I hear you asking. Yes, Windows 7. To me, a tool called "Windows 7 File Recovery" would be some sort of tool for recovery files from Windows 7 (perhaps a backup). And, indeed, it is. But it's also where they decided to hide the System Image tool (used for Windows 8). Strange, but let's continue...

In the Windows 7 File Recovery menu, there are two links on the side:
1) Create a System Image
2) Create a System Repair Disc

We're going to use the first one.

Broken out of the box

Sadly, it turns out the System Image tool is broken out of the box. If you try to run the tool and following the instructions to put the image on DVD, you may get a rather cryptic and unhelpful error message:

"The backup failed. The drive cannot find the sector requested. (0x8007001b)."

The error is actually referring to the fact that the disc isn't formatted. You could probably manually format the disc, and it would work fine, but you'd think the too would do that for you, no?

Well, it does, as long as you install the update to fix it. Installing all the recent updates (which is a good idea before doing a System Image anyway) should repair it, or if you are the impatient type, here's a link to the Knowledge Base article which will help you download the specific patch:

After you are up to date, click the link to create the system image and follow instructions. You can choose an external hard drive, or a "one or more DVDs". I opted for the DVD option (on DVD-RW's so as to not be deleted by accident, which led to the error above). On a fresh out of the box system, it took me four DVD's. Don't forget to label them!

Create a system repair disc

Last but not least, you should probably create a System Repair disc. It seems the system image you made above is useless without a tool to load the image back onto your hard drive. The system repair disc might also come in handy for other reasons. You'll find one of the options on the system repair disc is to restore the machine from a system image. However, I won't go into those details here.

Note: TechRepublic posted an article great here which goes into far more detail on the steps than what I mentioned above. It suggests that creating a System Repair Disc and a Recovery Drive are effectively the same thing, and you probably don't need to do both. Although I find it a little strange that the Recovery Drive takes up most of a 16GB flash drive, but the System Repair Disc fits on a single DVD. Regardless, I felt more comfortable having both, so I created both.

A few other tips:
1) Feel free to check for (and install) any BIOS updates before removing Windows. There's a handy Windows-based tool for updating your BIOS, though my machine was update to date out of the box. You can probably also do the flash from within the BIOS, but I'm not 100% sure.

2) You might get bugged after a few boots to register your system. This is probably a good idea if you want your manufacture warranty.

3) You can get to the recovery partition by holding down "F9" on boot. As far as I can tell, the interface is very similar to the Repair Disc and the Recovery drive interface.

That's it for now! In Part 2, I'll show you what BIOS you need to update to boot from USB or DVD, either for restoring one of your backups (or installing Linux). All the best!