MidnightReign.org

Incoherent Keyboard Bashing

Browsing Posts in Technical

VirtualBox – Cloning Ubuntu (or Debian) based image issues

Comments off

In the interest of having this information somewhere handy:
Firstly, to successfully install VirtualBox Guest Additions within a server based image:

sudo apt-get install dkms build-essential linux-headers-uname -r

I discovered that if you clone an ubuntu server based image, networking stops functioning in the clone.
The reason for this is that the new Machine assigns a new MAC address to the NIC. So the Udev rules think it's a new card, and assign it a new device id, like eth1, or eth2, etc.

To prevent this from happening, in your base image, edit /lib/udev/rules.d/75-persistent-net-generator.rules

Search for 'xen', and you'll see a block about ignoring the Xen virtual interfaces. Add the following below it:

# ignore VirtualBox virtual interfaces ATTR{address}=="08:00:27:*", GOTO="persistent_net_generator_end"

Save it, and then remove the file /etc/udev/rules.d/70-persistent-net.rules.

Do the same thing in any cloned images with broken networking, and reboot the VMs.

Virtual Box – Compacting Images

Comments off

NOTE: This is a technical article. While this is a fairly simple process, I'm not going to walk you through the basics of using a computer. Also – this is aimed at NTFS based images.

You've been messing about in your VM, installing and removing software, etc. Your disk space usage inside your machine says you've only used 3Gb of disk space, yet your actual image is much bigger. How do you fix it?

It's fairly simple to fix. First, you should probably remove all the unnecessary crap that you never use. There's a bunch of utilities out there that can help you with this.

Defrag your drive using your favourite defragger.

