19

Many people claim that it is impossible to install Ubuntu onto RAID 1 with the Desktop CD. Is this really true? If not, how can it be done?

Sunday
  • 783

3 Answers3

27

Edit: This guide does not take UEFI boot into account. Additional or different steps may be required if UEFI boot is desired. This guide assumes legacy boot!

It is true, that the ubiquity installer does not know about mdadm software raid devices. Also it is true, that the live-cd is missing the mdadm raid administration tool. However, doing some work by hand, it is very much possible to install Ubuntu on RAID1.

In the following I will assume two identical hard disks (/dev/sd[ab]) which will be used completely for our new install. To simplify the recovery if one drive fails, there will be only one mdadm-volume /dev/md0 which will then be partitioned for /, swap and data storage, e.g. /home.

After booting up the live-cd and (if necessary) configuring network access, open up a terminal and assume root access sudo -s

apt-get install mdadm

Now we create a single primary partition each of /dev/sda and /dev/sdb from sector 2048 to the end of the disk, for example using sudo fdisk. I also like to already set the partition type to fd for linux raid autodetection. The keystroke-sequence in fdisk (if the disk is emptyin the beginning, meaning no partitions) is n <return> p <return> 1 <return> 2048 <return> <return> t <return> fd <return> w <return>.

Now we create the mdadm volume:

mdadm --create /dev/md0 --bitmap=internal --level=1 -n 2 /dev/sd[ab]1

I noticed, that the ubiquity installer also does not quite manage to create partitions inside this /dev/md0, so I also did this by hand - again using fdisk. So on /dev/md0 create the following partitions:

  • /dev/md0p1 for your root filesystem, the size of course depending upon how much software you are going to install.
  • /dev/md0p2 for swap, the size of course also depending on what you use the machine for and how much ram it's got
  • /dev/md0p3 for /home, all the space that's left

After that we can begin the Installation. Make sure to start the installer from the terminal with the -b option, because installing the bootloader will fail anyway:

ubiquity -b

Make sure to go for manual partitioning and "use" the 3 partitions you just created and tick the format checkbox for / and /home so a filesystem will be created.

After the installation the system is not yet bootable, so do not restart the box right away. We need to chroot into the installed system and fixup some stuff:

sudo -s
mount /dev/md0p1 /mnt
mount -o bind /dev /mnt/dev
mount -o bind /dev/pts /mnt/dev/pts
mount -o bind /sys /mnt/sys
mount -o bind /proc /mnt/proc
cat /etc/resolv.conf >> /mnt/etc/resolv.conf
chroot /mnt
apt-get install mdadm
nano /etc/grub.d/10_linux  # change quick_boot to 0
grub-install /dev/sda
grub-install /dev/sdb
update-grub
exit

Now the newly installed system is ready to boot. Have fun!

Sunday
  • 783
  • 4
    Will it ever be supported out of the box? Is there any reason not to offer this feature. In the perfect world there should be option for RAID install. – umpirsky Jan 17 '15 at 11:17
  • @Mwithii says: "The guide is ok, except for the "apt-get install mdadm" in chroot that was not working as is. I had to "cp /etc/resolv.conf /mnt/etc/resolv.conf" to solve as described here: http://ubuntuforums.org/showthread.php?t=1268160&p=7960338#post7960338" – MadMike Feb 06 '15 at 12:26
  • 1
    prob. easier to move the already-downloaded mdadm .deb from /var/cache/apt/archives into /mnt before chrooting in, and dpkg -i to install it. – Peter Cordes Feb 15 '15 at 06:25
  • I'm not seeing a way to get Ubiquity to put a filesystem directly on an md device. I don't particularly want to partition my md devices; I'd rather have multiple RAIDs for different filesystems. That way I could potentially keep / and /home redundant with an old small drive, while /data where I put big files is degraded until I get around to getting a replacement that's as big as the original drives. (semi-made-up example, various other scenarios should be obvious.) – Peter Cordes Feb 15 '15 at 06:30
  • @PeterCordes: Copying only the mdadm deb is not enough, it needs to pull some dependencies. I really should have added something about resolv.conf to the original posting. Replacing it (like @Mwithii proposed) might break the automatic configuration by the resolvconf package. Better do the following: cat /etc/resolv.conf >> /mnt/etc/resolv.conf. – Sunday Feb 16 '15 at 11:32
  • @PeterCordes: If ubiquity won't put a filesystem there, it might work to do it manually before launching ubiquity. Otherwise creating one partition for the whole md is also a perfectly fine solution. – Sunday Feb 16 '15 at 11:33
  • mdadm doesn't have any depends:, only recommends:. I copy the .deb to my flash drive and install it (and smartmontools ) after booting a live CD/USB. – Peter Cordes Feb 16 '15 at 18:24
  • I wanted to test GRUB booting a filesystem on a RAID10,f2. The extra hoop for GRUB to jump through of a partition on a RAID on a partition is a bit much. – Peter Cordes Feb 16 '15 at 18:26
  • @Sunday: good suggestion to try making filesystems first. Ubiquity noticed that, and let me tell it to put / on the existing md0 without partitioning it or even re-doing the mkfs. (Which also allows using non-default options like mkfs.xfs -m crc=1,finobt=1 that mkfs leaves off until kernel support for them has been around for years.) Anyway, the install finished, but then grub-install failed. Sorting that out now. – Peter Cordes Feb 21 '15 at 00:33
  • 2
    Grub install failed for me: grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible. grub-install: error: embedding is not possible, but this is required for RAID and LVM install. Looks like boot parttition is missing? Maybe creating bios boot partition on both sda and sdb will help, like on http://serverfault.com/questions/386041/ubuntu-server-gpt-partition-table-mdadm-grub-boot-fail? – umpirsky May 02 '15 at 12:28
  • I followed this instructions and installed grub without errors. Everything went fine, but after reboot, there were no boot options. I was prompted with BIOS with no boot options to choose from. The only difference in my case is that raid level is 0, not 1. @Sunday Any hints? – umpirsky May 03 '15 at 10:54
  • I did not have GPT/UEFI in mind when doing this. Maybe there are a few things that need to be adjusted, especially considering boot loader installation. Maybe your system is in a state where it will only boot in the BIOS compatibility mode of your UEFI. – Sunday May 04 '15 at 07:18
  • @Sunday maybe, I am not familiar with it. I have Asus Zenbook and there are some UEFI related options in BIOS. – umpirsky Oct 17 '15 at 16:31
  • Your procedure worked for me with one modification. After starting the installer and configuring mount points, I would open a root shell and chroot /target. Then copy mdadm.conf from live system to installed system. After this I could proceed with the normal install, and even installing GRUB worked. – kasperd Oct 18 '15 at 16:32
  • I am left with one problem though. During boot I get an error message saying error: diskfilter writes are not supported. – kasperd Oct 18 '15 at 16:36
  • Ah, that was the quick_boot setting was for. Changing that to 0 and running update-grub fixed that problem for me. – kasperd Oct 18 '15 at 16:43
  • Should same work for RAID0? – umpirsky Nov 19 '15 at 15:30
  • Propably. But I would leave the swap partition out of the raid0 and create two seperate swap partitions, because the kernel automatically does load-balancing between multiple swap spaces and this could give better performance than a single swapspace on a raid0. – Sunday Dec 09 '15 at 13:42
  • @Sunday Looks like something has changed, and this instruction needs to be updated, after installing, I'm getting some errors. It still works, but would be good to have this fixed, I had troubles and unable to boot after few months. I would appreciate if you take a look at my question http://askubuntu.com/questions/766355/error-unknown-command-hwmatch. Thanks in advance. – umpirsky Jun 13 '16 at 12:18
  • 1
    @umpirsky I added a warning to the guide. Please look into http://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-64-bit-with-a-dual-boot-raid-1-partition-on-an-uefi]. – Sunday Jun 15 '16 at 08:51
  • @Sunday Yes, I was kinda aware of this, but a year ago when I was installing 15.04, I created instruction https://gist.github.com/umpirsky/6ee1f870e759815333c8 which was combination of this 2, and was working perfectly. Now with 16.04 UbuntuGnome, I have this http://askubuntu.com/questions/766355/error-unknown-command-hwmatch problem. So I'm trying to identify what should I change in my gist or how to fix this error. Thanks! – umpirsky Jun 16 '16 at 08:18
  • @Sunday: I was looking for the same solution as you, except I had an UEFI system. You are correct that a few tweaks were needed for UEFI (details: http://askubuntu.com/questions/660023/how-to-install-ubuntu-14-04-64-bit-with-a-dual-boot-raid-1-partition-on-an-uefi]). Furthermore, I needed to insert a sleep in the local-premount scripts, otherwise I ended up at the grub rescue prompt when I disconnected one of my drives for testing! Does your solution work without a sleep if you unplug one of the disks? – Niclas Börlin Aug 13 '15 at 19:31
2

Do not install Ubuntu Desktop CD with RAID 1. My advice:

  1. Use the Ubuntu Server CD to have a guided RAID 1 install. The manual for this is here (ignore the LVM part, not needed) :
    https://help.ubuntu.com/lts/serverguide/advanced-installation.html
  2. After that install the Ubuntu desktop environment with
    sudo apt-get install ubuntu-desktop
  3. Reboot and you have a Ubuntu desktop (installed with the server cd).
  • 1
    I think it is well known (and to be expected), that the server installer has RAID support. This question however was specifically about clarifying wether the desktop installer could be used anyhow. But thanks for letting us know anyway! – Sunday Jun 05 '15 at 09:30
-1

I haven't tried, but just came accross http://www.salamander-linux.com/.

Salamander is a modified version of the default installer for Ubuntu Linux, Ubiquity. This modified installer allows users to easily install Ubuntu Linux onto a Software RAID array. No special hardware is required -- the Salamander installer can be used on any system with multiple hard disks.

umpirsky
  • 4,050
  • this seems pretty outdated from 2010. – therealmarv Jun 03 '15 at 20:15
  • @therealmarv Yes, must find new solution. – umpirsky Jun 04 '15 at 07:45
  • I think the overall better solution is to use a Ubuntu Server CD with very good RAID1 support and install everything like in the official docs: https://help.ubuntu.com/lts/serverguide/advanced-installation.html then at the end install sudo apt-get install ubuntu-desktop and the server is also a desktop. – therealmarv Jun 04 '15 at 10:55
  • @therealmarv Maybe, but I read somewhere that there are some drawbacks with this approach. Desktop distribution is somehow different. – umpirsky Jun 04 '15 at 11:02