-   Linux - Newbie (
-   -   fsck and fstab explanation sought (

nickhoare 08-09-2012 05:45 AM

fsck and fstab explanation sought
We use drbd and I need to fsck the drbd volume. I thought I new the drbd partition name but looking in fstab it did not appear. I could not mount it. I tried fsck and that was able to see the partition.

The fsck manual says it looks in fstab but it must be looking somewhere else to find partitions. Where does it look? There is an entry in /dev/disk/by-id for this partition. Is fsck looking there?

A secondary question is whether I need to fsck the Secondary drbd image on the other server, as well, but I am still investigating that.

MensaWater 08-09-2012 09:56 AM

Exactly what command line did you type that did the fsck of the device? What output did you get that tells you it did the fsck of the one you're interested in? (That is did you type just "fsck" or "fsck -A" or "fsck /dev..."?)

With fsck you can specify the device to check so would not need to read /etc/fstab if you did this. (In fact this is the most common usage at command line - most fsck's are done at boot instead.)

After a filesystem is mounted it appears in /etc/mtab (this file should NOT be edited manually).

However, in general it is a bad idea to run an fsck on a mounted filesystem - you should first unmount it.

nickhoare 08-09-2012 11:46 AM

I typed fsck -n /dev/sda9 . I was unable to mount using "mount /dev/sd9" but have since discovered that "mount /dev/sda9 /mnt" works I presume because I am telling mount where to mount it and so it can manage without an entry in fstab?

My understanding of fstab is now that it is a list of normally mounted partitions (filesystems?), used e.g on boot, whereas I originally thought it was a list of all available partitions. /etc/mtab has a list of currently mounted partitions . There may be other partitions not appearing in fstab. All partitions can be found in /dev/disk ?

I think fsck warns about mounted filesystems. I was able to run fsck on my unmounted volume and repair it. There is now a mass of files in a folder lost+found yet everything works, which is disconcerting.

Thanks for your help

MensaWater 08-09-2012 01:04 PM

The mount (and umount) commands will read /etc/fstab to find information you didn't supply at command line. If you had the entry in /etc/fstab for /dev/sda9 to mount it somehwere (e.g /mnt) and also had any filesystem specific options in that file then when you typed "mount /mnt" it would read fstab and know you meant to mount /dev/sda9 as /mnt and also use any options you'd put in fstab as if you'd typed them with the mount command.

Of course typically you wouldn't want to use "/mnt" by itself in /etc/fstab. Not that you can't but that it would not be coventional - people typically use /mnt (or subdirectories thereof) for temporary mounts. If you're putting it in /etc/fstab you should probably create a mount point (empty directory) to mount it. For example if you wanted to access the files on /dev/sda9 in a directory called /my/long/mount/path/mydir and it was an ext4 filesystem you'd:
1) mkdir -p /my/long/mount/path/mydir
2) Add the entry to /etc/fstab that looked something like:
/dev/sda9 /my/long/mount/path/mydir ext4 defaults,_netdev 1 3
3) Type "mount /my/long/mount/path/mydir" to mount it.
If you do ls -l of mydir before the mount you'll see it is empty. After the mount it will have any files you put in it.
As a test you could write to the mount you did in /mnt then do umount /mnt then do the above steps and you'll see the files that were previously in /mnt are now in mydir.

/etc/fstab is read during boot to mount any filesystem that you want to mount statically and automatically. (There is a separate setup called automount in the /etc/auto* files for mounting filesystems on demand temporarily.)

chrism01 08-09-2012 09:33 PM

All of the above & in short:

# show all disks/partitions the system can see
fdisk -l    # lowercase L

# disk/partitions you would LIKE mounted at boot time
cat /etc/fstab

# disks/partitions ACTUALLY currently mounted
cat /etc/mtab

# automount in the /etc/auto* files for mounting filesystems on demand temporarily (MensaWater)
ls /etc/auto*


nickhoare 08-10-2012 04:21 AM

Thanks for the clear succinct explanation guys. I do RTFM but man documents do not give overviews like yours. And knowing what to google can be a problem if you don't know the terminology.

MensaWater 08-10-2012 09:17 AM


Originally Posted by nickhoare (Post 4750671)
knowing what to google can be a problem if you don't know the terminology.

You think it is bad in Google! When I first started working on computers one had to rely on actual books (manuals). The first time I needed the database concept of "outer join" I had no clue it was called that and ended up having to read most of an Informix manual just to find that was what it was called. I knew such a concept existed because I'd previously used Paradox to join tables but they didn't call it that. Informix manuals had the worst INDEXES of any manuals I've ever come across which is somewhat ironic given how important INDEXES are to a DBMS.

When I was in school (not long after the dinosaurs roamed the earth) they regularly taught us how to search for books in card catalogs and how to find information in them in indexes in the back of the books and various other ways to find information from periodicals and such. With the advent of web searches I wonder if they bother teaching that any longer.


nickhoare 08-10-2012 11:18 AM

Mensa, I remember the days of Technical Manuals! I may have been trying to disguise myself as a youngster, but in fact I carry a lot of historical baggage from DEC VMS, DBMS, ORACLE, through Windows, Netware, VB, SQL Server, ASP.NET and now have lumbered myself with something else new. Did I mention Delphi, C++ and dBase?

At least with manuals you only had one place to look.....

MensaWater 08-10-2012 12:03 PM

Ah dBase II I remember it well but not fondly. Paradox was a superior product until Borland merged dBase and Paradox together to make them indistinguishable later. Funny thing about dBase II - There never was a dBase I - they named it II to make it sound more advanced. Up until M$ started giving away Access most folks with PCs who needed a DB used dBase or Paradox (or some other oddities like Foxpro).

When I first started working on PCs it was the original IBM PC with 4.7 MHz processor, DOS 2.0 and Lotus 123 v1.A. DOS 2.0 was fun because if you were sitting on your C drive and typed "format" it didn't ask if you really meant to format C - it just went ahead and did it. D'oh!

Oddly enough I've worked with IBM System 34/36, NetWare, multiple flavors of UNIX (including odd ones like Qnix, Apple's early one called A/UX, Dynix and DEC's Astrix. Despite that the only place I ever saw the Alphas was at my present job and they decommissioned them shortly after I got here. As common as they were it always amazed me I never seemed to be anywhere where they were.

All times are GMT -5. The time now is 10:11 AM.