Moving Linux on a windows drive for dual booting

README! There are many use cases for dual booting and guides for achieving it, this one concerns moving an existing Linux to a drive on which Windows is already installed and dual booting them. In other words, you will be combining existing Windows and Linux systems to coexist on the same hard drive.

I’ve been using the same hard drive for a while and transporting it from laptop to laptop whenever one would fail me (you can do that with linux). Now, after 8 years, I was fearing it was the actual hard drive that would break next so this time, I had to move my actual operating system to another physical disk.

Wanting to be able to dual boot into windows as well, I was stuck in a scenario for which there was not much help on the web. Here’s what I did:

  1. Resize your Windows partition using the disk management tool to make room for Linux and its swap. The new Linux partition must be larger that the one you are moving from.
  2. Reboot to a Linux live CD or GParted and create a bootable Linux and a swap partition (they must be primary) after the Windows partition.
  3. Clone you existing Linux OS partition from the old hard drive to the new.
    1. Plug in your old drive (external SATA, external disk case, extra hard-drive bay, etc.) but leave it unmounted.
    2. dd if=/dev/sdXY of=/dev/sdWZ bs=1M

      where XY is the drive letter and partition of the Linux OS you are moving from and WZ those of the partition you are moving to.

    3. Wait for a while, depending on the size of the partition, this could take a bit because you are cloning every single byte from one partition to the other. In my case, it tool a good solid two hours and half.
  4. Unmount and disconnect your old Linux OS hard drive. In case something goes wrong, simply popping it back in your computer will restore your setup just the way it was before.
  5. Mount your new Linux partition.
  6. From within the Live CD, restore the GRUB2 bootloader by executing
    grub2-install --root-directory /mountPoint /dev/sdW

    where mountPoint is where you new Linux partition is mounted and sdW is the drive where it resides.

  7. Since the partition’s GUIDs have changed you need to update the /etc/fstab file on your Linux with the new ones. Any file editor will do. Look up the new GUIDs for your new OS and swap partitions by running
    ls -al /dev/disk/by-uuid/
  8. Remove the live CD and restart the computer.  From within GRUB2’s boot menu, you should only see your Linux and not Windows, that’s normal. Boot your Linux OS.
  9. Run
    grub-mkconfig -o /boot/grub2/grub.cfg

    GRUB2 will scan your hard drive, find the Windows install and create a new boot configuration file. Now, when you reboot your machine, you will see Windows within the boot menu menu entries.

  10. Finally, since the size of the underlying partition holding your Linux installation has changed, the size of the file system has to be updated as well:
    resize2fs /dev/sdW

Done! Moving operating systems around and getting them to cohabit alongside each other is tricky and far from being straightforward so I hope this guide worked for you. You will most likely have to adapt it to your own situation and if you feel something you did could benefit others, please comment.

How to program a new Toyota transponder key

In need of an extra key for your Toyota? Avoid the dealer, they charge an arm and a leg for a simple procedure you can do yourself for free. Searching the web turned up a couple of techniques, but the one that worked for me was found in a youtube comment by user Nazareth434.

My car is a Toyota Matrix 2005 but apparently this procedure is valid for several Toyota models and years. If it did or did not work for you please let me know in the comments. And if nothing including this procedure has worked for you, don’t despair, at least your copy can open doors. Attach the key to a concealed spot under you car and save it for the “oops I’ve locked myself out”situation.

Procedure

First, you need a blank transponder key for your model and year. You can get one for 10$ or so through eBay or amazon. Then, have the key cut by your local hardware store and make sure it fits you ignition lock: you should be able to turn it all the way to the start position and hear the starter going without the engine turning on. With the master key (the black key, not the valet key, which is grey) and the copy in hand, install yourself in the driver’s seat and follow the procedure carefully. It took me about 30 minutes and many tries to get the steps right as there is timing involved. Persevere and and it should work.

  1. Insert the MASTER key in the ignition 5 times, leaving it IN the ignition on the 5th time. Do not turn the key. Don’t rush that step, do it slowly.
  2. Open and close the driver’s door 6 times, leaving the door closed on the 6th time.
  3. Remove the master key from the ignition. The security light should now be solid red to indicate programming mode. If it’s not, repeat from the beginning.
  4. Insert the new key in the ignition but don’t turn it. Do that step quickly as the computer only stays in this mode for a couple of seconds.
  5. The security light will resume blinking. After 60 seconds (maybe more, be patient), the light will stop blinking and turn off.
  6. Remove the new key, insert the master and turn the engine on and then off.
  7. Done! Test your new key. When you insert it, the security light should stop blinking and the car should start.

The theory

