Friday, November 23, 2007

Lost Root Password (Linux: Debian Derivatives)

If you've lost your root password, you might be able to do it this way. However, some systems are protected with boot loader passwords that won't let you do that without THAT password. If the boot loader is password protected, you need to boot from other media - for newer systems, the install CD probably has the recovery tools for that.

But let's try it the easy way first. The first thing to try is to boot to single user mode. This MIGHT not work for you, because your system might be configured to still ask for a root password to get to single user mode. If that's the case, we'll use another trick that replaces init with /bin/bash.

First, try single user. If you don't see either a LILO or GRUB boot screen, try hitting CTRL-X to get one. If it's LILO, just type "linux single" and that should do it (assuming that "linux" is the lilo label). If GRUB, hit 'e", then select the "kernel" line, hit "e" again, and add " single" (or just " 1") to the end of the line. Press ENTER, and then "b" to boot.

You should get a fairly normal looking boot sequence except that it terminates a little early at a bash prompt. If you get a "Give root password for system maintenance", this isn't going to work, so see the "init" version below.

If you do get the prompt, the / filesystem may not be mounted rw (although "mount" may say it is). Do

mount -o remount,rw /

If that doesn't work (it might not), just type "mount" to find out where "/" is mounted. Let's say it is on /dev/sda2. You'd then type:

mount -o remount,rw /dev/sda2

If you can do this, just type "passwd" once you are in and change it to whatever you like. Or just edit /etc/shadow to remove the password field: move to just beyond the first ":" and remove everything up to the next ":". With vi, that would be "/:" to move to the first ":", space bar once, then "d/:" and ENTER. You'll get a warning about changing a read-only file; that's normal. Before you do this, /etc/shadow might look like:

root:$1$8NFmV6tr$rT.INHxDBWn1VvU5gjGzi/:12209:0:99999:7:-1:-1:1074970543
bin:*:12187:0:99999:7:::
daemon:*:12187:0:99999:7:::
adm:*:12187:0:99999:7:::


and after, the first few lines should be:

root::12209:0:99999:7:-1:-1:1074970543
bin:*:12187:0:99999:7:::
daemon:*:12187:0:99999:7:::
adm:*:12187:0:99999:7:::


You'll need to force the write: with vi, ":wq!". (If that still doesn't work, you needed to do the -o remount,rw, see above).

Another trick is to add "init=/bin/bash" (LILO "linux init=/bin/bash" or add it to the Grub "kernel" line). This will dump you to a bash prompt much earlier than single user mode, and a lot less has been initialized, mounted, etc. You'll definitely need the "-o remount,rw" here. Also note that other filesystems aren't mounted at all, so you may need to mount them manually if you need them. Look in /etc/fstab for the device names.

Reference: http://www.securitypronews.com/it/operatingsystems/spn-22-20040209LostRootPasswordLinux.html

Tuesday, November 20, 2007

Debian: Writing to NTFS

  • Installation

On Debian Etch


First, download NTFS-3g. 2 packages are needed here: ntfs-3g and libntfs-3g. You can use wget to download them:

wget http://snapshot.debian.net/archive/2007/03/01/debian/pool/main/n/ntfs-3g/libntfs-3g0_0.0.0+20061031-6_i386.deb
wget http://snapshot.debian.net/archive/2007/03/01/debian/pool/main/n/ntfs-3g/ntfs-3g_0.0.0+20061031-6_i386.deb


Then install the dependencies:

sudo apt-get install fuse-utils libfuse2


Finally you can install ntfs-3g (using the 2 Debian packages you just downloaded):

sudo dpkg -i libntfs-3g0_0.0.0+20061031-6_i386.deb
sudo dpkg -i ntfs-3g_0.0.0+20061031-6_i386.deb




On Debian Sid, Ubuntu Edgy or Ubuntu Feisty


No need to download anything, nor to install any dependencies. Simply typing:

sudo apt-get install ntfs-3g


will do the trick.


  • Mounting partitions


Mounting partition is done quite simply. For example, this command (one line):

sudo mount -t ntfs-3g /dev/sdb1 /media/sdb1 -o umask=0,nls=utf8

