Ubuntu 11.04 Convert Movies for Ipod

Its been a while since I’ve tried to install some movies on my Ipod, and the way I used to do it doesn’t work anymore!  I’ve already installed the beta of Ubuntu 11.04, and everything seems to work fairly well.  However, I couldn’t find support for faac for the audio codec, but I was able to use aac with the -strict experimental option.

To rip the DVD, I found the AcidRip DVD Ripper and the Arista Transcoder programs to work fairly well, but when they converted the movie for the ipod (in either mp4 of m4v format) it didn’t work.  I had to use ffmpeg instead to convert the video .  Here is an example for the movie Inglorious Bastards.  I looked up the requirements on Apple’s website for the video format on an Ipod, and this command worked successfully.  After converting the video I was able to use Banshee to load the video onto my Ipod.

ffmpeg -strict experimental -i inglourious_basterds.avi -f mp4 -vcodec libxvid -s 320×240 -b 600k -r 30 -acodec aac -ar 48000 -ab 160k Inglorius\ Bastards.mp4

Apple specified the following requirements for the video format on their website:

  • H.264
    File formats: .m4v, .mp4, and .mov
    Video: Up to 768 kbits/sec, 320 x 240, 30 frames per second (fps), Baseline Profile up to Level 1.3.
    Audio: AAC-LC up to 160 kbits/sec, 48 Khz, and stereo audio.
  • MPEG-4
    File formats: .m4v, .mp4, and .mov
    Video: Up to 2.5 Mbits/sec, 480 x 480, 30 fps, Simple Profile.
    Audio: AAC-LC up to 160 kbits/sec, 48 Khz, stereo audio.

Passwords and Encryption Keys Fedora 13

The program Passwords and Encryption Tools can be used to create and manage SSH and PGP keys.  It can be accessed from the menu bar by going to Applications ->  Accessories -> Passwords and Encryption Keys, and provides a nice way to manage encryption keys in perhaps a more user friendly manner; although everything done using this tool can also be accomplished in the terminal.

In Ubuntu, encryption keys created using the Passwords and Encryption Keys program can be used to encrypt files by right clicking on them and selecting Encrypt, but apparently this option is not available in Fedora 13 (At least I don’t seem to have it).

Creating a New PGP Key

Before encrypting files and mail, a new PGP key must first be created, unless you already have one, by going to File -> New.  Select PGP Key and then select continue.  Enter in your full name, email address, and a comment if you choose to.  Under the advanced key options, the encryption method and other encryption settings can be modified if you know what you’re doing.  By default the key will be created using RSA encryption.

When you’re ready, select create at the bottom of the screen.  A screen will pop up and request the pass-phrase for the key.  Enter in the pass-phrase and then hit next.  It will take a few moments for the key to be generated.

This creates both a public and private key.  The public key can be sent to anyone, and is used for encrypting files.  The private key should not be shared with anyone and hidden in a safe place.  It is used for decrypting files.

Encrypting Files With Your PGP Key

Encrypting files and folders can be done by using the gpg command.  However, only files can be encrypted using gpg.  To encrypt a folder, use the tar command to create a gzipped tar file, and then encrypt the compressed tar file.  To get started, open up a terminal and enter in the command below:

gpg --list-keys

This will list all of your PGP keys, but the public key id can also be found on the right side of the Passwords and Encryption Keys window.  Take note of the key id for the public key you just created.    To encrypt a file run the following command, where [key id] is the id of your public key and [file] is the file you wish to encrypt:

 gpg --default-key [key id] --encrypt [file]

Make sure any files that are encrypted are not stored with the private key, or this would defeat the purpose of encrypting a file since the private key is used for decryption.

To decrypt a file run the following command:

gpg --output [output file name] --decrypt [encrypted file].

Encrypting Mail Using Thunderbird

In order to encrypt mail messages, Thunderbird requires the enigmail addon, which can be downloaded through yum.

sudo yum install thunderbird-enigmail

