Pages

Tuesday, September 23, 2008

Formating a undetectable flash drive

Here some more recent RnD done on one of flash drive of friend - Rishit. He was about to dump harddisk data to professional data recoverer.. Eventually settled down on party ;-)

A Transiant flash drive of 120GB space, which was undetectable on WindowsXp.
Condition :
  • Drive undetected on Windows
  • Mounted on Linux-FC6, but could not delete dirty partition sectors
  • Nor move corrupted data to other location.
  • Drive was almost in condition to dump


===========================================
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
23520588 20259704 2046832 91% /
/dev/sda3 101105 16544 79340 18% /boot
tmpfs 512748 0 512748 0% /dev/shm
/dev/sda2 30701264 25927728 4773536 85% /home/mahendra/D_drive
/dev/sda1 20972824 15270744 5702080 73% /mnt/c
/dev/sdb1 117218240 3006620 114211620 3% /media/Rishit Shah
[root@localhost ~]# mkfs /dev/sdb1
mke2fs 1.39 (29-May-2006)
/dev/sdb1 is mounted; will not make a filesystem here!
[root@localhost ~]# mkfs -t vfat /dev/sdb1
mkfs.vfat 2.11 (12 Mar 2005)
mkfs.vfat: /dev/sdb1 contains a mounted file system.
[root@localhost ~]# mkfs -t vfat /dev/sdb1
mkfs.vfat 2.11 (12 Mar 2005)
mkfs.vfat: /dev/sdb1 contains a mounted file system.
[root@localhost ~]# mkfs /dev/sdb1
mke2fs 1.39 (29-May-2006)
/dev/sdb1 is mounted; will not make a filesystem here!
===========================================

[root@localhost ~]# fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2611 20972826 7 HPFS/NTFS
/dev/sda2 2612 6435 30716280 c W95 FAT32 (LBA)
/dev/sda3 6436 6448 104422+ 83 Linux
/dev/sda4 6449 9729 26354632+ 5 Extended
/dev/sda5 6449 9729 26354601 8e Linux LVM

Disk /dev/sdb: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 14593 117218241 7 HPFS/NTFS
[root@localhost ~]# fdisk /dev/sd
sda sda1 sda2 sda3 sda4 sda5 sdb sdb1
[root@localhost ~]# fdisk /dev/sdb1

The number of cylinders for this disk is set to 14592.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb1: 120.0 GB, 120031478784 bytes
255 heads, 63 sectors/track, 14592 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

This doesn't look like a partition table
Probably you selected the wrong device.

Device Boot Start End Blocks Id System
/dev/sdb1p1 ? 13578 119522 850995205 72 Unknown
Partition 1 does not end on cylinder boundary.
/dev/sdb1p2 ? 45382 79243 271987362 74 Unknown
Partition 2 does not end on cylinder boundary.
/dev/sdb1p3 ? 10499 10499 0 65 Novell Netware 386
Partition 3 does not end on cylinder boundary.
/dev/sdb1p4 167628 167631 25817+ 0 Empty
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Partition number (1-4): 2

Command (m for help): d
Partition number (1-4): 3

Command (m for help): d
Selected partition 4
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

===========================================
Tried deleting all partitions but w command in fdisk dosnt work. Its bad man.

[root@localhost ~]# mkfs.vfat -F 16 /dev/sdb1
mkfs.vfat 2.11 (12 Mar 2005)
mkfs.vfat: /dev/sdb1 contains a mounted file system.

Final try for umounting & then formating the drive

umount -f /dev/sdc1
[root@localhost ~]# mkdosfs -F32 -I /dev/sdc1
mkdosfs 2.11 (12 Mar 2005)
[root@localhost ~]#



Wow !!! I removed the drive & reconnected

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
23G 20G 2.0G 91% /
/dev/sda2 30G 25G 4.6G 85% /home/mahendra/D_drive
/dev/sda3 99M 17M 78M 18% /boot
tmpfs 501M 0 501M 0% /dev/shm
/dev/sda1 21G 15G 5.5G 73% /mnt/c
/dev/sdc1 112G 16K 112G 1% /media/disk-1

It works !


Thursday, September 18, 2008

Remote Printer on Linux - FC6

Had encounter with printer configuration on Dell laptop. I did it myself as we had no system admin for linux

Lets see how we can install/config remote printer :
  1. Make sure cup daemon is running
  2. /etc/init.d/cups restart , u can check by ps -eaf | grep cup
  3. Add printer from System-->Administration-->printing
  4. Select valid driver/model. General linux printer driver list/ dtd file list comprise most of standard printers. If some printer name is not available, select closed cousin of it. Eg HP Deskjet 5500 is not present in FC6, select Deskjet 3300. It works !
  5. Select host-name (ip addr) of printer machine. Put port 9100 as its default port.
  6. Device URL should look like socket://<-ip->:9100
  7. Do finish once u see correct URL.
  8. Try printing test page
  9. Wow ! It works!!!
