Tag Archives: linux

fsck and filesystem type

I just learned something that I thought worked through filesystem magic when I connected an old usb harddrive to one of my systems.

If you move a drive from one system to another and want to run fsck on it as usual, it will fail.
character# fsck /dev/da1s1
fsck: Could not determine filesystem type
character#

This is since fsck needs an entry in /etc/fstab or to be given it as an argument to know what filesystem is on the disk or partition in question..
character# fsck -t UFS /dev/da1s1
** /dev/da1s1
** Last Mounted on ...
...

Checking the manual actually says it uses fstab, but I guess I have just never noticed it before by pure luck of either having it in there or using the proper flags wihtout thinking of it..

The behaviour seems to be roughly the same in linux except that if no argument is given and no entry found in fstab fsck attempts to use the systems default fs type.

And now I know!

Share

oneliner of the day – ps

This is one of my old favourites, that is useful both for verifying what shell you are running and also the $$ variable is very useful for scripting and writing pid files, lock files, statuses etc.

Let’s have a look at it:
ps -p $$

What this does is tell ps to look at the process specified with the -p flag.
And in this case that is $$.
$$ is in turn a shell variable expanding to the pid of the current running process, in our case the shell.

Example output:
%ps -p $$
PID  TT  STAT      TIME COMMAND
47991  p0  Ss     0:00.03 -csh (csh)

$ ps -p $$
PID   TT  STAT      TIME COMMAND
5404 s002  S      0:00.02 ksh

[henrik@character ~]$ ps -p $$
PID TT STAT TIME COMMAND
40668 1 S 0:00.02 bash

henke@3(NXDOMAIN):~> ps -p $$
PID TTY TIME CMD
3152 pts/2 00:00:00 bash

(FreeBSD; Mac OS X, FreeBSD and OpenSuSe respectively)
You get the point.

Share