Once enigmail is installed, open up Thunderbird.  In the menu bar should be a new drop-down menu titled OpenPGP.  Go to OpenPGP – > Setup Wizard.  Read through the next few screens carefully, and follow the steps.  Everything is fairly straight forward, and there should be no difficulty in setting things up.  Eventually a prompt will require the encryption key, and the one that was previously created can be chosen or alternatively a new one may be created.  At the end of the setup process it will be possible to sign and encrypt all email messages through Thunderbird.

Installing Xfoil on Fedora 12 Linux

These are the steps that I went through to build Xfoil using double point precision on Fedora 12.  I used the gcc and gfortran compilers, and if you choose to use different ones, then some of the compiler flags may be different.  Before trying to build Xfoil, run the command sudo yum groupinstall “Development Tools”.  Not everything downloaded from the development group is needed to install Xfoil.  Alternatively, you can try to individually install the certain packages that are needed just to build Xfoil.

To get started first download the source file from http://web.mit.edu/drela/Public/web/xfoil/.  Extract the source tar file, cd into the directory Xfoil, and then follow the steps below.

Step 1 – Build the Orrs-Summerfield Database

Use cd to switch into the Xfoil/orrs/ directory and then run pwd.  Copy the ouput from pwd, and then cd into the src/ directory.  Edit the file osmap.f and look for the line DATA OSFILE / ‘/var/local/codes/orrs/osmap.dat’ /.  Change this line to DATA OSFILE / ‘{Output from pwd}/osmap.dat’ /, where {Output from pwd} is what was just copied before.

Now run cd ../bin/ and edit the make file, MakeFile_DP.  Make the following changes to that file.

  1. Change FC = f77 to FC = gfortran.
  2. Change FLG = -O -r8 to FLG = -O -fdefault-real-8 -fdefault-double-8.
  3. Look for the line #  Uncomment for Intel Fortran Compiler, and then comment out everything related to the Intel compiler.

Then run the following commands:

[brad@localhost ~]$ make -f Makefile_DP osgen
[brad@localhost ~]$ make -f Makefile_DP osmap.o
[brad@localhost ~]$ cd ..
[brad@localhost ~]$ bin/osgen osmaps_ns.lst

Step 2 – Build the Plot Library

Use the cd command to switch to the Xfoil/plotlib/ directory.  Open up the make file and then make the following changes.

  1. Find the line PLTLIB=libPlt.a.  Comment out this line and uncomment the line below it, which should read PLTLIB = libPltDP.a.
  2. Find the section Default compilers and flags, install commands, and change the default compilers by setting FC = gfortran and CC = gcc.
  3. Find the line DP = -r8 and replace it with DP = -fdefault-real-8 -fdefault-double-8.  Make sure it is uncommented.
  4. Comment out the line include ./config.make.

Save and close the make file, and then run the make from the terminal.

Step 3 – Make Programs in /bin

Now switch to the Xfoil/bin/ directory, and open up the make file.  Then make the following changes.

  1. Set the BINDIR equal to /usr/local/bin (BINDIR = /usr/local/lib).
  2. Find the line PLTOBJ = ../plotlib/libPlt.a and comment it out.
  3. Find the line ###  Default compilers and flags.
  4. Change FC = f77 to FC = gfortran.
  5. Change CC = cc to CC = gcc.
  6. Comment out the FFLAGS and FFLOPT variables.
  7. Look for the line ### Intel Fortran Compiler, and then comment out the next few lines for this compiler.  They are not needed.
  8. Find the line ###Double precision option.
  9. Change FFLAGS  = -O -r8 -CB to FFLAGS  = -O -fbounds-check -fdefault-real-8 -fdefault-double-8.
  10. Change FFLOPT  = -O -r8 -CB to FFLOPT  = -O fbounds-check -fdefault-real-8 -fdefault-double-8.
  11. Comment out the second set of FFAGS and FFLOPT.  These variables only need to be set once.

If you try to compile at this point you will get most likely get the following error.

gfortran -c -O -fbounds-check -fdefault-real-8 -fdefault-double-8  ../src/xoper.f
../src/xoper.f:117.22:

IINPUT(I) = 2**31
1
Error: Arithmetic overflow at (1)
make: *** [xoper.o] Error 1

