Migrate Proxmox 3.3 to software RAID 1 by 15 steps


Proxmox installer is not able to do when you are prompted to software raid, here’s a quick tutorial how to migrate proxmox 3.3 to software raid 1 immediately after installation:

  1. Comment out existing repository, add free of use:
    # vi /etc/apt/sources.list.d/pve-enterprise.list
    # echo "deb http://download.proxmox.com/debian wheezy pve pve-no-subscription" >> /etc/apt/sources.list.d/proxmox.list
  2. Intsall packages that we need:
    # apt-get update && apt-get install mdadm initramfs-tools screen
  3. Copy the partition table on the second hdd:
    # sgdisk -R /dev/sdb /dev/sda
    The operation has completed successfully.
    # sgdisk -G /dev/sdb
    The operation has completed successfully.
    # sgdisk --randomize-guids --move-second-header /dev/sdb
    The operation has completed successfully.
  4. Change the partition type to raid
    # parted -s /dev/sdb set 2 "raid" on
    # parted -s /dev/sdb set 3 "raid" on
  5. Next:
    # mdadm --zero-superblock /dev/sdb2
    mdadm: Unrecognised md component device - /dev/sdb2
    # mdadm --zero-superblock /dev/sdb3
    mdadm: Unrecognised md component device - /dev/sdb3
  6. Create arrays:
    # mdadm --create /dev/md1 --level=1 --raid-disks=2 missing /dev/sdb2
    mdadm: Note: this array has metadata at the start and
        may not be suitable as a boot device.  If you plan to
        store '/boot' on this device please ensure that
        your boot-loader understands md/v1.x metadata, or use
        --metadata=0.90
    Continue creating array? y
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md1 started.
    # mdadm --create /dev/md2 --level=1 --raid-disks=2 missing /dev/sdb3
    mdadm: Note: this array has metadata at the start and
        may not be suitable as a boot device.  If you plan to
        store '/boot' on this device please ensure that
        your boot-loader understands md/v1.x metadata, or use
        --metadata=0.90
    Continue creating array? y
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md2 started.
  7. Next:
    # cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
    # mdadm --examine --scan >> /etc/mdadm/mdadm.conf
  8. Copy the /boot partition to the array:
    # mkfs.ext3 /dev/md1
    mke2fs 1.42.5 (29-Jul-2012)
    Filesystem label=
    OS type: Linux
    Block size=1024 (log=0)
    Fragment size=1024 (log=0)
    Stride=0 blocks, Stripe width=0 blocks
    130560 inodes, 521920 blocks
    26096 blocks (5.00%) reserved for the super user
    First data block=1
    Maximum filesystem blocks=67633152
    64 block groups
    8192 blocks per group, 8192 fragments per group
    2040 inodes per group
    Superblock backups stored on blocks:
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
    
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (8192 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    # mkdir /mnt/md1
    # mount /dev/md1 /mnt/md1
    # cp -ax /boot/* /mnt/md1
    
  9. Change the mount boot partition in /etc/fstab – now /boot point mount from /dev/md1
    # vi /etc/fstab
  10. Next we reboot the sysytem:
    # reboot
  11. Modify GRUB config:
    # echo 'GRUB_DISABLE_LINUX_UUID=true' >> /etc/default/grub
    # echo 'GRUB_PRELOAD_MODULES="raid dmraid"' >> /etc/default/grub
    # echo 'GRUB_TERMINAL=console' >> /etc/default/grub
    # echo raid1 >> /etc/modules
    # echo raid1 >> /etc/initramfs-tools/modules
    
  12. Reinstall GRUB:
    # grub-install /dev/sda --recheck
    Installation finished. No error reported.
    # grub-install /dev/sdb --recheck
    Installation finished. No error reported.
    # update-grub
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-2.6.32-34-pve
    Found initrd image: /boot/initrd.img-2.6.32-34-pve
    Found memtest86+ image: /memtest86+.bin
    Found memtest86+ multiboot image: /memtest86+_multiboot.bin
    done
    # update-initramfs -u
    update-initramfs: Generating /boot/initrd.img-2.6.32-34-pve
    
  13. Now add partition from the first disk to array:
    # parted -s /dev/sda set 2 "raid" on
    # mdadm --add /dev/md1 /dev/sda2
    mdadm: added /dev/sda2
  14. Migrate first disk to software raid:
    # screen bash
    # pvcreate /dev/md2
      Writing physical volume data to disk "/dev/md2"
      Physical volume "/dev/md2" successfully created
    # vgextend pve /dev/md2
      Volume group "pve" successfully extended
    # pvmove /dev/sda3 /dev/md2
      /dev/sda3: Moved: 2.0%
     ...
      /dev/sda3: Moved: 100.0%
    # vgreduce pve /dev/sda3
      Removed "/dev/sda3" from volume group "pve"
    # parted -s /dev/sda set 3 "raid" on
    # mdadm --add /dev/md2 /dev/sda3
    mdadm: added /dev/sda3
  15. After synchronization is complete, the array transfer process under Proxmox software raid 1 is completed. View the status of the array:
    # cat /proc/mdstat

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.