Difference between revisions of "Migrating a linux root partiton"

From Blue-IT.org Wiki

 
(3 intermediate revisions by the same user not shown)
Line 11: Line 11:
  
  
===Rsync=
+
=Rsync=
A method for a backup that checks, if the selected partition is mounted:
+
A method for a backup that checks, if the selected partition is mounted. It further checks if there is a file with a special name (here: itsroot) assuring that it is the right partition.
  
 
  mkdir -p /${ROOTDIR}
 
  mkdir -p /${ROOTDIR}
Line 41: Line 41:
  
 
  rsync -a --progress --delete /${ROOTDIR}/. /${BACKUPDIR}/${ROOTDIR}/.
 
  rsync -a --progress --delete /${ROOTDIR}/. /${BACKUPDIR}/${ROOTDIR}/.
 +
 +
from a personal backup script.
 +
 +
[[Category:Filesystem]]
 +
[[Category:Ubuntu]]

Latest revision as of 19:46, 8 January 2012

TAR

A method that only copies files and dirories from root "/":

$ mkfs -t ext2 /dev/hda4 
$ mkdir /mnt/temp 
$ mount -t ext2 /dev/hda4 /mnt/temp 
$ cd / 
$ tar lcf - .|(cd /mnt/temp; tar xpvf - )

from Linux and XFS HowTo


Rsync

A method for a backup that checks, if the selected partition is mounted. It further checks if there is a file with a special name (here: itsroot) assuring that it is the right partition.

mkdir -p /${ROOTDIR}
if test -e /${ROOTDIR}/itsroot
then echo ${ROOTDEV} already mounted as /${ROOTDIR}...
    echo ---------------------------------------------------------------
else
       if mount -rv ${ROOTDEV} /${ROOTDIR}
       then echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            echo Mounted ${ROOTDEV} on /${ROOTDIR} ...
            echo ---------------------------------------------------------------
       else
               if mount -r -o bind / /${ROOTDIR}
               then echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                    echo Mounted ${ROOTDEV} on /${ROOTDIR} VIA BIND - OK.
                    echo ---------------------------------------------------------------
                       if test -e /${ROOTDIR}/itsroot
                       then echo Seams to be the right directory - OK.
                       else echo ERROR mounting  ${ROOTDEV} on /${ROOTDIR};clear; canceled;
                       fi

               else echo ERROR mounting  ${ROOTDEV} on /${ROOTDIR};clear; canceled;
               fi
       fi
fi
rsync -a --progress --delete /${ROOTDIR}/. /${BACKUPDIR}/${ROOTDIR}/.

from a personal backup script.