There are two errors in the source code that need to be fixed.  The first one is in the file pplot.f and the second one is in the file xoper.f.  Running the following commands should fix these problems.  Note that before running the sed commands you want to be in the Xfoil/src/ directory.

[brad@localhost Xfoil]$ cd src/
[brad@localhost src]$ sed -i ‘s/LOGICAL ERROR, LGETFN/LOGICAL ERROR, LGETFN, LERR/g’ pplot.f
[brad@localhost src]$ sed -i ‘s/IINPUT(I) = 2\*\*31/IINPUT(I) = HUGE(0)/g’ xoper.f

Then change back to the Xfoil/bin/ directory and run make.

[brad@localhost bin]$ make xfoil
[brad@localhost bin]$ make  pplot
[brad@localhost bin]$ make pxplot

After I compiled everything, the xfoil command was not moved into /usr/local/bin.  This can be done manually by running sudo cp xfoil /usr/local/bin/.

Installing AVL on Fedora 12 Linux

These are the steps that I went through to get AVL running on Fedora 12.  I used the gcc and gfortran compilers.  If you choose to use different ones, then some of the compiler flags may be different.  Before trying to build AVL, run the command sudo yum groupinstall “Development Tools”.  Not everything downloaded from the development group is needed to install AVL.  Alternatively, you can try to individually install the certain packages that are needed to build AVL, but if one package is missed then it could cause an aggravating headache later on.

To get started first download the source file from http://web.mit.edu/drela/Public/web/avl/.  Extract the source tar file, cd into the directory Avl, and then follow the steps below.

Step 1 – Build XPlot 11

The first step is to build the XPlot11 library.  Change the current directory to plotlib/ and edit the file MakeFile.  Then make the following changes.

  1. Find the line PLTLIB=libPlt.a.  Comment out this line and uncomment the line below it, which should read PLTLIB = libPltDP.a.
  2. Find the section Default compilers and flags, install commands, and change the default compilers by setting FC=gfortran and CC=gcc.
  3. Find the line DP = -r8 and replace it with DP = -fdefault-real-8 -fdefault-double-8.
  4. Comment out the line include ./config.make.

Save and close the make file, and then run the sudo make from the terminal.

Step 2 – Build the Eispack Library

Now change to the eispack/ directory.  Open up the make file and make the following changes.

  1. Change the compiler to gfortran by commenting out the current line, FC = f77, and placing below it FC = gfortran.
  2. Change FLG = -O to FLG = -O -fdefault-real-8 -fdefault-double-8.

Save and close the file and then run sudo make.

Step 3 – Build AVL

Open up the Makefile in the bin/ directory and make the following changes.

  1. Set the BINDIR  equal to /usr/bin.
  2. Change libPlt.a to libPltDP.a.
  3. Change FC = f77 to FC = gfortran.
  4. Change the compiler flags from FFLAGS = -O -r8 to FFLAGS = -O -fdefault-real-8 -fdefault-double-8.
  5. Comment out all of the Intel Fortran Compiler 8.x options.

Save the make file and then run sudo make avl.  When I ran this it did not copy the bin file, avl, to /usr/bin/.  After it compiles this can done manually by running sudo cp avl /usr/bin/.

Try running an example to see that everything works.  In the Avl folder open up the file session1.txt and follow along.

How to Mount a Logical Volume

I am currently running Fedora 12, and on /dev/sda3 I have two logical volumes: one for swap and one for the root partition.  If I try to mount the physical volume, /dev/sda3, then I get the following error:

[brad@localhost ~]$ mount /dev/sda3 /mnt/disk
mount: unknown filesystem type ‘LVM2_member’

What I actually want to do is ‘mount the root filesystem on /dev/sda3′.  First, use the command pvs to get information about the physical volumes on the computer.

[brad@localhost ~]$ sudo pvs
PV         VG       Fmt  Attr PSize   PFree
/dev/sda3  VolGroup lvm2 a-   200.24G    0

So the volume group VolGroup is on the physical volume /dev/sda3.    Then use the lvdisplay command to list the logical volumes in the volume group VolGroup.

