Skip to content

Instantly share code, notes, and snippets.

@kfei
Created May 25, 2015 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfei/98179580527cf17c6507 to your computer and use it in GitHub Desktop.
Save kfei/98179580527cf17c6507 to your computer and use it in GitHub Desktop.
Migrate USB OS to mdadm RAID array on Arch Linux
# Create new array
mdadm --zero-superblock /dev/sd{a,b}
mdadm -C --level 1 /dev/md1 -n 2 /dev/sda2 /dev/sdb2
# Save to mdadm.conf since it will be used in initramfs for assembling arrays
mdadm --detail --scan >> /etc/mdadm.conf
# Make new file system and then migrate data
rsync -avxHAXS -P / /mnt/md1
# Chroot into the new world
cd /mnt/md1
mount -t proc proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/
mount --rbind /run run/
chroot /mnt/md1 /bin/bash
# Rebuild initramfs
# Add mdadm_udev to the HOOKS section of the mkinitcpio.conf first, then:
mkinitcpio -p linux
# Add MODULES="xfs" and BINARIES="fsck.xfs" to /etc/mkinitcpio.conf if needed
# (Chroot-ed) Edit /etc/fstab according to new `blkid` and then:
grub-mkconfig -o /boot/grub/grub.cfg
grub-install /dev/sda
grub-install /dev/sdb
# Verify success
reboot
# Ref(outdated): https://wiki.archlinux.org/index.php/Convert_a_single_drive_system_to_RAID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment