How should a RAID partition be created and configured using parted?

30,334

Start Parted using -a optimal to make sure it warns you in case you are creating a partition which is not correctly aligned. Create the partition without specifying any file system using mkpart:

mkpart primary 1MiB 512MiB

This command creates a 511MiB partition starting at 1MiB and ending at 512MiB.

Use MiB, GiB or TiB when creating the partition. This ensures correct alignment on HDD's with 512B as well as 4096B physical sectors.

Above 1MiB is used as the starting position, as it's the lowest position you can use without Parted complaining about alignment. But make a mental note that sector 40 really is the lowest position with correct alignment, but parted likes 1MiB boundaries and you're wasting very little disk space.

To make the kernel notice the RAID partition and mount it automatically you need to set the raid flag. If your new partition is identified as partition 1 in Parted (check with p) you set the raid flag using:

set 1 raid on

Verify the partitions sizes with print, but set unit display to KiB, MiB, or GiB. If you do not, the default compact units will show KB, MB and GB.

unit MiB
print

To sum the answers up:

I know that raid is a possible partition flag, do I have to use it? How is it used by the running system?

No you don't have to. In case you choose not to you have to mount it yourself.

Which file system type should I use? None?

Yes, don't specify one. Parted is moving away from handling file systems, the stuff relating to filesystems at the moment should be avoided.

Share:
30,334

Related videos on Youtube

Boston Kenne
Author by

Boston Kenne

Updated on September 18, 2022

Comments

  • Boston Kenne
    Boston Kenne almost 2 years

    For testing I want to create a mirrored (RAID 1) partition with a size of 1GB on /dev/sdb and /dev/sdc. When it comes to partitioning, I want to used parted, how should I create the partition I want to mirror?

    I start by initializing the partition table:

    (parted) select /dev/sdb
    Using /dev/sdb
    (parted) mklabel gpt
    Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
    Yes/No? Y
    (parted)
    
    • After the above steps. How do I create the partition and set any necessary flags?

    • I know that raid is a possible partition flag, do I have to use it? How is it used by the running system?

    • Which file system type should I use? None?

    • Boston Kenne
      Boston Kenne over 11 years
      The flag is used by the kernel (Linux) to indicate RAID partitions it should mount. That's not all of the answer I was looking for, so I write it here for now.
  • CMCDragonkai
    CMCDragonkai about 10 years
    Does it make sense to create 2 partitions on a single hard disk and then using the 2 partitions for RAID 1 or RAID 0? Or is RAID meant to be only be used with real independent hard disks?
  • rgs258
    rgs258 over 9 years
    @CMCDragonkai: Using the same disk for multiple members of the same array makes no sense. If the disk dies, you most likely lose access to the whole disk, not just a part of it. But nothing stops you from doing it anyway. You could even use loop devices if you just want to test stuff...