Before doing anything else, read and act on: http://wiki.postgresql.org/wiki/Corruption .
Most likely you have disk or file system problems.
If you suspect any kind of DB corruption for whatever reason you should stop the DB and copy the entire database at the file system level before attempting any recovery.
Once you've done that, then you can look into possible repairs. You'll probably have some significant data loss, so your goal should be to get it working to the point where you can pg_dump
the damaged databases, re-initdb, and reload.
If you have a recent backup, now would be a good time to think about using it.
[Is it] possible to setup PostgreSQL to use directly a block device (like /dev/sda) on for POSIX systems for data storage?
Nope.
PostgreSQL would have to implement its own file system to support this. It lets the operating system do that, on the theory that the OS will probably do it better.
The project tries to avoid duplicating functionality the operating system already provides. That's one of the reasons why it performs as well as it does; when the kernel folks make improvements, PostgreSQL gets them for free.
Of course, when the kernel folks add performance regressions and bugs we get those too, but that's true even if you use raw block devices. We're just exposed to more filesystem and memory management level differences too.
There are a lot more smart kernel hackers with a lot more time than there are PostgreSQL hackers. So letting them deal with the complexities of buffer eviction, NUMA scheduling, dirty page write-back, etc seems like a no-brainer and it's worked out well so far. Mostly.
If not for PostgreSQL are there database applications known that do not rely on keeping its data as files filesystem, but use block devices directly?
Oracle. It is virtually its own operating system; the Emacs of the database world.
MySQL with InnoDB can create InnoDB segments on raw disk partitions.
I know it's been looked into for SQLite but I don't know if anyone cared enough to finish the work.
backup can be simpler
I question your assertion that using a raw partition makes backups simpler. I see few advantages and plenty of disadvantages to relying on raw block devices.
Best Answer
Your storage subsystem is failing. This is not a PostgreSQL error, as such, it's an error from the underlying file system or disks.
You might learn more from the output of the
dmesg
command and/or the kernel logs.