Backup router, new hard drive.
Jerry McAllister
jerrymc at clunix.cl.msu.edu
Mon Sep 15 08:43:09 PDT 2003
>
> How do I copy the whole harddrive to a larger drive than the one being
> copied?
> This is an router that cant go down for more than a few minutes. I
> want to replace whole system to the new harddirve old one has noisy
> bearings. I have no backup at all.
First, find a way to make a backup!!!!!!!!!
Over the local net to another machine if necessary.
Is the larger hard drive already on the machine? Can it be put
there with the old one still left where it is? Is the whole disk
used for FreeBSD? If the larger drive can be put on the machine
and the old one is running only FreeBSD, then just
- use disklabel(8) to see what partitions are being used on the old disk.
disklabel -r da0
write the output down or pipe that to a file or to a printer so you
can easily refer to it later.
- physically install the larger drive if it is not already there.
Lets say the old disk is da0 and the larger one becomes da1.
- use fdisk(8) to create one large slice with boot manager that uses
the whole larger disk
fdisk -BI -v -b /boot/mbr da1
- use disklabel to partition the slice and write a boot record
disklabel -w -B -b /boot/boot1 -s /boot/boot2 da1s1 auto
- use disklabel to edit the partition sizes and rewrite the label
disklabel -r -e da1s1
refer to the output you saved above to create appropriate partition
sizes. Since the disk is bigger, you are free to adjust sizes as
long as they are both bigger than the old ones and all add up to
total space in the slice (or less). If there is one last large
partition, the new disklabel lets you use '*' for its size and it
will just use up all the remaining slice.
example partitions on a nominal 18GB DRIVE:
# size offset fstype
a: 2514944 0 4.2BSD # To mount as /
b: 4618240 2514944 swap # Used for swap
c: 35551782 0 unused # defines whole slice
e: 2514944 7133184 4.2BSD # To mount on /tmp
f: 25903654 9648128 4.2BSD # To mount on /home
You will need to create the appropriate partitions for your situation.
- newfs each new partition (except the one for swap - leave that alone)
newfs /dev/rda1s1a
newfs /dev/rda1s1e
newfs /dev/rda1s1f
These newfs commands just take the defaults for block and fragment
size, etc which are probably good for this.
- create mount points for the new partitions/filesystems
mkdir /newroot
mkdir /newtmp (Shouldn't really need one for /newtmp)
mkdir /newhome
- you might want to make entries for the new partitions in /etc/fstab
to make writing dump/restore and maybe fsck commands less tedious.
vi /etc/fstab
add lines using the new device types just created and appropriate mount
points otherwise like one of the other regular UFS lines.
/dev/da1s1a /newroot ufs rw 2 2
/dev/da1s1e /newtmp ufs rw 2 2
/dev/da1s1f /newhome ufs rw 2 2
- you might want to fsck the new partitions just in case, but it isn't
really necessary unless newfs is hosed.
fsck -f -y /newroot
fsck -fy /newtmp
fsck -fy /newhome
- now mount the new filesystems (don't bother with /newtmp)
mount /newroot
mount /newhome
- use dumpt(8)/restore() to copy everything. Note that if you have
tables and/logs being constantly updated, the only way to make true
copies is to take the system down and go to single user. This will
only copy files as they are at the instant of copying.
The actual dump/restores that you do will depend on the actual partitions/
filesystems your old disk has, so adjust accordingly.
cd /newroot
dump -0af - / | restore -xf -
cd /newhome
dump -0af - /home | restore -xf -
Now you should be able to shut the machine down, pull the old disk,
put the larger disk in the slot where the old disk was and reboot.
You can also probably put the old disk in to the slot where the larger
disk had been during the copying and it should mount OK - now as da1.
Have fun.
It is actually easier than the narrative would make is seem.
That is, if you can plug and switch the drives as described.
////jerry
>
> Dan
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>
More information about the freebsd-questions
mailing list