Brain Dump

A place to store my random thoughts and anything else I might find useful.

How-to: mount an uncompressed g4l image

Posted by mzanfardino on April 9, 2010

Occasionally it becomes necessary to mount an uncompressed g4l image (created with g4l explicitly with compression none). This is a simple process that can be accomplished with just a few commands. Firstly you must determine what the offset of the partition within the image you wish to mount. This is done using parted. Once you have the offset of the partition use mount to mount the partition, giving mount the offset discovered by parted.

This example assumes a file named: SMCCAPCON_HMBN_20100106.img

$ parted /home/ftp/img/SMCCAPCON_HMBN_20100106.img unit B print
WARNING: You are not superuser. Watch out for permissions.
Warning: Unable to open /home/ftp/img/SMCCAPCON_HMBN_20100106.img read-write
(Permission denied). /home/ftp/img/SMCCAPCON_HMBN_20100106.img has been opened
read-only.
Warning: Unable to open /home/ftp/img/SMCCAPCON_HMBN_20100106.img read-write
(Permission denied). /home/ftp/img/SMCCAPCON_HMBN_20100106.img has been opened
read-only.
Model: (file)
Disk /home/ftp/img/SMCCAPCON_HMBN_20100106.img: 4098834432B
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 32256B 3857656319B 3857624064B primary ext3 boot
2 3857656320B 4096189439B 238533120B extended
5 3857688576B 4096189439B 238500864B logical linux-swap

