sobota, 1 grudnia 2012

Ubuntu 12.10: Rip audio to wav/mp3 directly from bin/cue image

Today I wanted to rip audio tracks from the image of a CD stored in cue format into a bunch of encoded audio files. Instead of burning the CD first and then ripping it into the desired format I decided to check if this can be done directly from the image file. Unfortunately I did not find a way to do it in one step but the described below two-step approach is not that bad at all.

Ripping audio from bin/cue into wav files

In order to do that you need to install bchunk utility (available in the standard repo) as in the example below:

$ sudo apt-get install bchunk
[sudo] password for krychu: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  daemon
Use 'apt-get autoremove' to remove it.
The following NEW packages will be installed:
  bchunk
0 upgraded, 1 newly installed, 0 to remove and 24 not upgraded.
Need to get 13.1 kB of archives.
After this operation, 59.4 kB of additional disk space will be used.
Get:1 http://ubuntu.task.gda.pl/ubuntu/ quantal/universe bchunk amd64 1.2.0-12 [13.1 kB]
Fetched 13.1 kB in 8s (1,468 B/s)
Selecting previously unselected package bchunk.
(Reading database ... 548740 files and directories currently installed.)
Unpacking bchunk (from .../bchunk_1.2.0-12_amd64.deb) ...
Processing triggers for man-db ...
Setting up bchunk (1.2.0-12) ...


Afterwards you are ready to rip the audio files from the bin/cue. Please check the command below for reference:

$ bchunk -w Audio\ Disc.bin Audio\ Disc.cue audio
binchunker for Unix, version 1.2.0 by Heikki Hannikainen
Created with the kind help of Bob Marietta ,
partly based on his Pascal (Delphi) implementation.
Support for MODE2/2352 ISO tracks thanks to input from
Godmar Back , Colas Nahaboo
and Matthew Green .
Released under the GNU GPL, version 2 or later (at your option).

Reading the CUE file:

Track  1: AUDIO         01 00:00:00
Track  2: AUDIO         01 03:13:72
Track  3: AUDIO         01 07:05:72
Track  4: AUDIO         01 10:41:25
Track  5: AUDIO         01 14:47:30
Track  6: AUDIO         01 17:57:65
Track  7: AUDIO         01 20:56:54
Track  8: AUDIO         01 24:29:40
Track  9: AUDIO         01 28:07:22
Track 10: AUDIO         01 31:07:67
Track 11: AUDIO         01 33:39:47
Track 12: AUDIO         01 37:18:62

Writing tracks:

 1: audio01.wav   32/32   MB  [********************] 100 %
 2: audio02.wav   39/39   MB  [********************] 100 %
 3: audio03.wav   36/36   MB  [********************] 100 %
 4: audio04.wav   41/41   MB  [********************] 100 %
 5: audio05.wav   32/32   MB  [********************] 100 %
 6: audio06.wav   30/30   MB  [********************] 100 %
 7: audio07.wav   35/35   MB  [********************] 100 %
 8: audio08.wav   36/36   MB  [********************] 100 %
 9: audio09.wav   30/30   MB  [********************] 100 %
10: audio10.wav   25/25   MB  [********************] 100 %
11: audio11.wav   36/36   MB  [********************] 100 %
12: audio12.wav   18/18   MB  [********************] 100 %
$

Ok, now you have the audio tracks in the wav file format. in the next section you can find how to encode it into your preferred format (e.g. mp3).

Converting wav files to mp3

There are few utilities allowing to encode the wav file into mp3 available on linux. I used soundconverter, simple GUI tool, downloadable from the repo.


$ sudo apt-get install soundconverter
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  daemon
Use 'apt-get autoremove' to remove it.
The following packages will be upgraded:
  soundconverter
1 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.
1 not fully installed or removed.
Need to get 0 B/138 kB of archives.
After this operation, 1,029 kB of additional disk space will be used.
(Reading database ... 548746 files and directories currently installed.)
Preparing to replace soundconverter 2.0.1-1 (using .../soundconverter_2.0.1-1_all.deb) ...
Unpacking replacement soundconverter ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for man-db ...
Setting up soundconverter (2.0.1-1) ...
$

