Grub2 Customizer

Linux No Comments

My previously written custom script to make Windows and Ubuntu show as the first two items in Grub no longer works after my latest install of Ubuntu 12.04. Looks like its back to using a utility to do the job.

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

Taken from:

Custom Grub Script for Dual Booting Ubuntu 9.10 and Windows XP

Linux No Comments

Most of the work I do with Ubuntu Linux is on home computers where the user needs to have Windows XP (Vista, 7) as a boot option. The best way for Ubuntu, or Linux in general, to work is if its on its own partition and not installed with the Wubi Installer. One of the main issues I have with installing Ubuntu on its own partition is that the Grub2 Boot Loader menu looks terrible and is confusing once you’ve gone through several kernels updates. I wanted a simple and easier to understand Grub2 menu and something that would take care of itself in the long run.

This script makes four entries at the top of the Grub2 boot menu.


Other boot options:

The one titled “Ubuntu” should be the same as your first Ubuntu option and most updated kernel. The “Windows” is the first option returned by “/etc/grub.d/30_os-prober”. Which should return a bootable Windows Partition. This still leaves all the original boot options underneath so you can still take advantage of selecting an older kernel or the recovery mode. It will also include any Windows Recovery partitions as well towards the very bottom.

Disclaimer: I have no idea what this will actually do out in the wild. I surely can’t account for every scenario but I’ve done MY best and tested with a couple of systems with success!

Note: Do not use this if you are doing more than just dual booting Ubuntu and Windows!

Here is what my partition tables look like on the computer I tested with today. The script worked perfectly on it. As well as another Windows 7 machine I tested on.

/etc/grub.d/05_custom :


awk '/BEGIN\ \/etc\/grub\.d\/10_linux/,/END\ \/etc\/grub\.d\/10_linux/' /boot/grub/grub.cfg > /tmp/grub1.tmp
LINE1=`grep menuentry /tmp/grub1.tmp -n | cut -f1 -d: | head -n1`
LINE2=`grep } /tmp/grub1.tmp -x -n | cut -f1 -d: | head -n1`
echo 'menuentry "Ubuntu" {'
sed -n "${LINE1},${LINE2}p" /tmp/grub1.tmp | sed -n "2,${LINE2}p"

#check for NTFS partitions!
#This also means this script is only for XP, Vista, or Win 7. (Not tested with Vista and Win7 yet!)
chkntfs=`sfdisk -l 2> /dev/null | grep NTFS -n | cut -f1 -d:`

if [ -n "$chkntfs" ]; then 
#grub-mkconfig 2> /dev/null | awk '/BEGIN\ \/etc\/grub\.d\/30_os-prober/,/END\ \/etc\/grub\.d\/30_os-prober/' > /tmp/grub2.tmp
awk '/BEGIN\ \/etc\/grub\.d\/30_os-prober/,/END\ \/etc\/grub\.d\/30_os-prober/' /boot/grub/grub.cfg > /tmp/grub2.tmp
LINE1=`grep menuentry /tmp/grub2.tmp -n | cut -f1 -d: | head -n1`
LINE2=`grep } /tmp/grub2.tmp -x -n | cut -f1 -d: | head -n1`
echo 'menuentry "Windows" {'
sed -n "${LINE1},${LINE2}p" /tmp/grub2.tmp | sed -n "2,${LINE2}p"
echo "There were no NTFS partitions found!" >&2

#entries must point somewhere or they don't show up.
#might as well be the partition that houses our kernel. 
#also, when its selected it just shows the menu again.
#which makes it a nice dummy file.

echo "menuentry \\" \\" {"
echo "	insmod ext2"
echo `cat /tmp/grub1.tmp | grep "set root" | head -n1`
echo "}"

echo "menuentry \\"Other boot options:\\" {"
echo "	insmod ext2"
echo `cat /tmp/grub1.tmp | grep "set root" | head -n1`
echo "}"

To create the file and mark it executable… Open Terminal (Applications > Accessories > Terminal)

sudo gedit /etc/grub.d/05_custom
sudo chmod +x /etc/grub.d/05_custom
sudo update-grub

End result:

At this point you could make Windows default by editing /etc/default/grub and chaning the line:


I welcome any and all suggestions on how to improve this script. I make no claim to be very good at BASH scripting but I needed this and couldn’t find any other solutions!

Basic GUI for Ubuntu Server

Linux No Comments

Lots of people frequently need a GUI for their servers. I like to use mine without a GUI but even I have found many instances where one would be incredibly useful.

You can install the full Ubuntu desktop by installing ubuntu-desktop however, if you just want the basic plain Gnome desktop then consider running this…

sudo apt-get install xorg gnome-core gdm ubuntu-gdm-themes

Note: After you start Gnome it will display an error about fast user switching applet. Just tell it to delete the applet. You won’t be shown the error again.

For good measure I also installed firefox and synaptic.

sudo apt-get install firefox synaptic


SSH Proxy

Linux No Comments

I was unaware until today about the SOCKS proxy in SSH.

Using yesterdays example… make the connection with the added -D and a custom port number.

ssh -p 22 -D 1456

Then in Firefox Preferences, Advanced, Network, Settings. Select Manual Proxy Configuration. In the SOCKS HOST type “localhost” and in the PORT type the number you chose earlier, for this example I chose 1456.


Notice at the bottom I added to the “No Proxy for:” section. is my local subnet. If you don’t exclude your local subnet you can’t access any web traffic on your local LAN.

SSH Tunneling

Linux No Comments

I use Putty nearly every day at work to remote from a Windows boxes to remote manage my Linux Servers. Although there is a Putty client for Linux, and available in the Ubuntu repos, it doesn’t work the same nor does the tunneling work. I basically have to work from the command line in order to do ssh tunneling. I haven’t found another good GUI yet, although I’m sure it exists.

ssh [user]@[ipaddress] -p [port#] -L [localport]:[host]:[remoteport]

So for example this would connect me to remote host and redirect my local port 1443 to the remote port 443.

ssh -p 22 -L 1443:localhost:443

At this point I could simply point my web browser to http://localhost:1443 and it would tunnel my traffic to Simple and works. I do hope to find a GUI soon though.

VirtualBox 2.1

Linux, MySQL, Virtualization, Web, Windows No Comments

Although I have been a huge fan of VMWare Server I’m not apposed to alternatives. I’ve tried VirtualBox in the past with very little luck due to the Host Networking issues. However, it appears in the latest 2.1 version they have greatly improved on the networking. When I found out the new version had been released I was quick to download the pre-compiled version, which falls under the VirtualBox Personal Use and Evaluation License (PUEL). The license doesn’t matter to me because I mainly use it just for testing and at the School which is completely under the PUEL.

Host Networking worked without a hitch on a Windows XP Professional SP3 host as well as my Ubuntu Intrepid Ibex 8.10 setups. I think this product has finally, truely, entered the game! I’m sure it will still take some time for the Open Source Edition to enter the Repos for Ubuntu. But I expect to see great things from this.

Ubuntu Startup Services

Linux, Web No Comments

I have a server that sits at a desk all by itself, not running anything terribly important, and frequently I found myself needing to have a workstation there. Since Ubuntu Server doesn’t come with a GUI I went ahead and installed it via…

apt-get install ubuntu-desktop

However, I didn’t want the GUI to startup everytime the server came up. I only wanted it running if I needed it. I already knew I could do…

sudo /etc/init.d/gdm stop

but I wanted a way to stop it from starting. Of course I already know about the rc.d directories and I could manually go in and delete it from there but here are a couple of tools that apparently work on Ubuntu/Debian based distros.

To remove a service from startup:
     update-rc.d -f gdm remove

To add a service to startup:
     update-rc.d -f gdm defaults


IPCop, Linux, VPN, Web 7 Comments

The Zerina (OpenVPN) addon for IPCop is an excellent VPN addon.  One thing it does for simplicity is the keys are compiled into a pkcs12 (*.P12) file, which contains the Certificate Authority, the Certificate, and the Key for authentication.  Which is great if you are wanting to drop it directly into OpenVPN GUI for Windows.  Its an easy setup.  However, I’ve been working on making my switch to Ubuntu Linux and the only way to use the P12 files is at the command line.  I needed an easier way to connect to the VPN’s so in comes network-manager-openvpn.

apt-get install network-manager-openvpn

After you install the openvpn addon for Network Manager you can click on the Network Manager icon on your task tray and select “VPN Connections” > “Configure VPN” where you can add your VPN connection.  The problem is that this does not [yet] support pkcs12 (*.P12) files. In comes openssl, You have to extract the p12 file into PEM format.

To extract the CA Certificate:
     openssl pkcs12 -in myvpn.p12 -cacerts -nokeys -out myvpnca.pem

To extract the Personal Certificate:
     openssl pkcs12 -in myvpn.p12 -clcerts -nokeys -out myvpncert.pem

To extract the Private Key:
     With a password: openssl pkcs12 -in mydccert.p12 -clcerts -nocerts -out myvpnkey.pem
     Without a password: openssl pkcs12 -in mydccert.p12 -clcerts -nocerts -nodes -out myvpnkey.pem

At this point we now have the three files required to setup our VPN connection in Network Manager. (see screenshot below)
Click on Add.
Select OpenVPN as the connection type and click Create.
Give you connection a name.
The gateway is the FQDN or IP address of your OpenVPN server.
Type is Certificates (TLS)
The user certficate is the myvpncert.pem file from earlier
The CA Certificate is the myvpnca.pem file from earlier
The Private Key is the myvpnkey.pem file from earlier, you may have to type in your password if you chose to have one.

I did not have to change any other settings for this to be able to work. Enjoy!

Linux Wireless (ndiswrapper)

Linux No Comments

I just had a Ubuntu install with an older Linksys Wireless card.  Long story short I tried the ndswrapper from command line to install the driver without luck. I usually like to try and figure these things out however I didn’t have much time to play this time.  Thats when I discovered ndisgtk.

sudo apt-get install ndisgtk

That will install ndiswrapper and a GUI. Found it to be much quicker.

note: I don’t recall looking for it on the menu’s. I always just hit Alt+F2 and type ndisgtk.

Backing up IPCop

IPCop, Linux No Comments

I recently replaced my IPCop firewall computer and had a perfect chance to test my backups. I like to customize my IPCop install so I have the Advanced Proxy, URL Filter, Update Accelerator, Block out Traffic, ntop, Zerina (OpenVPN), Firewall Logs (Pie Charts for Firewall Information), Guardian, and sometimes CopFilter addons installed. The backup feature that comes with the IPCop doesn’t include all the addons when you create a backup. So I wrote me a little script, scheduled it once a week, and have it rsync’d to a backup server.

I always keep downloaded addons in /root/Addons. Always! That way I know what version was installed and its included in the backup so when I restore I reinstall the same version for the config files stored in /var/ipcop.


echo Starting backup process...

if [ -f /root/backup.tar.gz ]
        rm /root/backup.tar.gz

# This should grab all settings. Addons will need to be reinstalled.
tar zcvf /root/backup.tar.gz \
/var/ipcop \
/root/Addons \
/root/ \
/var/log/rrd \
/var/log/logwatch \
--absolute-names \
--exclude /var/ipcop/ethernet/settings

rsync -vu /root/backup.tar.gz "[IP.OF.BACKUP.SERVER]::IPCOP/" --progress &

# Notes
# Be sure to add the backup script to the new systems crontab
# fcrontab -e
# Add "0 1 * * 6 /root/"

When I went to replace my box I reinstalled IPCop 1.4.20 on it. I setup my networking just as I had before. I specifically exclude the /var/ipcop/ethernet/settings file because it also tells the system what network card to use. Since this is a new box with different network cards I don’t want any confusion. I then transfer, usually using WinSCP, the backup.tar.gz to the new system from the backup server. I always keep the file in /root. You will need to turn on SSH access from the IPCop GUI to remote into the system to extract the backup and install the addons.

At this point I reinstall all the addons from the /root/Addon folder. Each having their own instructions, refer to the documentation for each addon. Another post perhaps?

Restore the backup:

tar zxvf /root/backup.tar.gz -C /

Restart the system and you should be up and running.

« Previous Entries