"The Linux Gazette...making Linux just a little more fun!"


(?) The Answer Guy (!)


By James T. Dennis, answerguy@ssc.com
LinuxCare, http://www.linuxcare.com/


(?) Copying boot partitiion

From the Linux User Support Team (L.U.S.T) List on Mon, 19 Jul 1999

(?) Hello all,

I have a disk in a Redhat Linux 6.0 machine that has developed some bad sectors, about 200 meg's worth. Everything seems to be working but I would like to replace the disk. Is there a way I can copy the whole partition to another disk and then just swap them. I suppose I can do something like mirroring the disks but I haven't a clue where to start.

Thanks for any help.
Darren Pedley

(!) I usually mount new disks under /mnt after fdisk & mke2fs to make it ext2fs


mount /dev/newdrive /mnt
cd  /

for i in `\ls |grep -v  proc |grep -v  mnt`
do
cp -aRv  $i /mnt/
done

boot with boot stiffy & rerun lilo

all done

(!) Ack! So complicated.
If you have three partitions that you want backup to /mnt (let's say /, /usr, and /home) you could use something as simple as:
for i in / /usr /home; do
cp -pax $i /mnt
done
.... the -x will prevent the GNU cp command from crossing over filesystem/mount boundaries. Thus you needn't worry about inadvertantly copying /proc or recursing down into /mnt.
(Obviously to just get the root filesystem you'd just use cp -pax / /mnt; to list all your currently active filesystems just use the mount command with no arguments; to list all the partitions/filesystems on your system use the 'fdisk -l' command).


Copyright © 1999, James T. Dennis
Published in The Linux Gazette Issue 44 August 1999
HTML transformation by Heather Stern of Starshine Techinical Services, http://www.starshine.org/


[ Answer Guy Index ] 1 4 7 9
11 12 14 17
18 19 20 21 24 25 26
28 29 30 31 32 33 34
35 36 37 38 39 40 41
42 43 44 45 46 47 48


[ Table Of Contents ] [ Front Page ] [ Previous Section ] [ Next Section ]