Tuesday, September 4, 2012

Dhoom 1 & 2 from Bollywood

I've been into Bollywood movies lately, experiencing slight culture shock from the other side of the world. One of the movies I watched is Dhoom, which is about young and restless criminals trying to outsmart cops during a robbery spree.

Here's Dhoom 1 in 8 parts.


Dhoom 1 Part 1 w/Eng Subs HQ DvDRip [2004] by CBoii789
Dhoom 1 Part 2 w/Eng Subs HQ DvDRip [2004] by CBoii789
Dhoom 1 Part 3 w/Eng Subs HQ DvDRip [2004] by CBoii789
Dhoom 1 Part 4 w/Eng Subs HQ DvDRip [2004] by CBoii789
Dhoom 1 Part 5 w/Eng Subs HQ DvDRip [2004] by CBoii789
Dhoom 1 Part 6 w/Eng Subs HQ DvDRip [2004] by CBoii789
Dhoom 1 Part 7 w/Eng Subs HQ DvDRip [2004] by CBoii789
Dhoom 1 Part 8 (Last) w/Eng Subs HQ DvDRip [2004] by CBoii789

Here's Dhoom 2 in 8 parts.


Dhoom 2 Part 1 w/Eng Subs HQ DvDRip [2006] by CBoii789
Dhoom 2 Part 2 w/Eng Subs HQ DvDRip [2006] by CBoii789
Dhoom 2 Part 3 w/Eng Subs HQ DvDRip [2006] by CBoii789
Dhoom 2 Part 4 w/Eng Subs HQ DvDRip [2006] by CBoii789
Dhoom 2 Part 5 w/Eng Subs HQ DvDRip [2006] by CBoii789
Dhoom 2 Part 6 w/Eng Subs HQ DvDRip [2006] by CBoii789
Dhoom 2 Part 7 w/Eng Subs HQ DvDRip [2006] by CBoii789
Dhoom 2 Part 8 (Last) w/Eng Subs HQ DvDRip [2006] by CBoii789

Using cdrtfe 1.5

cdrtfe is free CD/DVD/BD burning software for Windows. cdrtfe actually use the command-line program cdrtools as its burning engine. I have used cdrtools on Linux to create ISO images and burn or rip CD. I'd like to have cdrtools on Windows also. Fortunately, cdrtfe includes cdrtools Win32 binaries along with the nice-looking GUI application.



To install cdrtfe, I downloaded the cdrtfe zip archive (cdrtfe-1.5.zip) and unpacked the zip archive. Double-clicking on the cdrtfe file will start the cdrtfe program. (Warning: Running the Cygwin terminal and cdrtfe at the same time can cause a problem due to cygwin1.dll incompatibility, so close the Cygwin terminal before starting cdrtfe.)



So far, I have only tried ripping music CD's with cdrtfe. I will add more as I get to know more about cdrtfe.



Ripping Audio CD's


To rip a music CD, click on the DAE tab and click the Options button. Check to make sure the options are okay.


cdrtfe_dae_options_1
cdrtfe_dae_options_2

Back to the main window, click Read TOC to update the track list, check the Save tracks to folder, and click Start to begin ripping.


cdrtfe_dae

Sunday, September 2, 2012

Setting Up Cygwin For C/C++ Software Development on Windows

Cygwin provides a Unix-like environment for Windows users. Cygwin is useful for people who want to learn Unix or popular Linux without having to install Unix or Linux. Cygwin can also be used to port Linux applications to Windows or develop genuine Windows applications. To install Cygwin, download setup.exe from the Cygwin website and run it.



Cygwin Packages for Software Development


In addition to the default packages, select the following packages for common development environment:


  • bison
  • gettext-devel
  • libtool
  • make
  • patch
  • pkg-config


To select a package for installation, type the name of the package in the Search box, expand the categories by clicking a plus, and clicking on the package until its version number shows up.



cygwin_setup_mingw64

If you want to develop software applications that depend on cygwin1.dll (which emulates Unix on Windows), install one of the following packages. This is when you want to port Linux applications to Windows with little modification.


  • gcc-g++

    outdated version 3.4.4
  • gcc4-g++

    GCC 4.x that links applications with cygwin1.dll


If you want to develop pure Windows applications, install one of the following packages.


  • mingw-gcc-g++

    The original MinGW compiler from mingw.org can't build 64-bit applications.
  • mingw64-i686-gcc-g++

    New MinGW compiler from mingw-w64.sourceforge.net.
  • mingw64-x86_64-gcc-g++

    Install these to develop 64-bit Windows applications.


When you see the Resolving Dependencies window, just accept and click Next.


cygwin_setup_dependencies

Setting HOME Variable


Setting the environment variable %HOME% is useful for various reasons. First of all, it allows regular users to compile freely in their user folder without requiring access to C:\Cygwin. Secondly, it allows users to save user-specific configuration in their user folder. For example, user configuration files such as .profile, .gtkrc-2.0, .fonts.conf and .pango-aliases can be saved in the folder specified by %HOME%.


Set HOME environment variable for MinGW and Cygwin

Setting Up mingw* compiler for Cygwin


The file C:\Cygwin\etc\fstab is used to set up mount points in Cygwin. If you installed mingw64 packages, open the file C:\Cygwin\etc\fstab in a text editor and append the following line.


/usr/i686-w64-mingw32/sys-root/mingw /mingw none bind

Start the Cygwin terminal and type the following commands to set up Cygwin for Windows compilation.


ln -s /usr/bin/i686-w64-mingw32-g++.exe /usr/i686-w64-mingw32/bin/g++.exe
ln -s /usr/bin/i686-w64-mingw32-gcc.exe /usr/i686-w64-mingw32/bin/gcc.exe

Also, set up some environment variables.


export CFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
export CXXFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
export CPPFLAGS="-I/mingw/include"
export LDFLAGS="-L/mingw/lib -Wl,--enable-auto-image-base -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
export PATH=/mingw/bin:/usr/i686-w64-mingw32/bin:/usr/local/bin:/usr/bin
export PKG_CONFIG_PATH=/mingw/lib/pkgconfig


Setting Up gcc* Compiler for Cygwin


If you installed the gcc4 compiler (as opposed to mingw*), set up some environment variables to customize your build environment. I usually type the following commands:


CC="/usr/bin/gcc.exe"
CFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
CPPFLAGS="-I/usr/include"
CXXFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
LDFLAGS="-L/usr/lib -Wl,--enable-auto-image-base -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
export CC CFLAGS CPPFLAGS CXXFLAGS LDFLAGS

Friday, August 31, 2012

To Create a Live Linux CD/DVD

A live CD is a bootable CD that contains the whole operating system and any applications you want to run from the CD. With the increasing popularity of DVD and Blu-ray drives, there is even a live DVD. A live CD is useful when you want to copy your existing Linux system to a CD and run it on multiple computers. In this post, I show how I normally create a live CD.



Rebuild a kernel with SquashFS and UnionFS patch


A new kernel should be built with SquashFS and UnionFS patches. The live CD will have a huge file that is actually a SquashFS image containing a copy of your existing Linux system. We will use UnionFS so that any changes to the read-only SquashFS will be saved to the volatile memory. Download the patches from the following locations.





After patching the kernel and rebuilding it, install the new kernel.



Make a SquashFS image of an existing Linux system


A SquashFS image needs to be created from an existing Linux system. Copy the contents of the Linux filesystem to an empty directory, assuming the filesystem is mounted at /mnt.



mkdir /tmp/livecd
cd /mnt
tar cf - . | (cd /tmp/livecd; tar xf -)


Empty the contents of fstab so that the live CD will not mount any hard disk partition, including the original root partition.



cp /dev/null /tmp/livecd/etc/fstab


Create a squashfs image.



mksquashfs /tmp/livecd /tmp/linuxfs.sqz -comp xz -b 262144 -Xdict-size 196608 -no-xattrs -e boot lost+found selinux srv


Create a Custom InitRamFS image


This is a tricky part of the job. Basically, the init script of the initramfs image will mount the CD-ROM, then mount the SquashFS image, and then mount a UnionFS. Refer to this post on building an initramfs image.



Create a Live CD structure.


Create an empty directory which will be the contents of live CD. The live CD will contain:




  • SquashFS image (named linuxfs.sqz, for example)
  • isolinux.bin and isolinux.cfg
  • kernel
  • initramfs image


Finally, create an ISO image for the live CD.



genisoimage -V LIVECD -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table /tmp/isofs > ~/livecd.iso


Burn the ISO image.



cdrskin -v dev=/dev/sr0 speed=8 driveropts=burnfree ~/livecd.iso

Wednesday, August 29, 2012

Six-Pack Abs Workout

The following abdominal workouts will help you get sexy abs.

Ab Crunch

ab_crunch

Crunches are a good exercise to help trim your waist line and build abdominal strength. The following steps are taken from eHow.

  1. Lie on your back with your knees bent and your feet flat on the floor in front of you. Using an exercise mat rather than a hard floor can help prevent back strain. Position your feet as wide as your hips, and place your hands behind your head so that your thumbs are tucked behind your ears.
  2. Curl up and forward using your stomach muscles so that your head, neck and shoulder blades lift off the floor. Pause for a moment, squeezing your abdominal muscles. Lift your head up enough so that middle and lower back stay on the floor. While you lift your head, slowly breathe out.
  3. Slowly lower your head, neck and shoulder blades to starting position. Keep your knees bent, your feet in the same position and your back straight throughout the entire exercise. While you lower your head, breathe in.
  4. Make sure you are not pulling your head forward with your hands. This can cause serious damage to the neck and spinal cord regions. If your chin is making contact with your chest, the abdominal muscles aren't being used in the exercise.

