GregLedet.net Adventures in networking, security, and other things

7May/108

My pain is your gain: Installing Windows after Ubuntu and the joy of GRUB2

Do yourself a favor and never do this if you have other things on your mind.  The information is sparse and not very well written, so I'm going to fix that right now.  Today I had to install Windows XP on my wife's laptop because some company that makes software that she needs decided that it would be too easy to allow people to use virtual machines to run their software.  When I installed Ubuntu on the machine a few months back, I left a 30GB partition at /dev/sda1 to put Windows on there at a later date should she need it.  Well, she needed it and I installed it.  Once installed, I needed to get GRUB back.  If you haven't done this with GRUB2, consider yourself lucky.  Here's the easiest way to do it.

  1. Boot to the LiveCD Desktop (Ubuntu 9.10 or later).
  2. Open a terminal by selecting Applications, Accessories, Terminal from the menu bar.
  3. Determine the partition with the Ubuntu installation. The fdisk option "-l" is a lowercase "L".
    1. sudo fdisk -l

      If the user isn't sure of the partition, look for one of the appropriate size or formatting.Running sudo blkid may provide more information to help locate the proper partition, especially if the partitions are labeled. The device/drive is designated by sdX, with X being the device designation. sda is the first device, sdb is the second, etc. For most users the MBR will be installed to sda, the first drive on their system. The partition is designated by the Y. The first partition is 1, the second is 2. Note the devices and partitions are counted differently.

  4. Mount the partition containing the Ubuntu installation.
    sudo mount /dev/sd''xY'' /mnt

    Example: sudo mount /dev/sda1 Note: If the user has a separate /boot partition, this must be mounted to /mnt/boot

  5. Run the grub-install command as described below. This will reinstall the GRUB 2 files on the mounted partition to the proper location and to the MBR of the designated device.
    sudo grub-install --root-directory=/mnt/ /dev/sdX

    Example: sudo grub-install --root-directory=/mnt/ /dev/sda

  6. Reboot
  7. Refresh the GRUB 2 menu with sudo update-grub

That doesn't look that difficult, does it?  Yeah, well, it was a pain in the ass to get to that point.  If you notice, I highlighted the example for #5.  If you do what I did and try to sudo grub-install --root-directory=/mnt/ /dev/sda1, then you're going to end up getting something that looks like this:

grub-setup: warn: Attempting to install GRUB to a partition instead of the MBR. This is a BAD idea.
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and its use is discouraged.

You don't want this.  You're going to try to force it and you're going to fuck something up.  Make damn sure you do it right.  Let's look at my particular situation.

My setup looks like this:

/dev/sda1 is NTFS
/dev/sda2 is ext4
/dev/sda3 is swap

I would have to enter the following commands:

sudo mount /dev/sda2 /mnt
sudo grub-install --root-directory=/mnt/ /dev/sda

After knocking that out, it should tell you that it's been successful and all you now need to do is reboot!  It took me 5 different times to get this damn thing back.  I ended up bombing out the Windows MBR by installing GRUB on it, which made me have to do a fixboot/fixmbr from the windows recovery console and start all over again.  Once I was back to square 1, following the commands above got me done in 5 minutes.

I hope this helps you!

-Greg

10Nov/0916

Western Digital MyBook World Edition Hacks

I know that I've been moving further and further away from the main purpose of this blog, and that's Cisco networking and security. I'm putting this here so I can remember how to do this stuff later and have a place to look! The MyBook World Edition is a great device that you can do tons of stuff with. It runs Linux, so just about anything you can do with Linux, you can do with this device.

First off, you need to enable SSH on your NAS. There's a few different ways of doing it. Martin Hinner was the original hack. I've used this method before and it works just fine. There's also a slightly cleaner way of doing it found here. I have both scripts on my server should something happen to either one of those.

Martin Hinner Original Hack

http:///auth/firmware_upgrade.pl?fwserver=gregledet.net/mybook/firmware.php

Slightly Cleaner Hack from Mybook-Linux

http:///auth/firmware_upgrade.pl?fwserver=gregledet.net/mybook/enablessh.php

For both of those, simply plug the link into your browser, add the IP of your MyBook, and it will tell you that there's new firmware available. Click the button that tells you Download and Install. It's not going to take the 30 minutes that it'll say on your screen, it should take around 5 or 10. With the Hinner hack, you may get an error message saying that the firmware update failed. This happens with firmware 2.00.15 and higher. Don't fret, the script did run. You'll be fine. Continue on with the instructions.

  • *NOTE* If you have an SSH client, great. If now, download PuTTY. I use it and it works perfectly fine. Login with the username "root" and the password "root".
  • *NOTE* If you don't know how to use vi, or if you are uncomfortable using it, you can get a program like WinSCP that will allow you to secure FTP into the device. Then you can download the files to your computer and use the editor of your choice to edit the file (notepad works fine) and upload the new file back to the device.

If you use the Martin Hinner hack, after you install the "firmware", you need to make SSH permanent by editing the /etc/inittab and adding the following under the "# Startup the system" part of the file.

::sysinit:/usr/sbin/sshd

The other way should turn it on permanently by itself. After you add that line for the Hinner hack, or once the "firmware" is installed and you can SSH into the device, you need to reboot.

[root@MyBookWorld ~]# reboot

Now you have SSH permanently installed on your MyBook World Edition!

