7

When I have run fsck in the past I have always run it on what I thought was a filesystem partition, ie. fsck -yf /dev/sdaN, where N is the partition number on disk A. A friend of mine recently ran fsck on his brand new disk and it reported a bunch of errors using fsck -yf /dev/sda. I am curious, what is the difference between running fsck on the whole disk (/dev/sda), verses running it on just a single partition (/dev/sda1)?

  • You should recieve some kind of "useless message" like "/dev/sda is in use" like this guy: askubuntu.com/questions/239316/dev-sda-is-in-use-from-livecd – user34720 Oct 22 '14 at 16:54
  • @nwildner That was not the result seen in this case. It seems like /dev/sda was truly not being used, as my friend was in some sort of recovery shell which made itself available before the drive was mounted. – dinkelk Oct 22 '14 at 17:07
  • It should stop as it does not recognize any fs at all as it is not to be meant to inspect partition tables. – Max Ried Oct 22 '14 at 18:31
6

When fsck runs, it should first try to locate the superblock of a filesystem to begin traversing the filesystem's structure in order to validate it. Since the /dev/sda device corresponds to whole drive, the first portion of the disk will likely contain the partition table or Master Boot Record and fsck will not be able to locate the superblock for a supported filesystem (unless you get something that somehow matches a magic number for a known filesystem). I would expect it to exit in error or provide inaccurate output (as your friend experienced). However, I have not yet performed this experiment myself.

5

It won't work, if the filesystem was installed in a partition (e. g. sda1).

fsck and its brethren are tools for performing maintenance on filesystems (hence the name: filesystem ccheck), not of block devices.

It is, I suppose, theoretically possible to put a filesystem directly onto a block device by way of something like mke2fs -j /dev/sda, but this is very, very bad practice. But if you do, the filesystem would then live directly on sda, and then to fsck it, you would indeed just point fsck at the device. Do not do this. Partition tables are there for a reason, and it's not just to take up a nominal amount of space for a table of contents.

1

If the device contains a supported filesystem, fsck should work. The device can be an entire hard drive like /dev/sda, or a partition, or a flopy disk (anyone remeber what those were?) like /dev/fd0, or even a file on another hard disk like ~/hdimage.img. For floppy drives the entire drive is normally used, so there is no reason to partition, so the filesystem is made on /dev/fd0. Conventionally hard drives are divided into partitions and file systems are built in the partitions. However if you want to use the whole drive as one partition and you do not need to boot from it, you could make a filesystem directly on the device (mke2fs /dev/sdb), mount it and copy a lot of files to it, then fsck /dev/sdb should work. This has been called a "superfloppy" configuration. I think the old iomega 100MB disks were also normally formatted this way. A disk doesn't even need to have a filesystem- it could have a single file. I often make tar files the right size to fit on a DVD, burn them to the disk. The disk is then not mountable, but tar -xvf some/where/myfile /dev/sr0 extracts myfile from the disk.

  • Come to think of it it may be possible to make a superfloppy bootable, the same way floppy drives are. – Ed Berry Dec 7 '16 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.