Now you will need one of two possible utilities (There may be more, but these are the ones I'm aware of):

  • SDelete from http://www.sysinternals.com – this is a tiny 47kb executable.
  • Precompact.iso – Obtained from Microsoft Virtual Server installation (May be available in other MS VM products)

Precompact.iso is MUCH easier to use. All you need to do is mount the ISO inside your VM, and it will prepare your disk for compaction.

SDelete is only marginally more difficult. Run it in a command prompt like so: SDelete -c C:
(or use whatever drive letter you want to compact). SDelete will write zeroes to the free space on your drive image. This allows compaction to take place properly.  Note – this is exactly what the Precompact.iso does, just without the fancy Windows GUI progress bar.

As soon as Precompact or SDelete is finished, shut down the VM.

Open command prompt on your host machine, and navigate to the folder where your hard disk images are located.

NOTE: It's probably MUCH easier to have the path to Virtual Box set in your PATH statement, otherwise you have to specify the full path to VBoxManage every time you use it.

In the command prompt, run:

\VBoxManage modifyhd "Name Of Image.vdi" --compact

Your disk image will now be compacted, and should end up quite a bit smaller than it was.
If you get an error about the disk image not being found blah blah, specify the FULL path to the image, like so:

\VBoxManage modifyhd "C:\Users\Username.VirtualBox\HardDisks\Name of Image.vdi" --compact

Virtual Box – Resizing Disk Images

Comments off

NOTE: This is a technical article. While this is a fairly simple process, I'm not going to walk you through the basics of using a computer. Also – this is aimed at NTFS based images, but the basic principles should still work fine for other OS's.

Like a tool, and not thinking ahead, I created an XP Base dynamic image of max 10gb in size.  While this is usually enough space to mess around with things, I find it can be a pain in the backside when you want to install a sizeable program – say Visual Studio. While possible, you end up with very little disk space left over at the end of the day.

A possible solution to this dilemma would be to simply add a new disk to the machine, as needed. However, I like making things difficult for myself, so I rather wanted to resize the initial disk.  Unfortunately this is not possible with the provided VBoxManage utility. So, you need to jump through a few hoops, but it's really not that difficult.

You will need:

  • Clonezilla – http://clonezilla.org
  • GParted – http://sourceforge.net/projects/gparted/

Download the ISO versions – and for Clonezilla – DO NOT download the "Alternate" version, it will NOT work.

Using the Virtual Media Manager, create a new dynamic disk of your desired larger size. Call it whatever you like.
While you are there, add the CloneZilla and GParted iso's to the CD/DVD library.
Create a new VM, but do not attach any disks to it. Configure it as Linux, Debian. I called mine Clone Master.
Edit the VM settings, go to the Storage node, and add a new hard disk. Select your SOURCE disk (The disk  you want to enlarge). Add another hard disk, and select the DESTINATION disk (the big image you just created). Click the CD node, and select the clonezilla image. Boot the new VM.

The CloneZilla CD should now boot (If it doesn't, check the boot priority in your VM settings, and make sure CD is set to boot first).


Use the utility to do a local disk to disk clone. Using "beginner" mode is fine.  The "expert" mode has a setting to extend the partition to the size of the destination disk, but it didn't work for me at all – the cloned partition was the original size. Not sure if it's because of the NTFS partitions, or a bug in the version I was using. If it works for you then EXCELLENT – you won't need to do the GParted segment.
 

Once you have cloned the disk, power off the cloning VM, edit the settings, and detach the hard disks from it. Attach the newly cloned bigger image to your original VM, or create a new VM for it, and boot it. Check that the system works ok. If the partition hasn't grown to fill the new partition, you will need to continue to the next step.

Shut down the VM with the new large image.
Edit the settings of your cloning VM, set the CD to use the GParted iso, and attach the newly cloned image to the machine.
Boot the machine, and GParted should load. Just accept default settings, and eventually X-Windows will load with a copy of GParted. Click the extend button, and increase the partition to fill the disk. Apply the changes. It will only take a few seconds to completed. Exit the system, and shut down the VM. Edit the VM settings, and detach the disks (It's not strictly necessary – more of a safety measure).

Boot your previous VM to test the disk. All should be good.
 

Pushing PuTTY

Comments off

Couldn’t resist that title, forgive me :P

I was mucking about with SSH tunneling with PuTTY a bit earlier. Although it looks completely mind boggling, it’s actually very very simple to do. I just wish some schmuck had written a concise howto, then I probably would’ve spent 2 minutes figuring it out instead of 5. :D

So… consider this my concise howto. (Ok, bear in mind, I have no idea how to spell concise, let alone speak it!)

First of all, you need to have an accessible SSH server somewhere that you can authenticate to, and hopefully the option AllowTCPForwarding is set to “Yes” in its sshd_config. If you have access to modify the config, I suggest checking that this option is on.

Load PuTTY on your workstation, and type the hostname and port of your ssh server on the “Session” window (That’s the default window that opens when PuTTY loads). If you have your connection saved, click it in the Saved Sessions list and click the “Load” button.

Now, in the tree list to the left, expand “Connection”, then “SSH”, and click on “Tunnels”.

In the dialog to the right, type in a source port (This is the port that you will connect to on your local machine) – pick something arbitrary – hopefully it won’t be in use. If you’re not sure, open a command prompt and run ‘netstat -a’, and pick a port that is NOT listed there :P

In the destination field, type the name of the server you wish to connect to, and the port, using host:port syntax. Click “Add”. If you want to add more local ports / remote hosts, do it now.

If you want your machine to be a gateway type machine, click the check box at the very top of the screen, “Local ports accept connections from other hosts”. — I have NOT tested this functionality, so who knows if it works.

Click ‘Open’ when you’re ready. If you like, you can switch back to the ‘Sessions’ section, and save your tunnel session.

The PuTTY console screen will open like normal, and you can authenticate to your ssh server. Leave that window open, and open whatever software you wish to tunnel with, and enter ‘localhost:port’ (set the port to whatever port you chose in the Source port for the tunnel).

Voila! You should be connected.

The only caveat I can see is using the tunnel for browsing the web is not that effective, especially in the case of name based virtual hosts – if you try access a site that is a virtual host on some web server, the default site will actually load, and not necessarily the site you were expecting. I’m not sure if there is a way around this.

OpenDNS Oogliness

Comments off

Argh. I hate frustrating issues that make me want to pull my hair out. Not that I’ve got much hair mind you. I tend to keep it short. Number 1 short. It adds to the mean don’t fuck with me look. Which also means it’s too short to actually grab. So my point is moot. Gah.

The DNS servers provided by my ADSL link are pretty crap. They take ages to update, and sometimes give shit, so some kind soul pointed me at Open DNS. I immediately configured my LAN to use them, and I was A for away.

Now my only niggle with them is whenever I configure a new sub-domain on my name server, it takes a little while for it to propagate – which is normal in DNS systems – however, with one particular sub-domain that I configured for one of my brother’s domains, I just could NOT access it from my own machine. It was seriously pissing me off. One minute I’d get resolution and the site would load, and then next I would just get DNS errors.

Doing a local lookup kept returning an IP that belongs to OpenDNS – wtf?

So I browsed to their site and searched around a bit. Eventually I happened across this link which allows you to query the status of their DNS cache. So, I do the obvious. Of the 4 servers (or so) that they have, one of them was showing invalid data. And typically, it was that fucker that I constantly seemed to query. Fortunately they provide tools to fix the problem, so in less than 5 seconds, I had resolved the issue.

Now, grasshoppers, what does this lesson teach us?

RTFM – Read the fucking manual.

Decrypting an IPCop 1.4.11 backup key

3 comments

I was put in the unfortunate position of needing to reload my IPCop. No problem, I’ll export the backup key, and download the latest backup file to my local machine. This I do, quite easily.

So, I reload the IPCop box, skip the floppy restore option, thinking I’m going to restore it via the web interface, so who cares anyway.

I get to the web interface, access the backup option. First thing I realise – there’s no way to import my saved backup key. Darn. So I try import the dat backup anyway. The interface tells me to bugger off, it can’t decrypt the file. Grrr. So what now?

I ssh to the IPCop box, and checkout the existing backup key. Then I check my saved backup key. My saved one is encrypted. Double darn (Ok, I said something far more nasty really).

Google… can’t find a damn thing. The only references I can find is some people copying their backup.key from an old hard disk to the new one. Whoop te doo. That does NOT help me. So, I download the IPCop source code, peruse a couple of files, and figure out how to decrypt the key.

To make my life easier, I used WinSCP to transfer my encrypted key to the IPCop box, then it’s a simple matter of running:

/usr/bin/openssl enc -a -d -aes256 -salt -pass pass:<yourpasswordhere> -in encrypted.backup.key -out decrypted.backup.key

You obviously need to insert your backup password where it says <yourpasswordhere>. If you forgot it, sorry mate, can’t help you.

Once that’s done, simply copy your decrypted.backup.key to the correct place:

cp decrypted.backup.key /var/ipcop/backup/backup.key

and overwrite the existing file.

Now you can import your saved backup and restore your settings.

Hope this helps someone. :p

EDIT: Whoops. Didn’t realise that the < & > that I inserted originally failed to render cuz the engine thought it was an html tag. Ugh.

Reload Shmeload

Comments off

So I’m reloading XP on my workstation. It goes through it’s usual crap before running that stupid welcome wizard thing where you add usernames etc. All’s fine and well.  Anyway, while loading up drivers, I realised that I had failed to install my sound drivers off CD first before installing the updated drivers, so I was missing a lot of the cool applications (I have an SB Audigy 2 ZS). So I thought that, instead of uninstalling the drivers I had just put on and tainting windows by loading off the CD and then reapplying drivers yadda yadda, I would just reload Windows yet again. No biggie, it doesn’t take all that long on my hardware anyway.

So I do exactly what I did before – I wipe the partition during setup, and recreate it, and let Windows install on to it.  I follow exactly the same steps as before.  This time, when Windows reboots after installation – instead of running that stupid lil welcome wizard, it dumps me at the welcome screen with just the administrator user visible.  What the…?  Where the heck was the wizard to add users etc?

I don’t get Microsoft, really I don’t.

Anyway, third time lucky.

You’re probably wondering why I’m reloading for a third time? I don’t know.  I just can’t handle the idea of trying to use Windows when the installation didn’t go as smoothly as I expected it to.  It’s like a psychological block – I’m going to constantly get the feeling that something is not right if I just let it go.

So I reload yet again. :p

I figured out that the welcome wizard didn’t run because when Windows asks to adjust the resolution, I bumped my keyboard and accidentally cancelled the change – which means the wizard does not run. Odd.

Powered by WordPress Web Design by SRS Solutions © 2010 MidnightReign.org Design by SRS Solutions

Bad Behavior has blocked 67 access attempts in the last 7 days.