General method for copying a partition
Hi, all!
In one of my web pages, as part of a larger overall procedure, I give
instructions for copying an entire partition. The basic procedure involves
mounting one partition on /media and the other on /mnt. Then the files
are copied between partitions by means of
cp -a /media/* /mnt
This seems to work OK except if there are "dot files" (files with names
beginning with a period) in the top directory of the source partition.
To generalize the procedure to handle this case, I modified it as follows:
GLOBIGNORE=.:..
cp -a /media/* /mnt
unset GLOBIGNORE
This works fine for bash. Unfortunately, when using the Debian Installer in
a rescue-type situation, the shell is ash, not bash, and GLOBIGNORE has no
special meaning to ash. When using ash, so far the best I have come up with
is
cp -a /media/* /mnt
for i in /media/.*;do if [ $i != /media/. -a $i != /media/.. ];then cp -a $i /mnt;fi;done
Of course, special handling is necessary to avoid processing "." (the current
directory) and ".." (the parent directory). Does anyone know a better way?
Reply to: