linux

Burning CDs/DVDs/Blu-Ray in Debian/Ubuntu

For long time I've been wondering why I can't seem to burn DVDs or Blu-Rays properly using k3b in Linux (or any other graphical burning software for that matter). The problem is cdrkit (a fork of the original cdrtools).

You can get the latest version of cdrtools, which actually supports burning to Blu-Ray and also should create DVDs properly, by installing cdrecord from this PPA. You might as well also install mkisofs from there too.

Prior to finding this PPA, I had compiled cdrtools from source, which is pretty easy. That also involved installing smake, also from the cdrtools author.

Wiping out a hard drive in Linux

To wipe a hard drive using zeros:

dd if=/dev/zero | pv -s 250000000000 | dd of=/dev/sdX bs=10M

To wipe a hard drive with random data (more secure):

dd if=/dev/urandom | pv -s 250000000000 | dd of=/dev/sdX bs=10M

For the "pv" progress bar, do "apt-get install pv" or similar. I highly recommend using "pv" so you have some idea of when the dd job is going to finish.

Tags:

Linux Mint Debian Edition: One word: FAST

I'm just trying out Linux Mint Debian Edition and the best part about it is how fast it is. The desktop is super responsive, almost feels like a new fresh Windows machine in that respect. User switching is also super fast and works perfectly, something that Ubuntu had never quite mastered. Most importantly, however, is the fact that it is not using Canonical's Unity, but instead it is still using Gnome 2.

It's been a long time since I have used an almost-pure Debian distribution but it feels good to be back. My Linux evolution went something like this: Redhat->Corel (debian)->Mandrake->Debian->Gentoo->Ubuntu->???. I will definitely move to something Debian-based or possible Gentoo. I may keep the LMDE on my laptop and put back Gentoo on my desktop. Unity is just plain awful and should never have seen the light of day. Ubuntu was great when it first started and it was basically a Debian derivative that just worked. Nowadays Ubuntu is a different beast. It's slow, awkward, cumbersome, bloated, and I can't stand the fact that they are forcing Unity down people's throats. I'm positive that Unity will be a failure in the end.

Create ISO and DVD from VIDEO_TS folder in Linux

On ubuntu systems, you'll need the following packages: genisoimage and dvd+rw-tools.

If you have a folder named "mydvd" in your home directory containing a VIDEO_TS folder, cd to your home folder mydvd, then run:

cd ~
mkisofs -dvd-video -o mydvd.iso mydvd

This will produce a mydvd.iso file. To verify, run

isoinfo -l -i mydvd.iso

At this point, you don't actually have to create a DVD. As a commenter pointed out If you have mplayer, you can play the .iso like this:

mplayer dvd:// -dvd-device mydvd.iso

Otherwise, you can mount the ISO to a mount point and play the DVD as if it were mounted from disc.

sudo mkdir -p /mnt/iso
sudo mount -o loop mydvd.iso /mnt/iso

I use totem or vlc and I can open this dvd by doing:

totem dvd:///mnt/iso
vlc dvd:///mnt/iso

To burn the ISO to a DVD:

sudo growisofs -dvd-compat -Z /dev/dvd1=mydvd.iso

You might need to change /dev/dvd1 to /dev/cdrom1 or /dev/dvd, depending on your system. Or

Tags:

NoMachine NX is awesome

Short-version:
Use NX. VNC sucks.

I love Remote Desktop for connecting to Windows machines remotely. I worked from home many times while at Kodak and if it weren't for Remote Desktop, it would have been impossible to enjoy a full-screen connection to my work desktop while at home. I didn't think there was anything for Linux besides VNC until now (I had used remote X a long time ago though, to connect to the Solaris machines at UBC). Then I discovered NoMachine NX (NoMachine is the company's name and NX is the product name). I downloaded the Free Edition for Linux and then grabbed the Windows Client (which apparently is also free?). It's ridiculously fast, as fast as Remote Desktop. Google is also working on neatx an open-source NX server implementation and there is the freenx project, a GPL-licensed implementation of the server and client components. If you are trying to connect to a Linux desktop remotely, don't even think about using any of the VNC derivatives. Use NX.

Gentoo gcc upgrade...again?

I just upgraded my mythtv backend's gcc from 3.4.6 to 4.1.2. It's still compiling all of world now and will be have been about 24 hours when it's all done. Then I did an emerge --sync and now there is a gcc 4.3! Arghh.

I've always touted gentoo's advantage of allowed me to run a mixed system. For a long time I was running an old version of mysql, and old kernel, and old glibc, and finally an old gcc. I would pull the odd update of certain packages if I felt like it. But the shear magnitude of the output when I would run emerge -uva world got on my nerves. I eventually caved and decided to go back to keeping an updated system. I had originally stopped updating most packages because I wanted my system to be as stable as possible (because it my MythTV machine and it records TV shows for me). At that time I was using it as a backend and as a frontend, but now I'm just using it as a backend which is a bit simpler (less room for breakage) and I'm a bit more careful now when doing upgrades. If any important packages are being updated I make sure to update them then reboot to make sure my system still boots. I also try not to fiddle with anything else. Anyways, in the case of my MythTV box I'm not longer taking advantage of Gentoo's biggest advantage, running system with mixed packages.

Tags:

Low Disk Space Warning Script

Have you ever experienced a full disk on a server or a desktop? Not fun. This script would normally be run as a cron job and would notify you by email if any drive's free disk space has passed below a certain threshold. The code could be better; I wrote this one a long time ago when I was a bit of a n00b and I was in a rush as well. I might make take a look at it again and see if I can make some improvements.

Topic:

init.d Script for Trac on Ubuntu Linux

I modified an nginx init.d script and created an init.d script for trac.d. I run tracd and then forward traffic from trac.davidgrant.ca to trac's port (using nginx) rather than using cgi or fast-cgi. Please let me know if you have any problems with this scripts and I will fix it.

#! /bin/sh
### BEGIN INIT INFO
# Provides:          tracd
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the tracd web server
# Description:       starts tracd using start-stop-daemon
### END INIT INFO
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/tracd
NAME=tracd
DESC=tracd
#DAEMON_OPTS="-s -r -d -p 8080 --basic-auth=*,/etc/tracd/tracusers,trac /trac"
DAEMON_OPTS="-s -d -p 8000 /home/david/trac --pidfile /var/run/$NAME.pid"
 
test -x $DAEMON || exit 0
 
# Include tracd defaults if available
if [ -f /etc/default/tracd ] ; then
        . /etc/default/tracd
fi
 
set -e
 
case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
                --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
        echo "$NAME."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --pidfile \
                /var/run/$NAME.pid
        sleep 1
        start-stop-daemon --start --quiet --pidfile \
                /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
        exit 1
        ;;
esac
 
exit 0

After you create the script at /etc/init.d/tracd, don't forget to do the following:

sudo chmod +x /etc/init.d/tracd
sudo /usr/sbin/update-rc.d -f tracd defaults

to make the script executable and to make it run on startup.

Tags:

Thumbs up to Tomato Firmware, Thumbs Down to X-Wrt

I have an old Linksys WRT-54G v3. I have ran various different firmwares over the years, but performance was never a big deal. I was mainly looking for something that allowed to me to access all of the devices features and a nicer frontend than the one that Linksys provides. At one point I was using different firmwares for QOS when we were sharing our connection with some other people in our building. Anyways, I had been using X-Wrt (white russian) for quite some time. It is basically a nice user-friendly version of OpenWrt.

Recently we purchased a Squeezebox Duet and even more recently we purchased a second Squeezebox Receiver. We finally have wirelessly-streamed music in pretty much every room of the house. We had been noticing gaps in the audio and I decided it was finally time to fix it. I discovered a diagnostics page (called "Server & Network Health", available via SqueezeCenter's Help page) and noticed that streaming rates I was getting were much lower than the 3000 kbps that I was expecting. In fact I was actually getting much lower than 1000 kps and had to change the scale of the measurement just to get a proper reading.

I decided to upgrade to Tomato firmware, which I had heard a lot of good things about. Immediately, I was getting about 3000+ kbps and the audio problems were gone. As an added bonus, we are now able to watch MythTV from a wirelessly-connected laptop, which were not able to do before (previously I had assumed that wireless streaming video was just too much for today's wireless networks to handle, or too much for MythTV to handle). I think I am going to make a donation to Tomato because it has made such a big difference for us. We can now enjoy listening to our mp3 library anywhere in the house (without gaps) and can watch recorded TV shows on our laptop.

rsync --delete is dangerous!

I hosed my entire home directory on this server last night with an incorrect rsync command. I tried syncing my svn repository to the server like this:

rsync -az -e ssh --delete /var/svn/repos/ servername:/home/username/

The problem is that I had an extra slash on the end of "/var/svn/repos/". Without the extra slash, it would create a directory called repos inside servername:/home/username and sync it with /var/svn/repos. With the slash, it syncs the contents of "/var/svn/repos" with the contents of servername:/home/username, thus causing all files in servername:/home/username to be deleted because of the --deleted command.

What I could have done instead is create a directory on the remote server called repos and then rsync like this (actually you don't need to create repos first):

rsync -az -e ssh --delete /var/svn/repos/ servername:/home/username/repos

Or I could have done this:

rsync -az -e ssh --delete /var/svn/repos servername:/home/username

The last command will create a directory called repos in servername:/home/username and it will sync it but not delete anything in servername:/home/username. Add a trailing slah to /var/svn/repos and it will!

Luckily I had a nightly backup of my entire home directory on my local server's external backup drive. I was worried because although I make these nightly backups I haven't actually inspected them in a while. Fortunately everything was intact.

Tags:

Sorry Kubuntu, I've Switched to Ubuntu

I've used Kubuntu for a long time. In fact I had never used plain Ubuntu except for once a long time ago on an old laptop but then I promptly removed it because it caused the laptop to overheat badly (it was painful on the thighs) and so I went Gentoo, my bread-and-butter distribution. I never liked Gnome for some reason. I never had good experiences with Gnome in Debian or Gentoo. KDE always seemed to work a lot better out of the box. It might be because KDE is an all-in-one solution whereas Gnome is a bit more modular and made up of metacity, gnome-panel, nautilus and a bunch of applets. I remember trying out Gnome in gentoo and metacity wouldn't start, or it would crash spontaneously. Not Gnome's fault, but it's a problem that just would never have happened in KDE.

Ubuntu has fixed all that by focusing on Gnome and ignoring all other desktop systems and window managers and making it work great out-of-the-box. Gnome is nothing like I remember it being. Kubuntu allowed me to continue using KDE, which I was used to but unfortunately I think Kubuntu has fallen behind Ubuntu. The biggest factor here is probably Ubuntu's far larger user base. More users reporting bugs and more developers eating their own dogfood. 90% of all Ubuntu tips & tricks and how-tos on the web are for Ubuntu, not Kubuntu. A few things turned me off Kubuntu in the last while:

  • Totally broken X config in KDE Control Center (mangles xorg.conf file badly, had to use nvidia-config or "dpkg-reconfigure xorg-server".
  • Documentation on the web is almost always Ubuntu-specific and relied on going to menu items that just aren't present in Kubuntu (at least not out of the box).
  • Not easy to set up Compiz on Kubuntu Gutsy (at least if you upgrade from Edgy). It's easy to set up in Ubuntu Gutsy or Hardy.
  • Bad experience with KDE 4. I tried it a few times after it was released and it felt like a piece of alpha software. Was hoping for a better experience but it was buggy and I don't think Kubuntu has the resources behind it to perfect it like Ubuntu does with Gnome.
  • Auto-mounting had been good in Kubuntu but once in a while I have problems (not able to unmount, devices spontaneously unmounting themselves, etc.... I have never had a problem in Ubuntu so far and I enjoy the fact that I don't get that annoying pop-up after I plug something in in Kubuntu or Windows.

Firefox 3.0 Memory Consumption Greatly Improved

Last time I blogged about Firefox (2.x), I was complaining about how much memory it was sucking up. I have read about how many memory leaks were supposed to have been fixed in Firefox 3 but I had to see it to believe it. So after suffering again from low memory while running VMWare and Firefox (whose memory consumption regurarly climbs to 500MB) at the same time, I decided to upgrade and leave Firefox 2.0 for good. Firefox 3.0beta5 is blazingly fast and I have yet to see it use more than 170MB of memory. Thanks to the all the Firefox developers for finally fixing what was probably the biggest problem with Firefox 2.0.

Update: I also installed it on my Linux machine at home and memory usage and performance with many tabs open is far better than Firefox 2.

Dual Boot Ubuntu and Vista on Dell Inspiron 1720

I just got a new Dell Inspiron 1720. A little background information on why we got this laptop... Previously we had one Desktop computer and a MythTV server/frontend and a TV in a separate room. The TV was a huge CRT TV, but not only that, the TV and couch took up en entire room. We recently got a 24" LCD for the desktop computer and decided that we could use that as our "TV" and computer and get rid of the TV room and use it for something else. We then found ourselves in the situation where one of us wants to watch TV and the other wants to use the computer so we definitely needed another computer. A laptop was the best idea as it allow us to use it as a MythTV frontend and watch TV from bed or any other place in the house. So in summary, we replaced a TV room, massive CRT TV and couch with a 17" widescreen laptop.

Unfortunately, the Dell Inspiron 1720 only comes with Vista. I thought about installing XP, but then I read about how I would have to get SATA drivers and slip stream them into the Windows XP CD and that Dell didn't have XP sound drivers for the 1720. In other words installing XP would be a huge PITA. Since I don't plan on using Windows that much anyways, I figure I can live with Vista. I will tweak it a bit anyways to get rid of its annoyances and I can live with the slightly worse gaming performance (which should improve over the next few years anyways, I suspect).

Here are all the steps I took to get Linux and Vista working on my Dell 1720.

Prepare for Linux:

  • Tell BIOS to boot from CD. Reconfigure BIOS to try booting from CD first so I don't have to remember to hit F12 while booting.
  • Reinstall Vista without Dell crap. I popped the Vista CD in the drive and booted to the CD. I deleted all 4 existing partitions (recovery partition, EISA partition, Windows Vista C: partition, and Dell media direct partition). I don't need the media direct and EISA junk. I then had to add the SATA driver from the Drivers and Utilities CD or else the installation would hang later on. I created one 120 GB partition for Vista.
  • Install Vista drivers. With the freshly installed Vista, all the drivers will be missing, most notably, the NVIDIA video drivers. I downloaded these from the Dell website along with a bunch of other drivers (sound driver required for microphone to work).
  • I downloaded Ubuntu 64-bit Live CD and burned it on another computer.

Installing Ubuntu: After selecting the first boot option from the Live CD it started to boot, but then the screen went completely blank (not just black but completely-turned-off-black. It turns out this is because the splash screen fails. X never did load. I pressed CTRL-ALT-F1 and then pressed Enter and the login prompt appeared (you may just see "running local boot scripts", until you press Enter. This is because the boot sequence steps run in parallel and the login prompt already started above). I then typed "startx" and X/Gnome loaded (I can't remember if it worked right away...I may have fiddled with the "Driver" setting in the "Device" section, by setting it to "nv"). I then installed Ubuntu and told the installer to automatically partition and use up all the remaining free space on the drive. When it came time to reboot, the screen went dead again on shut down and although I waited a long time, the computer never restarted and I had to power it down manually, then power up.

Fixing the "dead screen" on boot up and shutdown/reboot: Open up /boot/grub/menu.lst and remove all occurrences of the word "splash" and "quiet". Getting rid of the splash screen makes bootup a bit more interactive (rather than seeing a blank screen), but more importantly it allows the it to shut down properly.

Wireless/wi-fi: When ordering the laptop from Dell's website I chose the "Intel Corporation PRO/Wireless 3945ABG Network Connection (rev 02)" which I had heard had better Linux support (without using ndiswrapper), but wireless still did not work out-of-the-box. I changed two things at once, so I am not sure which made it work. The first thing I did was update all packages and brought in upgrades from gutsy-updates and gutsy-proposed repositories (of course you need to plug into a wired network to do that)). I installed and upgraded all linux-restricted-modules* packages. The second thing I did was to copy and paste my WEP key, rather than typing it out by end. Now wireless works great. The Network Manager applet is so easy to use.

Wireless Update: wireless seems to lock up after a while and a process called "ipw3945" uses 100% cpu. Using the laptop as a MythTV frontend requires a stable network connection so the fact that the wireless doesn't work sucks. I've tried using the MythTv Player in Vista and it does the job but it just doesn't compare to MythTV's own frontend. I have heard that the ipw3945 module that comes with Gutsy is basically deprecated and has been replaced with the iwlwifi module from Intel. The easiest way to get it is to use kernel 2.6.24 which comes from with the next release of Ubuntu, Hardy Heron (currently in Beta, to be released in a few weeks).

Sound: Sound didn't work out-of-the-box. I installed the "linux-backports-modules-generic" package from gutsy-backports and now it works. Since Ubuntu's volume control and the button on the laptop case both control the Master volume, I used "alsamixer" to increase the PCM volume to max.

Video: My screen was stuck in 800x600 mode. Running sudo dpkg-reconfigure -phigh xserver-xorg created an xorg.conf file that gave me maximum 1920x1200 resolution. The nvidia driver doesn't work though, it complains that my GeForce 8600M GT is not supported. After updated some kernel packages in previous steps, now when I enable the nvidia driver in the "Restricted Drivers Manager" it works.

DVD: I followed these instructions for DVD playback in Ubuntu.

Hardware Sensors: I ran sensors-detect and no hardware sensors were detected.

That's about it! I'll update this page with any other tips or tricks as I find them.

My Contributions to the Open Source Community

I thought it would fun to take a trip down memory lane by rediscovering all the little contributions I have made over the years to open-source projects or related things.

    Topic:

    Securing ssh

    I finally secured my ssh server after I got hacked twice. The first time was because I had a user named vmware with the password "vmware". The second time was because I had a user named test with the password "test". Yeah I know, not smart. Luckily both those users were not in the wheel group so they were fairly isolated. It looks like the just wanted my box to do port scans and cracking of other machines.

    Here are a few things to add to your /etc/ssh/sshd_config file to make it more secure (in addition to the standard defaults):

    #Change your port to something other than 22 (security by obscurity).
    Port 22
     
    #Limit which users can log on
    AllowUsers david
     
    #Not sure what this does but it is "turned on for security"
    UsePrivilegeSeparation yes
     
    #Enable key authentication
    PubkeyAuthentication yes
     
    #Fairly obvious
    PermitEmptyPasswords no
     
    #Disable passwords (force key authentication)
    PasswordAuthentication no
    ChallengeResponseAuthentication no

    A couple other things I did was to install libpam_cracklib and set a better password for myself. Secondly I installed denyhosts which dynamically adds bad behaving clients to the /etc/hosts/deny list. Beware that it will add svn-over-ssh clients to this list (because svn often makes multiple ssh logins in succession) so you'll need to add the host that you're using svn from to the /etc/hosts.allow list.

    Tags:

    Pages

    Subscribe to RSS - linux