Discover how your partitions are set up

Before i re-install windows I thought it would be prudent to ensure that I select the correct partition to install on.

Finding out how your partitions are set up is quite easy in Ubuntu. Bring up a command shell and start the The GNU Parted disk partition resizing program, otherwise known as “parted”. To start it type sudo parted at the prompt.

Then all you have to do is type print all. Here is the output from print all on my PC:

Disk /dev/hda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
.
Number Start End Size Type File system Flags
1 32.3kB 7863MB 7863MB primary fat32 boot
4 7863MB 15.7GB 7863MB primary ext3
2 15.7GB 79.5GB 63.8GB primary fat32 lba
3 79.5GB 80.0GB 526MB extended lba
5 79.5GB 80.0GB 526MB logical linux-swap
.
Disk /dev/hdc: 200GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
.
Number Start End Size Type File system Flags
1 32.3kB 200GB 200GB primary ntfs

You can see I have two hard drives. Ubuntu references them as /dev/hda and /dev/hdc.

/dev/hdc is just a single partition of 200GB that I use to stash data on (My Documents, family pictures, mp3’s etc).

The other one – /dev/hda is a smaller drive I use to hold my operating systems. The logic here is that I can re-install Windows/Ubuntu as often as I like and my data will remain intact on the PC.

hda: [80GB] First hard drive

  • hda1: [7.8GB] Windows installation (C:\)
  • hda2: [63.8GB] General dumping ground – shared between operating systems. (G:\ in windows. Known as /media/hda2 in ubuntu).
  • hda3: [0.5GB] extended partition for holding logical partitions
  • hda4: [7.8GB] Ubuntu installation (\)
  • hda5: [0.5GB] linux swap partition

hdc: [200GB] Second hard drive

  • hdc1: [200GB] Data drive. (D:\ in windows. Known as /media/hdc1 in Ubuntu).

backing up a wiki

I use a wiki to record stuff. In the hope of not wrecking it when I move to another windows installation I thought I should back it up

Here’s the contents of a batch file I whipped up to back up my wiki.


@ECHO OFF
REM
REM Date
for /f "tokens=2" %%i in ('date /t') do SET thedate=%%i
SET dd=%thedate:~0,2%
SET mm=%thedate:~3,2%
SET yyyy=%thedate:~6,4%
REM
REM Time
SET thetime=%time%
SET hh=%thetime:~0,2%
SET min=%thetime:~3,2%
SET ss=%thetime:~6,2%
REM
REM Fix hours
if %hh%==0 SET hh=00
if %hh%==1 SET hh=01
if %hh%==2 SET hh=02
if %hh%==3 SET hh=03
if %hh%==4 SET hh=04
if %hh%==5 SET hh=05
if %hh%==6 SET hh=06
if %hh%==7 SET hh=07
if %hh%==8 SET hh=08
if %hh%==9 SET hh=09
REM
:printdate
REM ECHO %date% %time%
ECHO Creating L:\backup\wiki\wiki_%yyyy%%mm%%dd%T%hh%%min%%ss%.sql
REM
mysqldump --default-character-set=latin1 --user=root --password=<<YourDatabasePassword>> wikidb -c > L:\backup\wiki\wiki_%yyyy%%mm%%dd%T%hh%%min%%ss%.sql

There is a bit of superfluous code, plus some dodgy REM statements. ONly there bc it’s getting late and I am in a hurry.

I also had to back up the images folder and the configuration files; LocalSettings.php and AdminSettings.php

Backup/restore your MBR

I am going to re-install windows soon.

I haven’t done it in years, and the amount of cruft that has built up over that time has slowly increased. I am usually pretty on the ball regarding system maintenance and hat not but some things have recently started to go quirky on me. Typical stuff like general unresponsive system, Skype won’t recognise my microphone, even though I can hear it coming through the speakers, blah blah.

The only problem is that I have Ubuntu installed on the first partition and Windows installed on the second. Windows has little respect for the master boot record (MBR), and will happily overwrite it when I re-install, so I need to do something so I can restore the MBR back to it’s original state after the Windows installation.

Use disk druid and a live-CD:

  • Backup: $dd if=/dev/hdx of=MBR-backup bs=512 count=1
  • Restore: $dd if=MBR-backup of=/dev/hdx bs=512 count=1

Alternatively just use a live-CD in rescue-mode and use grub-install to fix it up for you! (Details provided on same page as previous link – first comment)

hard drive encryption broken with can of compressed air…

(…and a fair bit of nerd action).

This arstechnica article discusses how a few geeks at Princeton Uni figured out that freezing the RAM chips in your computer can preserve the state of the memory, long enough for them to extract the contents ofthe keys used to encrypt your hard-drives of files.

Using the gas from of compressed air can (and some USB-bootable operating systems) they can get access to drives/files encrypted using BitLocker and TrueCrypt.

Wow. Awesome effort.

Use a sandbox environment to test install your new applications

At work I’ve been involved with software download management. I work in *what should be* a safe environment, but the download policy for the devs has been historically, erm, non-existent.

One of the areas we had to look at was how to judge the footprint of a new tool that one may want to use.

Sandboxie to the rescue. “Sandboxie intercepts changes to both your files and registry settings, making it virtually impossible for any software to reach outside the sandbox. Sandboxie traps cached browser items into the sandbox as a by-product of normal operation, so when you throw away the sandbox, all the history records and other side-effects of your browsing disappear as well.”

The bonus is that it can also enumerate the changes that an applicationhas attempted to make – in the registry and on the file system.

It’s currently shareware, but I am pretty sure we’ll be ponying up some cash to show the developer we appreciate his work.