Archive for the ‘Linux’ Category

[Linux] Ext3 partition detected wrongfully as ext4

November 14, 2008
Oh No!

Recently, A partition on my backup harddrive was corrupted. It was i was clueless how it had happened. further, now the partition was refusing to mount and it was being detected as ext4.
I tried mounting is manually:

gaurish  ~  $   sudo mount /dev/sdb6 /media/fl/
mount: unknown filesystem type 'ext4'

Dmesg said

EXT3-fs: sdb6: couldn’t mount because of unsupported optional features (ca9bc1e0).”

I was not sure what to do next
So i cried for help on various online Forums[1][2][3] but all in waste.
After that i got pissed off and decided to take matter into my own hands and starting reading on how Partitions in linux are made etc. Then i came to know about superblock.
Bingo!, i had a bad superblock.
Here is a Quick Procedure to recover from a bad super block(read nightmare)
Open Terminal and type the following commands:
1) see backup superblock location

~ $ dumpe2fs /dev/sdb6 | grep -i superblock

Output:
dumpe2fs 1.41.3 (12-Oct-2008)
Primary superblock at 0, Group descriptors at 1-2
Backup superblock at 32768, Group descriptors at 32769-32770
Backup superblock at 98304, Group descriptors at 98305-98306
Backup superblock at 163840, Group descriptors at 163841-163842
Backup superblock at 229376, Group descriptors at 229377-229378
Backup superblock at 294912, Group descriptors at 294913-294914
Backup superblock at 819200, Group descriptors at 819201-819202
Backup superblock at 884736, Group descriptors at 884737-884738
Backup superblock at 1605632, Group descriptors at 1605633-1605634
Backup superblock at 2654208, Group descriptors at 2654209-2654210
Backup superblock at 4096000, Group descriptors at 4096001-4096002

2) Run Fsck with Alternative Superblock

$ sudo fsck -b 32768 /dev/sdb6
fsck 1.41.3 (12-Oct-2008)
e2fsck 1.41.3 (12-Oct-2008)
/dev/sdb6 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #12 (30380, counted=30381).
Fix? yes

Free blocks count wrong for group #127 (15027, counted=5927).
Fix? yes

Free blocks count wrong (10539272, counted=10530173).
Fix? yes

Free inodes count wrong for group #116 (32732, counted=32729).
Fix? yes

Free inodes count wrong (24812957, counted=24812954).
Fix? yes

/dev/sdb6: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sdb6: 934/24813888 files (6.2% non-contiguous), 14282211/24812384 blocks

3) Done! Partition is successfully recovered and data is safe. now we can mount it normally.

$ sudo mount /dev/sdb6 /media/test

Now, After this incident i have to rethink my backup strategy, which till now have been reply solely on HDDs as backup medium.
Comment & Suggestions are welcome 🙂

Advertisements

Dummies Guide to Scheduling Downloads(Linux Version)

October 2, 2008

Linux is a stable OpenSource Operating system.It has a ability to run for long hours and crashes are rarely seen.On top of it, it has a inbuilt scheduler which is robust and  it never misses tasks. All this Characteristics make Linux a perfect choice for downloading. Yeah almost perfect choice (discussed later).
In This Guide we would learn how to smartly schedule downloads. This way files would be automatically downloaded while you sleep. This Guide is mainly for BSNL/MTNL broadband subscribers. I have Tried to prescribe a general procedure which is applicable on all major Distributions.so distribution specific goodies are not discussed here.

Mainly there are two mode of this, you need to pick a method which applies to you.

  • Router Reboot method: Suitable when your connection is configured as always-on and router is PPPoE mode. so you don’t need to dial your connection every time you connect to Internet. it works with selected routers which supports telnet connectivity.Dependant upon routers.
  • Bridge Mode: Suitable when you dial to connect to Internet using a Dialer program on your PC. in this setting your PC is in Bridge mode.it works with every router.
Understanding Cron Daemon
Before we begin we should know how about cron – default linux scheduler
Cron Daemon is a default scheduler for Linux based systems.Cron Daemon is  responsible for scanning the crontab files and running the commands at the appropriate time. It always runs in background, wakes up every minute to check for any scheduled taks pending for execution. then it executes them and goes back to sleep.

Crond reads tasks from crontab, anything you write in your crontab with proper syntax will be read & excuted by crond. Crontab as name suggests, is basically a file where sheduled tasks are arranged in tabular forum.The syntax of crontab is fairly simple.

Minutes Hours Day Month Day of the month command
enter the minutes part of time, legal values 0-60 Enter the hours, in 24hr format. legal values 0-24 Enter the Day number starting from Monday, legal values 0-7 Enter the month,legal values 1-12 Enter a Date, legal values 1-31 Command you want to execute at scheduled time

use command “visudo” to edit crontab.it would load a editor depending upon your $EDITOR variable. on Ubuntu you would get nano
how to use nano(easy)
how to use vi (advanced)

Things Which are common among both methods

1) Create a simple text file in your home folder and name it “downloads.txt” & notedown its full path. Insert the *Direct* links of files you want to download into this newly created file. The files given in this would be downloaded by wget automactically.wget can handle http & ftp downloads. After download completes remove the link and enter new ones. insert one link per line. Remember to add direct link only.

2) If you use torrents, install your torrent client and notedown its full path to its binary. you can use “whereis” command to find its exact location. generally its /usr/share/sbin. If you are looking for worthy torrent clients, look for deluge or azurus now vuze

