Replacing drive with root file system on
Matthew Seaman
m.seaman at infracaninophile.co.uk
Fri Oct 24 04:35:29 PDT 2003
On Fri, Oct 24, 2003 at 10:47:45PM +1300, Richard Shea wrote:
> Hi - I have a system with two IDE drives on it and I need more disk space
> than I have . The current situation is :
>
> Filesystem 1K-blocks Used Avail Capacity Mounted on
> /dev/ad0s1a 257998 36308 201052 15% /
> /dev/ad0s1f 498398 424568 33960 93% /usr
> /dev/ad3s1e 7939980 6610848 693934 91% /usr/home
> /dev/ad0s1e 226734 2542 206054 1% /var
> procfs 4 4 0 100% /proc
>
> I would like to swop the 1Gb ad0 drive for a larger drive. As you can see
> the other IDE drive is almost full. Can anyone suggest how to move what's
> on ad0 to a larger disk ? I wondered about
>
> 1. disconnecting the ad3 and putting a new drive in its place
> 2. then (in some way) backuping up the entirety of ad0, restoring it to
> the 'fake' ad3 3. then taking out the original ad0 and replacing with ad3
> 4. then (in some way) persuading machine to boot off new, larget drive,
> with root on it
>
> ... would that work ? Can anyone fill in the details ? It it wouldn't
> work can anyone suggset an alternative bearing in in mind I can only have
> two drives and the largest each can be is 8Gb (old BIOS).
You have pretty much the right idea. I'd do the job something like
this:
i) Edit your /etc/fstab and comment out the line that mounts
/usr/home.
ii) Shutdown and remove the current ad3 drive. Add your new 8Gb
disk in it's place.
iii) Reboot to single user mode, mounting all of the partition from
ad0, much as you would for doing a {build,install}world cycle:
# fsck -p
# swapon -a
# mount -a
iv) Set up the fdisk(8) slice table on your new drive: presumably
you want the whole disk to be devoted to FreeBSD. This also
sets up the boot sector so that you can eventually boot from
the disk.
# fdisk -B -b /boot/mbr -I ad3
Once you're done, modulo the exact size/cylinders/heads/sectors
of the disk you should see output something like this:
# fdisk ad3
Password:
******* Working on device /dev/ad3 *******
parameters extracted from in-core disklabel are:
cylinders=4462 heads=255 sectors/track=63 (16065 blks/cyl)
Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=4462 heads=255 sectors/track=63 (16065 blks/cyl)
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 63, size 71681967 (35000 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
v) Set up FreeBSD partitions on your new drive using disklabel(8)
-- decide before hand what partitions and what sizes you want:
# disklabel -e ad3s1
This will pop you into an editor -- you need to add lines at
the end after where it says '8 partitions:' -- don't touch the
line for c:, but add lines for a: (/), b: (swap), e: (/usr), f:
(/var) etc. Set fstype to 4.2BSD (or swap for the swap
partition). Some calculation will be necessary here. Sizes are
given in numbers of sectors, which are usually 512bytes apiece.
Eventually you should end up with something that looks rather
like this:
# size offset fstype [fsize bsize bps/cpg]
a: 262144 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 16*)
b: 2097152 262144 swap # (Cyl. 16*- 146*)
c: 71681967 0 unused 0 0 # (Cyl. 0 - 4461*)
e: 262144 2359296 4.2BSD 1024 8192 16 # (Cyl. 146*- 163*)
f: 12582912 2621440 4.2BSD 1024 8192 16 # (Cyl. 163*- 946*)
g: 56477615 15204352 4.2BSD 1024 8192 16 # (Cyl. 946*- 4461*)
You need to fill in the first three columns -- you can fill in
the fsize, bsize and bps/cpg fields if you want, but the
newfs(8) command used in the next step will fill in the blanks
for you. The stuff after the '#' on each line is automatically
generated.
vi) Create filesystems on the new partitions using newfs(8). There
are any number of parameters to play with when creating
filesystems which is all very confusing. If you don't have a
specific need for a specially laid out FS, then just take the
defaults. These will be fine for general purpose filesystems
of the sort of size you'll be needing:
# newfs -v /dev/ad3s1a
and the same for the other partitions ad3s1e, ad3s1f. You
don't need to do anything special to prepare the swap (b)
partition.
If you want to use soft updates (definitely recommended for
/usr and /var and usually good for / unless space is
particularly tight) then you can enable it on the new
partitions by
# tunefs -n enable /dev/ad3s1a
and analogously for the other filesystems.
vii) Now mount the new partitions under /mnt:
# mount -t ufs -o rw /dev/ad3s1a /mnt
# mount -t ufs -o rw /dev/ad3s1e /mnt/usr
# mount -t ufs -o rw /dev/ad3s1f /mnt/var
viii) Use dump(8)/restore(8) to duplicate your original filesystems
onto the new disk
# dump -0 -f - / | ( cd /mnt ; restore rf - )
# dump -0 -f - /usr | ( cd /mnt/usr ; restore rf - )
# dump -0 -f - /var | ( cd /mnt/var ; restore rf - )
ix) Unmount your new partitions, shutdown the machine and move your
new disk to replace your original boot disk. Stick your
original /usr/home drive back in since you have the case open.
x) Reboot to single user mode again. The system should come up
smoothly from the new disk. If not, you'll have to open the
case again, swap the old root disk back into the machine as ad0
and the new disk back to ad3 and you should be able to get the
system back up and try and fix things.
When you get to single user, do the usual fsck and mount
things:
# fsck -p
# swapon -a
# mount -a
Now edit the /etc/fstab file to uncomment the /usr/home line.
Then fsck and mount that partition:
# fsck -p /dev/ad3s1e
# mount /usr/home
ix) If everything has gone well so far, type Ctrl-D to exit from
single user mode and continue booting up to full multi-user
mode. If not, you'll have to backtrack, work out what went
wrong and fix it.
x) That's it. You're done.
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20031024/1ea51274/attachment.bin
More information about the freebsd-questions
mailing list