[brad@localhost ~]$ sudo lvdisplay /dev/VolGroup
— Logical volume —
LV Name                /dev/VolGroup/lv_root
VG Name                VolGroup
LV UUID                j7d1k3-xELA-VQ7x-90T7-QwX1-62mc-0HgVaF
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                196.30 GB
Current LE             50253
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:0

— Logical volume —
LV Name                /dev/VolGroup/lv_swap
VG Name                VolGroup
LV UUID                G0AW8c-Pg1n-KFrL-koAj-pdhi-XjkK-LEGinf
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                3.94 GB
Current LE             1008
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     256
Block device           253:1

From this output I know that the root filesystem is in the logical volume /dev/VolGroup/lv_root.  To mount this volume, I would run the following command:

[brad@localhost ~]$ mount /dev/VolGroup/lv_root /mnt/disk

You will have to create the folder /mnt/disk.

How to Create an Encrypted Partition

This post is very similar previous one that I wrote on encrypting flash drives using cryptsetup, which may be useful since the procedure is very similar.  When installing Fedora, the option is given to encrypt the entire hard-drive, but sometimes this is unnecessary.  Instead it may be more convenient to simply have a separate encrypted partition to place more private information, and to leave the rest of the hard-drive decrypted.

First create the partition that you want to have encrypted.  This can be done by using a GParted live-cd.  The live image can be downloaded here, and GParted is very easy to use.  Simply shrink a current partition and then create a new one with the blank space left over.  It does not matter how you format the new partition since it will be rewritten later on.

The partition that I created was located on /dev/sda4, but you should of course use the location of your partition when going through the rest of the tutorial.

Formatting the Partition and Creating the Device Mapper

Encrypting the partition is easy and can be done in three steps.  The first step initializes the luks partition, the second opens the partition and creates a device mapper, and the third sets up the partition’s file system.  I have chosen cryptmap as the name of the device mapper, but the choice is arbitrary and can be changed to whatever you would like it to be.

[brad@localhost ~]$ sudo cryptsetup luksFormat /dev/sda4
[brad@localhost ~]$ sudo cryptsetup luksOpen /dev/sda4 cryptmap
[brad@localhost ~]$ sudo mkfs.ext3 /dev/mapper/cryptmap

Mounting the Partition

The first command opens the luks partition and creates the device mapper, which I have named cryptmap.   After entering the command into the terminal, the password to decrypt the partition will be requested.  The device mapper can then be mounted to access the contents of the partition by using the second command given below.  The folder /mnt/cryptpart will have to have to be created, and the naming convention here is also arbitrary.

[brad@localhost ~]$ sudo cryptsetup luksOpen /dev/sda4 cryptmap
[brad@localhost ~]$ sudo mount /dev/mapper/cryptmap /mnt/cryptpart

Unmounting the Partition

There are actually two steps to unmounting the partition.  The first step is to unmount the device mapper.  However, at this point the information on the partition is still accessible because it can be remounted without the necessity of the decryption password.  Therefore, it is also important to close the luks partition after the mapper is umounted.

[brad@localhost ~]$ sudo umount /dev/mapper/cryptmap
[brad@localhost ~]$ sudo cryptsetup luksClose /dev/mapper/cryptmap

No Password Prompt at Boot

To prevent being requested to enter in the password for the luks partition every time the computer is restarted, add the phrase rd_NO_LUKS to the vmlinuz line in /boot/grub/grub.conf.  Do not do this if your root partition is encrypted or you won’t be able to boot the OS.  The /boot/grub/grub.conf file should have a section that looks similar to text below.  The line that starts with kernel /vmlinuz is broken up into three lines so that it can be pasted here.  This line may not be exactly the same as yours depending on what boot parameters you have and it should not be copied.  The purpose of the text below is just to illustrate where the place the parameter rd_NO_LUKS, which is highlighted with red text.

default=0
timeout=1
splashimage=(hd0,1)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.32.9-70.fc12.i686)
 root (hd0,1)
 kernel /vmlinuz-2.6.32.9-70.fc12.i686 ro root=/dev/mapper/VolGroup-
 lv_root nomodeset noiswmd LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16
 KEYBOARDTYPE=pc KEYTABLE=us rhgb quiet rd_NO_LUKS
 initrd /initramfs-2.6.32.9-70.fc12.i686.img

Bash Function to Get Battery Charge

I added these two functions to my bashrc.  The first one is used to get the battery charge, and the second returns the battery’s current capacity.

function bchrg {
      # Returns battery charge as a percentage.
      now=`cat /sys/class/power_supply/BAT0/energy_now`
      full=`cat /sys/class/power_supply/BAT0/energy_full`
      out=`echo $now/$full*100 | bc -l | cut -c 1-5`
      echo "Charge: "$out"%"
  }

  function bcap {
      # Returns battery capacity as a percentage.
      design=`cat /sys/class/power_supply/BAT0/energy_full_design`
      current=`cat /sys/class/power_supply/BAT0/energy_full`
      out=`echo $current/$design*100 | bc -l | cut -c 1-5`
      echo "Capacity: "$out"%"
  }

Print List of Contents of a Folder

Sometimes it can be useful to print out a list of a folder’s contents.  The best way to do this on windows, in my opinion, is to use the commandline.  To open the prompt, hit Windows + R, and then type cmd into the prompt before hitting enter.  Afterwards, a screen should pop up that looks similar to this:

Cmd Prompt

Cmd Prompt

The basics you need to know are the dir, chdir, and help commands.  The  dir command outputs your current location and also the contents of the folder your in.  The chdir command lets you change your folder location.  However, to switch to another drive just type the drive letter followed by a colon.  For instance, to switch to the C drive type C:, and then hit enter.  For help with more options for dir and chdir just type help dir or help chdir.

Print Folder Contents Using Windows

  1. Hit the keys Windows + R.
  2. Type cmd into the run prompt and then hit enter.
  3. Use the chdir command to get the folder you wish.
  4. Run the command dir /b > list.txt to get a list of all the contents in the folder.
  5. Print the file list.txt.

Print Folder Contents Using Linux

  1. Open up a terminal.
  2. Use cd to get to the folder you want the list of contents from.
  3. Run the command ls -a > list.txt.
  4. Print the file list.txt.

Data Erasure and Recovery

When files/folders are deleted the information is not actually removed from your computer.  The file still exists, but the space that it exists on becomes free to be written over.  However, there are tools that you can use to erase this information completely so that it cannot be recovered. From what I’ve read, these tools actually just “make it harder” to recover information, and the best way to ensure that information is completely destroyed is to fry the hard drive by degaussing it or dissolving it in acid.

Normally I use a tool called shred to remove files, but it cannot remove directories.  There is another tool, called scrub, which can do this.  Shred and scrub work basically in the same way.  They just rewrite the disk space, where the file/folder is stored, over and over again to corrupt the information stored there.

Another tool you can use is called DBAN, which is a self contained boot disk that you can use to erase an entire hard drive.  It works basically the same way as shred and scrub by repeatdly rewritting then entire hard drive with random numbers.  The benefit of DBAN is that it can be booted from a CD, DVD, or USB and can erase the entire hard drive.  The homepage for DBAN is here.

To use shred:

  1. Open a terminal.
  2. CD to where the file is stored.
  3. Run the command shred -vz –remove [file_name].

The -v option is verbose so if you don’t want to see all the information shred will spit back at you the leave this option out.  The -z option rewrites the space on the final time with all zeros, and the  –remove option removes the file after it’s been rewritten.

Shred can be used recursively to erase a bunch of files in a folder by running find [directory] -type f | xargs shred -zu.

Recovering Lost Information

The best way to prevent loss of data is to backup your files.  I do this every once in a while on a separate hard-drive to also protect myself from hard-drive crashes.  In other cases, if just the operating system has crashed you can grab your files using a live-cd or live-usb.  I always keep a Fedora live-cd laying around, but there are others, such as Knoppix, that you can use as well.

However,  if you deleted a file/folder and didn’t repeatedly rewrite the disk space it was on, then you might be able to recover it using a program called testdisk, which I found here.  It can be used to scan drives to recover information, and it works on both Windows and Linux, although I have not tried it with Windows.

Here is the tutorial I used when learning how to use testdisk.

Next Page »



Follow

Get every new post delivered to your Inbox.