How to create a raid on Owncloud already working?

Good morning again,
I have installed dietpi on a raspberry pi zero w and running on it my personal cloud with Owncloud.

Now I would like to create a raid on it. I found this tutorial ( https://www.stewright.me/2017/08/create-raid-volume-raspberry-pi/amp/ ), for me very well done, but if I understood well, I should format also the volume already in use (where are stored already personal data of course :wink: ).

How can create the raid without losing data?

You have attached 2 physical drives? You would need to copy your data somewhere else, create the raid and copy data back.

Not yet, I was hoping not to copy data and back. Looks like this is the only way. isn’t it?

Thanks again

To setup a raid, you need at least 2 drives. Both will be initialised during the raid setup.

I go further on this topic because I’m still trying to create the raid.
I’ve tried to follow the step-by-step tutorial but I’m not sure if I made some mistakes.
when I launch this command: sudo mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdc1
it gives me this: mdadm: cannot open /dev/sda1: Device or resource busy
Please consider the sda is the drive where owncloud is already saving the data… maybe should I format somehow the drives before making all the processes?

As stated above, the 2 drives should be unused (not mounted) as they will be initialised. You can’t use a drive that is in-use.

Ah ok, so I should unmount it before giving those command, is this correct?
Should I also format them?

Please consider the sda is the drive where owncloud is already saving the data

If I understood correctly, the drive is in use already. Means, you will loos all your data if you use the drive to build up the raid. And yes you could format the drive before. At least it doesn’t hurt.

Yes, one of the drive is one I would like to use for the raid. And yes I’ll lose all the data, but I already backup everything on Google drive.
Is there a particular format to use to format the drives?

ext4 should be fine. But keep in mind to unmount the drive before creating the raid.

OK, I made all the suggested steps and everything went well.
The problem is that now, trying to reach Owncloud from the browser I’m back to this topic: https://dietpi.com/forum/t/solved-owncloud-doesnt-found-ocdata-file-after-have-change-the-drive/6062/7 where the page tells me it can find the .ocdata file in the data root…
I’m not sure if, following the steps suggested in the topic, I’ll solve the problem.
also because when I arrive at this command chown www-data:www-data /mnt/ownclouddrive/
it says me: chown: cannot access ‘/mnt/ownclouddrive/’: No such file or directory

What do you think?

well where did you mount your raid on? What is the mount point?

df -h
lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid

This is the result. Looks like it still hasn’t mounted. Isn’t it?

 root@DietPi:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       7.4G  3.6G  3.5G  52% /
devtmpfs         87M     0   87M   0% /dev
tmpfs           215M  5.4M  210M   3% /dev/shm
tmpfs            86M   11M   76M  13% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.0G     0  1.0G   0% /tmp
tmpfs            50M   20K   50M   1% /var/log
/dev/mmcblk0p1  127M   52M   75M  42% /boot
tmpfs            43M  8.0K   43M   1% /run/user/998
/dev/sdb1       7.3G  3.6G  3.7G  49% /mnt/backup
/dev/md0        916G   32K  870G   1% /mnt/raid0
root@DietPi:~# lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid
NAME FSTYPE LABEL   SIZE RO TYPE  MOUNTPOINT PARTUUID                             UUID
sda               931.5G  0 disk                                                  
└─sda1
     linux_ DietPi:0
                  931.5G  0 part             5cf75e0f-01                          57fe6d0d-5f9f-a801-56a0-a1308619e99d
  └─md0
     ext4         931.4G  0 raid1 /mnt/raid0                                      30c34f48-55f3-4e6e-b18f-2a72424cff6e
sdb                 7.5G  0 disk                                                  
└─sdb1
     ext4           7.5G  0 part  /mnt/backu 7903c760-bb51-4265-b9fb-36408acbecc4 2966eeaa-38a0-4cef-9469-fcd591d85249
sdc               931.5G  0 disk                                                  
└─sdc1
     linux_ DietPi:0
                  931.5G  0 part             8fbc00ec-b2c7-4568-8649-e4ce0bddabaf 57fe6d0d-5f9f-a801-56a0-a1308619e99d
  └─md0
     ext4         931.4G  0 raid1 /mnt/raid0                                      30c34f48-55f3-4e6e-b18f-2a72424cff6e
mmcblk0
│                   7.5G  0 disk                                                  
├─mmcblk0p1
│    vfat           128M  0 part  /boot      0e2887fb-01                          6725-6501

the raid is mounted to a different mount point

Filesystem      Size  Used Avail Use% Mounted on
/dev/md0        916G   32K  870G   1% /mnt/raid0

Therefore your are not able to reach /mnt/ownclouddrive/ because it did not exist

Ah ok,
so how can I change the mount location? Or tell owncloud to point to the raid at least?
Also because if I give this command: sudo mkdir /mnt/raid0/owncloud && sudo chown -R www-data:www-data /mnt/raid0/owncloud/ && sudo chmod -R 755 /mnt/raid0/owncloud/
this is the answer: mkdir: cannot create directory ‘/mnt/raid0/owncloud’: File exists

can you share following

cat /etc/fstab
ls -la /mnt/raid0/
root@DietPi:~# cat /etc/fstab
# You can use "dietpi-drive_manager" to setup mounts.
# NB: It overwrites and re-creates physical drive mount entries on use.
#----------------------------------------------------------------
# NETWORK
#----------------------------------------------------------------
192.168.1.112:/ /mnt/nfs_client nfs nofail,noauto,x-systemd.automount

#----------------------------------------------------------------
# TMPFS
#----------------------------------------------------------------
tmpfs /tmp tmpfs size=1024M,noatime,lazytime,nodev,nosuid,mode=1777
tmpfs /var/log tmpfs size=50M,noatime,lazytime,nodev,nosuid,mode=1777

#----------------------------------------------------------------
# MISC: ecryptfs, vboxsf, glusterfs, bind, Btrfs subvolume mounts
#----------------------------------------------------------------


#----------------------------------------------------------------
# SWAP SPACE
#----------------------------------------------------------------
/var/swap none swap sw

#----------------------------------------------------------------
# PHYSICAL DRIVES
#----------------------------------------------------------------
PARTUUID=0e2887fb-02 / ext4 noatime,lazytime,rw 0 1
PARTUUID=0e2887fb-01 /boot vfat noatime,lazytime,rw 0 2
UUID=2966eeaa-38a0-4cef-9469-fcd591d85249 /mnt/backup ext4 noatime,lazytime,rw,nofail,noauto,x-systemd.automount
UUID=30c34f48-55f3-4e6e-b18f-2a72424cff6e /mnt/raid0 ext4 noatime,lazytime,rw,nofail,noauto,x-systemd.automount
root@DietPi:~# ls -la /mnt/raid0/ls -la /mnt/raid0/

ls: cannot access '/mnt/raid0/ls': No such file or directory
/mnt/raid0/:
total 28
drwxr-xr-x 4 root     root      4096 Feb 23 22:16 .
drwxr-xr-x 9 root     root      4096 Feb 23 22:04 ..
drwx------ 2 root     root     16384 Feb 23 22:06 lost+found
drwxr-xr-x 2 www-data www-data  4096 Feb 23 22:16 owncloud
root@DietPi:~# 
root@DietPi:~# ls -la /mnt/raid0/
total 28
drwxr-xr-x 4 root     root      4096 Feb 23 22:16 .
drwxr-xr-x 9 root     root      4096 Feb 23 22:04 ..
drwx------ 2 root     root     16384 Feb 23 22:06 lost+found
drwxr-xr-x 2 www-data www-data  4096 Feb 23 22:16 owncloud
root@DietPi:~#

you could try to create the old mount point

mkdir /mnt/ownclouddrive/

and change the mount option in /etc/fstab. Change following

UUID=30c34f48-55f3-4e6e-b18f-2a72424cff6e /mnt/raid0 ext4 noatime,lazytime,rw,nofail,noauto,x-systemd.automount

into

UUID=30c34f48-55f3-4e6e-b18f-2a72424cff6e /mnt/ownclouddrive ext4 noatime,lazytime,rw,nofail,noauto,x-systemd.automount

I create the old mount point, but when I try to enter the /etc/fstab
It doesn’t allow me to enter the file.

-bash: /etc/fstab: Permission denied

you need to be root user or use sudo