Finding Interface Name Using IP Address

Tags: April 23, 2014 7:47 AM
0 comments

Getting network interface name using IP address could be accomplished by issuing:

$ ip addr show | grep "192.168.1.2" | awk '{print $7}'
or another alternative:
ifconfig | grep -B 1 "192.168.1.2" | head -n1 | awk '{print $1}'
Both command would output the name of interface such as eth0, eth1, etc.

Reference

Share on Facebook Twitter

Fix LVM Input/Output Error Caused by Node Change

Tags: April 13, 2014 8:42 AM
0 comments

I have LVM partition reside on my external hard drive which connected trough USB. Here's the output before I unplug the device.

$ pvs
  PV               VG    Fmt  Attr PSize   PFree  
  /dev/maxtor1-40g       lvm2 a-    37.27g  37.27g
  /dev/sde5        XENVG lvm2 a-   125.78g 121.78g
When I unplug and plug the device I always got I/O error like this:
$ pvs
  /dev/dm-0: read failed after 0 of 4096 at 0: Input/output error
  /dev/dm-0: read failed after 0 of 4096 at 4294901760: Input/output error
  /dev/dm-0: read failed after 0 of 4096 at 4294959104: Input/output error
  /dev/dm-0: read failed after 0 of 4096 at 4096: Input/output error
  PV               VG    Fmt  Attr PSize   PFree  
  /dev/maxtor1-40g       lvm2 a-    37.27g  37.27g
  /dev/sdd5        XENVG lvm2 a-   125.78g 121.78g
Well that sucks since it would become unmountable. The LVM still pointing to the old /dev/sde5 that's why the error comes.

Share on Facebook Twitter

Mapping Device to Persistent Name Using udev

Tags: April 12, 2014 11:38 PM
0 comments

To prevent device name changes from time to time i.e: /dev/sdc to /dev/sdd and so on a corresponding udev rules need to be created. The first step to dive into udev configuration is getting information from the device.

Getting Device Information

In this example I have Seagate 250GB hard drive which connected through USB. The device is currently attached to /dev/sdd. Here's how to get information from the device. All commands are run by root.

Share on Facebook Twitter

Linux Show Selected Route for Particular IP Address

Tags: April 8, 2014 11:11 AM
0 comments

When having multiple gateway it is very useful know which route is used by particular address. So we can know if the routing is work as expected. For this task we can use ip route get command.

Show Selected Route for particular IP

ip route get 8.8.8.8
8.8.8.8 via 192.168.42.129 dev usb0  src 192.168.42.243 
    cache

Share on Facebook Twitter

Backup Partition Using dd on Linux

Tags: 10:46 AM
0 comments

If you want backup entire partition the dd is a very handy tool. It let you create a snapshot of the partition and quickly restore it if you need to. No need to worry about timestamps, ownership, permissions, links, etc.

Backup a Partition (Snapshot)

Make sure the partition is offline or you'll end up with inconsistent result. If it is root partition then you may want to boot via rescue disk and making the backup. Below is an example I'm taking snapshot of my 4GB USB pendrive, the location of the USB pendrive is on /dev/sdc1.

Share on Facebook Twitter