Hardcore Linux

Anything about Ubuntu, Centos, openSuSe and Fedora

Category Archives: Device

Fix for Elantech touchpad on Ubuntu 14.04

Since I recently got my new Lenovo G5070 notebook few days ago, I rush in to install second OS : Ubuntu 14.04, though installation process is tough, need to fix video card defaults, from fgrlx to intel graphics. Then another issue is wireless network RTL8723BE drops after each connection, but this article is about the touchpad: the ElanTech Touchpad, which by default not functioning well. Issues like there’s no switch off touchpad option in Ubuntu settings, multi-touch is not working, neither the scrolling.

Now to fix this issues, here’s the guide:

1. First, download the patch for the touchpad here.

2. Install dkms (if you haven’t done it yet)

sudo apt-get install dkms

3.  Go to the directory where you store the file and perform the following:

sudo dkms ldtarball psmouse-elantech-x551c.tar.gz
sudo dkms install -m psmouse -v elantech-x551c

4. Then reconfigure the driver

sudo rmmod psmouse
sudo modprobe psmouse
sudo update-initramfs -u -k all

5. Done


Ubuntu 11.04 Shutdown and Restart Problem with CIFS

UPDATE(07/29/2011): The GRUB thing didn’t work at all, back to basic trapping signal via upstart scripts in /etc/init/dbus.conf.  I tried it before using /etc/init/network-manager.conf but on Ubuntu 10.10, it’s not working anymore. Here’s another test and works for me.

1. Modify the current /etc/init/dbus.conf.

$> sudo vi /etc/init/dbus.conf

2. Add a pre-stop script, which looks like this:

pre-stop script
       trap "TERM signal" TERM
      /bin/umount -a -t cifs -l -f
      trap - TERM
end script 

3. Save the script and have a test.

4. Done.

UPDATE(07/28/2011): Found a better alternative via GRUB, link here. Mainly you just need to modify the  /etc/default/grub. Here’s the details:

1. Edit the /etc/default/grub

$> sudo vi /etc/default/grub

2. Add “reboot=pci” on the GRUB_CMDLINE_LINUX line, it should look something like this:

... GRUB_CMDLINE_LINUX="reboot=pci" ...

3. Update the grub

$> sudo update-grub


4. Done


It’s an ancient bug (here), which still exist in Ubuntu 11.04, or even in other distros. When you got a mounted samba shares before the shutdown or restart process, the machine waits for around 10 minutes before it complete the operation. Very troublesome that’s why I tried various workaround but none of them  works with Ubuntu 11.04. Not even the /etc/rc6.d/K*  or the upstart /etc/init configurations, nor the old python script I posted before (here’s the link).

After few considerations, I made a desperate workaround, creating a script that triggers before the /sbin/shutdown, /sbin/reboot and /sbin/restart commands.

1. Rename the current shutdown, reboot and restart commands in /sbin.

#> mv /sbin/shutdown /sbin/shutdown2
#> mv /sbin/reboot /sbin/reboot2
#> mv /sbin/restart /sbin/restart2 

2. Then create scripts with names of the previous commands in /sbin, which contains the following:

umount -t cifs -a -f -l
/sbin/shutdown2 $@
exit 0 

3. Make similar script for reboot and restart command which also points to /sbin/reboot2 and /sbin/restart2.

4.  Until the dbus implementation of stop on deconfiguring-networking comes to Ubuntu 11.04, which I think working with
Ubuntu 11.10 oneiric. I think this is the least workaround that works for me.

5. Done

Recover Deleted or Corrupted Files in Linux

In most cases, the data stored in your memory cards or USB drives likely being corrupted and there are some files you accidentally deleted and removed in trash. Fear not, there is another chance to recover them back again.

I tried scalpel but didn’t work our right, then tried foremost, and it works like a charm. I’ve been always a victim of corrupted memory cards every time I extracted or deleted something using memory card readers or even using the delete utility of my digital camera.

Well, here’s the basic command to recover things in your memory cards  or USB thumb drives.

1. First, install foremost

$> sudo apt-get install foremost

2. Then, determine the target device, mines is /dev/sdb1

$> sudo fdisk -l

3. Finally, issue the foremost command\

$> sudo foremost -t all -i /dev/sdb1 -o output_dir

4. Done

UDEV: Mount and Unmount External Drive

I got three sets of USB External Hard Drive I’m using for my system backup. Need it to have a hotplug capability to have multiple copies of backup. The backup operations are done midnight of the schedule date.

Here’s my list:

  1. Daily Backup – two (2) sets of hard drive of 500GB
  2. Weekly Backup – two (2) sets of hard drive with capacity of 1TB
  3. Monthly  Backup one (1) set capacity of 1TB

The previous problem I’ve encoutered is that I need to manually mount them as:


My backup script tend to use them on that location. So I made this udev script that will fix them and automatically mount and umount them. Though the umount should be safely done, but in case you forgot to umount the drive, the script will umount them for you.

Here’s my /etc/udev/rules.d/10-backupdrives.rules