Situp

situp

Strong stomach muscles give good core strength and are essential for all sports. Besides, they also make you look like Adonis. Situps are a great way to start toning your tummy and it's easy to do if you know how. The following steps are taken from videojug.

  1. Make sure you find somewhere comfortable like flat-level surface. you could use a yoga mat to lie on to make it soft on your back. When you are in the gym, make sure you're not obstructing anyone else's activity.

  2. Lie down on your back with your knees bent and balls and hills of your feet placed flat on the floor. Put your hands behind your ears with your elbows out to the side. You can cross your arms over your chest and touch your shoulders if you prefer. Don't grab the back of your neck as this can cause injury.

  3. Keeping your feet on the ground, tighten your stomach muscles and slowly lift your head first. You should feel the strain on your abdomen. Then, lift your shoulder blades and pull up from the floor about halfway. Hold position for a few seconds. And slowly put your back down again to the floor. But try to keep your back slightly elevated so you are not completely flat and relaxed.

  4. Repeat the action for 5 to 10 reps if you are a beginner. You can slowly build up the amount you do over time. But do not push yourself and always stop immediately if you feel a sharp pain.

  5. You could get a friend to hold onto your feet to give you a more solid platform to push on. Keep your chin away from your chest and your elbows out to the side. Try to concentrate on keeping your abs tense throughout the action as these are what should be controlling your movement.

Leg Raise

leg_lift

Lie on your back with your legs straight and together. Raise your legs, keeping them together. Lower them down making sure they stay around 2 inches from the floor. Hold for a few seconds and repeat. Try doing sets of 10 repetitions to start with.

V-sit

v_sit

Lie on your back with legs flat on the floor. Raise your back and your legs at the same time, forming a V shape. Pause for a brief moment. Lower your back and legs to the starting position.

Stand and Twist

stand_and_twist

Stand with your feet shoulder width apart and your knees relaxed. Keeping your hips stable twist your torso to the right bringing your left arm across your chest in a punching motion. Twist back and repeat in the opposite direction. Try doing 30 repetitions to start with and increase this the stronger you feel. Do not do this if you have any history of back troubles.

Tuesday, August 28, 2012

Manually Creating initrd / initramfs to Boot Linux

Initrd and initramfs files are used together with a Linux kernel and a bootloader (such as GRUB and syslinux) to start up Linux and boot it in many different ways. Many Linux distributions provide prepackaged kernels and convenient tools for creating initramfs, but I like to build my own kernel and initramfs because it allows me to customize the boot process. For instance, one can choose to boot from the local disk or network-mounted disk with the help of initramfs and some user-defined boot parameters. Here's a list of things that I'd like to achieve with my custom initramfs.




  1. Boot from a live CD
  2. Boot from a read-only filesystem image, compressed with SquashFS
  3. Copy the filesystem image to a RAM disk and run Linux entirely on memory
  4. Boot Linux from a USB flash drive or a Firewire disk
  5. Boot Linux from a local disk partition
  6. Boot Linux from a network drive
  7. Run a rescue shell without booting Linux
  8. Start a kdrive X-server and run gparted, partclone or partimage


In this post, I show how I normally create initrd / initramfs files. For this tutorial, the following Debian/Ubuntu packages are needed:




  • busybox

    provides small essential utilities for booting and rescue shell.
  • cpio

    is used to create the actual initramfs format.
  • dash

    provides a minimalist shell for running the init script and the rescue shell.
  • e2fsprogs, jfsutils, etc.

    provides fsck to check Linux filesystems and replay any stale journal
  • lzma or xz-utils

    compresses the initramfs
  • module-init-tools

    is used to load kernel modules necessary to activate hardware and mount the filesystem
  • pciutils

    is used to detect PCI hardware
  • unionfs-fuse

    makes it possible to use read-only Linux systems, such as live CD and filesystem images
  • unzip

    is used to apply customized settings and changes to the unionfs boot mode
  • v86d

    is used to set the screen resolution for the framebuffer screen


First, create a text file with a list of files to put in initramfs. The following is an example of such file:



bin/busybox
bin/dash
bin/mount
etc/filesystems
etc/fuse.conf
etc/group
etc/modprobe.d
lib/ld-linux.so.2
lib/libacl.so.1
lib/libattr.so.1
lib/libblkid.so.1
lib/libbz2.so.1.0
lib/libcom_err.so.2
lib/libc.so.6
lib/libdl.so.2
lib/libe2p.so.2
lib/libext2fs.so.2
lib/libfuse.so.2
lib/libkmod.so.2
lib/libmount.so.1
lib/libm.so.6
lib/libpci.so.3
lib/libpthread.so.0
lib/libresolv.so.2
lib/librt.so.1
lib/libselinux.so.1
lib/libsepol.so.1
lib/libuuid.so.1
lib/libx86.so.1
lib/libz.so.1
lib/modules/3.5.3/kernel/drivers/ata
lib/modules/3.5.3/kernel/drivers/block/loop.ko
lib/modules/3.5.3/kernel/drivers/cdrom/cdrom.ko
lib/modules/3.5.3/kernel/drivers/connector/cn.ko
lib/modules/3.5.3/kernel/drivers/firewire/firewire-core.ko
lib/modules/3.5.3/kernel/drivers/firewire/firewire-ohci.ko
lib/modules/3.5.3/kernel/drivers/firewire/firewire-sbp2.ko
lib/modules/3.5.3/kernel/drivers/i2c/algos/i2c-algo-bit.ko
lib/modules/3.5.3/kernel/drivers/scsi/sd_mod.ko
lib/modules/3.5.3/kernel/drivers/scsi/sr_mod.ko
lib/modules/3.5.3/kernel/drivers/usb/host/ehci-hcd.ko
lib/modules/3.5.3/kernel/drivers/usb/host/ohci-hcd.ko
lib/modules/3.5.3/kernel/drivers/usb/host/uhci-hcd.ko
lib/modules/3.5.3/kernel/drivers/usb/storage/usb-storage.ko
lib/modules/3.5.3/kernel/drivers/video
lib/modules/3.5.3/kernel/fs/ext3/ext3.ko
lib/modules/3.5.3/kernel/fs/ext4/ext4.ko
lib/modules/3.5.3/kernel/fs/fat/fat.ko
lib/modules/3.5.3/kernel/fs/fat/vfat.ko
lib/modules/3.5.3/kernel/fs/fuse/fuse.ko
lib/modules/3.5.3/kernel/fs/isofs/isofs.ko
lib/modules/3.5.3/kernel/fs/jbd2/jbd2.ko
lib/modules/3.5.3/kernel/fs/jbd/jbd.ko
lib/modules/3.5.3/kernel/fs/jfs/jfs.ko
lib/modules/3.5.3/kernel/fs/nls/nls_cp437.ko
lib/modules/3.5.3/kernel/fs/nls/nls_iso8859-1.ko
lib/modules/3.5.3/kernel/fs/nls/nls_utf8.ko
lib/modules/3.5.3/kernel/fs/reiserfs/reiserfs.ko
lib/modules/3.5.3/kernel/fs/squashfs/squashfs.ko
lib/modules/3.5.3/kernel/fs/xfs/xfs.ko
lib/modules/3.5.3/kernel/lib/crc16.ko
lib/modules/3.5.3/kernel/lib/crc-t10dif.ko
lib/modules/3.5.3/modules.dep
lib/modules/3.5.3/modules.dep.bin
lib/modules/3.5.3/modules.pcimap
sbin/blkid
sbin/e2fsck
sbin/jfs_fsck
sbin/modprobe
sbin/v86d
usr/bin/pcimodules
usr/bin/unionfs-fuse
usr/bin/unzip


Then, create an empty directory, for example, /tmp/initrd and copy the files listed in the above-mentioned text file (called rd354.txt) to the new directory.



mkdir /tmp/initrd
cd /
tar cvhf - -T rd354.txt | (cd /tmp/initrd; tar xf -)


Then, create the necessary directory structure under /tmp/initrd:



cd /tmp/initrd
mkdir -p dev media mnt proc root sys tmp


Since I chose to use busybox, I need to create symbolic links to busybox in /bin. Busybox provides incomplete functionality for modprobe, mount, sh and unzip, so I removed their symbolic links.



cd /tmp/initrd/bin
for f in $(./busybox --list); do [ -e $f ] || ln -s busybox $f ; done
rm modprobe unzip


Then, create essential device nodes in /tmp/initrd/dev:



cd /tmp/initrd/dev
MAKEDEV std fb0 fd0 sda sdb scd
mknod console c 5 1
mknod fuse c 10 229
chmod 666 fuse


Now, create an init script. The contents of this init script is crucial for customization of the boot process. The following is the script I use. This script is capable of booting a live CD and running Linux within memory in addition to booting Linux from hard drives and USB flash.



#!/bin/dash

# Define a function to parse kernel command line options.
get_opt() {
echo $@ | cut -d "=" -f 2
}

# Define a function to load drivers.
loadmod() {
for i in $@ ; do
for j in $(grep $i /tmp/pcimodules.txt); do
modprobe $j
done
done
}

# Define a function to guess the partition type.
gpart() {
for i in $(blkid | grep $1); do
case $i in
*\=*)
eval $i
;;
*)
true
;;
esac
done
}

# Define a function for mounting the root partition.
mountr() {
if [ $uuid ]; then
if [ $# = 2 ]; then
mount -r -U $uuid $2
elif [ $# = 1 ]; then
mount -r -U $uuid $1
else mount -r -U $uuid /mnt
fi
elif [ $label ]; then
if [ $# = 2 ]; then
mount -r -L $label $2
elif [ $# = 1 ]; then
mount -r -L $label $1
else mount -r -L $label /mnt
fi
else
gpart $1
case $TYPE in
ext*)
e2fsck -p $1
[ $# = 2 ] && mount $1 $2 || mount $1 /mnt
;;
jfs)
jfs_fsck $1
if [ $# = 2 ]; then
mount -t jfs -o ro,iocharset=utf8 $1 $2
else mount -t jfs -o ro,iocharset=utf8 $1 /mnt
fi
;;
vfat)
if [ $# = 2 ]; then
mount -t vfat -o ro,gid=100,dmask=2,fmask=113 $1 $2
else mount -t vfat -o ro,gid=100,dmask=2,fmask=113 $1 /mnt
fi
;;
*)
[ $# = 2 ] && mount -r $1 $2 || mount -r $1 /mnt
;;
esac
fi
}

# Create a union filesystem
union() {
mount -t tmpfs none /opt/tmp
modinfo unionfs > /dev/null 2>&1 &&
mount -t unionfs -o dirs=/opt/tmp=rw:/opt=ro none /mnt ||
( mkdir /opt/tmp/.change
modprobe fuse
unionfs-fuse -o allow_other,use_ino,suid,dev,nonempty,kernel_cache \
-o cow,chroot=/opt,max_files=32768 /tmp/.change=RW:/=RO /mnt )
}

# Mount proc and sysfs.
mount -t proc none /proc
mount -t sysfs none /sys

# Find the available PCI hardware
mount -t tmpfs none /tmp
pcimodules > /tmp/pcimodules.txt

# Populate /dev (Needs kernel >= 2.6.32)
mount -t devtmpfs none /dev
mkdir -m 755 /dev/pts
mount -t devpts -o gid=5,mode=620 none /dev/pts

# Set default values
boot=ata
root=/dev/sda6

# Find the root=, label=, uuid= and boot= values on kernel command line.
for i in $(cat /proc/cmdline); do
case $i in
root\=*)
root=$(get_opt $i)
case $root in
/dev/cdr* | /dev/dvd* | /dev/sr* | /dev/scd*)
boot=cdrom
;;
0x200)
root=/dev/fd0
;;
esac
;;
label\=* | uuid\=* | boot\=* | vmode\=* )
eval $i
;;
single)
RUNLEVEL=single
;;
nox)
RUNLEVEL=2
;;
esac
done

# Activate framebuffer display devices.
if [ $vmode ]; then
if [ $boot = cdrom ]; then
modprobe uvesafb scroll=ywrap mode_option=$vmode-16
else for i in $(grep fb /tmp/pcimodules.txt); do
case $i in
atyfb)
modprobe $i mode=$vmode-16
;;
nvidiafb | rivafb)
modprobe nvidiafb mode_option=$vmode bpp=16 hwcur=1
;;
radeonfb | savagefb)
modprobe $i mode_option=$vmode-16
;;
sisfb)
modprobe $i mode=$vmodex16 mem=12288 font=SUN12x22
;;
viafb | vt8623fb)
modprobe viafb viafb_mode=$vmode viafb_bpp=16
;;
*)
modprobe $i
;;
esac
done
if grep -q i915 /tmp/pcimodules.txt; then true
else [ -c /dev/fb0 ] || modprobe uvesafb scroll=ywrap mode_option=$vmode-16
fi
fi
fi

case $boot in
cdrom)
# Boot Linux from a live CD.
loadmod ata_ ahci pdc_adma ^.hci-hcd
modprobe usb-storage &&
modprobe sr_mod &&
sleep 7
modprobe isofs
mount -t iso9660 /dev/sr0 /media
[ -d /media/isolinux -o -d /media/boot/isolinux ] ||
mount -t iso9660 /dev/sr1 /media
if [ -f /media/*.[Ss][Qq]* ]; then
SQF=$(ls -t /media/*.[Ss][Qq]* | head -n 1)
if [ $root = /dev/ram ]; then
echo "Please wait until the RAM disk is ready."
dd if=$SQF of=/dev/ram1 bs=2048 &&
mount -t squashfs /dev/ram1 /opt
else modprobe loop
mount -t squashfs -o loop $SQF /opt
fi
else
mount --move /media /opt
fi
union
;;
loop)
# Boot Linux from an image file.
loadmod ata_ ahci pdc_adma ^.hci-hcd
modprobe usb-storage &&
modprobe sd_mod &&
sleep 7
mountr $root /media
modprobe loop
if [ -f /media/*.[Ss][Qq]* ]; then
SQF=$(ls -t /media/*.[Ss][Qq]* | head -n 1)
mount -t squashfs -o loop $SQF /opt
elif [ -f /media/*.[Ii][Ss][Oo] ]; then
ISO=$(ls -t /media/*.[Ii][Ss][Oo] | head -n 1)
modprobe isofs
mount -t iso9660 -o loop $ISO /opt
fi
union
;;
ram)
# Boot Linux from ramdisk.
loadmod ata_ ahci pdc_adma ^.hci-hcd
modprobe usb-storage &&
modprobe sd_mod &&
sleep 7
mountr $root /media
echo "Please wait until the RAM disk is ready."
if [ -f /media/*.[Ss][Qq]* ]; then
SQF=$(ls -t /media/*.[Ss][Qq]* | head -n 1)
dd if=$SQF of=/dev/ram1 &&
mount -t squashfs /dev/ram1 /opt
elif [ -f /media/*.[Ii][Ss][Oo] ]; then
ISO=$(ls -t /media/*.[Ii][Ss][Oo] | head -n 1)
dd if=$ISO of=/dev/ram1 bs=2048 &&
modprobe isofs
mount -t iso9660 /dev/ram1 /opt
fi
union
;;
usb*)
# Boot Linux from a USB drive.
loadmod ^.hci-hcd
modprobe usb-storage &&
modprobe sd_mod &&
sleep 7
mountr $root
;;
ata*)
loadmod ata_ ahci pdc_adma &&
modprobe sd_mod &&
mountr $root
;;
esac

# Make sure that init exists and is executable.
if [ -x /mnt/sbin/init ]; then
mount --move /dev /mnt/dev
mount --move /proc /mnt/proc
mount --move /sys /mnt/sys
umount /tmp

# Start init from the root filesystem.
cd /mnt
[ -f /media/updates.zip ] && unzip -o /media/updates.zip
case $boot in
cdrom)
[ $root = /dev/ram ] && umount /media
[ $RUNLEVEL ] || RUNLEVEL=3
;;
loop | ram)
umount /media
[ $RUNLEVEL ] || RUNLEVEL=3
;;
*)
[ $RUNLEVEL ] || RUNLEVEL=5
;;
esac
[ -d initrd ] && pivot_root . initrd
exec chroot . /sbin/init $RUNLEVEL
fi

# Start a shell as a last resort.
echo "Error booting from the root filesystem. Starting a shell."
exec /bin/dash


Copy the init script to the initrd folder (Assuming its filename is init.sh).



cp init.sh /tmp/initrd/init
cp init.sh /tmp/initrd/etc
chmod 775 /tmp/initrd/init


Now, use cpio and lzma to create an initramfs file. This assumes that the kernel was compiled with CONFIG_RD_LZMA option enabled.



cd /tmp/initrd
find . | cpio -H newc -o | lzma -c > ../initram.lzm


A file named initram.lzm will be created. If you want to create an old-style initrd file instead, use the mkcramfs command. This assumes your kernel has built-in cramfs support (CONFIG_CRAMFS):



mkcramfs /tmp/initrd /boot/initrd.bin


Copy the kernel and the initramfs file to your boot directory (whereever it is). I use SYSLINUX which I installed at /dev/sda1 partition. Finally, edit the boot configuration file. The following is the contents of a sample syslinux.cfg:



LABEL debian
KERNEL 314.lnx
INITRD /initrd/initram.lzm
APPEND root=/dev/sda7

LABEL sid
KERNEL 314.lnx
INITRD /initrd/initram.lzm
APPEND boot=usb label=SID edd=off vmode=800x600

LABEL bfile
KERNEL 314.lnx
INITRD /initrd/initram.lzm
APPEND boot=loop root=/dev/sda1

LABEL ram
KERNEL 314.lnx
INITRD /initrd/initram.lzm
APPEND boot=ram ramdisk_size=524288 root=/dev/sda1

Friday, August 24, 2012

Getting Eclipse to Work with MinGW C/C++ Compilers

Eclipse is one of my favorite programming environment which is used to develop C, C++ and/or Java software efficiently. Let's set up Eclipse so that we can use it to work with MinGW C/C++ compiler and Java.




  1. First, install MinGW (as shown in this post). You have two choices for the MinGW compiler:




    I prefer the original MinGW compiler to MinGW-w64, but individual tastes may vary. Make sure that you add the folder containing gcc.exe to the PATH environment variable.




  2. Then, install JRE because Eclipse won't run without it. If you want to develop Java, then install JDK (Java SE or Java EE) instead of JRE.



  3. Now, download Eclipse IDE for C/C++ Developers (eclipse-cpp-juno-win32.zip) and unpack it. You need it to develop C/C++ programs.



  4. If you also want to develop Java, then download Eclipse IDE for Java Developers (eclipse-java-juno-win32.zip). Just unpack the Java Developer package into the same folder as Eclipse for C/C++, avoiding to overwrite existing files.



  5. Create a shortcut on your desktop that points to the Eclipse program (eclipse.exe). To start Eclipse, double-click the Eclipse shortcut that you just created.



  6. Let's test our Eclipse installation and create a simple C++ program. Start a new C++ project (File->New->C++ Project). Type in any Project name, and select Empty Project under Executable Project types. Choose MinGW GCC for toolchains. Click Finish.




    Once a new C++ project is open, create a new source file (File->New->Source File).




    Try typing in a simple code like the following:


    #include <iostream>
    using namespace std;

    int main()
    {
    cout << "Hello, boys and girls.\n";
    return 0;
    }


    Save the project (File->Save). Build the project (Project->Build Project). If the build was successful, run the generated program (Run->Run, or Ctrl+F11).


Thursday, August 23, 2012

MinGW: Compiling LZO Compression Library

LZO, short for Lempel-Ziv-Oberhumer, is compression software that is designed for decompression speed. I compiled the LZO library like this.


tar xzvf lzo-2.03.tar.gz

cd lzo-2.03/

./configure --prefix=/mingw

make

make install

I only got a static library liblzo2.a. So I had to convert it to a DLL.



gcc -shared -o liblzo2-2.dll -Wl,--out-implib,liblzo2.dll.a -Wl,--whole-archive /mingw/lib/liblzo2.a -Wl,--no-whole-archive -L/mingw/lib -lwinmm

Compiling gtkmm for Windows with MinGW

gtkmm is a C++ wrapper library that makes it possible to write C++ programs with GTK+. After compiling the GTK+ library, you can build gtkmm as follows.




  1. libsigc++ 2.2.10


    libsigc++ implements a typesafe callback system for standard C++. Download the libsigc++ source code from here and compile it:


    ./configure --prefix=/mingw
    make
    make install

  2. glibmm 2.32.1


    glibmm is a C++ wrapper for Glib. Compile it like this:


    ./configure --prefix=/mingw
    make
    make install

  3. atkmm 2.22.6


    atkmm is a C++ wrapper for ATK. Compile it like this:


    ./configure --prefix=/mingw
    make
    make install

  4. cairomm 1.10.0


    cairomm provides C++ interface to the Cairo library. Compile it like this:


    ./configure --prefix=/mingw
    make
    make install

  5. pangomm 2.28.4


    pangomm is a C++ wrapper for Pango. Compile it like this:


    ./configure --prefix=/mingw
    make
    make install

  6. gtkmm 3.4.0


    gtkmm is a C++ wrapper for GTK+. Build it as follows:


    ./configure --prefix=/mingw
    make
    make install

Friday, August 17, 2012

Building GraphicsMagick

GraphicsMagick is a powerful tool for processing image files. I'm using MinGW to build GraphicsMagick for Windows.




  1. zlib 1.2.7


    Download the zlib source (zlib-1.2.7.tar.gz) and unpack it.


    tar xzvf zlib-1.2.7.tar.gz
    cd zlib-1.2.7

    Compile and install zlib.


    make -f win32/Makefile.gcc
    cp -iv zlib1.dll /mingw/bin
    cp -iv zconf.h zlib.h /mingw/include
    cp -iv libz.a /mingw/lib
    cp -iv libz.dll.a /mingw/lib


  2. bzip2


    Now download bzip2 source from bzip.org and unpack it.


    tar xzvf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6

    Change line 78 of bzlib.h to read:


    #if defined(_WIN32) && !defined(__MINGW32__)

    Compile and install bzip2.


    make
    cp bzlib.h /mingw/include/
    cp libbz2.a /mingw/lib


  3. liblzma


    Get the XZ Utils source code and unpack it. Go to the src/liblzma folder and compile liblzma like this:


    tar xzvf xz-5.0.4.tar.gz
    cd xz-5.0.4
    ./configure --prefix=/mingw
    cd src/liblzma
    make
    make install


  4. libpng 1.5.12 and libjpeg 8d


    Compile libpng and libjpeg as follows:


    ./configure --prefix=/mingw
    make
    make install


  5. libjasper


    Compile Jasper:


    ./configure --prefix=/mingw
    make
    make install

    If you encounter an error "undefined reference to _sleep", replace sleep() with _sleep with a factor of 1000 in the code:


    _sleep(1000)


  6. JBig


    Get jbigkit from here.


    make
    cp libjbig/*.h /mingw/include
    cp libjbig/*.a /mingw/lib


  7. libtiff 4.0.2


    Compile libtiff like this:


    ./configure --prefix=/mingw
    make
    make install

    If the shared library libtiff-5.dll is not generated and you want to create it manually, use such a command as the following and update libtiff.la accordingly:


    gcc -shared -o libtiff-5.dll -Wl,--out-implib,libtiff.dll.a -Wl,--whole-archive /mingw/lib/libtiff.a -Wl,--no-whole-archive -L/mingw/lib -ljpeg -ljbig -llzma -lz


  8. freetype


    Compile freetype:


    ./configure --prefix=/mingw
    make
    make install


  9. libxml2


    Compile libxml2:


    ./configure --prefix=/mingw
    make
    make install


  10. libwmf 0.2.8.4


    Compile libwmf:


    ./configure --prefix=/mingw
    make
    make install


  11. Little CMS


    Compile liblcms:


    ./configure --prefix=/mingw
    make
    make install


  12. Build GraphicsMagick


    Get GraphicsMagick code and build it like this:


    ./configure --prefix=/mingw --with-gs-font-dir='C:/Windows/Fonts' --with-windows-font-dir='C:/Windows/Fonts' LIBS='-ljbig'
    make
    make install



Creating a PDF document from JPEG files


GraphicsMagick comes in handy when you want to convert scanned JPEG images to a PDF document:


gm convert *.jpg doc.pdf

Monday, February 20, 2012

HSQLDB Installation and Usage

HyperSQL is relational database software that can be downloaded and used for free. It works on top of Java.







HSQLDB Installation




I downloaded the HyperSQL package (hsqldb-2.2.8.zip) and extracted its contents into the "C:\Program Files\hsqldb" folder.





Starting an HSQLDB Server




The following example command starts the HyperSQL server with one database called "mydb" and the public name of "xdb". The public name hides the file names from users.


java -cp ../lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:mydb --dbname.0 xdb

If the files named "mydb.*" do not already exist, they will be created. This way you can start the HSQLDB server and create a new database at the same time.





If the computer hosting the database server is restricted to the HTTP protocol by a firewall, use the HyperSQL HTTP Server.


java -cp ../lib/hsqldb.jar org.hsqldb.server.WebServer --database.0 file:mydb --dbname.0 xdb

When a HyperSQL server is running, client programs can connect to it using the HSQLDB JDBC Driver contained in hsqldb.jar.





Running Database Access Tools




HyperSQL includes the Database Manager JDBC frontend to connect to a HSQLDB server, query and modify tables.


java -cp ../lib/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing

At the Connect dialog, enter the information necessary for connecting to the database.









SQL Commands


After I started the Database Manager using the command above, I entered the following SQL commands to create tables for MyBooks database.




CREATE CACHED TABLE Publishers (pnum INTEGER NOT NULL PRIMARY KEY, publisher VARCHAR(50) NOT NULL, parent VARCHAR(50));



CREATE CACHED TABLE Authors (anum BIGINT NOT NULL PRIMARY KEY, author
VARCHAR(50) NOT NULL, lastname VARCHAR(25), aka VARCHAR(50));



CREATE CACHED TABLE Books (index VARCHAR_IGNORECASE(20) NOT NULL PRIMARY KEY, title VARCHAR(50) NOT NULL, edition TINYINT, pubdate DATE NOT NULL, author VARCHAR(64) NOT NULL, anum BIGINT NOT NULL REFERENCES Authors, pnum INTEGER NOT NULL REFERENCES Publishers, pages SMALLINT, format VARCHAR_IGNORECASE(20), isbn13 CHAR(13), isbn10 CHAR(10));



CREATE CACHED TABLE Keywords (index VARCHAR_IGNORECASE(20) NOT NULL PRIMARY KEY REFERENCES Books, genre1 VARCHAR_IGNORECASE(25), genre2
VARCHAR_IGNORECASE(25), subject1 VARCHAR_IGNORECASE(36), subject2
VARCHAR_IGNORECASE(36), subject3 VARCHAR_IGNORECASE(36), keyword1
VARCHAR_IGNORECASE(25), keyword2 VARCHAR_IGNORECASE(25), keyword3
VARCHAR_IGNORECASE(25));

When you finish using the Database Manager, make sure that you properly shut down the database.



SHUTDOWN: To save changes and close the database.

SHUTDOWN COMPACT: To save the database in the minimal size and close it. Should be used periodically.





Using OpenOffice.org Base to Work with HSQLDB Server


You can use OpenOffice.org Base to work with a server-based HyperSQL database. First, you need to set up OpenOffice.org so that it can use the HyperSQL JDBC driver. Select Tools > Options > Java and click Class Path.





Click the Add Archive... button and enter the path to the hsqldb.jar file. Click OK to save the changes and restart OpenOffice.org Base. Make sure that you also close the OpenOffice.org Quickstart in the notification area of the taskbar. At the Database wizard, choose JDBC to connect to an existing database, and enter org.hsqldb.jdbc.JDBCDriver for the JDBC driver class.





Enter SA as username. Password is not required.

Thursday, January 5, 2012

Setting Up Filezilla FTP Server In Windows 7

The Windows operating system has built-in features that allow you to share documents, photos, music and video with other Windows users in the local network. However, users of Linux or another non-Windows OS may have a hard time trying to access shared resources on Windows computers. Setting up an FTP server on a Windows machine can solve such interoperability issues in sharing files between different types of computers.



FileZilla Server is a free, fast and powerful FTP server for Windows. By default, the FileZilla server starts automatically with Windows, and the admin port is 14147.





I don't like to see the admin interface started at every login.





You should define some ports for passive mode.





I like to enable TLS/SSL for added security in FTP transfers.





I created a group called users.





Then, I created a user for myself.





You should create a new rule for FileZilla in Windows Firewall.





In the new inbound rule wizard, select the following settings.



  • What type of rule would you like to create? Port
  • Does this rule apply to TCP or UDP? TCP
  • Does this rule apply to all local ports or specific local ports? 21, 990, 2100-2121
  • What action should be taken when a connection matches specific conditions? Allow the connection
  • Name: FTP connections

Sunday, January 1, 2012

Open-Source Database Servers

I've been thinking about installing an open-source database server for personal and commercial uses. My choices were limited as shown below.



Monday, December 26, 2011

Compiling MLDonkey for Windows

MLDonkey is a nifty program that helps you share files with other people. MLDonkey works on Linux, but the Windows version I downloaded didn't work on my computer running Windows XP. So I compiled MLDonkey using Cygwin's mingw64-i686-gcc-* compiler toolchain. Here I show how I did it. Part of the information below is taken from the MLDonkey Windows guide.


  1. Cygwin Setup

    First, install Cygwin using the Cygwin installer(setup.exe). I set the Root directory to C:\Cygwin and chose to install the following packages in addition to base packages.



    • bison

    • gettext-devel

    • libtool

    • make

    • mingw64-i686-binutils

    • mingw64-i686-gcc-core

    • mingw64-i686-gcc-fortran

    • mingw64-i686-gcc-g++

    • patch

    • pkg-config



  2. Open the file C:\Cygwin\etc\fstab in a text editor and append the following line.


    /usr/i686-w64-mingw32/sys-root/mingw /mingw none bind


    Set the HOME variable.



    Start the Cygwin terminal and type the following commands to set up Cygwin for Windows compilation.



    cp /usr/bin/i686-w64-mingw32-g++.exe /usr/i686-w64-mingw32/bin/g++.exe
    cp /usr/bin/i686-w64-mingw32-gcc.exe /usr/i686-w64-mingw32/bin/gcc.exe
    cp /usr/bin/i686-w64-mingw32-cpp.exe /usr/i686-w64-mingw32/bin/cpp.exe
    export PATH=/mingw/bin:/usr/i686-w64-mingw32/bin:/usr/local/bin:/usr/bin:/usr/lib/gcc/i686-w64-mingw32/4.5.3
    export CC=/usr/bin/i686-w64-mingw32-gcc.exe
    export PKG_CONFIG_PATH=/mingw/lib/pkgconfig

  3. Compile zlib and bzip2

    Download the zlib source (zlib-1.2.7.tar.gz) and unpack it.


    tar xzvf zlib-1.2.7.tar.gz
    cd zlib-1.2.7

    Compile and install zlib.


    make -f win32/Makefile.gcc
    cp -iv zlib1.dll /mingw/bin
    cp -iv zconf.h zlib.h /mingw/include
    cp -iv libz.a /mingw/lib
    cp -iv libz.dll.a /mingw/lib

    Now download bzip2 source from bzip2.org and unpack it.


    tar xzvf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6

    Change line 78 of bzlib.h to read:


    #if defined(_WIN32) && !defined(__MINGW32__)

    Compile and install bzip2.


    make
    cp bzlib.h /mingw/include/
    cp libbz2.a /mingw/lib



  4. libiconv

    Download and compile libiconv:


    tar xzvf libiconv-1.14.tar.gz
    cd libiconv-1.14
    ./configure --build=i686-w64-mingw32 --prefix=/mingw --enable-static
    make
    make install



  5. JPEG, PNG & Freetype

    Compile JPEG, libPNG and Freetype in the following way:


    ./configure --build=i686-w64-mingw32 --prefix=/mingw
    make
    make install


  6. GD Graphics Library

    Now get the libgd source, unpack and configure:


    ./configure --build=i686-w64-mingw32 --prefix=/mingw LIBS="-lbz2 -ljpeg -lws2_32 -liconv"

    Once Makefile is generated, change line 233 to read:


    DEFS = -DHAVE_CONFIG_H -DBGDWIN32

    Also fix gd.h near line 25:


    --- ./gd.h      Sat Oct 30 12:54:58 2004
    +++ ./gd.h Sun Jan 05 17:56:09 2006
    @@ -24,7 +24,7 @@
    #endif /* WIN32 */

    #ifdef NONDLL
    -#define BGD_DECLARE(rt) extern rt
    +#define BGD_DECLARE(rt) extern rt _stdcall
    #else
    #ifdef BGDWIN32
    #define BGD_DECLARE(rt) __declspec(dllexport) rt __stdcall

    Then, build and install gdlib:


    make install


    To create a DLL file called libgd-2.dll, run the following commands:



    mkdir /tmp/gdlib
    cd /tmp/gdlib
    ar x /mingw/lib/libgd.a
    gcc -shared -o /mingw/bin/libgd-2.dll -Wl,--out-implib,libgd.dll.a *.o -L/mingw/lib -lz -lbz2 -ljpeg -lpng -liconv -lfreetype




  7. wget

    Build wget as shown in this post. If you don't want to compile wget yourself, get the executable (wget.exe) somewhere, and put it in the same folder as mlnet.exe later.

  8. regex and libmagic

    Download regex-0.12.tar.gz and compile regex as required by libmagic.


    gcc -DSTDC_HEADERS -DHAVE_STRING_H=1 -I. -c regex.c
    ar ru libregex.a regex.o
    cp -iv libregex.a /mingw/lib
    cp -iv libregex.a /mingw/lib/libgnurx.a
    cp -iv regex.h /mingw/include

    Get the source tarball of open-source file command. Configure as follows:


    ./configure --build=i686-w64-mingw32 --prefix=/mingw

    Open config.h and add the following lines:


    #define WIN32 1
    #define MAGIC "magic"

    Then compile:


    make && make install


  9. OCaml

    You need flexdll (flexdll-0.27.zip) to build OCaml. Extract it to /mingw/bin. Then, download the latest OCaml source (3.12.1). Patch ocaml with this Unicode patch.


    tar xzvf ocaml-3.12.1.tar.gz
    cd ocaml-3.12.1
    patch -p1 -l < ../ocaml-3.12.1-unicode.patch


    In the config subfolder, copy Makefile.mingw to Makefile.



    cp config/m-nt.h config/m.h 
    cp config/s-nt.h config/s.h
    cp config/Makefile.mingw config/Makefile


    Begin compiling OCaml.


    make -f Makefile.nt world
    make -f Makefile.nt opt
    make -f Makefile.nt opt.opt
    make -f Makefile.nt install


    Set up OCaml environment variables:


    export CAMLLIB=/mingw/lib
    export OCAMLLIB=/mingw/lib
    export CAMLP4LIB=/mingw/lib/camlp4



  10. Build MLDonkey

    Get the MLDonkey source, then unpack and configure it.


    tar xjvf mldonkey-3.1.0.tar.bz2
    cd mldonkey-3.1.0
    ./configure --build=i686-w64-mingw32 --prefix=/mingw --disable-fasttrack


    To link with the static GD library, append -DNONDLL to the CPPFLAG line of config/Makefile.config



    CPPFLAGS=-I/mingw/include -DNONDLL


    Start compilation.


    export OCAML_SRC=~/ocaml-3.12.1
    cp -iv /mingw/lib/stublibs/dllunix.dll .
    make depend
    make mlnet.static
    strip mlnet.static
    mv mlnet.static mlnet.exe

    If the final linking stage fails, here is the command I used to produce mlnet.exe:


    g++ -g0 -O3 -o mlnet.exe -Wl,--subsystem,windows -L/lib/gcc/i686-w64-mingw32/4.5.3 -L/mingw/lib /tmp/camlstartup00193d.s build/flexdll_mingw.o /mingw/lib/std_exit.o src/daemon/common/commonMain.o build/driver.a build/core.a build/client.a build/common.a build/magic.a build/bitstring.a build/cdk.a build/extlib.a /mingw/lib/nums.a /mingw/lib/str.a /mingw/lib/unix.a /mingw/lib/bigarray.a /mingw/lib/stdlib.a src/utils/cdk/gdstubs.o src/networks/direct_connect/che3_c.o src/utils/lib/CryptoPP.o src/utils/lib/CryptoPP_stubs.o src/utils/net/upnp_stubs.o src/daemon/common/commonHasher_c.o src/utils/lib/magiclib_stub.o src/utils/bitstring/bitstring_c.o src/utils/cdk/zlibstubs.o src/utils/cdk/heap_c.o src/config/mingw/os_stubs_c.o src/utils/lib/fst_hash.o src/utils/lib/md4_comp.o src/utils/lib/md4_c.o src/utils/lib/charsetstubs.o src/utils/lib/md5_c.o src/utils/lib/sha1_c.o src/utils/lib/tiger.o src/utils/lib/stubs_c.o -lnums -lcamlstr -lunix -lbigarray -lgdi32 -luser32 -ladvapi32 -limm32 -lshell32 -lole32 resfile.o -lpthread -lmagic -lgd -ljpeg -lfreetype -lpng -lz -lbz2 -lws2_32 -lshlwapi /mingw/lib/libasmrun.a /mingw/lib/libcharset.dll.a /mingw/lib/libiconv.dll.a


    Optonally, compress the executable with upx.

    upx --best --strip-relocs=0 mlnet.exe




  11. Here's my mldonkey builds.




Tuesday, December 20, 2011

To build wget.exe with MinGW

wget is a useful command-line downloader. To build wget for the Windows platform, first install MinGW. Then, compile zlib, openssl and wget in that order. To compile zlib:



make -f win32/Makefile.gcc
cp -iv zlib1.dll /mingw/bin
cp -iv zconf.h zlib.h /mingw/include
cp -iv libz.a /mingw/lib
cp -iv libz.dll.a /mingw/lib


To compile openssl:



./Configure -DHAVE_STRUCT_TIMESPEC -DPTW32_STATIC_LIB -L/mingw/lib -lz -lpthreadGC2 -lws2_32 --prefix=/mingw threads zlib mingw
make
make test
make install


Now, build wget



./configure --prefix=/mingw --enable-threads=win32 --disable-nls --with-ssl=openssl
make
make install

Monday, October 17, 2011

Compiling Zip and Unzip with MinGW

The current version of zip supports higher compression with the bzip2 method. To build zip with bzip2 compression using MinGW, first prepare the bzip2 library:



tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make
cp bzlib.h /mingw/include/
cp libbz2.a /mingw/lib


Then, get the zip source. Use the LOCAL_ZIP environment variable to configure zip.



export LOCAL_ZIP='-DLARGE_FILE_SUPPORT -DZIP64_SUPPORT -DUNICODE_SUPPORT -DBZIP2_SUPPORT -DALLOW_REGEX


Edit the LIBS line in the file makefile.gcc in the win32 folder to link zip with bzip2 library



LIBS=-luser32 -ladvapi32 -lbz2


Compile zip.



make -f win32/makefile.gcc


You'll find zip.exe in the source folder.



Compiling Unzip with MinGW



Unzip is a command-line extraction tool for .zip archives. In order to be able to unpack bzipped .ZIP archive, I need to compile unzip with bzip2 support. After compiling bzip2 as above, I downloaded unzip60.tar.gz from Info-Zip project at Sourceforge and unpacked it.



tar xzvf unzip60.tar.gz
cd unzip60


I fixed the file win32/Makefile.gcc in the section following "# optional inclusion of bzip2 decompression"



INC_BZ2LIB = -I/mingw/include
LOCFLAGS = -I/mingw/include -DUSE_BZIP2
LD_BZ2LIB = -L/mingw/lib -lbz2
LIBBZIP2 = /mingw/lib/libbz2.a


Then, I compiled Unzip like this:


make -f win32/Makefile.gcc
ls -l *.exe

Three executables unzip.exe, unzipsfx.exe and funzip.exe are created. Copy them to a folder in your path or /bin.


cp -iv *.exe /C/Windows


Usage Examples


To back up a folder:


zip -Z bzip2 -b C:\Windows\Temp -SDurX backup.zip *

Thursday, August 18, 2011

Logging Into Linux Desktop with Xming, Xnest and Putty

I use Xming and Putty to remotely log into my Linux desktop over a secure connection. Since I use xdm for the X11 login screen, I had to set up xdm for remote login. I made sure /etc/X11/xdm/xdm-config had this setting:


DisplayManager.requestPort: 117

I changed /etc/X11/xdm/Xaccess to allow any connection:


echo "*" > /etc/X11/xdm/Xaccess

I installed xnest on the Linux machine.


On Windows, install xming and X11 fonts. Start the Xming server.


Xming.exe :16 -clipboard -multiwindow -nolisten inet6

Then, start putty, enable X11 port forwarding and connect to the Linux box. Once you are logged into the remote terminal, start Xnest:


Xnest :16 -ac -geometry 960x720 -once -query 127.0.0.1

A window will pop up showing your lovely Linux destkop. Now, enjoy your Linux applications on Windows.

Sunday, April 3, 2011

Cloud Storages for Linux

Today the trend is to put your valuable data somewhere on the Internet and access it anywhere. This is a dramatic departure from the past as our trust grows towards Internet companies. More companies are offering cloud storage services, for example, Box.net and Zumodrive. Here I show how to set up Linux to access cloud storages.


Box.net offers 5GB of free online storage for personal use, but each upload must be smaller than 25MB. Zumodrive offers 2GB free space initially, but unlike box.net you can upload any size of files using the ZumoDrive desktop application.




Adding a Box.net folder in KDE Dolphin



  1. Select Network from the Places panel. Then, double-click on Add Network Folder.



  2. Choose the WebFolder (webdav) and click Next.



  3. Enter information for Box.net as follows.




Setting up Zumodrive on Mint KDE edition



  1. Download the Zumodrive package for Ubuntu 8 or later (zumodrive-ubuntu8-i386-0.989.deb).
  2. The Zumodrive package depends on openjdk-6-jre, but Sun's JRE is installed in Mint, so you don't have to install openjdk-6-jre.

    However, you need install libinotifytools0, libgnet2.0-0 and libnautilus-extention1. I used Synaptics to install the missing packages.
  3. Unpack the zumodrive package into the system.

    cd /
    dpkg --extract zumodrive-ubuntu8-i386-0.989.deb .

  4. Copy /usr/share/applications/zumodrive.desktop to your Desktop folder, so you can start Zumodrive by double-clicking the icon on desktop. Optionally, right-click on the icon, choose Properties and make it executable.


  5. Now double-click on the Zumodrive icon. Once you type in your email and password, you can access Zumodrive through the ~/Zumodrive folder.

Wednesday, March 23, 2011

Hacker's Guide To Installing Windows 7

Many people want to try the new Windows 7, but they're not too sure if Windows 7 is worth it. After all, it doesn't make sense to buy a new computer to try Windows 7 and then find out it's another lame bloatware. This guide will help an average joe to download, install and activate Windows 7 with freely available tools.



Hardware Requirements of Windows 7


First, you need to decide if your computer is capable of running Windows 7. According to Microsoft, Windows 7 has the following hardware requirements:



  • 1 GHz or faster 32-bit or 64-bit processor
  • 1 GB RAM (32-bit) or 2 GB RAM (64-bit)
  • 16 GB available hard disk space (32-bit) or 20 GB (64-bit)
  • DVD-ROM drive or DVD burner
  • DirectX 9 graphics card with WDDM 1.0 or better driver


That means Windows 7 can run on most computers available. You may have to buy additional memory or a new video card to be able to run Windows 7. See the Windows 7 Compatibility site.



Next, decide which edition of Windows 7 you want to install on your computer. There are many editions of Windows 7, for example, Home Premium, Professional, Enterprise and Ultimate. For most people, Windows 7 Home Premium is good enough.



Windows 7 Direct Downloads and Bittorrents



It is recommended that you use aria2, Halogenware Retriever or Free Download Manager to download Windows 7 so you can resume a download in the event of connection problems. On the Web, you can download DVD images of Windows 7 from the following locations:



  • Windows 7 Home Premium SP1 (x86 English) X17-24208.iso

    MD5: c5bb99b2f1a9e7a5b4fbc6e3eff70882

    SHA1: 22df3e5a80f8dbf014c2776a01b1cd9f24d83233

    CRC32: 9c5dc931
  • Windows 7 Home Premium SP1 (x64 English) X17-24209.iso

    MD5: 971843a457b6e0db0af61258cbe7256a

    SHA1: b4821f46a171708f5f8f8a0ef48fc16529437961

    CRC32: d236fd70
  • Windows 7 Professional SP1 (x86 English) X17-24280.iso

    MD5: befd4f1e00ec8da2effbd789f4e66fbf

    SHA1: 917a542b0541054bb9c2a06a11a46aed6943856b

    CRC32: 20078d8d
  • Windows 7 Professional SP1 (x64 English) X17-24281.iso

    MD5: 338f3245d68527db47b8a44e55317d0a

    SHA1: 5ed2584110e03f498db4458ba9fafd5a7ef602ed

    CRC32: 74f3cb73
  • Windows 7 Ultimate SP1 (x86 English) X17-24394.iso

    CRC32: C2966895

    MD5: 24F3A45D43D7C532AA3126CC094C61BD

    SHA1 : 92c1ada4ff09c76ec2f1974940624cab7f822f62

    SHA2: BBB5E0BAF3659F6DEC96B50381CBB05C09F066675EE639324B728215D5D47C43
  • Windows 7 Ultimate SP1 (x64 English) X17-24395.iso

    CRC32: 8589EE18

    MD5: 56A26636EC667799F5A7F42F142C772D

    SHA1: 1693b6cb50b90d96fc3c04e4329604feba88cd51

    SHA2: 9A2F3972FBBBB4974255CCCC26CDA9B1A75D9D0179867D6111162AC33F0CB693
  • Windows 7 Home Premium (x86 English) X15-65732.iso

    SHA1: CC9D8220B2179E784D85BF1EA98D2EE2190D534F

    ISO/CRC: 5DF6DBA0
  • Windows 7 Home Premium (x64 English) X15-65733.iso

    SHA1: 336779EA6B65F63E11A609B4D021439C47AB315B

    ISO/CRC: 56D954E4
  • Windows 7 Professional (x86 English) X15-65804.iso

    SHA1: 697FA06554502FB21D30275273B25747299C020D

    ISO/CRC: 578725D1
  • Windows 7 Professional (x64 English) X15-65805.iso

    SHA1: 50127304441A793EE51B3F501289F6599A559E9F

    ISO/CRC: 502C42C1
  • Windows-7-SP1-EN-MSDN-TechNet.torrent


I like using aria2 for download. Get my aria2 win32 build from here. To use aria2c to download Windows 7 Home Premium, open the Command Prompt and type the following command.



aria2c --file-allocation=prealloc http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65732/X15-65732.iso


To stop the download, press Ctrl+C twice. Later, you can resume download with the command:



aria2c -c http://msft-dnl.digitalrivercontent.net/msvista/pub/X15-65732/X15-65732.iso


After the download has finished, verify the checksums of the download with md5deep or HashCheck shell extension.

This is optional. If you want to create a single All-in-One DVD that can be used to install Home Basic, Home Premium, Professional and Ultimate edition, download and run eicfg_remover. This tool removes ei.cfg from the ISO file.

Then, burn the image to a blank DVD. You need to have a DVD burner and a blank DVD, of course. For free DVD-burning software, you can get ImgBurn, InfraRecorder or CDBurnerXP.



Wednesday, March 2, 2011

Compiling Linux Kernel 2.6.38

Let's compile a Linux kernel. To build a kernel, I installed the following packages:




  • binutils
  • gcc-4.4
  • libglade2-dev for "make gconfig"
  • libqt3-mt-dev or libqt4-dev for "make xconfig"
  • make
  • module-init-tools
  • patch


libglade2-dev is needed to configure the kernel by running “make gconfig”. In addition, I am going to include the following features.




  • unionfs is a union filesystem that allows me to merge several filesystems into a single logical one. It has several uses, such as Live CD's and modifiable read-only filesystem.
  • ndiswrapper allows me to use many network devices by installing native Windows drivers.

I downloaded the kernel source and unpacked it.


tar xjvf linux-2.6.38.tar.bz2
cd linux-2.6.38

Then, I applied the unionfs patch.


gzip -dc ../unionfs-2.5.3_for_2.6.18.8.diff.gz | patch -p1 -l

Then, I configured the kernel with a GTK configuration tool.


cp /boot/config-2.6.31.5 .config
make gconfig


Open Makefile with an editor and define EXTRAVERSION if necessary.



Now let's compile the kernel.


make bzImage
make install
make modules
make modules_install
depmod -e -F /boot/System.map-2.6.38 -m 2.6.38


Set the default root device and ramdisk size for the new kernel.



cd /boot
rdev vmlinuz-2.6.38 1,0
ramsize vmlinuz-2.6.38 4096


Finally, compile ndiswrapper (Patches available here).



tar xzf ndiswrapper-1.55.tar.gz
cd ndiswrapper-1.55
KVERS=2.6.31.6 make uninstall
KVERS=2.6.31.6 make
KVERS=2.6.31.6 make install


Generate modules.* files.


depmod -e -m -F /boot/System.map-2.6.31.6 2.6.31.6

Sunday, January 2, 2011

Building mplayer on Debian Linux

MPlayer is one of my favorite media players. It is used with such frontend as smplayer, gnome-mplayer or MPlayerGUI to provide a good alternative to Windows Media Player and VLC. First, I installed the necessary compiler toolchain.



  • autoconf
  • automake
  • binutils
  • bison
  • cpp
  • g77 or fort77
  • gcc
  • gettext
  • g++
  • libtool
  • make


Next, I installed the necessary development libraries:



  • libasound2-dev
  • libbz2-dev
  • libesd0-dev
  • libfontconfig1-dev
  • libfribidi-dev
  • libjpeg62-dev
  • libncurses5-dev
  • libpng12-dev
  • libxv-dev


Some useful libraries are not included in the Debian distribution, so I had to compile them on my own. They are faac, lame, libdca, live, x264 and xvidcore. First, I built liblzo.



tar xzvf /usr/src/lzo-2.04.tar.gz
cd lzo-2.04/
./configure --prefix /usr
make
make install


Then, I built the giflib.



tar xjvf /usr/src/giflib-4.1.6.tar.bz2
cd giflib-4.1.6/
ls
./configure --build=i586-pc-linux-gnu --prefix=/usr --disable-shared
make
make install


I built cdparanoia.



tar xzvf /usr/src/cdparanoia-III-10.2.src.tgz
cd cdparanoia-III-10.2/
./configure --build=i586-pc-linux-gnu --prefix=/usr --disable-shared
make
make install


I compiled libdca in the following way:



tar xjvf libdca-0.0.5.tar.bz2
cd libdca-0.0.5/
./configure --build=i586-pc-linux-gnu --prefix=/usr --disable-shared
make
make install


I built ogg, vorbis, theora and speex.



./configure --build=i586-pc-linux-gnu --prefix=/usr --disable-shared
make
make install


To compile lame, run:



tar xzvf /usr/src/lame-3.98.4.tar.gz

cd lame-3.98.4/

./configure --build=i586-pc-linux-gnu --prefix=/usr --disable-shared --mandir=/usr/share/man --enable-expopt=full --enable-nasm

make

make install


Unpack live555 source in /usr/lib and compile live555 as follows:



cd /usr/lib/live

./genMakefiles linux

make


To compile x264, do:



tar xjvf /usr/src/x264-snapshot-20110102-2245.tar.bz2

cd x264-snapshot-20110102-2245/

sh configure --host=i586-pc-linux-gnu --prefix=/usr --enable-pic --disable-asm

make

make install


Compile the xvid library as follows:


cd xvidcore/build/generic

./configure --build=i586-pc-linux-gnu --prefix=/usr

make

make install


Finally, you're ready to compile MPlayer. Get the latest snapshot tarball and extract it:



wget ftp://ftp.mplayerhq.hu/MPlayer/releases/mplayer-export-snapshot.tar.bz2

tar xjvf mplayer-export-snapshot.tar.bz2

cd mplayer-export-2009-05-29

CPPFLAGS='-DLIBTWOLAME_STATIC' ./configure --prefix=/usr --enable-runtime-cpudetection --yasm=/usr/bin/yasm --language=all --confdir=/etc/mplayer

make

make install

chmod 4755 /usr/bin/mplayer

Wednesday, December 29, 2010

ssh + netcat + tar + xz = Secure Network Transfer Link

I found a way to use simple command-line tools to transfer files between computers far apart. Using this method, I was able to duplicate the contents of an entire filesystem securely over a SSH tunnel between two computers. In this method, no NFS server or scp command is needed. However, netcat plays an important role in this method. Let's first make sure we have everything ready.



  • OpenSSH
  • netcat
  • tar or cpio
  • xz, lzma, lzo, bzip2 or gzip


I'll be really brief.




  1. At the computer where you will receive files (say, 192.168.1.2), type the following commands to start netcat in listening mode and use tar + xz to unpack the incoming stream of data.



    cd /my/downdoad/folder
    nc -l 7749 | xz -dc | tar xvf -


  2. At the computer where you will send files (say, 192.168.1.1), create a ssh tunnel to the computer receiving files (192.168.1.2).



    ssh -l username -L 5525:192.168.1.2:7749 192.168.1.2


  3. Open another terminal window and type the following command to start sending files.



    tar cvf - . | xz -c | nc 127.0.0.1 5525


Partition Imaging with Netcat



Backing up hard drive partitions over the network can be accomplished with just a few simple tools like netcat. This is another handy usage of netcat. At the receiving computer where you'll store the backup, type the command to receive the partition image:



nc -l 7749 | lzma -dc | dd of=/dev/sda8 bs=640K


At the sending computer from which you'll transmit the partition, establish an SSH link first:



ssh -l username -L 5525:192.168.1.2:7749 192.168.1.2


Then compress the partition data and transmit over the secure SSH channel:



dd if=/dev/sda11 bs=640K | lzma -9c | nc 127.0.0.1 5525


Note that the transfer may take many hours for a large partition.

Sunday, November 14, 2010

Transmission-Daemon for Windows

Here are my Windows builds of transmission-daemon. I built it with Cygwin's GCC compiler. 7-zip or a newest version of unzip should be used to unpack them.


The package contains the following files:


  • Cygwin1.dll

    Cygwin Unix layer

  • transmission-cli.exe

    Command-line Bittorrent Client

  • transmission-create.exe

    Create .torrent files

  • transmission-daemon.exe

    Transmission server

  • transmission-edit.exe

    Edit .torrent files

  • transmission-remote.exe

    Control the transmission daemon

  • transmission-show.exe

    Show .torrent contents


Unpack the package into a folder, for example, C:\Program Files\Transmission. Then, create a shortcut with the following command:

transmission-daemon -b -o -m -ep -a 127.0.0.1,192.168.*.* --utp


Double-clicking the shortcut will not open any window. However, transmission-daemon is silently running in the background. You can control the daemon with any Web browser by opening this local Web address:


http://127.0.0.1:9091/

Although you can control transmission-daemon with a Web browser, it's not a pretty thing to do so. I recommend using transmission-remote-dotnet or transmission-remote-gui. The following is a screenshot for Transmission Remote .NET which is written in C#.



And, below you can see Transmission Remote GUI that's written in Pascal.




The settings for the daemon are stored in the ~/.config/transmission-daemon folder. Make sure the HOME environment variable points correctly to your folder.



Also, TRANSMISSION_WEB_HOME environment variable should be correctly set up to use the web browser interface.



To learn how to build transmission-daemon for Windows, read this post.

Saturday, August 21, 2010

Debian Linux: Simple steps to recover files from /lost+found

The following steps illustrate how one can use simple shell commands to recover files from the /lost+found directory in Linux. This assumes that you actually have some files in /lost+found.




  1. First, concatenate all the *.md5sums files in /var/lib/dpkg/info into a single file:


    cd /var/lib/dpkg/info
    cat *.md5sums | sort -k 2 > /tmp/all.md5


  2. Go to the /lost+found directory. fsck may have placed some files here after fixing the Linux partition. If you don't find any file here, you can relax and skip the following steps. Run md5sum on files in /lost+found.


    cd /lost+found
    md5sum * | sort > /tmp/lost.md5


  3. Put only the md5sum values into a temporary file, called 0.txt.


    awk '{print $1}' /tmp/lost.md5 > /tmp/0.txt


  4. Search all.md5 for the md5sum values in 0.txt and save the results in 1.txt.


    for f in $(cat /tmp/0.txt); do grep $f all.md5 >> /tmp/1.txt; done


  5. Put the names of files in /lost+found into a temporary fie 2.txt.


    awk '{print $2}' /tmp/lost.md5 > /tmp/2.txt


  6. Move the lost+found files to their original locations.


    cd /
    for $f in $(cat /tmp/2.txt); do MD5=$(grep $f /dev/shm/lost.md5 | awk '{print $1}'); ORIGIN=$(grep $MD5 /tmp/1.txt | awk '{print $2}'); mv /lost+found/$f /$ORIGIN; done

Monday, August 9, 2010

Tweaking Lenovo IdeaPad S12

I bought Lenovo IdeaPad S12 for $400. This little laptop has 12.1" display, VIA Nano processor, 1GB memory and 160GB hard drive. It's shipped with Windows XP, but I want to install Windows 7 alongside XP, so as to have a dual-boot system.



Shrinking the Recovery Partition


I booted IdeaPad S12 with my own Linux Live CD. In Xterm, I typed the following command:



fdisk -l -u /dev/sda


I got the following output.



Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xee8a96be

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 217909247 108953600 7 HPFS/NTFS
/dev/sda2 217909248 281638911 31864832 f W95 Ext'd (LBA)
/dev/sda3 281638912 312581807 15471448 12 Compaq diagnostics
/dev/sda5 217911296 281638911 31863808 7 HPFS/NTFS


The last primary partition /dev/sda3 seems to be Lenovo's recovery partition. I was able to boot the recovery partition with the following GRUB commands:



root (hd0,2)
chainloader +1
boot


Once I boot into Lenovo's OneKey Recovery System, I can use OneKey AntiVirus to scan the laptop for virus or use OneKey Recovery to restore the laptop to the factory state. I rebooted the laptop with my Linux Live CD. Then, I used GParted to shrink /dev/sda3 and changed its partition number to /dev/sda4:


  1. Shrink /dev/sda3 to 6 GB.
  2. Duplicate /dev/sda3 to a new primary partition /dev/sda4.
  3. Remove the partition /dev/sda3.
  4. Change the type of the new partition /dev/sda4 to 12.


After that, my partition layout looks like this:



Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0xee8a96be

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 217909247 108953600 7 HPFS/NTFS
/dev/sda2 217909248 281638911 31864832 f W95 Ext'd (LBA)
/dev/sda4 299997810 312576704 6289447+ 12 Compaq diagnostics
/dev/sda5 217911296 281638911 31863808 7 HPFS/NTFS


I restarted my laptop. I was able to boot Lenovo's OneKey Recovery System using the following GRUB commands.



root (hd0,3)
chainloader +1
boot


Moving Lenovo's pre-installed Windows XP to a logical partition


To reserve primary partitions for other crucial operating systems, I moved the Windows XP partition to the extended partition. This technique is explained in this post. Roughly speaking:



  1. Shrink the Windows XP partition (/dev/sda1) by half using GParted. Space is created between /dev/sda1 (Windows XP, type 7) and /dev/sda2 (extended, type f).
  2. Enlarge the extended partition (/dev/sda2) to the left. A space is created at the beginning of the extended partition.
  3. Make a copy of Windows XP partition in the space of the extended partition. The new partition will become /dev/sda6.
  4. Fix the partition numbers with fdisk (switching partition numbers of /dev/sda6 and /dev/sda5). Previously, /dev/sda6 came before /dev/sda5.
  5. Fix BOOT.INI of the new XP partition (/dev/sda5).
  6. Boot the new XP partition (/dev/sda5) in safe mode using GRUB or SYSLINUX. Change drive letters in the registry.
  7. Reboot Windows XP (/dev/sda5) normally and remove the old partition (/dev/sda1).


Starting Windows XP with SYSLINUX


Recently, I switched to SYSLINUX. I created a 100MB primary partition (/dev/sda1) formatted with FAT16. Then, in Linux, I installed SYSLINUX.


syslinux /dev/sda1

A new MBR had to be installed, too.


install-mbr /dev/sda -v --drive 0x80 --enable +14

I copied chain.c32 from the SYSLINUX package to the SYSLINUX partition (/dev/sda1). Then, I copied NTLDR, NTDETECT.COM and BOOT.INI to the SYSLINUX partition (/dev/sda1), too.


I created a text file named SYSLINUX.CFG with the following instruction.


TIMEOUT 30
DEFAULT chain.c32 ntldr=NTLDR

This will let you boot Windows XP in a logical partition.



Installing Programs on Windows XP


I removed the following programs from factory-installed Windows XP of Lenovo S12:


  • Symantec Norton Internet Security
  • Diskeeper
  • Veriface

Then, I installed the following software:


  • Avast Anti-virus
  • MyDefrag


Installing Windows 7 Home Premium


I created a new NTFS partition (/dev/sda2) using GParted. I set its bootable flag and hid all other FAT and NTFS partitions. Then, I installed Windows 7 Home Premium.


After that, I moved the Windows 7 partition into the extended partition as /dev/sda6. Then, I removed the original partition (/dev/sda2). I rebooted with Windows 7 installation DVD, clicked the Repair option and opened the Command Prompt. I typed the following commands to make the new Windows 7 partition bootable.


C:
bcdedit /store C:\Boot\BCD /enum
bcdedit /store C:\Boot\BCD /set {bootmgr} device partition=C:
bcdedit /store C:\Boot\BCD /set {default} device partition=C:
bcdedit /store C:\Boot\BCD /set {default} osdevice partition=C:

Then, I added the following entry to SYSLINUX.CFG.


LABEL win7
KERNEL chain.c32
APPEND hd0 6

To make sure that SYSLINUX can boot Windows 7, I typed the following command at the boot: prompt.


chain.c32 hd0 6

Now I am able to boot Windows 7 from a logical partition.



Booting Windows 7 with Software SLIC emulation


There are many ways to emulate SLIC so that Windows 7 can be activated. In my case, I've set up a boot sequence like this.


MBR -> SYSLINUX -> GRUB -> Windows 7

GRUB was patched for the loadslic command which is crucial for Windows activation. The SYSLINUX command to invoke GRUB is like this.


chain.c32 grub=stage2 grubcfg=(hd0,0)/win7.cfg

Then, I created a file WIN7.CFG with the following contents.


hiddenmenu
timeout 0
default 0

title Windows 7 Home Premium
loadslic (hd0,0)/lenovocb-01.bin
chainloader (hd0,5)+1

About This Blog

KBlog logo This blog is about current events and issues concerning general population. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

icon
Powered By Blogger