One error that I ran into was not being able to get mplayer CE to connect via samba to the network share on the MyBook. To fix this I had to enable Microsoft Directory Service on the device. First, you need to add the following lines to the /etc/services file.

microsoft-ds    445/tcp                         #Microsoft Directory Service
microsoft-ds    445/udp

Add this after "snpp 444/udp # Simple Network Paging Protocol" and before "saft 487/tcp # Simple Asynchronous File Transfer". Do your best to make it fit in the file. By that, I mean use the tab key.

After this, you need to edit the /etc/inet.d file and add:

microsoft-ds stream tcp nowait root /usr/local/samba/sbin/smbd smbd -s/etc/smb.conf -l/var/log -d0

I would just add it on the second line or at the bottom. I don't think it matters.

One more file to edit. This time you need to add the following to the /etc/smb.conf file under "[global]" after "max log size = 1"

smb ports = 445

A quick reboot and you're done! This will have you connected to your Wii to stream movies with no problem.

There are tons of sites out there that have great information on hacking your MyBook World Edition. With the following 2 sites, you should be able to do whatever you want with it.

Martin Hinner's site on Hacking the MyBook World Edition
MyBook World Hacking at wikidot.com

Those sites should answer any questions you have about anything having to do with Hacking the MyBook World Edition!

28Sep/097

Ubuntu + Netgear WGPS606 = Wireless printing!

Today I decided to upgrade my Ubuntu installation to 64bit. I've been running the 32bit version because there was no solid version of flash for the 64bit. Well, after a little research, I found Adobe's alpha version of flash for 64bit Linux.

I didn't have a printer setup in my last installation because I didn't use Linux for any kind of printing.  I want to get into using Linux for more and more things, so I figured it was about time to setup my printer.  I have an HP PSC 1510 All-In-One that is upstairs in my office and it's plugged into a Netgear WGPS606 Wireless print server.  I have no cables running into the office (stupid apartment!), so everything up there is coming off this print server/wireless bridge. A little bit if digging and I finally figured out how to setup this print server in Ubuntu.  Follow the directions below and it works like a charm.  I know this had nothing to do with Cisco networking, but neither did my article on Creating a transparent signature stamp in Adobe Acrobat.

Before you get started, make sure you have the latest firmware on your print server. You can find it here. The latest firmware is 1025 as of today.

  1. Go to http://localhost:631
  2. Click "Administration" in the header.
  3. Authenticate with user: root, password: root's password if you are asked to.
  4. Click "Add Printer" in the Printers section.
  5. Fill in at least "Name" and click "Continue"
  6. In the Device Dropdown box, select "LPD/LPR Host or Printer" and click "Continue"
  7. In the Device URI box put "lpd://<your_wgps606_ip>/L1" or "lpd://<your_wgps606_ip>/L2".  L1 is for the first printer, L2 is for the second.  In my case the full URI is lpd://192.168.1.5/L1.
  8. Select your printer's make and click "Continue"
  9. Select your printer's model and click "Continue"

That's all it takes! Shoot a test page to the printer to make sure that everything is working and you should be done! If you have more than one printer plugged into the print server, simply run through the process again and put the other port number in the URI box in #7.

-Greg

27Nov/0852

DD-WRT? In my WRT54G2? It’s more likely than you think!

Happy Thanksgiving kiddies!  I've decided to put together a little how-to for the home users that may be throwing around the idea of upgrading the firmware on their WRT54G2 to DD-WRT.  "But the WRT54G2 isn't supported by DD-WRT yet Greg!".  Well, that's not exactly true.  Follow these simple instructions and you'll have it done in less than 10 minutes.

You'll need the following files:

Linksys TFTP utility
VxWorks Prep
VxWorks Killer
DD-WRT Firware

I've put them all here for your convenience.

Here is another How-to with a little more information that is based off this one.

Get and install Linksys tftp.exe, set your PC to static IP, 192.168.1.10.

1. Reset the router to defaults on the Linksys Admin page, and let it reboot or manually reboot it after its finished.

2. Set your computer to a static IP of 192.168.1.10/24 and plug Ethernet cable into one of the LAN ports on the router.

3. Close all your browser windows. Start the tftp utility, set server to 192.168.1.1.  Password is "admin" and browse to the VxWorksPrep-G2V1.bin file. Click Upgrade. Wait a minute for it to reboot on its own, if it doesn't, then power cycle the router manually.

4.  In the tftp utility, browse to the VxWorksKiller-G2V1.bin file and click Upgrade. Wait 2 minutes for it to reboot on its own, if it doesn't, then power cycle the router manually.

5. Tftp the DD-WRT firmware to the router, use "dd-wrt.v24-10709_NEWD_micro.bin"; after successful tftp, wait 3 min for the router to finish writing new nvram defaults, etc... It should reboot on it's own at least two times, so give it the 3 min and then open a browser to http://192.168.1.1 (If it not reboots on its own, wait another 1 min, and then power cycle it).

6. When if finishes booting up...do a hard reset on the unit...let it boot again, and configure.

That's it! Now you have a lot more control over your WRT54G2 v1!

   
7 visitors online now
4 guests, 3 bots, 0 members
Max visitors today: 16 at 04:18 am UTC
This month: 94 at 05-03-2013 04:12 pm UTC
This year: 94 at 05-03-2013 04:12 pm UTC
All time: 106 at 08-27-2010 05:48 am UTC

Switch to our mobile site