(Note: might need to add 'force' option in /etc/fstab "/dev/sdb1 /media/sdb1 ntfs-3g umask=0,nls=utf8,force 0 0", if it doesn't get mounted in some cases. After that whenever we say `mount /media/sdb1` it gives following funny message "WARNING: Dirty volume mount was forced by the 'force' mount option." As if NTFS is seemed to be Dirty volume for Debian ;-) )

will mount a partition (/dev/sdb1 in that case, replace with your actual windows partition) on the /media/sdb1 directory (which must exist and be empty), using the utf8 character set (for maximum compatibility with foreign languages) and giving read/write/execute permissions to everyone.

Once you have established that this command work fine on your system, you can add an entry for it in /etc/fstab:

/dev/sdb1 /media/sdb1 ntfs-3g umask=0,nls=utf8 0 0


If you wish, you can unmount that partition in the standard way:

sudo umount /dev/sdb1


  • Tips


The output of

sudo fdisk -l | grep -i ntfs

will tell you the location of your windows partition.


Reference :
http://technowizah.com/2006/11/debian-how-to-writing-to-ntfs.html


  • Troubleshooting:

If in a case sdb1 device is suddenly removed from your /dev dir, that means the system has lost support for USB devices i.e kernel is not able to recognize it (USB storage devices), check out this;

$> lsmod | grep usb_storage

if nothing gets displayed do

$> modprobe usb_storage

$>
lsmod | grep usb_storage

usb_storage 72736 2
ide_core 112392 2 usb_storage,generic
usbcore 114372 5 usbhid,usb_storage,ehci_hcd,uhci_hcd
scsi_mod 125160 5 sg,sr_mod,usb_storage,sd_mod,libata

if the later command gives you o/p like this, u've got the USB support back :-)

Labels:

Tuesday, November 06, 2007

Another Breakthrough !! Sound and Wireless Networking (Now Working !!)

on IBM Lenovo 3000 N100 with BOSS 2.0 i.e debian lenny/sid (debian testing/unstable, kernel 2.6.21-1-486, gnome 2.18)

Although I've tried my hands-on with various Debian derivatives this one actually made me WORK !!

For Sound, apparently problem was with Alsa Drivers (1.0.14) that wasn't able to make Sound Card (Intel Corporation) work. At first instance whenever system was up some process was holding /dev/dsp i.e audio device used to get blocked by some process (since it was throwing error "can't access /dev/dsp" whenever I tried to use festival TTS for sound test). Then I tried with the most popular "patched alsa" from here .

But didn't work :-(

Eventhough the module ("high definition audio" module: snd-hda-intel) is loaded, the laptop produces no sound (known for kernel 2.6.21 and 2.6.22)

Seems to be known kernel/alsa-source bugs (#431314 & #431775). But there's a workaround :-)

Building Alsa-Module

Below is a small script to patch & compile Alsa. It downloads latest alsa-source (ALSA driver sources) from lenny/sid (my OS had debian's testing/unstable repositories), apply small patches to it then shell script (t61-build-alsa-module.sh) builds the alsa module with these three patches. This script does it so easily :-)

Shell Script : t61-build-alsa-module.sh
------------

--------------------------------------------------------------------------------------------------

#/bin/sh
# Small script to download,patch,build the alsa module for Thinkpad T61/R61/X61.
# t61-build-alsa-module.sh v0.4 (C) Franklin Piat 2007. released under GPL.
# thanks to
# Alsa teams
# http://www.thinkwiki.org/wiki/AD1984
# http://www.linuxquestions.org/questions//showthread.php?s=0b8d3760255e43abaecdfc8e0e4cba12&t=564079&page=3
#
m-a prepare || exit
m-a clean alsa || exit
m-a get alsa-source || exit
m-a unpack alsa || exit
cd /usr/src/modules/alsa-driver/alsa-kernel/ || exit
## kernel alsa 1.0.14 don't need the first three patch
case "$(cat ../version)" in
1.0.13*)
wget -O - http://hg.alsa-project.org/alsa-kernel/raw-diff/ed48e4edc677/pci/hda/patch_analog.c | patch -p1 || exit
wget -O - http://hg.alsa-project.org/alsa-kernel/raw-diff/45179b325c8e/pci/hda/patch_analog.c | patch -p1 || exit
wget -O - http://www.klabs.be/~fpiat/linux/debian/Etch_on_Thinkpad_T61/t61-alsa-1.0.13-backport-patch.diff | patch -p1 || exit
;;
esac
wget -O - http://hg.alsa-project.org/alsa-kernel/raw-diff/958b39f3e8dd/pci/hda/patch_analog.c | patch -p1 || exit
wget -O - http://hg.alsa-project.org/alsa-kernel/raw-diff/47ca87407c84/pci/hda/patch_analog.c | patch -p1 || exit
wget -O - http://hg.alsa-project.org/alsa-kernel/raw-diff/ca37aeeeb0ea/pci/hda/patch_analog.c | patch -p1 || exit
m-a --not-unpack build alsa || exit
#Install with : dpkg -i /usr/src/alsa-modules-$(uname -r)_1.0.14-1+$(uname -r).deb
#You might have to enable "speaker" (in the gnome mixer's "switch" tab ; Or in "alsamixer").
#You might need to add "options snd-hda-intel model=thinkpad/lenovo" at the end of /etc/modprobe.d/alsa-base

--------------------------------------------------------------------------------------------------

Of course there are three things at the last of the script that needs to be done manually (might need) !

Now DONE with Sound, it's working out-of-the-box :-)


Wireless Networking (Not Working) !!

Intel's wireless driver not seems to be included in the debian yet :-(

Following packages solved the issue (apt-get install)

firmware-ipw3945
ipw3945d
ipw3945-source
madwifi-tools
wireless-tools
kernel-package (for make-kpkg)
ipw3945-modules-2.6.21-1-486 (depends on kernel version)
fakeroot
ipw3945-modules

/etc/apt/sources.list had following repositories;

deb http://packages.bosslinux.in/boss anant main contrib non-free
deb http://ftp.us.debian.org/debian testing main contrib
deb-src http://ftp.us.debian.org/debian testing main contrib


After rebooting the machine again check if /dev/dsp gets blocked by some process (run `/bin/fuser -v /dev/dsp` through console), if so kill the particular process to make audio device free. Then go for any multimedia player.

At last after spending almost half day I could make Sound and Wireless Networking (Now Working ;-) ) on Lenovo 3000 N100 with BOSS 2.0 (debian testing, kernel 2.6.21-1-486, gnome 2.18) :-)


Labels: