Backing up ext3 root partition with dd

Yassin Hania-CHY002 Hania.Yassin at motorola.com
Tue Feb 20 20:45:34 UTC 2007


Is there a reason why an ext3 root partition cannot be copied to an
alternate partition using the "dd" command?   
The dd is copying the mounted root partition into an alternate partition
that is not mounted.  The dd returns success, but the fsck on that
partition fails with errors as follows:
-----------------
fsck 1.37 (21-Mar-2005)
/dev/Active_Update/root2: recovering journal
/dev/Active_Update/root2: Clearing orphaned inode 57554 (uid=0, gid=0,
mode=010600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57552 (uid=1010,
gid=3002, mode=010600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57548 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57547 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57546 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57545 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57544 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57543 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57542 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57541 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57540 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57539 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57538 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57537 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Clearing orphaned inode 57536 (uid=0, gid=0,
mode=020600, size=0)
/dev/Active_Update/root2: Deleted inode 90369 has zero dtime.  FIXED.
/dev/Active_Update/root2: Inode 90370 is in use, but has dtime set.
FIXED.
/dev/Active_Update/root2: Inode 90371 is in use, but has dtime set.
FIXED.
/dev/Active_Update/root2: Inode 90372 is in use, but has dtime set.
FIXED.
/dev/Active_Update/root2: Inode 90373 is in use, but has dtime set.
FIXED.
/dev/Active_Update/root2: Inode 90373 has imagic flag set.  retfrom fsck
is 1024
-------------------------------
 
When mounting that partition, an error is logged to /var/log/messages as
follows:
EXT3-fs warning: mounting fs with errors, running e2fsck is recommended
 
We are seeing this on boxes running RHEL4 and even boxes running a PPC
version of Linux.
This failure is not seen on every run of the scripts, and is mostly seen
when mirroring the root partition.
 
Here is the script which reproduces this ext3 corruption after running
it 5-6 times:
------------------------------------------
#!/usr/bin/perl -w
my $ret;

##
## Determine the backup partitions
##
my @temp =  `cat /etc/fstab | grep alt_root`;
my (@temp2, @alt_parts, @parts, @part);
my $cnt = 0;
foreach (@temp)
{
   @temp2 = split / /;
   push @alt_parts, $temp2[0];
}

##
## Determine the active partitions
##
@temp = `cat /etc/fstab | grep Active_Update | grep -v alt_root | grep
-v log | grep -v swap`;
foreach (@temp)
{
   @temp2 = split / /;
   push @parts, $temp2[0];
}


while (`cat /var/log/messages | grep -ci "running e2fsck is
recommended"` <= 0)
{
   foreach my $alt_part (@alt_parts)
   {
      $alt_part =~ /(\D+)\d/;
      @part = grep /$1/, @parts;
      `dd if=$part[0] of=$alt_part > /dev/null 2>&1`;
      $ret = $?;

      ##
      ## Abort if the partition copy fails as there is likely something
      ## seriously wrong
      ##
      if ($ret != 0)
      {
         `logger "ERROR: Problems copying data to $alt_part."`;
         `logger "       Contact Motorola for assistance."`;
         `logger "Partition Copy exit code: $ret"`;
         exit 1;
      }

      ##
      ## Check the filesystem on the copied partition
      ##
      `/sbin/fsck -fp $alt_part > /dev/null 2>&1`;
      $ret = $?;
      `logger "fsck exit code for $alt_part was: $ret"`;
   }

   ##
   ## Modify the copied partition
   ##
   `mount /mnt/alt_root; rm -f /mnt/alt_root/bob; touch
/mnt/alt_root/bob; umount /mnt/alt_root`;
}

-------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/ext3-users/attachments/20070220/b2369cb0/attachment.htm>


More information about the Ext3-users mailing list