convert 1x2TB HDD with LVM into 2x2TB HDD with RAID1+LVM or with LVM mirroring?
Solution 1:
assuming sda is the original disk, and sdb is the new disk:
- partition the new drive. if using fdisk, be sure to hit
c
so it is aligned, and change the partition type toda
. -
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 missing
to create the raid device from the newly partitioned drive. -
sudo mdadm -Es
and copy the output of this to/etc/mdadm/mdadm.conf
so the raid device gets started automatically when the server reboots. -
sudo pvcreate /dev/md0
, after this just do vgcreate on /dev/md0 and lvcreate like usual, or you can use pvmove
After the data is moved off the old drive and on to the new, you can repartition the old drive, making sure the partition size is the same as the new raid drive. Then add it to the raid device with: sudo mdadm --manage --add /dev/md0 /dev/sda1
. Since it sounds like these are boot drives, you'll want to install grub to both drives.
Since this is a remote system, you'll probably want to do sudo dpkg-reconfigure mdadm
(assuming this is a debian-based system, such as Ubuntu) and enable boot with degraded raid.
You'll also want to set up email so mdadm can notify you of issues with the Raid device (such as a failed drive).
sudo aptitude install postfix
- choose a satellite system, I use the fqdn servername (or whatever you prefer), enter a smarthost if necessary.
- Edit
/etc/aliases
and addroot: yourusername
so root's mail go to you - Edit
~/.forward
with[email protected]
so your emails go to your email account
Solution 2:
I was advised that possibly the easiest way to convert 1xHDD into 1xRAID1 is by:
- creating a degraded 1-disk RAID1 on the newly installed HDD
- copying data from current HDD to that degraded RAID1
- adding the earlier-installed HDD to the degraded RAID1, and rebuilding the RAID.
Relevant links: 1, 2.