Monday, May 14, 2007

Moving to a Larger Hard Drive in FreeBSD

Moving to a Larger Hard Drive in FreeBSD
By Super Admin | Published 04/7/2006 | FreeBSD | Rating:

1. Shutdown and install the new drive in the computer, leaving the
existing drive as the primary master. Installing the new drive as the
master on the secondary ATA channel will give you faster throughput for
transferring data, but the new drive may be installed as the slave drive
on the primary ATA controller. Be sure to set both new drive and
existing drive jumpers as required.
2. Boot to single user mode. If you are using FreeBSD 5.x or 6.x,
choose the 'Boot FreeBSD in single user mode' option at the boot menu;
otherwise, during the boot loader countdown, press any key other than
the Enter key, and at the boot prompt, enter the command:

ok boot -s

At the shell prompt, mount the file systems:

# fsck -p
# mount -u /
# mount -a -t ufs
# swapon -a
3. Run sysinstall:

# /usr/sbin/sysinstall (In FreeBSD 4.x, it's /stand/sysinstall)
1. Choose 'Configure,' then 'Fdisk' from the menu, then choose
your new drive. (For ATA drives, the new drive will be 'ad1' if it's the
primary slave, or 'ad2' if it's the secondary master; for a SATA master
on channel 4, it will be 'ad8'.) For the purpose of this procedure, we
will assume that the new drive is 'ad2'.
2. In the FDISK Partition Editor, choose 'A' to use the entire
disk. Press 'Q' to continue.
3. At the "Install Boot Manager" prompt, choose the appropriate
boot manager. This procedure assumes that FreeBSD is the only operating
system, so choose the 'Standard' master boot record.
4. Back at the sysinstall menu, choose 'Label'.
5. In the Disklabel Editor, create the following partitions:

ad2s1a /mnt 512MB as UFS2
ad2s1b swap 2048MB as swap (4x system RAM)
ad2s1d /var 4096MB as UFS2 + Softupdates
ad2s1e /usr remaining as UFS2 + Softupdates

To get partition 'a', tell Disklabel Editor the mount
point is '/', then change it to '/mnt' using the 'M' option.

Choose 'Q' to continue.
6. Exit sysinstall.
4. Mount the new filesystems:

# mount /dev/ad2s1a /mnt
# mount /dev/ad2s1d /mnt/var
# mount /dev/ad2s1e /mnt/usr
5. Copy the existing filesystems:

# tar cf - --one-file-system -C / --exclude='mnt/*' . | tar xpvf -
-C /mnt
# tar cf - --one-file-system -C /var . | tar xpvf - -C /mnt/var
# tar cf - --one-file-system -C /usr . | tar xpvf - -C /mnt/usr
6. Shutdown and remove the old hard drive. Move the new drive to the
location of the old drive; make sure to set the new drive's jumpers
accordingly. If you are moving from an ATA drive to a SATA drive, make
sure you change the boot device in the computer's System BIOS.
7. Boot to single user mode as described previously.

At the shell prompt, mount the file systems:

# fsck -p
# mount -u /
# mount -a -t ufs
# swapon -a
8. Verify that all of the filesystems are properly mounted:

# mount

You should see something like:

/dev/ad0s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ad0s1e on /usr (ufs, local, soft-updates)
/dev/ad0s1d on /var (ufs, local, soft-updates)

9. Reboot and observe startup messages to ensure the system is
functioning properly.

1 comment:

Unknown said...
This comment has been removed by a blog administrator.