Ubuntu 12.04 - Add RAID 1 Array on existing device?
Solution 1
Create a new RAID1 array with a "missing" device using the following in a terminal (may have to employ the sudo
command):
# mdadm --create /dev/md0 -n 2 -l 1 /dev/sda1 missing
You'll be able to move all the data onto /dev/md0
, boot with that, then add /dev/hdb1
into the mirror:
# mdadm --manage /dev/md0 -a /dev/hdb1
Backup your data first and get familiar with mdadm and software RAID on Linux to avoid shooting yourself in the foot.
Solution 2
It seems that you are most of the way there. I'm trying to do the same thing and found you on google. Notwithstanding the issue that your drives may not be the same size (mine are), I think all you need to do is :
- boot Ubuntu live CD, add and start mdadm
- start your md0, partition it
- rsync -av from /dev/hdb1 to /dev/md0p1
- change grub to boot your raid
- reboot into your raid
- repartition your first disk
- add the other disk to the raid
Done
But that is only guessing :-) It may be a week or so before I get to try it myself.
This is similar to something I've done - move an Ubuntu box from one piece of HW to another using rsync. I learned there that you NEED to copy the OS from a live CD - you can't get a good copy of the OS when booted from the OS itself.
You want to
rsync -av --exclude-from=excludefile /source/ /destination/
and your exclude file looks like :
# Include + /dev/console + /dev/initctl + /dev/null + /dev/zero # Exclude - /dev/* - /proc/* - /sys/* - /tmp/* - lost+found/ - /media/backup/*
Related videos on Youtube
senzacionale
Updated on September 18, 2022Comments
-
senzacionale over 1 year
I read How can I add a RAID 1 array in Ubuntu 10.04 and Installing Raid 1 on Existing Ubuntu Server. However, I only have the following 2 hard drives:
dev/sdb1
where Ubuntu 12.04 is currently runningdev/sda1
empty diskI want to create a RAID on these two hard drives, but I don't want to delete the
sdb1
partition because Ubuntu is working fine.How can I create a RAID on existing device?
I performed
mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sda1
Then
mkfs -t ext2 /dev/md0
And I run
echo "DEVICE partitions" > /etc/mdadm/mdadm.conf mdadm --detail --scan >> /etc/mdadm/mdadm.conf
Then I change boot to
md0
ingrub2
menuentry 'Ubuntu, with Linux 3.2.0-23-generic' --class ubuntu --class gnu-linux --class gnu --class os { recordfail gfxmode $linux_gfx_mode insmod gzio insmod part_msdos insmod ext2 set root='(md0)' search --no-floppy --fs-uuid --set=root 8fff7794-a156-46d2-92f8-4931d42abf36 linux /vmlinuz-3.2.0-23-generic root=/dev/mapper/ubuntu--server-root ro initrd /initrd.img-3.2.0-23-generic }
But, when I want to add
mdadm --manage /dev/md0 -a /dev/sdb1
I always get
mdadm: Cannot open /dev/sdb1: Device or resource busy
-
senzacionale about 12 yearsThx for answer. can you give me en example how to add hdb1 to mirror?
-
MikeyB about 12 yearsYou'll need to read the mdadm and software RAID documentation to avoid losing your data and get familiar with it. For example, are your hard drives the same size? Probably not since one is IDE and one is SATA. You'll need to ensure the RAID device you create is not too large.
-
senzacionale about 12 yearsdisks are the same size. hdb1 is sdb1, my mistake sorry. both disks are SATA1
-
senzacionale about 12 yearsi am reading mdadm but i am not sure how to mirror sdb1
-
MikeyB about 12 yearsI already edited how to add sdb1 to the mirror into the question.
-
senzacionale about 12 yearsThx i see. but i get root@ubuntu-server:~# mdadm --manage /dev/md0 -a /dev/sdb1 mdadm: Cannot open /dev/sdb1: Device or resource busy
-
senzacionale about 12 yearsi try stop it first and then restart but is the same. mdadm --stop /dev/md0
-
MikeyB about 12 yearsYou need to boot using /dev/md0 first.
-
senzacionale about 12 yearsyou mean changing root (hd0,msdos1) in grub to root (md0)? but i still get Device or resource busy
-
senzacionale about 12 yearsi try everything even this howto howtoforge.com/… but i don't know how to boot. now i get error when booting md0
-
MikeyB about 12 yearsDid you copy the data over to it?
-
senzacionale about 12 yearsyes sfdisk -d /dev/sdb | sfdisk --force /dev/sda ke is in this howto: howtoforge.com/…
-
MikeyB about 12 yearsYou made backups, right?