Its wrongly called programming a key but in fact, no key gets programmed by itself, its the car that gets programmed. Keys have an RFID emitter in them which outputs a unique identifier when prompted by the car’s anti-theft device’s reader upon insertion in the ignition. If that identifier is not in the car’s computer valid key identifier list, the car will not start.

What the procedure above does is putting the car’s anti-theft system in programming mode and then telling it that it should include the new key’s id in its list of permitted keys. This is done by doing a set of special steps with the master key in. If you possess the master key, chances are you are the master, but should you loose all you keys, there will be no way of starting the car again other than replacing the anti-theft computer; something the dealer will charge a lot for.

Fixing AMD (ati) radeon display issues on Fedora

Note (09/01/17): also worked on a recent upgrade from 23 to 25.

I had put off system upgrades for so long that I found myself having to go from Fedora 20 to 23. It took a while but everything was going smoothly until I hit Fedora 23 on. There, after the mandatory reboot, hooking up my secondary monitor would freeze the display and screen repainting on some programs (like Eclipse) had become problematically slow and CPU demanding. This being Linux, I scoured the web on a quest to find some clues on what was not configured correctly but nothing came up. I’m running an AMD A6-3420M APU and while AMD provides driver for that chip, they are according to reports very finicky and a pile of trouble to get running.

I resorted to simply downgrading the driver. It was working correctly in the past, so I could see no obvious reason an older version would not do it this time.

First find the version of the driver currently installed:

dnf info xorg-x11-drv-ati

Which should spit out something along the lines of:

Installed Packages
Name        : xorg-x11-drv-ati
Arch        : i686
Epoch       : 0
Version     : 7.6.0
Release     : 0.4.20150729git5510cd6.fc23
Size        : 151 k
Repo        : fedora
Summary     : Xorg X11 ati video driver
URL         : http://www.x.org
License     : MIT
Description : X.Org X11 ati video driver.

So the faulty driver is version 7.6.0. Now, run:

sudo dnf --showduplicates --allowerasing --releasever=24 downgrade xorg-x11-drv-ati

Here, we’re asking dnf to go look in a previous release of Fedora for an earlier version of the driver. If the problems you are experiencing appeared with a recent update, you could avoid the –releasever argument altogether to just revert back to the previous version.

If the downgrade does not work, you rerun the command to roll back the driver even further in the past, but if after a couple times you haven’t had success, the issue probably lies with another package so run a dnf update to and take your investigation elsewhere, maybe the kernel, wayland, X, the window composer or gnome-shell.

When you update your system in the future, you’ll have to run:

sudo dnf --exclude=xorg-x11-drv-ati update

Otherwise, dnf will reinstall the broken later version of the package. This command will also give you packages with broken dependencies. That’s normal, those are packages that share dependencies with the one you have downgraded and for all I know could actually have been the ones causing you trouble. Just let them be.

Make sure you check back from time to time if another version of the offending package has been released by issuing a simple dnf update and checking the version now available.

How to download a CBC radio show episode no longer available as a podcast

Sadly, CBC (Canadian Broadcasting Corporation) has a policy to keep podcasts available for download only 3 months for daily shows and 6 months for weekly shows with some of them being available for an even shorter time. Luckily, most shows can still be streamed from the CBC radio website using a flash/web player but are still no longer available for direct download. That’s convenient if you’re in front of your computer (which is seldom the case when listening to radio), but not that practical if you want to take an old favorite on a run.

Most of what we do on our computers is just data copying and playback, always in that order. So if it’s playing in your computer speakers, its coming from a stream, and if it’s coming from a stream, it can be copied as file. There are tons of software and websites that will let you do just that, but most of them are geared towards more popular streaming sites of the likes of YouTube and such so I had to resort to another technique for the CBC’s website. The non-trivial part here is to find the URL from which the data is coming from but modern web browsers and their built-in debugging facility have made this an easy task. Once you have the URL, you’re free to download the wanted file at will. This process assumes you’re using Chrome, but it works just as well with Firefox.

So let’s say I want to download this past episode of the show Ideas. There is a player on the page, but no download link.

  1. Bring up the page in Chrome but don’t start streaming yet.
  2. Left-click anywhere on the page and click on “Inspect element“, this will bring up the Chrome debugger.
  3. Within the debugger, switch over to the “Network” tab.
  4. On the episode’s page, start steaming the episode by clicking the play button, you’ll see a bunch of things happening in the debugger window.
  5. Click on the “type” column to sort the data elements by type and find the audio/mpeg (or media) one, that’s the file you’re streaming (see screenshot below). Mine’s name is ideas_20130307_53465_uploaded.mp3.
  6. Left-click on the name and select “Copy link address” or “Open in new tab” and that’s it, from there you can download the episode as a file. The link for my episode is http://thumbnails.cbc.ca/maven_legacy/thumbnails/14/881/ideas_20130307_53465_uploaded.mp3. When opening up the link in your browser, it might bring up its own player but if you click around, you’ll find an option to download the file instead of playing it.
