Backing up ext3 root partition with dd

tweeks tweeks at rackspace.com
Wed Feb 21 23:25:23 UTC 2007


For the same reason you can't xerox a piece of paper that your wiggling. ;)

More precisely... the act of mounting it in a state other than read only makes 
it "uncopy-able" (from an image perspective).  It sounds like you want a type 
of snapshot feature like what XFS offers.

Tweeks

On Tuesday 20 February 2007 14:45, Yassin Hania-CHY002 wrote:
> 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`;
> }
>
> -------------------------


Confidentiality Notice: This e-mail message (including any attached or
embedded documents) is intended for the exclusive and confidential use of the
individual or entity to which this message is addressed, and unless otherwise
expressly indicated, is confidential and privileged information of Rackspace
Managed Hosting. Any dissemination, distribution or copying of the enclosed
material is prohibited. If you receive this transmission in error, please
notify us immediately by e-mail at abuse at rackspace.com, and delete the
original message. Your cooperation is appreciated.




More information about the Ext3-users mailing list