Samba share on software raid1

Hello!
i am having a ubuntu server with two empty disks and connected software raid1 to it.
I am having /mnt/raid folder which i created to mount it.

SO should i now make a share folder inside that or what? I ama bit confused when a raid is present.

Assuming that you have completed the following steps:
You created a raid1
You partitioned the space that the raid1 provides like any other hard drive
You created a file system in that one of the partitions (xfs or ext4)

Now you can mount that filesystem somewhere:
You create an empty directory. It looks like you have /mnt/raid. In my opinion that would not be a desirable place /mnt is more for temporary mounting of filesystems. To provide a service like samba probably /srv/samba or /var/samba would be better.
After that you can share that space configuring the samba service.

Thank you. I will put itto there but it is tnan on my host machine, i want that folder to be in one of the raid discs,thats the point.
Ubuntu is installed on seperate hard disk.

There is no need to be confused because a RAID is present.

When you create a RAID1 (mirror) the pair of disks are afterwards managed as a single drive. The second disk becomes invisible.

Having a RAID1 has no bearing or influence on what the storage is used for, Samba or anything else.

The RAID1 is managed using a single device (/dev/dsk/<whatever>) for mounting/dismounting and will mount/dismount like any other single drive.

So once the RAID1 is formed, ignore the fact it's a RAID and treat it like any other single disk.

You can mount the space anywhere you like and use the storage like any other storage.

thanks, i am a bit confused, but thanks for answer.
I had setup a share folder in /mnt/raid/ called test, and it is working via windows but when i deattach one drive it is lost, i cant access and i cant see it in linux also

cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb[0] sdc[1]
      1953383488 blocks super 1.2 [2/2] [UU]
      bitmap: 0/15 pages [0KB], 65536KB chunk
 lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
NAME                    SIZE FSTYPE            TYPE  MOUNTPOINT
sda                   232.9G                   disk
sda1                232.9G LVM2_member       part
  johna--vg-root     227G ext4              lvm   /
  johna--vg-swap_1   5.9G swap              lvm   [SWAP]
sdb                     1.8T linux_raid_member disk
md0                   1.8T ext4              raid1 /mnt/raid
sdc                     1.8T linux_raid_member disk
md0                   1.8T ext4              raid1 /mnt/raid

these are permission to folder

drwxr-xr-x 4 root root 4096 Aug 30 23:12 raid
drwxr-xr-x   3 root root  4096 Aug 30 12:39 mnt
drwxr-x--x 2 nobody nogroup  4096 Aug 31 08:54 test

smb.conf

[test]
path = /mnt/raid/test
valid users = johna myuser
read only = no
browsable = yes
guest ok = no
public= no
create mask = 0644
directory mask = 0755
force user = myuser

Hmmmmm.......so both members of the RAID are shown as present and active....good.

So this RAID is on device /dev/md0