Chrome debugger view with the stream data row highlighted. Left-clicking on the row will bring up a link to the stream itself and allow its downloading.

Chrome debugger view with the stream data row highlighted. Left-clicking on the row will bring up a link to the stream itself and allow its downloading.

Fold-down back seat modification on a Toyota Corolla 1999 VE

Toyota Corolla 1999 VEOn several occasions lately, I’ve had to transport long objects or gain access to the rear strut mounts in my Toyota Corolla. On most cars, this would have meant to simply pull a lever in the trunk and fold the back seat down but for some reason, Toyota had made this an option on my vehicle (the North American VE model).

So in order to be able to take advantage of the full length of the car, I had to remove the rear seat, which is not that difficult and only requires a socket wrench, but still massively inconvenient. While undoing the seats, I had originally thought of a way to make removal easier and tool-less in the future, but did not decide to make the modification. Until now, with winter at my doorstep, I’m convinced fold-down seats are going to prove themselves quite practical should I want to go skiing.

The mod is quite easy and requires no specialized tools or knowledge. The end result is that you will be able to lift the backrest up and lay it flat on top of the bottom cushion, exposing the opening to the trunk .  Since the seat belts are bolted to the frame, disturbing the seating should not have any effect on their function. However, you might end-up discarding a part I call the V frame, which could possibly have some structural or security importance, I’ll get to it later. Lastly, I’m not going to post a full disclaimer, this is the internet so you’re following this guide at your own risk. If you or your passengers get hurt because of this modification, nothing can be held responsible but you and your judgement.

Removing the rear seat

Bottom cushion out

Bottom cushion out

Taking the rear seat apart is nothing really complicated. The bottom cushion is held to the frame of the car by only two plastic clips that are approximately lined with the two front seats. You can even feel them by running your hand under the cushion along the outer edge. Pry them out with a sudden pull and they should give.

Backrest out

Backrest out

Next, undo the three bolts holding the back cushion to the frame. There is a bolt in the middle and two at the extremities close to where the seat belts attach to the frame. Lift the backrest out and set it aside outside the car. At this point you can re-install the bottom cushion to make working in the car a bit more comfy. Finally, push out the black plastic cache that separates the trunk and the interior.

If you just wanted your rear seat out only as a temporary measure, stop here. The car is perfectly drivable in this state. You might notice the road vibrations becoming somewhat louder but that’s entirely normal given the amount of noise insulation you just removed.

Removing the V frame

V frame removed

V frame removed

What I refer to as the V frame is the coincidentally V shaped piece of pressed sheet metal bolted right in the middle of the opening to the trunk. It’s in the way but if it does not bother you you can certainly keep it there. I, for one, decided to remove it because I did not deem it to be critical for the safety or handling of the car. First, Corollas with factory installed fold-down back seats do not have it and I’d be really surprised if their frame was any different than the standard model to account for the added structural integrity. Second, if it’s purpose was to give the body more stiffness, the V would be upside down. It could have a part to play in case of rear collisions, but my theory is that it’s meant to add support to the rear seat. So If you agree with my logic, you can go ahead and remove the six bolts that hold the V frame in place.

Fastening the bottom cushion

Bottom cushion fastened

Bottom cushion fastened

Last major step is fastening the bottom cushion. It has three metal prongs that would normally slide under the backrest part of the seat, but since it will now become loose, the bottom cushion needs to be attached to the frame. Once you have re-installed the cushion, simply drill holes where the prongs are. Rest assured, the metal is not very thick and your fuel tank is a safe distance below. Once that is done, use properly sized sheet metal screws and washers and thread them through the holes you just did to hold the cushion down.

Cut that metal prongOf the metal prongs on the bottom of the backrest that used to be screwed to the frame, the middle one get in the way and should preferably be removed. Its not absolutely necessary, but it will make installation easier. This procedure can be accomplished with a bolt cutter or a metal saw. There is another prong right next to the one you just cut that is meant to slide under the seat cushion; leave it in place.

Finally, slide in the backrest, thread the seat belts in their correct position and set it so the metal loops below the headrests pair up with the hooks on the frame. Give it good tap so it sits correctly and you’re done. Nobody should ever notice this little trick but I’m sure its going to prove itself very useful.

Done! You can now transport dead bodies in your trunk without having to cut them up.

Done! You can now transport dead bodies in your trunk without having to cut them up.