linux software raid - is this right?

Red Squirrel

No Lifer
May 24, 2003
70,176
13,576
126
www.anyf.ca
I'm creating a raid1 for redundancy. I have an existing regular ext3 drive with data on it and added another drive of same size. So I created a raid 1 with just the new drive (obviously degraded state atm) so its called /dev/md0 I created an ext3 partition on that device, but it does not show up in /dev/md0p1 like it should according to fdisk.

In fact, I was able to do mkfs.ext3 /dev/md0

It's formatting now.

Does this even make sense? From my understanding md0 is equivalent to like sda, its a device, not a partition. So how is this working and why does /dev/md0p1 not show up?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Because you didn't partition it. You can create a filesystem on the entire block device of anything if you want, partitioning is optional.
 

Red Squirrel

No Lifer
May 24, 2003
70,176
13,576
126
www.anyf.ca
I was trying to partition it, but it would not show up in /dev/ so I could do it. The partition itself existed as I made it in fdisk, but it would not show up in /dev/mdp1. I rebooted after I created it in fdisk as it gave me a warning and said it would only be active on reboot so I rebooted as well.
 

SleepWalkerX

Platinum Member
Jun 29, 2004
2,649
0
0
Originally posted by: RedSquirrel
I was trying to partition it, but it would not show up in /dev/ so I could do it. The partition itself existed as I made it in fdisk, but it would not show up in /dev/mdp1. I rebooted after I created it in fdisk as it gave me a warning and said it would only be active on reboot so I rebooted as well.

I'm kind of confused. If /dev/md0 exists then you are able to partition it. If you partitioned a new partition correctly then it shows up under /dev/md0<whatever>. Check out the cfdisk tool. If you run a cfdisk /dev/md0 you can see if any partitions are listed under /dev/md0 and if not then you can create one. It makes working with disks a lot easier.
 

Red Squirrel

No Lifer
May 24, 2003
70,176
13,576
126
www.anyf.ca
ohh so I should use cfdisk for raid devices? I was using fdisk. Shows up that there is a partition, but then when I try to do mkfs.ext3 /dev/md0 and hit tab, nothing else comes up, in fdisk it shows up as md0p1. I was able to format md0 directly though and its working. Is this a bad idea? (I don't plan to make multiple partitions)

 

SleepWalkerX

Platinum Member
Jun 29, 2004
2,649
0
0
cfdisk is just a program built around fdisk that provides a different interface afaik.

It sounds like /dev/md0 is your block device, like Nothinman said. You can format that directly and make it ext3, but you wouldn't be making any partitions. As long as you have room for the Master Boot Record then it should be fine. I'm not sure how the MBR fits in with how you're formatting it.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
I never, ever, paritition software raid devices. There is very little point to it.

After partitioning a device fdisk issues a special call to get that device 'reset'. This makes the kernel re-read the device and discover the new partitions. Otherwise the OS doesn't know that you've repartitioned stuff. Since I never partition md devices I don't know this for a fact, but if the system call fails then fdisk will tell you to reboot, since the reboot will cause the OS to re-read everything. It's a safe bet, more or less.

If you want partitions on a raid device don't use partitions. Use logical volume management. Logical volumes are much much smarter then partitions for a large number of reasons.

I repeat, LVM is your friend.

Either that or just use the entire md0 device directly. There is no problems with that, I do it all the time.
 

Red Squirrel

No Lifer
May 24, 2003
70,176
13,576
126
www.anyf.ca
Good to know, that was my plan anyway. Say I want to later expand that, is it doable? Like say I got a raid 5 with 3 drives so I want to add 2 more and use the capacity of 3 with 2 parity, would I be able to expand without loosing data or would I need to rebuild it?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I think you'd have to use RAID6 for double parity, but otherwise yes you can expand software RAID sets just fine.