First time opening printer adding wizard may hang your machine. May be due to huge resource use.

I got +ve results on FC6 on Dell D520 and CentOS 5.0 on Dell D630

Problems welcome !!!


Monday, September 15, 2008

Thunderbird mail backup/moving/shifting to other machin

Hi All,

Another post to save your mails.

Mozilla - Thunderbird always get installed at its location but keeps mails & configs in user's home.

On Linux/Unix system :
/home/mahendra/.thunderbird

while on windows :
C:\\Document & Se...\mahendra\.Thunderbird\

structure in /home/mahendra/.thunderbird :
[mahendra@localhost .thunderbird]$ pwd
/home/mahendra/.thunderbird
[mahendra@localhost .thunderbird]$ ls -1
17jgza7q.default
appreg
profiles.ini
[mahendra@localhost .thunderbird]$
17jgza7q.default is directory for default mail address.

[mahendra@localhost .thunderbird]$ cd 17jgza7q.default/
[mahendra@localhost 17jgza7q.default]$ ll
total 5936
-rw-rw-r-- 1 mahendra mahendra 0 Apr 14 15:39 abook-1.mab
-rw-r--r-- 1 mahendra mahendra 202839 Sep 15 17:29 abook.mab
-rw-r--r-- 1 mahendra mahendra 248 May 28 11:22 blocklist.xml
-rw------- 1 mahendra mahendra 65536 Sep 15 11:17 cert8.db
-rw------- 1 mahendra mahendra 144 Apr 7 10:33 compatibility.ini
-rw-rw-r-- 1 mahendra mahendra 169297 Apr 7 10:34 compreg.dat
-rw------- 1 mahendra mahendra 235 Aug 22 2007 cookies.txt
-rw-r--r-- 1 mahendra mahendra 4118 Sep 15 15:55 downloads.rdf
drwxr-xr-x 6 mahendra mahendra 4096 Jan 24 2008 extensions
-rw-r--r-- 1 mahendra mahendra 604 Apr 7 10:34 extensions.cache
-rw-r--r-- 1 mahendra mahendra 527 Apr 7 10:34 extensions.ini
-rw-r--r-- 1 mahendra mahendra 8889 Apr 7 10:34 extensions.rdf
-rw-r--r-- 1 mahendra mahendra 1438 Aug 20 2007 history.mab
drwxr-xr-x 3 mahendra mahendra 4096 Aug 20 2007 ImapMail
-rw------- 1 mahendra mahendra 16384 Sep 15 11:17 key3.db
-rw-r--r-- 1 mahendra mahendra 33265 Sep 15 17:29 localstore.rdf
lrwxrwxrwx 1 mahendra mahendra 15 Sep 15 11:22 lock -> 127.0.0.1:+6722
drwxr-xr-x 5 mahendra mahendra 4096 May 27 18:29 Mail
-rw-r--r-- 1 mahendra mahendra 477 Jan 17 2008 mailViews.dat
-rw-r--r-- 1 mahendra mahendra 8161 Jul 22 13:05 mimeTypes.rdf
-rw-r--r-- 1 mahendra mahendra 46531 Sep 15 17:52 panacea.dat
-rw-r--r-- 1 mahendra mahendra 45 Aug 7 20:11 persdict.dat
-rwxr-xr-x 1 mahendra mahendra 14641 Sep 15 11:17 prefs.js
-rw------- 1 mahendra mahendra 16384 Jan 17 2008 secmod.db
-rw------- 1 mahendra mahendra 269 Jul 21 11:26 signons.txt
-rw-r--r-- 1 mahendra mahendra 18922 Aug 29 16:39 training.dat
-rw-r--r-- 1 mahendra mahendra 0 Aug 20 2007 urlclassifier2.sqlite
drwxr-xr-x 2 mahendra mahendra 4096 Aug 20 2007 US
-rw-r--r-- 1 mahendra mahendra 10 Sep 15 11:17 virtualFolders.dat
-rw-r--r-- 1 mahendra mahendra 1083041 Feb 28 2008 XPC.mfasl
-rw-rw-r-- 1 mahendra mahendra 109260 Apr 7 10:34 xpti.dat
-rw-r--r-- 1 mahendra mahendra 4144667 Sep 2 18:23 XUL.mfasl



Actual mails are present in :
/home/mahendra/.thunderbird/17jgza7q.default/Mail/Local Folders


Whenever u want to change the machine/laptop OR want to backup state of mails at that pertucular time. Zip the /home/mahendra/.thunderbird/17jgza7q.default/Mail and save it to backup locations.

