Showing posts with label how-to. Show all posts
Showing posts with label how-to. Show all posts

Saturday, September 20, 2014

Adding Startup Disk Support to Mac Linux USB Loader

Hello all. Here's a long-awaited Mac Linux USB Loader update.

I've made a number of small changes to Mac Linux USB Loader, but perhaps the biggest new feature that I'm working on is making USB drives created with Mac Linux USB Loader compatible with OS X's startup disk selector. Here is the screen I'm referring to:


In order for this to work, a few prerequisites have to be met:

  • You must enable support for HFS+ drives in Mac Linux USB Loader's preferences, under the Experimental section
  • You must be willing to have files placed outside of the EFI folder on the root of your USB drive, as OS X must find certain files in certain places (essentially, we're tricking it into thinking that your USB has an install of OS X on it)
  • You must use a distribution which includes drivers for the HFS+ file system in its initrd. Otherwise, your distribution will not be able to load properly. You may need to disable journaling.
More information will be forthcoming. In the mean time, feel free to comment, email me, or donate to the project.

Sunday, November 24, 2013

A Sneak Preview of Enterprise

So, after a long, hard month of serious development (before this was a rather lackluster and on-and-off effort) I am pleased to show some screenshots of Enterprise, my custom UEFI boot manager program that I wrote about at length in this post. However, there are some (small) details that are different in the plan versus the implementation, and that's of course because I've found a better way to do things. So, here's are some screenshots, as promised, with comments:


This screen (which may receive minor tweaking) allows the user to select one of two basic options: starting the Linux distribution immediately or, in case there's issues with the video card, etc, to customize Linux kernel boot options.


This is what the boot options screen that I just mentioned looks like. You can toggle a variety of boot options (up to 9 is supported with this approach) that have a variety of functions. Some of them make troubleshooting easier, while others facilitate installing Linux to your Mac. I plan on adding more before the final release. Please note that not all options are supported by all distributions.

Love it? Hate it? Have suggestions? Drop me a line. I'm shooting for a release date of the 30th of November and I'd love to get some feedback.

Monday, April 1, 2013

Mac Linux USB Loader: 1.0 Looming

The 1.0 release of Mac Linux USB Loader will be out very soon, within the next 2 to 3 days. Although I didn't make my initial target of a March release, the additional time figuring out Sparkle has allowed for a more stable final product.

Release notes will be coming very soon! I'll let everyone know when it's out via this blog, and if you told Mac Linux USB Loader to automatically check for updates, you'll know as soon as you start the application.

Monday, December 3, 2012

A Method to Boot Linux from Flash Drives via EFI on Macs and Why I Hate the EFI Support in Linux

Linux and Macs are like estranged cousins who are always a little antsy around each other. While they can trained to play together, deep down there is a deep resentment of each other. This relationship is not inherently by fault of either Linux or Apple; rather, the issues seem to lie with the hardware and firmware on Mac computers.

Sadly, the situation does not look like it will fix itself anytime soon. Macs require booting via EFI, which for all intents and purposes is horrible on the Linux platform. The only real way to boot Linux via EFI is unfortunately by hacks: GRUB 2, the rudimentary and ubiquitous Linux boot loader used on practically every installation, has working but poor EFI support, and other software like ELILO is not much better.

EFI is going to be way more common now than it was in the past largely due to Microsoft's decision to require UEFI firmware on all new PCs shipping as Windows 8 certified. So the Linux community finds it necessary to get a working EFI boot solution going quickly, but, as the video below demonstrates, everything is not all roses and unicorns:


So, what is to be done with PCs (and Macs) that are now booting via EFI? Well, I have one solution for   a common issue faced by Mac users: booting a Linux distribution from a USB drive without using rEFIt or rEFInd. Fedora seems to have something going, as shown by the following video below, which demonstrates Fedora booting natively on a Mac via EFI:

Sadly, Ubuntu and its derivatives do not have any native or supported way to boot via EFI on Mac platforms. So, I have created a tool called Mac Linux USB Loader to do just that! Open source (license pending) and on GitHub, Mac Linux USB Loader is a free application that copies a selected Linux distribution's ISO file and copy it and an EFI boot loader to the thumb drive of your choice. Best yet, it is non-destructive, which means that unlike other tools, you do not have to erase your thumb drive: all your data is preserved and untouched.

The tool has been successfully used to boot Linux Mint 14.1 from a 2 GB thumb drive. In theory, this shouldn't be restricted to Ubuntu; the only real requirement is that the distribution supports loopback. If you want to try the tool, fork the repository on GitHub and then compile the code in Xcode (binary releases will be released when the code is cleaned up a bit). Please note that the tool is in beta, is buggy, and may not work. You have no warned.

Give it a try and leave your comments/questions/thoughts in the comments below.

Friday, July 27, 2012

Product Review: Notepad++

Imagine a super fast, sleek, and easy to use text editor that doesn't give you shit. Well, Notepad++ is it. Sleek, elegant, and easy to use, it is exactly what I like to use everyday. Inspired by Scintilla, the editor component, but written in pure Win32, Notepad++ is perfect for code editing, HTML webpage coding, and other tasks that require plain text.


Although it is only available for Windows, it runs very fast on platforms such as Linux and Mac OS X through the use of software emulation layers like Wine. For instance, it runs fairly well under OS X:


It offers support for many programming and markup languages: from ActionScript to Matlab to Fortran to C, Notepad++ does any task for me (did that seriously just rhyme)? To get the lowdown on Notepad++ go over to their website at their website. And to download it, click here.

Wednesday, April 18, 2012

Simple Document Viewer: A Help Utility for My Projects

Considering I’m starting a large toolkit of tools for computer users, I’d figure I’d start by posting about my newest complete utility: a Simple Document Viewer designed to view online help for the rest of my toolkit in a fast and efficient manner. It renders pages in basic HTML, sadly CSS is not supported. I was going to add the Firefox renderer in, but that’s too large for my purposes here.

Here’s a screen capture:

screenie2

As you can probably see, its GUI is more sophisticated and involved than that of my simple File Incinerator tool. It consists of the standard back and forward navigation buttons, as well as an HTTP address bar. This address bar, however, is most likely going to be removed and replaced with a label showing the current address. The drop-down options dialog box is used to view the About text as well as choose the application of which help will be displayed.

Any comments on how the GUI looks will be much appreciated and welcome in the comments form below.

Thursday, April 12, 2012

Mint Linux: The Open-Source Future!

I just downloaded Linux Mint, one of around 300 active Linux distributions, onto a Live CD which I can boot from. I played with it, and really love it. I think that Linux is a fine and dandy OS. The first time I used it, I went like lightning. It did go a bit slower the second time, because I tried to download a bunch of stuff from the built-in package manager, even though it was running on a DVD.

I had to plug it directly into my Internet, and when I did, bang! Firefox was the fastest I’ve ever seen it. On my first run-through, I also played music directly from my Windows drive, which was great.

I’ll post screenshots in the future. You can download Linux Mint at http://linuxmint.com/.

Saturday, March 24, 2012

File Incinerator

Have you seen large pizza vans with small, opaque windows? That same van has been following for ages? Getting that weird feeling from your gut someone’s watching?

You need File Incinerator, a new tool by me. It securely shreds file so there’s no trace of them on your disc. Soon enough, you’ll want to get rid of something securely: only something my tool can do for you.

So Why Do I Need It?

Excellent question. When you delete a file, it isn’t actually gone. Using tools like Recuva, it is possible to go over a seemingly empty disc and potentially recover loads of files.

So It Removes any Trace of the File on My Disc?

Indeed it does, though this is not guaranteed. Due to the way the operating system handles files, it may be possible for some file data to remain – but likely not. So in all honesty, you probably have nothing to worry about.

Where Can I Find It?

You can find a command line version for Windows and Macintosh computers in the attached archive. A graphical user interface (GUI) version is nearing completion for Windows, but has not been started for Mac OS X.

Is This Illegal?

No. Incinerator works by writing over the selected file with random pieces of information equal to the size of the old file. All technology utilized in this software is legal, but how you use it is up to you. Just keep in mind I’m not responsible for how you use it.

Can I See Screenshots of the GUI?

Sure:

screenie1

A screenshot of the basic, beta version of the GUI. The progress bar is not functional as of this time.

I hope you enjoy what you see.

What Are Your Planned Features?

Here’s a short list of planned features and how likely they are to be added:

  1. Secure Empty Recycle Bin: Emptying the recycle bin only regularly deletes the file, so anything in there will be recoverable. Incinerator will soon be able to overwrite all files in the recycle bin. Likelihood: Excellent
  2. Ability to customize the deletion process through the GUI. This can already be done through the command line version as a command line argument passed to the program (up to 32 iterations is supported). Likelihood: Good
  3. Ability to incinerate the file, but not delete it (i.e allowing you to inspect its contents in a program like a Hex Editor). Likelihood: Good

Download:

You can download the files below in this ZIP archive.

 

Monday, December 5, 2011

Little Java Neaties–Swing

Today I’m going to show you all the neat little things you can do with Java.  Java is a very versatile programming language, and tonight I’m focusing on Swing.  Included in the package javax.swing and included on all versions of Java, it can be used to create interesting GUI applications.  For those of you who think they know what Java is but are a little sketchy, here’s a small sample to entertain ye:
 
   1:  import java.io.*;
   2:  import java.net.*;
   3:   
   4:  public class RemoteFileCopier {
   5:      public RemoteFileCopier(File name, Socket connection) throws java.io.IOException {
   6:          OutputStream out = connection.getOutputStream();
   7:          InputStream in = new FileInputStream(name);
   8:          
   9:          int ch;
  10:          
  11:          while ((ch = in.read()) != -1)
  12:          out.write(ch);
  13:          
  14:          in.close(); out.close();
  15:      }
  16:  }

Being as it is, I’m not going to explain how to compile or run this code.  If you don’t know how, find yourself a good Java book.  I like Head First Java by Oreilly Publishing, as it includes interesting examples to help you learn Java, including a rudimentary drum beat player.

Anyhow, there are a lot of things Swing can do, namely that it is much simpler than the native Win32 API – heck, I suppose there are WYSIWYG Java GUI builders out there, but Swing (and the AWT) provide an easy way to build complex GUIs in code.  Check this little snippet out, taken from this website.

   1:  // file: EmptyFrame.java
   2:  // Adapted from Core Java, vol.1, by Horstmann & Cornell
   3:      
   4:  import javax.swing.*;
   5:      
   6:  class MyFrame extends JFrame {
   7:    public MyFrame() {
   8:     setTitle("My Empty Frame");
   9:     setSize(300,200); // default size is 0,0
  10:     setLocation(10,200); // default is 0,0 (top left corner)
  11:    }
  12:      
  13:  public static void main(String[] args) {
  14:      JFrame f = new MyFrame();
  15:      f.show();
  16:    }
  17:  }

This class extends the JFrame class, so it doesn’t have to create an instance of it and can call its public methods directly.
Deprecation Warning: If your Java compiler complains about line 15 being “deprecated”, and you want to shut it up, change it to   f.setVisible(true);
Now that code snippet created a window with a size of 300 pixels by 200 pixels.  However, it’s rather empty.  Let’s add a small push button.

   1:  // file: EmptyFrame.java
   2:  // Adapted from Core Java, vol.1, by Horstmann & Cornell
   3:      
   4:  import javax.swing.*;
   5:   
   6:  class MyFrame extends JFrame {
   7:    public MyFrame() {
   8:      setTitle("My Empty Frame");
   9:      setSize(300,200); // default size is 0,0
  10:      setLocation(10,200); // default is 0,0 (top left corner)
  11:      Container pane = getContentPane();
  12:      JButton button = new JButton("CHANGE THIS TEXT");
  13:      pane.add(button);
  14:    }
  15:      
  16:    public static void main(String[] args) {
  17:      JFrame f = new MyFrame();
  18:      f.show();
  19:    }
  20:  }

Now the entire window will be filled with a button.  I hope now you see what Swing is capable of – in fact, you can obviously use Swing to create a GUI for a previously command line run application.  And because it’s Java, it’ll work in every operating system that has a JVM, though the controls will look a bit different depending on your OS.

To demonstrate this point, here’s a simple terminal application using two text fields.  It’s actually a small part of a large module I’m writing for yet another project called Tracker.

   1:  import javax.swing.*;
   2:  import java.awt.event.*;
   3:  import java.awt.*;
   4:  import java.util.StringTokenizer;
   5:   
   6:  public class CommandWindowDialog extends JDialog implements ActionListener {
   7:   
   8:      private JTextArea log = new JTextArea(5, 40);
   9:      private JTextField prompt = new JTextField();
  10:      
  11:      private static final String COMMANDS = "help (h) - shows this window.\n" +
  12:          "quit (exit) <exit code> - exit the program with error code.  if error not specified, command ignored.\n" +
  13:          "clear (cls) - clears the screen.\n" +
  14:          "what - displays information.\n" +
  15:          "echo <message> - echos the message.\n" +
  16:          "exec <program name> - executes the specified program.\n";
  17:      
  18:      public CommandWindowDialog(Tracker parent) {
  19:          super(parent, "Command Window", false);
  20:          setSize(500, 250);
  21:          
  22:          log.setText("Type <help> for a list of commands.\n\n");
  23:          log.setEditable(false);
  24:          
  25:          addComponents();
  26:          
  27:          setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  28:          setVisible(true);
  29:      }
  30:      
  31:      private void addComponents() {
  32:          Container c = getContentPane();
  33:          c.add("Center", new JScrollPane(log));
  34:          c.add("South", prompt);
  35:          
  36:          prompt.addActionListener(this);
  37:      }
  38:      
  39:      public void actionPerformed(ActionEvent e) {
  40:          try {
  41:              CommandWindowDialog.processCommand(prompt.getText(), log);
  42:              prompt.setText("");
  43:          }
  44:          catch (java.io.IOException exec) { JOptionPane.showMessageDialog(this, exec.getMessage()); }
  45:      }
  46:      
  47:      public static void processCommand(String command, JTextArea log) throws java.io.IOException {
  48:          StringTokenizer parser = new StringTokenizer(command);
  49:          
  50:          String head = parser.nextToken();
  51:          
  52:          if (head.equals("quit") || head.equals("exit")) {
  53:              if ((JOptionPane.showConfirmDialog(null, "This will immediatly kill your current connection.  Okay?") == JOptionPane.YES_OPTION)) {
  54:                      System.exit(Integer.parseInt(parser.nextToken()));
  55:              }
  56:          }
  57:          
  58:          if (head.equals("cls") || head.equals("clear")) {
  59:              log.setText("");
  60:          }
  61:          
  62:          if (head.equals("help") || head.equals("h")) {
  63:              log.setText(log.getText() + "Understood Commands:\n" + COMMANDS + "\n");
  64:          }
  65:          
  66:          if (head.equals("what")) {
  67:              log.setText(log.getText() + "This is the Tracker command window.  Here you can see various processes and enter commands.\n");
  68:          }
  69:          
  70:          if (head.equals("echo")) {
  71:              log.setText(log.getText() + command.substring(5) + "\n");
  72:          }
  73:          
  74:          if (head.equals("exec")) {
  75:              Process p = new ProcessBuilder(command.substring(5), null).start();
  76:              p = null; //Prevent memory leaks.
  77:          }
  78:      }
  79:  }

If you strip out the vast majority of the input-processing code, what you’re left with is actually the GUI-building code:

   1:  import javax.swing.*;
   2:  import java.awt.event.*;
   3:  import java.awt.*;
   4:  import java.util.StringTokenizer;
   5:   
   6:  public class CommandWindowDialog extends JDialog implements ActionListener {
   7:   
   8:      private JTextArea log = new JTextArea(5, 40);
   9:      private JTextField prompt = new JTextField();
  10:      
  11:      ...
  12:      
  13:      public CommandWindowDialog(Tracker parent) {
  14:          super(parent, "Command Window", false);
  15:          setSize(500, 250);
  16:          
  17:          log.setText("Type <help> for a list of commands.\n\n");
  18:          log.setEditable(false);
  19:          
  20:          addComponents();
  21:          
  22:          setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  23:          setVisible(true);
  24:      }
  25:      
  26:      private void addComponents() {
  27:          Container c = getContentPane();
  28:          c.add("Center", new JScrollPane(log));
  29:          c.add("South", prompt);
  30:          
  31:          prompt.addActionListener(this);
  32:      }
  33:      
  34:      ...
  35:   
  36:  }

Although some of you may find this cumbersome, it is certainly much simpler when compared to the native Win32 API, whose code looks like this (when coded in C):

   1:  ...
   2:   
   3:  LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
   4:  {
   5:      switch(Message)
   6:      {
   7:          case WM_CREATE:
   8:          {
   9:              HMENU hMenu, hSubMenu;
  10:              HICON hIcon, hIconSm;
  11:   
  12:              hMenu = CreateMenu();
  13:   
  14:              hSubMenu = CreatePopupMenu();
  15:              AppendMenu(hSubMenu, MF_STRING, ID_FILE_ADD, "&Add File");
  16:              //hSubMenu = CreatePopupMenu();
  17:              //AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "E&xit");
  18:              AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&File");
  19:   
  20:              hSubMenu = CreatePopupMenu();
  21:              AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Go");
  22:              AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Control");
  23:   
  24:              SetMenu(hwnd, hMenu);
  25:   
  26:              hIcon = (HICON)LoadImage(NULL, "menu_two.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
  27:              if(hIcon)
  28:              {
  29:                  SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
  30:              }
  31:              else
  32:              {
  33:                  MessageBox(hwnd, "Failed to load large file icon.  It should be in same directory as program.", "Error", MB_OK | MB_ICONERROR);
  34:              }
  35:   
  36:              hIconSm = (HICON)LoadImage(NULL, "menu_two.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
  37:              if(hIconSm)
  38:              {
  39:                  SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
  40:              }
  41:              else
  42:              {
  43:                  MessageBox(hwnd, "Failed to load small file icon.  It should be in same directory as program.", "Error", MB_OK | MB_ICONERROR);
  44:              }
  45:          }
  46:          break;
  47:          case WM_COMMAND:
  48:              switch(LOWORD(wParam))
  49:              {
  50:                  case ID_FILE_EXIT:
  51:                      PostMessage(hwnd, WM_CLOSE, 0, 0);
  52:                  break;
  53:                  case ID_STUFF_GO:
  54:                      if (strcmp (szFileName,"") != 0) {
  55:                          IncinerateFiles(hwnd); }
  56:                      else {
  57:                          MessageBox(hwnd, "No file selected. Select a file using File > Add File.", "Error", MB_OK | MB_ICONERROR); }
  58:                  break;
  59:                  case ID_FILE_ADD:
  60:                      GetNameOfTarget(hwnd);
  61:                  break;
  62:                  case ID_STUFF_ABOUT:
  63:                      MessageBox(hwnd, "(c) 2011 Subversion Systems.  All rights reserved.\n\nNot responsible for any potential illegal use of program.", "About", MB_OK);
  64:                  break;
  65:              }
  66:          break;
  67:          case WM_CLOSE:
  68:              DestroyWindow(hwnd);
  69:          break;
  70:          case WM_DESTROY:
  71:              PostQuitMessage(0);
  72:          break;
  73:          default:
  74:              return DefWindowProc(hwnd, Message, wParam, lParam);
  75:      }
  76:      return 0;
  77:  }
  78:   
  79:  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  80:      LPSTR lpCmdLine, int nCmdShow)
  81:  {
  82:      WNDCLASSEX wc;
  83:      HWND hwnd;
  84:      MSG Msg;
  85:   
  86:      wc.cbSize         = sizeof(WNDCLASSEX);
  87:      wc.style         = 0;
  88:      wc.lpfnWndProc     = WndProc;
  89:      wc.cbClsExtra     = 0;
  90:      wc.cbWndExtra     = 0;
  91:      wc.hInstance     = hInstance;
  92:      wc.hIcon         = NULL;
  93:      wc.hCursor         = LoadCursor(NULL, IDC_ARROW);
  94:      wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  95:      wc.lpszMenuName  = NULL;
  96:      wc.lpszClassName = g_szClassName;
  97:      wc.hIconSm         = NULL;
  98:   
  99:      if(!RegisterClassEx(&wc))
 100:      {
 101:          MessageBox(NULL, "Window Registration Failed!", "Error!",
 102:              MB_ICONEXCLAMATION | MB_OK);
 103:          return 0;
 104:      }
 105:   
 106:      hwnd = CreateWindowEx(
 107:          WS_EX_CLIENTEDGE,
 108:          g_szClassName,
 109:          "Incinerator",
 110:          WS_OVERLAPPEDWINDOW,
 111:          CW_USEDEFAULT, CW_USEDEFAULT, 640, 480,
 112:          NULL, NULL, hInstance, NULL);
 113:   
 114:      if(hwnd == NULL)
 115:      {
 116:          MessageBox(NULL, "Window Creation Failed!", "Error!",
 117:              MB_ICONEXCLAMATION | MB_OK);
 118:          return 0;
 119:      }
 120:   
 121:      ShowWindow(hwnd, nCmdShow);
 122:      UpdateWindow(hwnd);
 123:   
 124:      while(GetMessage(&Msg, NULL, 0, 0) > 0)
 125:      {
 126:          TranslateMessage(&Msg);
 127:          DispatchMessage(&Msg);
 128:      }
 129:      return Msg.wParam;
 130:  }

Now isn't that a good old fashioned pain in the ass?  So, sure, you could use Visual C, which I hear has a drag and drop GUI builder (correct me if I’m wrong), but that requires .NET, which has dependencies and requires the system to be installed for the end user.  Java, although it requires a JVM, requires no such other dependencies, so you’re set on a new PC install.

Also, you’ll notice just code size.  The C Win32 implementation required 130 lines (the actual code is bigger due to trimming of irrelevant parts).  That’s a lot of code for a programmer to write, debug, and maintain.

So, in essence Swing is a much easier GUI creation tool in nearly every way.  If you want to full API docs, the version 7 link is here.

That’s all for tonight, folks.  You can grab our RSS feed to subscribe and always stay up to date.  Hopefully we’ll have more Java talks in the future!  Thank you, and goodnight.

-SevenBits