(After the RAID is create you should never address these disks as their original devices (/dev/dsk/... or whatever the format is on Ubuntu), only as /dev/md0.

What command are you using to mount the RAID where you want it? Are you specifying /dev/md0? If so, the system should know that it's a RAID mirror and if one disk fails, access to data on the surviving copy should remain.

sudo mount /dev/md0 /mnt/raid

So when you say you "detach" a disk how are you doing that?

i just reconfigure a permissions and add a group

drwxr-xr-x 4 root root 4096 Aug 30 23:12 raid
drwxr-xr-x   3 root root  4096 Aug 30 12:39 mnt
drwxrwx--- 2 root admins  4096 Aug 31 08:54 test

smb.conf

[test]
path = /mnt/raid/test
valid users = @admins
read only = no
browsable = yes
guest ok = no
public= no

when deattach one disk, i cant see test folder in /mnt/raid/

------ Post updated at 03:26 AM ------

i turned off from the board, just pull off sata cable.

After you created the RAID did you format it/create a new filesystem on it?

Did you see the resilvering process occur?

You are right to assume that you should be able to remove one of the drives and the volume still be available.

Does it also disappear if you detach the other disk?

This is what I did

sudo mkfs.ext4 -F /dev/md0

folder /mnt/raid/test disappear only. But this is only folder that I need.
/mnt/raid is steal present.

When you detach a disk, is the RAID still shown as mounted?

You might have /mnt/raid existing on your root filesystem which is covered when you mount /dev/md0 over the top. Then, if the RAID dismounts (although it should'nt) you will be left with /mnt/raid but the test folder will seem to be gone.

yeah raid is present, but inactive, no another disk.
How can i get my windows users allways have their files, and me also.
I cant get to lost my test folder.

I now deattach disk and no folder.
this is lsblk command

lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
NAME                    SIZE FSTYPE            TYPE MOUNTPOINT
sda                   232.9G                   disk
sda1                232.9G LVM2_member       part
  johna--vg-root     227G ext4              lvm  /
  johna--vg-swap_1   5.9G swap              lvm  [SWAP]
sdb                     1.8T linux_raid_member disk

------ Post updated at 04:25 AM ------

cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : inactive sdb[0](S)
      1953383512 blocks super 1.2

unused devices: <none>

------ Post updated at 04:35 AM ------

sudo mdadm --examine --scan --config=mdadm.conf >> /etc/mdadm/mdadm.conf
ARRAY /dev/md/0  metadata=1.2 UUID=bd34d949:34a3999d:949d6038:a871e1c1 name=johna:0

You posted this in "Unix for Beginners Question and Answers" but this isn't a beginners question so I'll move this thread to the Ubuntu forum proper in the hope that more Ubuntu experts will see it.

1 Like

what also i notice, when deattach disk LIVE when system is running, disk disappear from array after restart, it cant be access.
It is present like /dev/sdb but not in raid...

If you are saying /dev/sdb is not in RAID after a reboot(?) then I would ask, do you have the /dev/md0 mount in /etc/fstab?

Can you tell me what happens if you follow the following tutorial :
How To Create RAID Arrays with mdadm on Ubuntu 16.04 | DigitalOcean

All the setup, with carefull reading and understanding.
Of course, you are creating RAID1 so you can ignore other possible configurations.

Are you sure the disk or disks initialized with mdadm are not mentioned in /etc/fstab. They should not be there, but only meta(MD) device(s).

Also, did you execute as root at the end of operation :

sudo update-initramfs -u

Hope that helps
Regards
Peasant.

1 Like

This is exactly tutorial i was follow.
this is fstab last line

/dev/md0 /mnt/raid/ ext4 defaults,nofail,discard 0 0

This is now lsblk

sdb                     1.8T linux_raid_member disk
md0                   1.8T ext4              raid1 /mnt/raid
sdc                     1.8T linux_raid_member disk
md0                   1.8T ext4              raid1 /mnt/raid

when remove one disk, it is good, i can access my folder via windows, but when get another out, just goes from md0

sdb                     1.8T linux_raid_member disk

and sdc is a part of md0

Please answer the question asked by Peasant about did you run:

# sudo update-initramfs -u

sorry i don't write it.
Yeah, ofcourse.
this is output

sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-4.10.0-19-generic

i have notices that in conf file array is /dev/md/0

ARRAY /dev/md/0 metadata=1.2 name=johna:0 UUID=bd34d949:34a3999d:949d6038:a871e1c1

------ Post updated at 06:41 AM ------

i also cant access to my data after deattach one hard drive.

------ Post updated at 06:43 AM ------

THis is output of mdstat

root@myuser:/mnt/raid/test# cat /proc/mdstat
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdc[1] sdb[0]
      1953383488 blocks super 1.2 [2/2] [UU]
      bitmap: 0/15 pages [0KB], 65536KB chunk

unused devices: <none>

------ Post updated at 07:23 AM ------

i now do it like this
Link
i delete array and added like in example. No errors found.
I can see that it is monuted

Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/johnas--vg-root  223G  1.4G  210G   1% /
/dev/md0                     1.8T  898M  1.7T   1% /mnt/md0
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
NAME                    SIZE FSTYPE            TYPE  MOUNTPOINT
sda                   232.9G                   disk
sda1                232.9G LVM2_member       part
  johnas--vg-root     227G ext4              lvm   /
  johnas--vg-swap_1   5.9G swap              lvm   [SWAP]
sdb                     1.8T linux_raid_member disk
md0                   1.8T ext4              raid1 /mnt/md0
sdc                     1.8T linux_raid_member disk
md0                   1.8T ext4              raid1 /mnt/md0

I am now waiting to sync and try again to deattach disks and try to copy for example to /home/johnas/something, to see if it is good to go or not.
Just one question.
If I deattach one disk, and restart, it should be also in md0 because i added it in fstab.