Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have setup software RAID1-arrays using two 250GB harddrives. There's two arrays - one named md0 in which the system is kept and the other, md1 works as swap:

# cat /proc/mdstat 
md0 : active raid1 sda1[1] sdb1[0]
      239256512 blocks [2/2] [UU]

md1 : active raid1 sda2[1] sdb2[0]
      4940736 blocks [2/2] [UU]

To keep things a bit more organized, I would like to use separate partitions for /tmp, /home, /var, /opt & and so on in the future. Do I need to create separate arrays for each partition or can I someway let my current md0 contain all these partitions without creating a dozen additional arrays?

Thanks

share|improve this question
4  
Any reason you're not using LVM? –  Mat Feb 4 '12 at 12:33
    
No idea. I followed this guide some time ago and ended up with working software raid and was quite happy with it, help.ubuntu.com/community/Installation/SoftwareRAID –  Industrial Feb 4 '12 at 13:06
    
Software RAID and LVM are not mutually exclusive. LVM on top of RAID (soft or hard) is quite common. –  Mat Feb 4 '12 at 13:09
    
Oh. LVM is completely new to me (besides seeing it in the installation prompts here and there) so I need to read up on it. –  Industrial Feb 4 '12 at 13:13
    
I know several sysadmins that consider LVM to be overkill in many situations. If you will be adding, removing and resizing mounts over time then LVM is a good choice. If you want something simple then it's easier not to have to learn two sets of tools (mdadm & LVM). –  i_grok Feb 4 '12 at 14:11
show 2 more comments

2 Answers

up vote 1 down vote accepted

Mat already said it. I will give you a quick example of a standard layout for software raid and LVM:

  • sd[ab]1: /boot, 256MB - can be run as Raid1 (md0), install grub on both partitions
  • sd[ab]2: /, 3GB - run as Raid1 (md1)
  • sd[ab]3: md2 - use for VG system:

After you created md2:

  1. pvcreate /dev/md2
  2. vgcreate system /dev/md2
  3. lvcreate -n vartmp -L 2G system
  4. mkfs -t ext3 -L vartemp /dev/system/vartemp
  5. mount /dev/system/vartemp /var/tmp

I hope that is enough to get the idea. You can use LVs just like you would use a partition. If / is big enough, you can start by installing everything there, then set up your LVs and move the contents there after you booted from a rescue ISO/DVD/CD.

share|improve this answer
1  
You don't need to have separate raid arrays for / and /boot. / can be a logical volume too, and if you are using grub2 ( any recent version of Ubuntu ), you don't need a separate /boot partition at all. –  psusi Feb 4 '12 at 22:53
    
That may be a speciality from me - I install grub into the /boot partition. Thus the separate partition. –  Nils Feb 5 '12 at 21:37
add comment

Older versions of the mdadm utility and Linux kernel (2.4) did not support partitioning of software RAIDs. This was introduced in the 2.6 kernel, but partitioning of so-call "non-partitioned" arrays was not introduced until 2.6.28.

From mdadm man page:

The standard names for non-partitioned arrays (the only sort of md array available in 2.4 and earlier) are of the form

          /dev/mdNN

   where NN is a number.  The standard names for partitionable arrays
   (as available from 2.6 onwards) are of the form

          /dev/md_dNN

   Partition numbers should be indicated by added "pMM" to these,
   thus "/dev/md/d1p2".

   From kernel version, 2.6.28 the "non-partitioned array" can actually
   be partitioned.  So the "md_dNN" names are  no longer needed, and
   partitions such as "/dev/mdNNpXX" are possible.

If you're using a version of mdadm older than 3.0, mdadm is responsible to create all the device nodes (see the --auto option). Later versions rely on udev.

share|improve this answer
    
Having swap on a RAID1 (like above) versus spread across two partitions (like you suggest) is not the same thing at all. If one of the drive dies with your setup, the OS is very likely to go down too. Not so with swap on RAID1. –  Mat Feb 4 '12 at 14:48
    
Thanks. Corrected. –  i_grok Feb 4 '12 at 15:36
    
Actually, you can partition raid arrays just fine. Seeing as how it currently has no partition table though, adding one now would require reformatting the whole thing. –  psusi Feb 4 '12 at 22:51
    
Gah, I'm a dinosaur. Edited again. –  i_grok Feb 5 '12 at 14:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.