To replicate the mails on other machine. Install Thunderbird & unzip the Mail folder at same location.
Similar stuff is also possible for other Mozilla products like Firefox...
Addons, Plug-ins , bookmarks can be saved in similar fashion.

C U :)

Friday, September 12, 2008

Twittering with world!!

We would always love to be in touch with all. Here is the asap way to be updated & to update other about what you are doing?

Yes. I'm talking about "Twitter" with Widset http://www.widsets.com/

I 've been using Widset from last 2 months. It been always in very frequently used programs.

My updates : http://twitter.com/mahenT
Somemore details http://friendfeed.com/mahent

I'm sure you 'll love to be connected & updated with your mobile phone. :)
There 1000 things u can do with your widset. You can create own widset, rss feed reader, whether updates, games, list is huge....

Wednesday, September 10, 2008

SSH connection reuse

It really speedup my ssh connection & never prompt passwd for second connection to same host.
Very handy to use.

Open ~/.ssh/config file (ssh client configuration file). If you need system wide settings add to /etc/ssh/ssh_config file:
$ vi ~/.ssh/config
Append following code to reuse ssh connection for all hosts:

host *
controlmaster auto
controlpath /tmp/ssh-%r@%h:%p

Where,

  1. controlmaster auto: Set controlmaster to auto
  2. controlpath /tmp/ssh-%r@%h:%p: Specify the path to the control socket used for connection sharing. In the path, ‘%h will be substituted by the target host name, %p the port, and %r by the remote login username. It is recommended that any ControlPath used for opportunistic connection sharing include at least %h, %p, and %r. This ensures that shared connections are uniquely identified.

You can also match any host in the 192.168.0.[0-9] network range with following pattern:

Host 192.168.0.?
controlmaster auto
controlpath /tmp/ssh-%r@%h:%p

For any host in the ".co.in" set of domains, reuse the connection:

Host *.co.in
controlmaster auto
controlpath /tmp/ssh-%r@%h:%p

Save and close the file. Now connect as usual,
$ ssh vivek@vpn.nixcraft.co.in
Next, time you connect again it will use connection socket /tmp/ssh-vivek@vpn.nixcraft.in:22 to speed up things. You don't have to input password or anything else. You need one connection to be active for the second to be accelerated. This also works with scp / sftp etc:
$ scp /path/to/file.txt vivek@vpn.nixcraft.co.in:/tmp


Welcome if still its not working on your machine.


You can have ~/.ssh/config file configured as
===============================================

host lin
hostname 172.16.13.20
user root
port 22

host Lin
hostname 172.16.13.20
user mahendra
port 22

host *
controlmaster auto
controlpath /tmp/ssh-%r@%h:%p

===============================================

Comments welcome !!!

Friday, September 5, 2008

Getting Hardware information without opening Box on LInux

With Linux- FC6 running on Dell machine, How can I get hardware info of my machine?

"dmidecode " is the key command to fetch such info.

Command is readily available on most of Linuxes

Here is some more details on same command :
-t, --type TYPE
Only display the entries of type TYPE. TYPE can be either a DMI type number, or a comma-separated of type numbers, or a keyword from the following list: bios, system, baseboard, chassis, pro cessor, memory, cache, connector, slot. Refer to the DMI TYPES section below for details. If this option is used more than once, the set of displayed entries will be the union of all the given types. If TYPE is not provided or not valid, a list of all valid keywords is printed and dmidecode exits with an error. Mutually exclusive with --string.

[root@localhost drive_c]# dmidecode -t1
# dmidecode 2.7
SMBIOS 2.4 present.

Handle 0x0100, DMI type 1, 27 bytes.
System Information
Manufacturer: Dell Inc.
Product Name: Latitude D520
Version: Not Specified
Serial Number: DV9SQ1S
UUID: 44454C4C-5600-1039-8053-C4C04F513153
Wake-up Type: Power Switch
SKU Number: Not Specified
Family:


We can use type in below format :
Type Information
----------------------------------------
0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply

Keywords can be used instead of type numbers with --type. Each keyword is equivalent to a list of type
numbers:

Keyword Types
------------------------------
bios 0, 13
system 1, 12, 15, 23, 32
baseboard 2, 10
chassis 3
processor 4
memory 5, 6, 16, 17
cache 7
connector 8
slot 9

Keywords are matched case-insensitively. The following command lines are equivalent:

· dmidecode --type 0 --type 13

· dmidecode --type 0,13

· dmidecode --type bios

· dmidecode --type BIOS



Here is some more command info , very frequently used :

top - I guess u know ;)
vmstat - Virtual memory stats
iostat - I/O stats
uptime - load avg
sar - system activity report
lspci - show all PCI peripherals attached to system


Welcome !!!