Step-by-step command list for remotely converting a FreeBSD 5.3-STABLE system from a single-disk/single-slice (ad0s1) to a two-disk/single-slice (ad0s1 & ad1s1) GEOM mirror (gm0s1) based setup without the need for console access or fixit/livefs CDROM: ----------------------------------------------------------------------------- # make sure the first disk is treated as a really fresh one # (not really necessary, but makes procedure more deterministically ;-) dd if=/dev/zero of=/dev/ad1 bs=512 count=79 # place a PC MBR onto the second disk # (with a single FreeBSD slice /dev/mirror/gm0s1 as large as the /dev/ad0s1) fdisk -v -B -I /dev/ad1 size=`fdisk ad0 | grep ', size ' | head -1 | sed -e 's;^.*size \([0-9]*\).*$;\1;'` (echo "p 1 165 63 $size"; echo "a 1") | fdisk -v -B -f- -i /dev/ad1 # place a GEOM mirror label onto first slice of second disk # (actually on the last block of the disk) gmirror label -v -n -b round-robin gm0s1 /dev/ad1s1 # activate GEOM mirror kernel layer # (makes the /dev/mirror/gm0s1 device available) gmirror load # place a BSD disklabel onto /dev/mirror/gm0s1 # (ATTENTION: the /dev/mirror/gm0s1 device has to be specified as just # "mirror/gm0s1" or the bsdlabel(8) will use the incorrect GEOM name # "gm0s1" instead!) # (NOTICE: start "a" partition at offset 16, "c" partition at offset 0) bsdlabel -w -B mirror/gm0s1 bsdlabel -e mirror/gm0s1 # manually copy filesystem data from first to to second disk # (same procedure for partitions "g", etc) newfs -U /dev/mirror/gm0s1a mount /dev/mirror/gm0s1a /mnt dump -L -0 -f- / | (cd /mnt; restore -r -v -f-) newfs -U /dev/mirror/gm0s1d mount /dev/mirror/gm0s1d /mnt/var dump -L -0 -f- /var | (cd /mnt/var; restore -r -v -f-) newfs -U /dev/mirror/gm0s1e mount /dev/mirror/gm0s1e /mnt/usr dump -L -0 -f- /usr | (cd /mnt/usr; restore -r -v -f-) # adjust new system configuration for GEOM mirror based setup cp -p /mnt/etc/fstab /mnt/etc/fstab.orig sed -e 's/dev\/ad0s1/dev\/mirror\/gm0s1/g' /mnt/etc/fstab echo 'swapoff="YES"' >>/mnt/etc/rc.conf echo 'geom_mirror_load="YES"' >>/mnt/boot/loader.conf # instruct boot stage 2 loader on first disk to boot # with the boot stage 3 loader from the second disk # (mainly because BIOS might not allow easy booting from second ATA disk # or at least requires manual intervention on the console) echo "1:ad(1,a)/boot/loader" >/boot.config # reboot system # (for running system with GEOM mirror on second disk) shutdown -r now # make sure the first disk is treated as a really fresh one # (also not really necessary, but makes procedure more deterministically ;-) dd if=/dev/zero of=/dev/ad0 bs=512 count=79 # switch GEOM mirror to auto-synchronization and add first disk # (first disk is now immediately synchronized with the second disk content) gmirror configure -a gm0s1 gmirror insert gm0s1 /dev/ad0s1 # wait for the GEOM mirror synchronization to complete sh -c 'while [ ".`gmirror list | grep SYNCHRONIZING`" != . ]; do sleep 1; done' # reboot into the final two-disk GEOM mirror setup # (now actually boots with the MBR and boot stages on first disk # as it was synchronized from second disk) shutdown -r now ----------------------------------------------------------------------------- It is also possible to easily switch back to a single-disk non-GEOM-mirror based setup running on the first disk only: # revert to old system configuration cp -p /etc/fstab /etc/fstab.orig sed -e 's/dev\/mirror\/gm0s1/dev\/ad0s1/g' /etc/fstab cp -p /etc/rc.conf /etc/rc.conf.orig sed -e '/^swapoff="YES"/d' /etc/rc.conf cp -p /boot/loader.conf /boot/loader.conf.orig sed -e '/^geom_mirror_load="YES"/d' /boot/loader.conf # remove second disk from GEOM setup and remove GEOM mirror meta-data on it gmirror remove gm0s1 ad1s1 # reboot shutdown -r now # remove GEOM mirror meta-data from first disk $ gmirror clear /dev/ad0s1 $ gmirror clear /dev/ad1s1