Note that this image contains an entire disk image which has been formatted with a primary partition (#1) which contains root and an extended partition (#5) which contains the swap file.

The next step is to mount the root partition as a loop-back device to a local path. For this example create a mount point at /tmp/mnt (this mount point can of course be anywhere on your file system). Since the image contains both a root partition and the swap partition, it’s critical to use the offset of the root partition as a parameter for the mount command. The offset for root in this example is 32256B.

$ mkdir /tmp/mnt
$ sudo mount -o loop,offset=32256B /home/ftp/img/SMCCAPCON_HMBN_20100106.img /tmp/mnt
The partition is now mounted on /tmp/mnt. To unmount the partition, simply use umount as usual.
$ umount /tmp/mnt

NOTE: If it happens that the image is compressed using lzop, simply uncompress the image first, then take the same actions above. To uncompress a lzop file, use lzop.

$ lzop -x SMCCAPCON_HMBN_20100106.lzo
The resulting file for this example will be SMCCAPCON_HMBN_20100106, not SMCCAPCON_HMBN_20100106.img.
To verify the file type, use the file command.
$ file SMCCAPCON_HMBN_20100106.lzo
SMC_CAPCON_PLM_2010-01-21.lzo: lzop compressed data - version 1.020, LZO1X-1, os: Unix

$ file SMCCAPCON_HMBN_20100106
SMC_CAPCON_PLM_2010-01-21: x86 boot sector; partition 1: ID=0x83, active, starthead 1, startsector 63, 7534422 sectors; partition 2: ID=0x5, starthead 0,
startsector 7534485, 337365 sectors

NOTE: There maybe a need to resize the partitions of an image file. It is possible to resize the partitions using gparted. gparted can be called with the image file as a parameter. However, in my case gparted was unable to resize my partition (could not find the device to resize). I tried mounting the partition to /dev/loop0 using:

$ sudo losetup /dev/loo0 my.img

This succeeded in mounting the image to /dev/loop0 but again gparted could not find the individual partitions to mount (/dev/loop0p1 in my case). This left me to attempt to use ‘parted’. Another road-block, as my partition is ext4 and parted does not support ext4 (at least, the version I’m running).

parted suggested I use resize2fs but again, no individual partition to resize! This is becoming a tricky process.

So what did I need? I needed access to the individual partitions inside the image as accessible devices. Specifically, using the tool ‘kpartx’ I was able to mount each partition in the image to a device mapper such as /dev/mapper/loop0p1. Now I could use ‘resize2fs’ to resize /dev/mapper/loop0p1!

Advertisements

Posted in Uncategorized | 1 Comment »

Unofficial feature for obsolete version of GRUB

Posted by mzanfardino on December 18, 2009

Recently I had been asked to ‘brand’ the GRUB menu for my company’s servers. The company has made the decision to deploy Ubuntu Long Term Support server software. And though we maintain current with security patches, we do not wish to radically alter the distribution that Canonical has release under its LTS program.

As such, we have a number of server running Ubuntu 8.04 LTS and 9.04 LTS. Canonical has seen fit to distribute these distribution with GRUB 0.97. And though GRUB2 is available, it has been decided by the company not to install GRUB2 at this time.

This, coupled with a recent change in the look of the company colors, has cause a problem with ‘branding’ the GRUB menu. It seems that GRUB 0.97 does not support the COLOR attribute if the SPLASHIMAGE attribute is in use. The result of which left me with an untenable problem: when I load the new company SPLASHIMAGE which is red lettering on a white background, I was unable to change the color of the text, which is also white by default (thankfully with black shading, so it’s at least visible).

While researching this issue, I came across bug #16190 filed with the GRUB project (https://savannah.gnu.org/bugs/?16190). In it, a helpful user (adrian15) wrote:

Non-standard grub such as the one from Ubuntu is not supported officially by Grub.

However I am going to help you. The color command when having a background image does not work as you have seen.

Use the following commands instead:

background RRGGBB
foreground RRGGBB
adrian15

I followed adrian15’s suggestion, knowing full-well that this is not an officially supported feature of GRUB. My first attempts failed to yield any results. No matter what color combination I defined it was not reflected in the GRUB menu. I continued to explore this option though, as I was certain that had adrian15 been wrong it would have been noted in the bug.

I found while editing the menu interactively I could in fact set the foreground and background colors to values of my choosing. I concluded then that it must be the order in which these settings appeared in /boot/grub/menu.lst that was the problem. Sure enough, by moving the foreground and background setting after the SPLASHIMAGE setting I was able to achieve my desired results!

In summery, if you are using GRUB 0.97 (I don’t care why) and you have need to customize your GRUB menu with a splash image of your own design and you want to change the color of the text, you can do so with the unofficial settings: FOREGROUND and BACKGROUND. Just remember that you must first specify the SPLASHIMAGE, otherwise the color choice will not appear to take effect.

ex:
...
splashimage=(hd0,0)/boot/grub/images/my_splash_image.xpm.gz
foreground ff0000
background 000000
...

This example will set the foreground color of the text to red and the background color of the text to black.

I have added a comment to the now-closed bug entry so that others may benefit. I must stress however that this is an unofficially feature of an obsolete version of GRUB! Do *NOT* expect to get support from the GRUB team or me if this does not work for you!

Posted in Uncategorized | Leave a Comment »

Replacing default desktop manager with qingy on Ubuntu intrepid

Posted by mzanfardino on January 30, 2009

I often find that I want to login to a text console as opposed to my GUI. I use Ubuntu 8.10 (intrepid ibex) with gnome which uses gdm desktop manager by default. I’ve found in the past while working with gentoo that I can replace the GUI login provided by kdm, gdm, etc. with qingy which uses framebuffer video support to provide a nice splash screen without the overhead of a full-blown GUI.

With the introduction of upstart as a replacement for inittab in ubuntu there are different steps to making qingy work and the qingy (and other) sites suggest. First, install qingy (this part hasn’t changed!). I installed from repos, but you can download and install from the qingy home page (http://qingy.sourceforge.net/). the repos will place the quingy binary in /usr/sbin. Next, edit /etc/event.d/tty1. Comment out the statement # exec /sbin/getty 38400 tty1 and add a new statement exec /usr/sbin/qingy tty1. This will alter tty1 from loading getty to qingy. NOTE: Many how-to’s suggest replacing getty with qingy for all but one tty. I do not feel this is necessary, as I’m merely using qingy as a replacement for gdm and I only need one instance of this.

Next, disable your desktop manager. I’ve stated that I use gdm so if you are using kde or xdm (or something else entirely) you may have to figure out the best way to do this. The easiest way to disable gdm is by using bum (boot-up manager GUI). This will likely have to be installed using your favorite installation method. I use sudo aptitude install bum from the command line. Once running, locate GNOME Display Manager and un-check it. If you click apply the GUI session will end! You have been warned!

At this point you should be able to boot your machine and find that you have a nifty splash screen with options to start different sessions, among them will be text-console.

Note: you will likely want to change some of the default configuration for qingy. For instance, by default qingy will launch your GUI session in the open tty (tty1 in this case). If, like me, you are used to seeing the GUI on tt7, you have to change /etc/qingy/settings x_server_tty = unused_tty. There are many other settings that can be adjusted in the setting files as well.

Also, you can find a nice selection of themes for qingy on freshmeat (http://themes.freshmeat.net)

*** HEADS UP ***
Now, this is where things got a little frustrating for me. When I logged into a gnome session, I discovered that my audio was not initializing. I could not playback audio or work with audio in any way. I did not get any specific errors: dmesg, /var/log/syslog and /var/log/messages did not reveal any obvious errors. I tested audio from a text-console and found that I could playback mp3 files using mpg321 or ximp3 (both console based mp3 players), but only if I run these apps as sudo.

This gave me the vital clue that helped to solve the problem with gnome. It turns out that my user account was not a member of the audio group that is installed when ubuntu was installed. It’s apparently not necessary when you use gdm as your desktop manager. By adding my user to the audio group I was able to playback audio from text-console without the need of sudo *and* when I logged into my gnome session audio was working!

In addition to audio not working, nm-applet (the panel NetworkManager icon control) is also not working.  This item took a little more effort to resolve, as it’s not a simple matter of adding a user account to a group.  The way I resolved this might not be the correct method, so please do your own research! However, I found that if I modified a number of files in /etc/dbus-1/system.d/ I could make it work.  Specifically I modified the following files:

  1. /etc/dbus-1/system.d/ConsoleKit.conf
  2. /etc/dbus-1/system.d/NetworkManager.conf
  3. /etc/dbus-1/system.d/nm-applet.conf
  4. /etc/dbus-1/system.d/nm-avahi-autoipd.conf
  5. /etc/dbus-1/system.d/ nm-dhcp-client.conf
  6. /etv/dbus-1/system.d/nm-dispatcher.conf
  7. /etc/dbus-1/system.d/ nm-system-settings.conf

For each of these files I copied the policy user section “root” and changed the user to my user account.

TO REPEAT: This may *not* be the correct way to do this, but in the end it worked.

Another issue I had was with the use of encfs which I used for directory encryption. I found that until I added my user account to the fuse group I was unable to mount my encrypted directories.

I suspect that there are other issues as well with this approach.

If you have any suggestions or comments regarding this method vs. some other method, please post here or provide a link to the suggestion.

Posted in linux, ubuntu | Tagged: , , , , , , , | 7 Comments »

Redirecting tomcat ROOT

Posted by mzanfardino on November 7, 2008

The goal is to force tomcat to redirect the default root homepage to another page altogether. With Apache2 it’s a simple matter of adding some code to apache2.conf

Redirect /index.html http://$server/$path/index.html

Where $server and $path represent the server and path to redirect.

This does not appear to be the case with Tomcat, or if it is, I can’t seem to find the right file to update in order to make this change. However, I did find a really good tip from another on how to override the default home page (source sited below).

Essentially when Tomcat is installed it’s configured to look for index.html, index.htm, and index.jsp in $TOMCAT_HOME/webapps/ROOT. (which for my system is /usr/local/tomcat/webapps/ROOT). The index.jsp file located there is the administrator welcome page that is displayed by default. Simply creating an index.html page will override the jsp as the html is loaded before the jsp according to the configuration file located in $TOMCAT_HOME/conf/web.xml. The files and their order is defined in <welcome-file-list>.

The index.html needs to be quite simple and should look as follows:

<html>
  <head>
    <meta http-equiv="refresh" content="0;URL=http[s]://$server/$path/index.html">
  </head>
  <body>
  </body>
</html>

This to me does not appear to be the ideal solution, as it forces the server to perform another round trip, which is inefficient particularly if you are redirecting to the same server but to a different application. However, until I can find a more proper solution such as the apache2 solution, this will have to be what I use.

Source: Tomcat Wiki

Posted in tomcat, webserrvices | Tagged: , , | 3 Comments »

Installing gentoo with root encryption: notes

Posted by mzanfardino on October 23, 2008

Note: This is compiled from several sources (which I will site at the end) and my own experience. This example assumes the following partition table:

/dev/sda1 /boot
/dev/sda2 swap
/dev/sda3 /
  • Follow Gentoo Handbook through 4.d. FUTURE: Add notes regarding flushing drive with /dev/urandom before encrypting.
  • Be sure to emerge cryptsetup. (NOTE: this should not be necessary as gentoo 2008.0 includes luks support).
  • Load necessary modules:
    modprobe dm-crypt # required
    modprobe dm-mod # required
    modprobe serpent # optional
    modprobe blowfish # optional
    modprobe aes # optional but required for aes-cbc-essiv
  • Encrypt the swap partition and mount it. NOTE: Encytping with random passkey – does not require passkey to mount:
    cryptsetup -c aes-cbc-essiv:sha256 -d /dev/urandom create swap /dev/sda2
    mkswap /dev/mapper/swap
    swapon /dev/mapper/swap
  • Encrypt the root partition. NOTE: This example assumes a keyword/passphrase. FUTURE: Add examples for keyfile encryption:
    cryptsetup -y --cipher serpent-cbc-essiv:sha256 --key-size 256 luksFormat /dev/sda3
  • Open newly encrypted partition:
    cryptsetup openLuks /dev/sda3 root
  • Create the file system on the logical root. This example assumes ext3. FUTURE: Add notes concerning the user of alternate file system:
    mke2fs -j -m 1 -O dir_index,filetype,sparse_super /dev/mapper/root -L root
  • Create the file system for /boot. This example assumes ext2 (as you needn’t journal a boot partition). FUTURE: Add notes concerning the use of alternate file system:
    mke2fs /dev/sda1 -L boot
  • Mount the file system for use during the remainder of install:
    mount /dev/mapper/root /mnt/gentoo
  • Return to the Gentoo Handbook from step 5 to 7.d (genkernel)
  • Build the kernel with genkernel
    cd /usr/src/linux
    genkernel --luks --menuconfig all

    The key here is that you configure your kernel for ramdisk support and luks support FUTURE: add details.
  • Continue with Gentoo Handbook from 7.e till 8.a
  • Modify /etc/fstab to mount root from /dev/mapper/root. fstab will look as follows:
    /dev/sda1 /boot ext2 defaults,noatime 1 2
    /dev/mapper/swap none swap sw 0 0
    /dev/mapper/root / ext3 noatime 0 1
  • Modify /etc/conf.d/dmcrypt to mount swap during boot:
    swap=swap
    source='/dev/sda2'
  • Continue with Gentoo Handbook from 8.b till 10.b.
  • Configure GRUB to use genkernel:
    title Gentoo Linux 2.6.25-r8 (genkernel)
    root (hd0,0)
    kernel /boot/kernel-genkernel-x86-2.6.25-gentoo-r8 root=/dev/ram0 init=/linuxrc ramdisk=8192 crypt_root=/dev/sda3 vga=791
    initrd /boot/initramfs-genkernel-x86-2.6.25-gentoo-r8

    NOTE:kernel name may be different,be sure to use the correct initramfs and kernel.

Unbelievably that’s it! After days and days of trying to create my own initramfs and writing my own linuxrc files it really comes down to passing using genkernel to build the kernel and initramfs with luks support by passing genkernel –luks! (well, and the rest).

More to come later.

Citation:
http://gentoo-wiki.com/SECURITY_System_Encryption_DM-Crypt_with_LUKS#Preparing_the_disk
http://gentoo-wiki.com/SECURITY_Encrypting_Root_Filesystem_with_DM-Crypt_with_LUKS#Using_initramfs_and_busybox
http://gentoo-wiki.com/SECURITY_Encrypting_Root_Filesystem_with_DM-Crypt
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=1

Here is a handy one for when you have to chroot into your system because you omitted something and it doesn’t boot: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=6

Posted in gentoo, linux | Tagged: , , , | 2 Comments »

Access MySQL with mysql-query-browser over ssh tunnel

Posted by mzanfardino on October 23, 2008

Problem:
Your mysql database lives on a server that has all but a handful of ports blocked. Specifically you can’t use mysql-query-broswer to connect directly as port 3306 is blocked.

Solution:
Tunnel traffic through an ssh connection and forward the traffic from some other port (assuming you have mysql running on your localhost on port 3306) to port 3306.

How?

Simple: Open a new shell and create the tunnel on the local machine to the remote server as follows:

ssh -L $localport:127.0.0.1:3306 -l $remoteuserid $remoteserveraddress

  • $localport can be any available port, include 3306, but only if mysql is *not* running on the local machine.
  • $remoteuserid is the user id used to connect to the remote server.
  • $remoteserveraddress is the address of the remote server.

Once the tunnel is established, leave the shell open. You might get timed out depending on your server configuration, so you might need to have some application running on the remote server to maintain the connection.

Now launch mysql-query-browser, set the Server Hostname to 127.0.0.1 and the port to $localport. That’s it!

Posted in linux | Tagged: , , , , | 1 Comment »

Linux: How to tunnel X over ssh through an intermediate host

Posted by mzanfardino on September 23, 2008

There have been times when I’ve needed to have access to some X application on a remote desktop that I could not access directly. However, I did have access to another machine on the same network via ssh. For instance, at work there is a server that is exposed to the outside world that I can access via ssh. Once connected, I can further ssh to my desktop which is not directly available to the outside. NOTE: Now that we have a properly configured VPN, this processes is not as much in demand.

Here is the general form I use when I want to use ssh tunneling to tunnel X through the intermediate server to the outside world (say from home) to access my work desktop:

General Form:

ssh -f $intermediate_host -L $local_port:$destination_host:$source_port sleep 5; ssh -X localhost -p $destination_port

So, say the public facing host ($intermediate_host) has IP address of 192.168.1.100 (this address could not be public, of course, as 192.168.x.x are non-routeable addresses). Let’s further assume that the internal address of the desktop workstation ($destination_host) is 10.10.10.100 (this address is also a non-routeable address and would not be visible to the outside world). Since we are going to tunnel X over ssh, we are going to want to actually tunnel ssh over a port other than the standard ssh port (22). The local port ($local_port) can be any unused port, so for this example I will choose 9999. The source post ($source_port) will be 22 as this is the port ssh uses. With this information I can rewrite the general form as:

ssh -f 192.168.1.100 -L 9999:10.10.10.100:22 sleep 5; ssh -X localhost -p 9999

The first parameter (-f) requests ssh to go to background just before command execution. This is done because we expect ssh to prompt for a password when connecting to the remote machine (see man ssh).

The second parameter (-L) specifies that the given port ($local_port) on the local host is to be forwarded to the given host and port ($destination_server:$source_port) on the remote machine. Therefore ‘-L 9999:10.10.10.100:22’ tells ssh to map local host port 9999 to port 22 on remote host 10.10.10.100.

We have to issue some sort of command when tunneling, so we use ‘sleep 5’. The could be something else, but ‘sleep 5’ will suspend execution of the calling thread for 5 second (see man sleep) which is sufficient to create the tunnel.

The command following the semicolon (;) must be appended to the original command and should not be broken into a separate step. Once the tunnel to the intermediate host ($intermediate_host) is established ‘ssh -X localhost -p 9999’ will be executed. This is the command that forwards X to the host over ssh through the tunnel. The ‘localhost -p 9999’ statement configures ssh to open a localhost connection at port 9999 ($local_port) which is being tunneled to the destination host ($destination_host) which for this example is 10.10.10.100 at port 22.

Pretty simple. When you first issue the command you will be required to provide passwords for both the intermediate host ($intermediate_host) and destination host ($destination_host). NOTE: this example assumes that you are logging into both hosts withe the same user name. If this is not the case, simple append ‘$intermediate_host_username@’ and/or ‘$destination_host_username@’ to each of the servers as appropriate:

General Form:

ssh -f $intermediate_host_username@$intermediate_host -L $local_port:$destination_host_username@$destination_host:$source_port sleep 5; ssh -X localhost -p $destination_port

Example 1:

ssh -f foo@192.168.10.100 -L 9999:bar@10.10.10.100:22 sleep 5; ssh -X localhost -p 9999

That’s it! You now have X tunneling through an intermediate host, thereby providing you with a pseudo-vnc connection. Of course, this all assumes that you have X running on your local machine as well. Now, given the general forms above, it shouldn’t be much of a stretch to write a fairly simple (and complete) bash script to automate this task. I’ll leave that exercise for another time.

Example 2:

Recently I had a need to tunnel through an intermediate host to access a remote customer server. The network admin has restricted access for ssh from specific IP addresses. The intermediate host originates from a qualifying address, hence tunneling through this host. To further complicate matters, I needed to port-forward port 902 in order to use vmware-server-console to perform maintenance on a crashed virtual machine. I will not debate the merits of maintaining a server running VMWare Server 1.0.10 with an up-time in excess of 1090 days (as of this writing)!

The following command is used to access the remote server through an intermediate host while port-forwarding port 902:

$ ssh -f intermediate_user@intermediate_host -L 9999:destination_host:22 sleep 5; sudo ssh -L 902:localhost:902 destination_user@localhost -p 9999

Note the use of “sudo” when establishing the port-forwarding. Root authority is required to port-forward any port <1024, so your intermediate user must have the authority to elevate rights to root via sudo. Alternatively you could configure the intermediate server to permit root user access from remote thereby eliminating this requirement, however it’s never a good idea to open ssh to root access!

Posted in linux | Tagged: , , , , | 1 Comment »

Linux: How to kill and logout users

Posted by mzanfardino on September 23, 2008

Task: How to halt/stop a user

# skill -STOP -u <user>

You muse be root to stop other users. For debian/ubuntu you should precede this command with sudo.

Task: How to resume already halted user

# skill -CONT -u <user>

Task: How to kill and logout user

# skill -KILL -u <userid>

Task: Kill and logout all users

The ultimate command to kill and logout all users:
# skill -KILL -v /dev/pts/*

Posted in linux, ubuntu | Tagged: , , | 1 Comment »

Creating a playable DVD from multiple video files

Posted by mzanfardino on September 19, 2008

Like many folks, I have from time to time wanted to burn a DVD of some video files so that I can watch them on my TV. This seems like a no-brainer, but as with so many no-brainers it does take a little bit of work. I will first summarize the tasks at hand, then work though a step-by-step example. Please note, this worked for me but is no guarantee that it will work for you (your mileage may vary).

In general, a DVD is made up of a number of files located in two directories: VIDEO_TS and AUDIO_TS. By and large it’s the VIDEO_TS directory that will hold all the necessary files. Specifically there are three types of files found: *.BUP, *.IFO and *.VOB. So, the ultimate goal will to create these files and directories from the source video in order to burn a DVD that can be played in a stand alone player.

The process starts with a video file. If it’s not already an .AVI or .MPG file it should be converted to .AVI. This can be done using mencoder (instructions to follow). Once you have an AVI file, use ffmpeg to convert it to an .MPG file (again, instructions to follow). The next step is to create the DVD file structure. This can be done with dvdauthor. However in order to add multiple videos and create separation it will be necessary to first create an .XML file (structure to follow) that will be used by dvdauthor when creating the DVD file structure. Once the file structure is in place the dvd can be burned either directly or after converting it to an .ISO file. I will discuss the merits of both at the end.

The applications required to perform this little bit of video transcoding magic are:

  1. mencoder
  2. ffmpeg
  3. dvdauthor
  4. mkisofs
  5. growisofs

For the first step (converting a video file to .AVI) it will be necessary to use mencoder. The following command will generate a log file which will be used by the next command to convert the file to an .AVI

mencoder <inputfile> -ovc xvid -xvidencopts pass=1 -oac mp3lame -lameopts vbr=3 -o /dev/null

Now use mencoder to create the .AVI:

mencoder <inputfile> -ovc xvid -xvidencopts pass=2:bitrate=1000 -oac mp3lame -lameopts vbr=3 -o <avifile>

Now the newly create .AVI file needs to be converted to an .MPG file. This is done with ffmpeg. This is also the time to add parameters that will convert to specific formats (NTSC or PAL) and aspect ratio (4:3 or 16:9). Since I’m in the US I will be formatting to NTSC and since I plan to watch this on my SD TV I will use 4:3 aspect ratio in this example.

ffmpeg -i <avifile> -target ntsc-dvd -aspect 4:3 <mpgfile>

NOTE: If the ffmpeg reports an error with the ntsc-dvd parameter, install transcode.

Before moving to the next step repeat the preceding steps for each of the video files that will be burned to the DVD. Once all the files have been converted to .MPG an XML file will be required n order to append multiple files to a single DVD. NOTE: this will not create a menu, but it will permit the use of next and back with the stand alone DVD player to select between videos. I will write up more about creating menus in a separate blog (once I figure it out!).

The XML file will looks something like this:

<dvdauthor>
<vmgm>
<menus>
<video/>
<audio/>
</menus>
</vmgm>
<titleset>
<titles>
<pgc pause=”4″>
<vob file=”video-1.mpg” chapters=”0″/>
<vob file=”video-2.mpg” chapters=”0″/>
</pgc>
</titles>
</titleset>
</dvdauthor>

I will not go into detail here about what the various xml fields manage save to say that pgc pause controls the delay between videos and that each video should be defined with the <vob file/> tag. More information can be found at http://dvdauthor.sourceforge.net/

Once the XML file has been created the DVD file structure can be created using dvdauthor as follows:

dvdauthor -o <dvd directory> -x <dvdauthor config xml>

At this point there should be a new directory (as defined by <dvd directory>) containing AUDIO_TS and VIDEO_TS directories. This new directory is the source for the DVD. At this point there are two ways to create the DVD. One is to create an .ISO file first. I can’t swear that this is strictly necessary, but I have found it to be useful for testing by mounting as an ISO9660 and then loading it as though it where the CD. To create the ISO file use mkisofs as follows:

mkisofs -dvd-video -v -o <isofile> <dvd directory>

The resulting ISO can be mounted using:

mount -o loop -t iso9660 <isofile> <mount point>

Using VLC (or any other video player) watch the results from the mount point. NOTE: this DVD should permit skipping from one chapter to the next and back. There will be no proper menu. This will be addressed in a later blog.

The last step is to burn the DVD. If you have created an ISO this can be accomplished with:

growisofs -dvd-compat -Z /dev/dvd=<isofile>

If instead you wish to burn directly from the source directory, this can be done with the following:

growisofs -Z /dev/dvd -dvd-compat <dvd directory>

There are additional options that can be used to add a title, etc. Check man growisofs for details.

That’s it! This is by no means a comprehensive process and is only meant as a jumping off point. The bulk of this information comes from http://ubuntuforums.org/showthread.php?t=320389 (my thanks to netyire for the source post!) and a lot of trial and error. There is a lot of really good information out there about transcoding videos and different methods of burning DVD’s. I highly recommend checking out http://dvdauthor.sourceforge.net/ for more information.

Mark Zanfardino

Posted in linux | Tagged: , , | 2 Comments »

Changing default Documents path in Kubuntu Hardy

Posted by mzanfardino on September 19, 2008

Since I started working with kubuntu 8.04.1 (hardy) with KDE 3.5.9 I have been irked that the default path to my documents folder has been changed from “documents” to “Documents”. I realize to some this might seem a trivial change, but when you work from the command line (cli) as I do, you find that a change in capitalization for such a frequently used folder can slow you down. As a result I have wanted to change my configuration to use “documents” but found that simply adding the documents directory was not enough. Several applications, such as System Menu (found in the applet panel) and Dolphin still point to Documents.

While doing some research I followed the trail from System Menu. First I found that the directories available from System Menu are derived from /usr/share/apps/systemview by way of .desktop files. Looking at documents.desktop reveals that the path is set by kio_system_documenthelper, which in turn is a script located in /usr/bin that relies on kde-config to return $document_path.

Okay, so it appears that there is a path that must be changed on a user level. Looking at System Settings (systemsettings) -> About Me -> Paths reveals three user paths that can be changed: Desktop, Autostart, and Documents. Simple right? Just change the path in Documents to point to documents instead of Documents. Wrong. Making this change and applying it is not enough. After a relog (and later a reboot) the path appears to remain set to it’s default of Documents.

What you say? How can this be? And how can I make this change permanent? It seems that there is another file that needs to be edited before these changes can be made permanent. Located in /etc/xdg is the file user-dirs.defaults. This file must be changed to reflect the new path as well. It appears there is some mechanism which I do not understand that reads the values from user-dirs.defaults and overwrites any changes made by the user in systemsettings (note: using kcontrol instead of systemsettings behaves in the same manner).

The good news? Simply change /etc/xdg/user-dirs.defaults to reflect whatever path you choose for documents. Once this has been done you can user systemsettings (or kcontrol) to change the path and this time the change will be made permanent.

NOTE: As with Documents, the Desktop path can also be changed as documented above.

Mark Zanfardino

Posted in kubuntu | Tagged: , , , , , , , | 1 Comment »