Afterwards you can start it from command line (soundconverter) or main menu and encode the wav files into desired format (mp3, ogg etc.) as presented on the figure below:

Figure 1 Soundconverter GUI - converting wav files into mp3





wtorek, 20 listopada 2012

Ubuntu 12.10: Recovering removed files on FAT32 usb stick

Have you ever removed a file from your disk and later on regret it... I am pretty sure you did, recently it happened to one of my colleagues. The lost or should I say deleted file was a document (.docx) on a USB stick.

Unfortunately none of the free windows based utilities was able to do the job. We decided to give the linux based open source utilities a try. On the net I found two utilities (originating from one foremost) that could be used for that purpose (actually there were more but these looked the most promising):
1) scalpel
2) foremost

Both are available in the Ubuntu repos, below one can find some guidelines on installing, configuring the utilities. Before we start - few things about my environment
1) /dev/sdb1 - usb stick device
2) /tmp/recovery - the directory where the recovered files will be put into

Please keep in mind if you have automount feature turned on (which mounts automatically the device from which you would like to recover files) please ensure that you unmount it (in my opinion it is safer to do so).

Scalpel

Scalpel was the first utility that I decided to give a try. First you need to install the utility using the apt-get as follows:

# apt-get install scalpel

# dpkg -l | grep scalpel
ii  scalpel                                                     1.60-1build1                                 amd64        A Frugal, High Performance File Carver

Scalpel utility comes with a configuration file located at /etc/scalpel/scalpel.conf, the default configuration coming with the package has all file extensions commented out (not configured). Fortunately for most typical file types it has already samples so all you need is to edit and uncomment the lines for the file types you want to recover (in my case .doc):

# vim /etc/scalpel/scalpel.conf
...
doc     y       10000000  \xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1\x00\x00 \xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1\x00\x00 NEXT
doc     y       10000000  \xd0\xcf\x11\xe0\xa1\xb1
...

Now all you need is to launch the scalpel utility as follows:

# scalpel /dev/sdb1 -o /tmp/recovery/scalpel

Afterwards you should go to the output directory where you should be able to find the recovered files (in my case recovered files were placed in two folders doc-0-0 and doc-1-0):

# ls -l
-rw-r--r-- 1 root root      760 Nov 20 13:03 audit.txt
drwxr-xr-x 2 root root     4096 Nov 20 13:05 doc-0-0
drwxr-xr-x 2 root root     4096 Nov 20 13:06 doc-1-0
#

Unfortunately it recovered only .doc files not even a single .docx ! I tried to find a proper definition for .docx that could be placed in scalpel.conf file - I found one example on the net but it did not work in my case, I guess the definition was not correct. 

Summarizing the scalpel tool recovered the document files (.doc) very fast (2 GB usb stick) but I was not able to make it working for .docx. 

That is why I checked the second tool...

Foremost

As mentioned before the foremost utility is available in the standard Ubuntu repos so all you need is to install it using apt-get as shown below:

# apt-get install foremost

# dpkg -l | grep foremost
ii  foremost                                                    1.5.7-2                                      amd64        forensic program to recover lost files

The foremost utility has a set of predefined file formats (types) to be recovered but there is no configuration file like in scalpel. However it also makes the utility to be simpler for a first time user. 
Below you can find the command I tried - with file types doc, ole and zip.

# foremost -t doc,ole,zip -i /dev/sdb1 -o /tmp/recovery/foremost

It took a bit longer than in case of scalpel but...  After checking the output directory;

# ls -l
-rw-r--r-- 1 root root     2405 Nov 20 13:25 audit.txt
drwxr-xr-- 2 root root     4096 Nov 20 13:26 docx
drwxr-xr-- 2 root root     4096 Nov 20 13:24 ole
drwxr-xr-- 2 root root     4096 Nov 20 13:24 zip
#

Voila - in the docx directory I could find the docx files ! 


Summary

Summarizing - both tools are able to recover permanently deleted files from the filesystem (in my case FAT32). Scalpel seems to have more advanced configuration capabilities that might make it usable in advanced tasks (custom format files etc.), however one needs to perfectly know how to properly define the type, which i was not able to do for the .docx format. On the other hand if you are looking for something simple, easy and the data to files to be recovered fit into the list of standard formats (jpg,     gif, png, bmp, avi, exe, mpg, wav, riff, wmv, mov, pdf, ole, doc, zip, rar, htm, cpp) then foremost is the perfect utility for your needs.



czwartek, 15 listopada 2012

KVM windows guest on Ubuntu 12.10 - no sound

Recently I faced a problem that I could play sound from the KVM windows based guest machine (even though the virtual sound card AC'97 was properly detected and installed). I went through several article recommending to change the type of the card, configure qemu.conf to grant access to the audio. Unfortunately none of these really helped. Then after doing all the previously described things I tried disabling the apparmor and... Now it works...

Below I enclose more detailed procedure on what was needed in my case to make the audio from the guest kvm machine working.

1. Change the type of the card (might not be necessary). In my case the es1370 was chosen

2. Configure qemu.conf - please ensure that the following entries are present in the qemu.conf configuration file. The username and groupname shall be adapted to your system configuration


#  vim /etc/libvirt/qemu.conf 
...

#
vnc_allow_host_audio = 1
...
# The user ID for QEMU processes run by the system instance.
user = "krychu"

# The group ID for QEMU processes run by the system instance.
group = "krychu"
...


3. Disable apparmor. Disabling armor really made the sound working on my box. Actually I completely removed the apparmor from my system (I think it is not necessary, you might try only disabling it).

First I stopped the service:
#  service apparmor stop

Next I removed it from the startup scripts
#  update-rc.d -f apparmor remove

Since I do not use apparmor at the moment I eventually decided to remove it completely (if it happens that you installed apparmor-utils as well you should remove it as well)
#  apt-get remove apparmor apparmor-utils 


Reboot...

piątek, 4 maja 2012

Ubuntu 12.04 LTS "Precise Pangolin"

After long time of inactivity I am hopefully back ;) I am not sure if all of you have noticed but the new 12.04 LTS Ubuntu version has been recently released (26-th of April 2012) - if you wantto find out what is new please check http://www.ubuntu.com/ubuntu/whats-new.

I have updated yesterday my HP EliteBook 8540W laptop from 64-bit Ubuntu 11.10 (Oneiric Ocelot), no major problems encountered so far - only minor related to ruby gems installed using the ruby gem engine (but some of them were resolved by reinstalling the gem).


Forwarding all root mails to local user and receiving them using Thunderbird

Yesterday I checked my root local mailbox on my laptop running Ubuntu 12.04 LTS and found out 1500 hanging mails regarding problems with anacron daemon, That is quite a lot. It seems that I forgot to check the mailbox for quite long time so I decided to make it more visible to a standard user that I am using on my laptop and use the Thunderbird mail client (that I am daily using) to get them. You will need to replace the username with your username.


1. Create mailbox

If you want to create a new one:
root@localhost# touch /var/spool/mail/

If you want to create one with root:

root@localhost# cp /var/spool/mail/root /var/spool/mail/

Next create proper access permissions:
root@localhost# chown :mail /var/spool/mail/
root@localhost# chmod 640 /var/spool/mail/

2. Forward mails from root account to local users

You need to add the following line to the .forward file in the root home directory (if it does not exists you need to create it e.g. using vim utility):


root@localhost# cat /root/.forward
@localhost

Now the mails coming to root user should be forwarded to the user indicated via

3. Configure Thunderbird

On my Ubuntu 12.04 LTS I am using Thunderbird version 11.0.1.

In order to manage your local mailbox account you need to configure a 'Unix Mailspool (Movemail)' account. You will find it when creating an other account (File -> New -> Other Accounts...):

Figure 1 The Account wizard for creating the Movemail account

Then just follow next steps (acoount name, mail etc.). As soon as you finish, you should have your local mailbox visible in the Thunderbird main window.


Now I hope to get more visibility especially with respect to anacron jobs running on my laptop.