Router Reboot Method

1) I wrote a simple Shell script for rebooting router. it works nicely on D-link GLB 502T. although you may need to change userid,password & command values.copy paste this script in a file and save it as router-reboot.sh. make it excutable by

chmod a+x router-reboot.sh

#!/bin/sh
#############################################
#Script Written By Gaurish Sharma                                           
#change the password,userid & command values with your own set
#the default password & username
# in most cased is 'admin'                         
#use it in terminal as sh router-reboot.sh | telnet                       
#(C) GaurishSharma.com
#############################################
add='open 192.168.1.1'
userid='root'
password='your_passoword'
command='reboot'
echo $add
sleep 1
echo $userid
sleep 1
echo $password
sleep 1
echo $command
sleep 1

2) Open Terminal and enter “crontab -e”. enter the following in your crontab and save it

# m h  dom mon dow   command
# Reboot Entry, please replace with correct path
10 2 * * * cd /home/gaurish/scripts && sh router-reboot.sh | telnet
# Start Torrent client, please replace with correct path of your router
12 2 * * * DISPLAY=:0.0 /opt/azureus/azureus
# Downloads via wget, Please replace with corrent path
13 2 * * * wget -ci /home/gaurish/downloads.txt
# Reboot Entry, please replace with correct path
50 7 * * * cd /home/gaurish/scripts && sh router-reboot.sh | telnet

3) Now we need to enter command to shutdown computer everyday at 7.51AM.this only can be done via root user. so now the enter command as “sudo crontab -e” and Insert this line.

50 7 * * * /sbin/shutdown -h 0

4) (Optional) you can install mailx package to see the log of what happened while you were sleeping

Bridge Mode

1) we would be using default command which you use to dial to internet. on most cases its pon dsl-provider for connectinig and poff for disconnection . in case the command are diffrent on your machine please replace them.

2) Open Terminal and enter “crontab -e” now paste the following in it

# m h  dom mon dow   command
# Start Torrent client, please replace with correct path of your torrent program
10 2 * * * DISPLAY=:0.0 /opt/azureus/azureus
# please replace with correct path of download.txt
13 2 * * * wget -ci /home/gaurish/downloads.txt

3) Now we need to use root crontab, use “sudo crontab -e” to access it.

10 2 * * *  /usr/bin/pon dsl-provider
49 7 * * * /usr/bin/poff
50 7 * * * /sbin/shutdown -h 0

4) (Optional) you can install mailx package to see the log of what happened while you were sleeping.

What you are missing in Linux, comparing to windows?
In starting of this post i said,  almost perfect choice for downloading. so you gotta missing something. which is ability to power on your PC automatically.
I am still searching for a method to start a Linux box automatically at a specific time.
As a workaround you can do the same thing via your BIOS, but a limited no of BIOS support this. so either leave your machine running with monitor turn off or use the BIOS trick.

Related Posts: 

ArchLinux: Stop dhcp from overwriting resolv.conf(Linux Only)

September 20, 2008

Here is a Quick tip for people using Archlinux:

Sometimes we don’t want dhcpcd overwriting our resolv.conf anymore, since it is customized. We do, however, want dhcpcd to continue to automatically set out IP, default gateway, et cetera. To cause this effect we will edit /etc/conf.d/dhcpcd as root, with our favorite editor. The directive we are looking for is DHCPCD_ARGS and by default that directive should look like the following figure:

 
DHCPCD_ARGS="-t 30 -h $HOSTNAME"

To that directive, add the -R flag. Your directive line should look something like the following figure:

DHCPCD_ARGS="-t 30 -h $HOSTNAME -R"

Taken from Archwiki

Ubuntu Linux as Family PC

July 10, 2008
We know Linux is a operating system where everything can be customized as tag line for linux is “Linux – We Have a Choice”. this way a person can get a tailor made working environment which does all the tasks in his/her way, he can schedule his daily encoding & downloading tasks,made custom keyboard shortcuts for his most used function.

This generally suits a single user Pc, but what about a system used by many persons in a single user account?, for them we need some customisations that does not need any prior expriance & comouter could be operated by use of common sense. now you would ask why use a single user account?, why not create accounts for every user. here are the reasons:-

* It would require you to always log-on & log-off every now, which requires you to restart all your running applications. For example:while you are burning a DVD, your dad needs to check a important e-mail from his boss. his E-mail is configured on Evolution(default mail client for ubuntu), so he has to login his account and check email whereas you can’t logoff as basaro can’t be stopped in the middle.
how convient it would have been if there was a single user account which would be suitable for all.

* Remembering Userid & passwords is also a big project. we already have bank a/c,ATM pin,login details at work,internet banking userid & passwords and tons of other such details. who add one more to the never ending list?

Question :
How to Manage a single user account which suits everyone in your family

Ans:
Manage Thundebird & Firefox using Profile Manager
Mozilla applications store your personal settings, added extensions and themes, and user data such as bookmarks, passwords, cookies and mail in a “profile”. The Profile Manager allows you to create and manage profiles. With a new profile the application will run without any extensions, themes, or customized settings that may be causing problems, but you can still import your data from another profile or switch back to a previous profile.
More Details

<Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically each day to your feed reader. If you don’t have a feed reader, you can always have these articles delivered to your email inbox every day. Click here to sign up.