Nerd Notes

/dev/brain: no space left on device

Archive for the ‘Linux’ Category

Apache hangs on digest secret generation

with one comment

This solved the issue. However, I couldn’t recompile apache with the urandom use flag, so I went for the randomness gathering daemon solution. On a gentoo box:

# cat /proc/sys/kernel/random/entropy_avail
# emerge -av rng-tools
# rc-update add rngd default
# /etc/init.d/rngd start
# cat /proc/sys/kernel/random/entropy_avail

Written by Mirko Caserta

April 21, 2008 at 7:30 pm

Posted in Linux

Tagged with , , , , , , ,

Backing up a vmware virtual machine

with 5 comments

I’ve learnt quite a number of new things today. One of these things is that an ISO9660 filesystem doesn’t allow files bigger than a couple of gigabytes. Another thing is that bzip2 kicks ass, even if it actually doesn’t implement the best compression algorithm available today (your milage may vary).

Another interesting thing is that the good old cdrtools package on Gentoo sucks. In my understanding that’s mainly because of licencing issues which came out during the software development. But, no worries, the new cdrkit ebuild has a modern cdrtools implementation with a compatible interface. That is, the good old mkisofs and cdrecord command lines you (and your GUIs) had learnt how to use are just the same. Different software, same interface. Great, uh? So, first of all, if you want the latest tools on a Gentoo box, you’ll need to:

# emerge -C cdrtools
# emerge -av cdrkit

Anyway, my job today was to backup on DVD-R media a large vmware virtual machine in order to regain free storage space on a server with serious shortage troubles. To begin with, we have a directory which holds the VM (virtual machine) files:

# du -sh my-very-cool-vm
21G my-very-cool-vm

Now, 21 gigabytes of data is a lot because this VM hosts a few extra virtual disks. But, if you’re lucky enough like me, some bzip2 goodness might help:

# tar cvf - my-very-cool-vm | \
bzip2 --compress --verbose --best --stdout > \
# ls -lh my-very-cool-vm.tar.bz2
total 4.3G
-rw-r--r-- 1 root root 4.3G Mar 8 15:32 my-very-cool-vm.tar.bz2

Depending on your iron, the time between tar and ls might be enough for you to gain a few extra golds in World of Warcraft. Anyway, now that might actually fit on a DVD-R. But, since there’s a 2GBytes file size limit on ISO9660 filesystems, we still need to do a little something before we can fire up mkisofs. Our old unix friend split comes to the rescue:

# split -b 1024m -d my-very-cool-vm.tar.bz2 \
# rm my-very-cool-vm.tar.bz2
# ls -lh
total 4.3G
-rw-r--r-- 1 root root 1.0G Mar 8 16:04 my-very-cool-vm.tar.bz2-part-00
-rw-r--r-- 1 root root 1.0G Mar 8 16:05 my-very-cool-vm.tar.bz2-part-01
-rw-r--r-- 1 root root 1.0G Mar 8 16:05 my-very-cool-vm.tar.bz2-part-02
-rw-r--r-- 1 root root 1.0G Mar 8 16:06 my-very-cool-vm.tar.bz2-part-03
-rw-r--r-- 1 root root 295M Mar 8 16:06 my-very-cool-vm.tar.bz2-part-04

This is just perfect. Assuming the above files are in a directory called mydir, I can now run mkisofs like this:

# mkisofs -o dvd.iso -r mydir

This creates a file which holds the ISO9660 filesystem that we can later feed to cdrecord. My peculiar incantation for cdrecord is as follows:

cdrecord -v dev=/dev/hdc driver=mmc_mdvd -sao dvd.iso

Written by Mirko Caserta

March 8, 2007 at 4:54 pm

Windows shares in /etc/fstab

leave a comment »

Ok, this is pretty much an easy one, but I keep forgetting what the heck you need to specify in your /etc/fstab in order to mount an smb share (at least on a Linux system). Here is an handy example:

//host.lan/sharename /mnt/host/sharename smbfs defaults,rw,noauto,username=scott,password=tiger,uid=myuid,gid=mygid 0 0

All of the above needs to be on one line. Of course you need to replace a few things:

hostname or ip address of the host you’re connecting to
the windows share name (pretty easy, uh?)
a local directory where the share is to be mounted (this must exist before mounting so “mkdir -p” it)
the windows share username
the windows share password
the user id the filesystem needs to be mounted as; this can be either numeric or symbolic and is usually your day-to-day user account
the group id the filesystem needs to be mounted as; this can be either numeric or symbolic and is usually your day-to-day user account’s primary group

Once you’ve added that line into /etc/fstab, you can simply:

# mount /mnt/host/sharename

Written by Mirko Caserta

March 2, 2007 at 5:19 pm

UNIX time to human readable

with one comment

The current issue of the Gentoo Weekly Newsletter has a good clue on how to easily convert a date from the standard UNIX time format (which basically is a number which represents the number of seconds elapsed since January 1, 1970 at midnight, UTC) to a human readable form. The best solution is using date -d on Linux systems such as in:

$ date -d @1161911504
Fri Oct 27 03:11:44 CEST 2006

However, on BSD derived systems, such as Mac OS X (and maybe Solaris), date -d won’t work so you have to used instead:

$ date -r 1161911504
Fri Oct 27 03:11:44 CEST 2006

Written by Mirko Caserta

November 1, 2006 at 8:10 pm

Posted in CLI, Console, Linux, UNIX