My power supply came in the mail this week for my Toshiba A200 notebook so I decided to add Windows 7 to the installed OS list (currently booting Leopard 10.5.2 and Ubuntu 9.04). As always Windows hijacked the master boot record with it’s inferior boot manager – I had to fix this immediately.
GRUB is not as complicated as people make it out to be. In fact it is a very elegant solution to handling multi-boot platforms. Here’s a quick guide to steal your MBR space back from Windows :
- Boot into live CD such as Ubuntu or Knoppix – DSL works well and is fast.
- Open a terminal, if your live CD boots into a GUI – press ALT+CTRL+F2 to access a different console.
- type “cfdisk”
This part is tricky – you must find where GRUB currently lives – in the case of the image below (my rig) sda5 is where Ubuntu is installed – in GRUB this is equal to hd0,4 – since GRUB counts from 0, not 1.
Once you have determined what partition holds grub root files – close cfdisk (q) and type :
grub
root (hd0,X) <– where X is the grub count from 0 to your current Linux installation*
setup (hd0,0)
This will opverwrite Windows MBR installation and give access back to GRUB hooray! Next step would be adding Windows boot back to grub which has already been covered in my “How To Dual Boot Hackintosh + Ubuntu” article.
* I have a difficult time expressing this simple idea – if Linux is installed on SD5 then grub should say (hd0,4). If your boot partition is /dev/sda87, GRUB would be (hd0,86) – I hope this helps.
EDIT : I forgot to mention a huge congratulations to Microsoft for making an operating system that looks and feels like Vista with the intermittent stability of XP – huge upgrade IMO.. still far from Leopard.
CodeIgniter is a SUPER powerful framework and I have picked up some tricks along the road. If you are looking for a simple way to jail access to parts of your application, the following is tried and tested – I use a similar approach in almost every application I write.
When you want to lock users out of just one function or an entire controller just create a new model (call it auth.php or something useful) and autoload it in the autoload.php file under config/
For a simple explanation consider the following :
Really all we are doing is determining which script they are trying to access and if they are allowed to be there or not based on their user permission level (set in a session at login authentication (usually from the database)).
To lock down a controller simply add $this->auth->jail(); to the constructor or whatever method / function you want to lock. This may not be the most elegant solution but it works and is tough to screw up – if you do not need group permissions and only a boolean result, take a look at this one :
As you can see, much simpler however only allows a check to see if the user is logged in or not. Once again, this can be loaded per function or per controller (in the constructor).
Hope this helps, I really do need to get to bed - probably have twenty revisions for this code after a wink of sleep. Always welcome feedback (criticism is expected with insomniatic posts).
PS. I am aware “insomniatic” is not a real word.




