0

I have x86 based box running FreeBSD 10.1. I have made it dual boot with Red hat Linux as other OS. Now I'm migrating a UFS partition 'A' on a FreeBSD (10.1) to ext2 based partition on Linux. I'm using partition 'B' as temporary storage.

I am following below procedure.

  1. In FreeBSD: I format 'B' as ext2 and move data from 'A' to 'B' using rsync. Reboot the box.
  2. Box comes up with Linux. I now format 'A' as ext2 in Linux , mount B as ext2 and move data from 'B' to 'A' using rsync

Issue: Many times mount of 'B' in Linux fails and suggest to run fsck. When I run fsck in non-interactive mode it fails and suggest to run in manually. I cannot 'fsck' run manually as box are remotely located. Secondly I'm worried if fsck may lead to data loss.

Queries:

  1. Why linux is asking me to run fschk? What I'm doing wrong?
  2. How safe is running fsck on a partition? My box will not able to come up cleanly in case files are removed in the operation.
  3. Is there any way to log all operation done under fsck that I can use for debugging

Operation done on FreeBSD:

#format raw partition as ext2 
mkfs.ext2  /dev/mfid0s1f

#mount newly formated partition as backup
mkdir -p /backup
mount /dev/mfid0s1f /backup 

#move data for UFS partition mounted as 'data' to ext2 partition 
rsync -a /data/*  /backup 

#reboot the box 
reboot

Operation done in Linux (via rc.local):

case 1: I try to mount 'backup' without fsck

mkdir -p /backup
mount /dev/sda8  /backup 
mount fail with suggestion to run fsck. 

case 2: I add non-interective fsck

mkdir -p /backup
e2fsck -p /dev/sda8 
fail with : /dev/sda8: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY
  • That could smell as a hardware failure, or some overlapping partitions. But it smells bad. I would recommend instead backup the data (perhaps as a .tar.bz2 archive on some external, maybe FAT32, media; or remotely) – Basile Starynkevitch Sep 16 '17 at 13:27
  • 2
    Just a little side issue, why on earth are you formatting as ext2 (rather than, say, ext4) in 2017? – roaima Sep 16 '17 at 13:40
  • 1
    The question makes no mention of unmounting the EXT partition before rebooting FreeBSD. – JdeBP Sep 16 '17 at 14:02
  • 3
    Are you saying this is a dual boot server? Nowhere does that get made clear. In one breath you talk about UFS on FreeBSD and then you talk about ext2 on Linux. Coupled with all of that you throw in a reference to rsync. Please go back to your question and make it quite clear what exactly you are doing (or trying to do). – roaima Sep 16 '17 at 14:30
  • 1
    You forgot sync and umount /backup on the BSD side, before the reboot – Basile Starynkevitch Sep 16 '17 at 17:07
4

Why OS is asking to run fsck?

As some point in the past the filesystem was not unmounted cleanly. The system needs you to run fsck to clear up the inconsistencies.

What I'm doing wrong? I use rsync to move data.

Conceptually you're doing nothing wrong that I can see, except that you should run fsck (see above). It would be good to see your rsync command here, too.

How safe is running fsck? My box will not able to come up cleanly in case files are removed

The filesystem is in an inconsistent state. That might be simply that the filesystem wasn't marked as clean but is otherwise fine. At the other extreme the entire filesystem might be corrupted and you could theoretically lose everything. Most times the fsck only cleans out files that have already been deleted but haven't yet been removed from the filesystem.

Is there any way to log all operation done under fsck?

There are a number of options available to you. One is to use the command in its dry run mode (see man fsck and man e2fsck):

fsck -n /dev/mfid0p7

I would strongly recommend you do not use the automatic recovery flag, -p until you are happy with the fixes it is going to make.

  • Thanks for your response. So we are not suspecting ext2 implementation incompatibilities as root cause of behavior. My migration was based on assumption that an 'ext2' partition is ext2 partition respective of which OS create or mount it. After above behavior I had doubts on my assumptions. – Satpal Parmar Sep 17 '17 at 2:38
  • @SatpalPatmar does FreeBSD require an explicit unmount of filesystems before a reboot? If so this could easily be the problem – roaima Sep 17 '17 at 6:57
  • I'm not sure about that so I tried both ways I see no impact of mount/unmount. I even tried sysync;sync,syc before un-mounting. No impact again. – Satpal Parmar Sep 17 '17 at 11:56
2

a) Why OS is asking for fsck run. What I'm doing wrong?

fsck stands for "file system consistency check".

On most systems, fsck is run at boot time if certain conditions are detected. Usually, these conditions are:

  • A file system is marked as "dirty" — its written state is inconsistent with data that was scheduled to be written.
  • A file system has been mounted a set number of times without being checked.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

b) How safe is running fsck? My box will not able to come up cleanly in case files are removed.

Well it depends, if you enter yes when prompted to delete a wrong inode or block, you will lose data. That is why using the -p option might not be ideal.

Do not run fsck on a mounted filesystem! If you run fsck on a filesystem that is currently mounted, you will (at best) receive an error message, and (at worst) corrupt your filesystem data.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

c) Is there any way to log all operation done under fsck?

For the fsck check at boot time, you can check /var/log/boot.log Maybe your OS also has a /var/log/fsck not every Linux flavor has it.

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.