• About
  • Manuals
  • Network
Confessions of a FreeBSD hacker Various tips & tricks about computers in general and FreeBSD in particular
Confessions of a FreeBSD hacker

Setting up a mirror through geom on a GPT labeled disk

March 4, 2012 16:57 / Leave a Comment / Magnus Strahlert

Synchronise the disklayout

gpart backup ada0 > /tmp/ada0.gpt
gpart restore -F /dev/ada1 < /tmp/ada0.gpt

Check that everything went as expected.

gpart show

Add the geom kernel module as loaded on startup

echo 'geom_mirror_load="YES"' >> /boot/loader.conf

Add bootcode to the second disk

gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 /dev/ada1

Reboot into single-user mode. Then load the geom kernel module

gmirror load

Set up the mirror

gmirror label -vb round-robin p1 /dev/ada0p1
gmirror label -vb round-robin p2 /dev/ada0p2
gmirror label -vb round-robin p3 /dev/ada0p3

Add the mirrored disk

gmirror insert p1 /dev/ada1p1
gmirror insert p2 /dev/ada1p2
gmirror insert p3 /dev/ada1p3

Wait for the disks to synchronise

gmirror status

Modify the fstab on the new device

mount /dev/mirror/p2 /mnt
cp /mnt/etc/fstab /mnt/etc/fstab.old
ee /mnt/etc/fstab

Reboot into multi-user mode

To backout from this, using the second disk as main disk do the following with the assumption that first disk is disconnected, thus there’s only one physical disk left now named ada0:

Boot into single-user mode. Then load the geom kernel module

gmirror load

Deactivate the now degraded mirror

gmirror deactivate p1 /dev/ada0p1
gmirror deactivate p2 /dev/ada0p2
gmirror deactivate p3 /dev/ada0p3

Clear metadata from the disks

gmirror clear /dev/ada0p1
gmirror clear /dev/ada0p2
gmirror clear /dev/ada0p3

fsck the the disk in order to be able to mount it

fsck /dev/ada0

Edit the fstab. ee can be run without having to mount /usr

mount /dev/ada0p2 /mnt
cp /mnt/etc/fstab /mnt/etc/fstab.mirrored
ee /mnt/etc/fstab

Reboot into multi-user mode

Posted in: FreeBSD / Tagged: freebsd, gpt, mirror, raid

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *

Post Navigation

← Previous Post
Next Post →

Recent Posts

  • Takeaways utilising VFIO in a KVM virtual guest
  • Converting VM from ESXi to KVM with iSCSI storage
  • Deploying oVirt in self-hosted mode
  • Ansible playbook for handling perl on FreeBSD
  • iSCSI: Migrating from istgt to ctld

Tags

ansible backup carp chroot cluster cross-server esxi freebsd ftp ftpchroot gpt grub hast install iscsi kvm linux lun lvm mirror network nfs nfsroot ovirt pxe raid ramdrive raspberrypi snapshot ssd ssh terminalserver usb vfio virtio virtualbox vlan vmware volumes winxp zfs zpool zroot

Archives

  • July 2019
  • March 2018
  • February 2018
  • July 2017
  • February 2016
  • January 2015
  • August 2014
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • September 2012
  • July 2012
  • April 2012
  • March 2012
  • November 2011
  • August 2011

Recent Comments

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    © Copyright 2013-2016 - Magnus Strahlert
    Infinity Theme by DesignCoral / WordPress