ACTION=="add",KERNEL=="sd[b-z][1-9]", PROGRAM="/sbin/blkid -s LABEL /dev/%k",RESULT=="*BACKUPD*", RUN+="/bin/mount /dev/%k /backup/daily",OPTIONS="last_rule"
ACTION=="add",KERNEL=="sd[b-z][1-9]", PROGRAM="/sbin/blkid -s LABEL /dev/%k",RESULT=="*BACKUPW*", RUN+="/bin/mount /dev/%k /backup/weekly",OPTIONS="last_rule"
ACTION=="add",KERNEL=="sd[b-z][1-9]", PROGRAM="/sbin/blkid -s LABEL /dev/%k",RESULT=="*BACKUPM*", RUN+="/bin/mount /dev/%k /backup/monthly",OPTIONS="last_rule"
ACTION=="remove",KERNEL=="sd[b-z][1-9]",RUN+="/bin/umount /dev/%k",OPTIONS="last_rule"

Backup Whole System via Network.

You could easily perform a full backup or even store a system into a raw image which can be used in as guest machine in KVM. This takes couples of hours (depends on the size of the source linux system).

Here’s how:

  1. From the target machine, you can either boot via a LiveCD or a rescue linux distro such as SystemRescueCD and via the console, check if it can detect your currently attached storage device.
    #> fdisk -l
  2. If it sees your hard drive  you can now perform the  arbitrary TCP/UDP connections and listens to port 12345.
    #> nc -l 12345 | dd of=/dev/sda
  3. In the source machine, you can know execute the command:
    #> dd if=/dev/sda | nc 12345
  4. Take note of the <port> 12345  and the <target IP> I used in the example.
  5. You can also store the dump in a raw image using this command:
    #> nc -l 12345 | dd of=myimage.img
  6. Done.

CUPS not running on boot (Ubuntu 10.04)

After the excitement of installing the new Ubuntu 10.04 to our test workstation. I’ve encountered this CUPS problem, the service is not automatically or faulty started  during the boot sequence. Even though I already fixed the problem, still have no clue what exactly causes it.

Here’s how:

1.  Reinstall cups package.

$> sudo apt-get install --reinstall cups

2.  Done.

Intel 5100 AGN on Ubuntu 10.04

For me this is a critical bug, because I’m frequently using my Lenovo SL400 on wireless networks. The problem is related to Intel 5100 AGN on Ubuntu 10.04. It connects fine on the start but degrades until it eventually disconnects to the wireless access point. Sometimes I have to reboot to be able to connect to the wireless network again. I’ve been experiencing this  until I’ve found this workaround (click here).

Here’s the fix (But it’s very ugly):

1. Create a new modprobe configuration, let’s call it options.conf

$sudo vi /etc/modprobe.d/options.conf

2. Add the following code:

options iwlagn 11n_disable=1 11n_disable50=1

3. Reboot the system and check if it fixes your Intel 5100 AGN wireless device’s problem.

4. Done.

Fake Webcam in Ubuntu / Linux

In windows, there are various program that can stream video loopback and act as a camera or webcam. In Linux previously you can use AVLD and Vloopback, but I’m having trouble compiling them using kernel 2.6.31 on Karmic (Ubuntu 9.10). But luckily, I’ve found this great tool which is much better then the previous, it’s called WebCamStudio .

Here’s an excerpt from sourceforge.net info.

“WebcamStudio helps you create a virtual webcam that can show: – Your webcam that won’t work with Flash site – Your desktop with your webcam in overlay – Your desktop/webcam with several video effects – You in all your glory! Compatible with Flash sites!”

It’s easy to use and very user-friendly.


Lenovo Brightness Key (Fn+Up/Down) Fix in Ubuntu 9.10

Recently I’ve discovered that my Lenovo G410’s  Brightness key (Fn + Up / Down) is not working in Ubuntu 9.10 which is previously fine in 9.04, and found out that there are various fix but the easiest is as follows:

1.  Modify your  grub.cfg

sudo vi /boot/grub/grub.cfg

2. Add  the word “nomodeset” on the end of the kernel options.

linux   /boot/vmlinuz-2.6.31 ...  quiet splash nomodeset

3. Then save the file and reboot the system.

4. Done.

Recover data from a RAID partition

Raids and LVM  are very vital to a Linux server, but then again it’s one hell of a complex step recovering data from a crashed linux system. In this tutorial, I’ll try to help you recover your data on a RAID partition.

But first, let me discuss the tool I’ll be using, for this tutorial, I will use SystemRescueCD, a gentoo-based system recovery distro which for me is the far easiest tool in recovering crashed system. So back to our topic, here’s how:

1. After a clean boot on your SystemRescueCD liveCD, create your /etc/mdadm.conf

mdadm --examine --scan /dev/sda1 >> /etc/mdadm/mdadm.conf

2. Check your /etc/mdadm/mdadm.conf , it must contains something like this:

ARRAY /dev/md0 level=raid1 num-devices=2 UUID=a28090aa:6893be8b:c4024dfc:29cdb07a

3. On the last part of that line, add the following:

ARRAY /dev/md0 level=raid1 num-devices=2 UUID=a28090aa:6893be8b:c4024dfc:29cdb07a devices=/dev/sda1,missing

The string /dev/sda1 is the hardware device and missing means that the second disk in this RAID array is not present at the moment.

4. Now, start your raid setup

/etc/init.d/mdadm start
/etc/init.d/mdadm-raid start

5. Check if the device is properly configured.

cat /proc/mdstat

It should contain something like this:

md0 : active raid1 sda1[1]

6. If from the raid setup, then the inner filesystem is ext3, then you just need to mount it to a temporary directory

mount /dev/md0 /mnt/recover

7. Done.

smb://rnartos@server/scan/uicscn4182.pdf mdadm –examine –scan /dev/hda1 >> /etc/mdadm/mdadm.conf
%d bloggers like this: