0

So I am working out how to add a new raid1 array to our server as we have a raid1 array which is almost full. I have replicated our server setup in a virtual machine and attempted to add a raid array but I want to check I have done everything correctly.

Before adding the raid array I have a setup like so:

lsblk -o NAME,SIZE,TYPE,MOUNTPOINT NAME SIZE TYPE MOUNTPOINT sda 100G disk |-sda1 10G part | `-- md0 10G raid1 [SWAP] `-sda2 90G part `-- md1 90G raid1 / sdb 100G disk |-sdb1 10G part | `-- md0 10G raid1 [SWAP] `-sdb2 90G part `-- md1 90G raid1 / sdc 8G disk sdd 8G disk sr0 1024M rom

I then use fdisk to partition the empty drives like so:

sudo fdisk /dev/sdc

command (m for help): p
Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/phyisical) : 512 bytes / 512 bytes
I/O size (minimum/optimal) : 512 bytes / 512 bytes
Disk identifier: 0x3e73dada

      Device Boot        Start            End       Blocks     ld      System

I create a 500MB swap partition:

Command (m for help): n Partion type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): <RETURN> using default value 1 First sector (2048-16777215, default 2048):<RETURN> Using default value 2048 Last sector, *sectors or +size(K,M,G) (2048-16777215, default 16777215): +1Gp

and want to use the rest for storage:

Command (m for help): n Partion type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 2): <RETURN> using default value 2 First sector (1026048-16777215, default 1026048):<RETURN> Using default value 1026048 Last sector, *sectors or +size(K,M,G) (2048-16777215, default 16777215):<RETURN> Using default value 16777215

The setup now looks like this:

Command (m for help): p
Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/phyisical) : 512 bytes / 512 bytes
I/O size (minimum/optimal) : 512 bytes / 512 bytes
Disk identifier: 0x3e73dada

      Device Boot        Start            End       Blocks     ld      System
/dev/sdc1                2048             1026047   512000     83      Linux
/dev/sdc2             1026048            16777215  7875584     83      Linux

I then make the 500MB partition into swap space the the 7.5GB partition into bootable space.

Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): 82 Changed system type of partition 1 to 82 (Linux swap / Solaris)

Command (m for help): a Partition number (1-4): 2

My system now looks like so:

Command (m for help): p
Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/phyisical) : 512 bytes / 512 bytes
I/O size (minimum/optimal) : 512 bytes / 512 bytes
Disk identifier: 0x3e73dada

      Device Boot        Start            End       Blocks     ld      System
/dev/sdc1                2048             1026047   512000     82      Linux swap / Solaris
/dev/sdc2       *     1026048            16777215  7875584     83      Linux

and I write these changes with w

I did the same to sdd so my system looks like so:

NAME SIZE TYPE MOUNTPOINT sda 100G disk |-sda1 10G part | `-- md0 10G raid1 [SWAP] `-sda2 90G part `-- md1 90G raid1 / sdb 100G disk |-sdb1 10G part | `-- md0 10G raid1 [SWAP] `-sdb2 90G part `-- md1 90G raid1 / sdc 8G disk |-sdc1 500M part `-sdc2 7.5G part sdd 8G disk |-sdd1 500M part `-sdd2 7.5G part sr0 1024M rom

I then created a raid array from these partitions with mdadm like so:

sudo mdadm --create --verbose /dev/md/2 --level=1 /des--raid-devices=2 /dev/sdc /dev/sdd

and I then created an ext4 filesystem on the array

sudo mkfs.ext4 -F /dev/md/2

Created a mount point like so:

sudo mkdir -p /media/md2

and then mounted my completed raid1 array like so:

sudo mount /dev/md/2 /media/md2

I then had to use chmod -R 777 /media/md2

If I then cd into the mounted partition I see a file called lost+found and am able to write to the drive.

However I then found when I shutdown the virtual machine and restart it the /dev/md/2 is gone and in it's place is dev/md/laz:2.

The virtual machine is called laz.

When I mount it in /media/md2 it still has all the files in, is this all setup ok?

1 Answers1

1

If I then cd into the mounted partition I see a file called lost+found and am able to write to the drive. Have I set everything up correctly?

You must change user owner to /media/md2 . You can make this with: (This step you make with unmounted drive sudo umount /media/md2):

sudo chown < you_user >:< you_user > /media/md2 # Example: sudo chown user:user /media/md2

And then, when you have folder with your user (check this with: ls -la /media | grep md2 ), then you can mount your disc into this folder, and write to this disc without sudo .

liske1
  • 114
  • 4