Exactly, here is an example of my config with RAID 1 and RAID 0 for different purposes, LVM being also used there. Optimal hard disk setup on Ubuntu 2 x SSD (Raid1) + 2 x HDDs (Raid1)
I have cloned my nextcloud installation, changed hostname and IP. Deleted the biggest users, so less data to move during testing.
I have added a new (4th) 600GB (virtual) hard disc.
I am going to try to figure out how to exactly move the data. After moving the data, shouldnât i also change references in config files which will point to the wrong location of the data (after moving).
Perfect post about how to move data folder is here HowTo: Change / Move data directory after installation
Only if you have a new location, you can also stop the server, move data to the new drive and mount it under old location. In this case no configuration change needed.
If you do not follow instructions from the link from above you could meet this nice bug Files amount after moving of data directory is wrong (much bigger)
Thanks again for all the help.
With regards to the bug, i already have a sort of similair problem. Like i told you, i cloned the nextcloud setup and removed all the users with much data. Ieft a couple accounts in total about 55GB. But when i look at the Nextxloud GUI it tells me 500GB is used.
I assumed that the nextcloud config wouldnât take about 450+ GB. So do you have any idea why my Nextcloud is so big?
With regards to the moving, yes i would like to mount the new drive onder the old location. That was how i thought about it in my head
But what do you mean by âstop the server offâ?
@gas85,
When i use ```
sudo -u www-data php occ files:files:scan --all
it tells me that:
There are no commands defined in the files:files namespace.
Did you mean one of these?
files
files:recommendations
should i just remove :files?
You right, i change this typo.
Docu about scan you can find here: https://docs.nextcloud.com/server/19/admin_manual/configuration_server/occ_command.html#file-operations
Just so you know, i tried to remove the 1.5TB disc on an extra cloned installation and this indeed broke the pool.
So i deleted this clone and will go back to trying to move the data to disc4 from the zfs pool on the first clone.
The problem with not showing the correct amount of data used, was solved by the commands you gave me. So on to the next problem
Sorry i am really a linux n00b. I have a new disc (sdd). But before i can move i will have to create a partition âsdd1â and format the partition as lvm right? I have tried this:
From this website:
https://docs.fedoraproject.org/en-US/quick-docs/creating-a-disk-partition-in-linux/
- sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
- sudo parted /dev/sdd
- mklabel gpt
- mkpart primary 0 214GB
When i did this i got âthe resulting partition is not properly aligned for best performance ignore/cancelâ so is this correct?
quit
Is what i did correct?
And i am not sure what to do next and how to do it. I have created a partition now right? But how do i format it as lvm? See picture for my new disc + partition.
@gas85, are you on holiday or maybe not receiving the email updates? Of course i am not in a big hurry and i am very greatful for you help so far and certainly not wanna rush you
Somebody else maybe a suggestion? @eehmke maybe? You helped me out before in a great way!
Sorry, have a lot to do at work and wedding anniversary also taking a lot of time
First of all you need to decide what you want to achieve: are U going to expand size of your hdds? Or you want to have something like RAID 1 where data is mirrored in case one of hdds is getting broken.
Why U need sdd? To move data folder from it? If yes, then it looks a bit too small, according to your screenshot from above you have around 1.4 Tb of data, it will not fit into 200 GB sdd.
Could you please check how you are using drives now?
df -h
Then check how big is your data directory. Please replace /var/www/nextcloud
with your path to the Nextcloud:
du -sh $(grep datadirectory /var/www/nextcloud/config/config.php | cut -d "'" -f4)
Basically LVM looks like this
How LVM works in a simple 3 steps:
- you initialize any drive or partition to LVM by
pvcreate
. You even do not need to create any partition, simply added whole drive. - you will create new virtual group on selected partition
vgcreate
- you will create new logical volume on selected virtual Group
lvcreate
- you will create FS on a logical volume that you set with e.g.
mkfs.ext4
or zfs if you need.
Now you can move data to the new volume and added new drives to expand space. This is short story⌠Long for example here but it is in Russian or here is in English.
first of all happy anniversary! I have removed a lot of user data from my test Nextcloud so it was easier to try/test.
I simply want to add a new (virtual) hard disc (which i think i did, the âsddâ). So i would like to move the data FROM the zfs pool to SDD. After that delete the zfs pool, and mount the data on SDD exactly the same as it was (i think that is /mnt/ncdata). According to df -h, the sdd drive should be big enough right? SDD is 200GB and Ncdata is 60GB right?
so now i just type in âpvcreateâ? I do not have to change my console to âsddâ first? (Like in windows from C to D partition)?
There are a lot of LVMs howto in internet. Just to not live you without anything above I post already example of reference.
You can ether reuse your existing Volume Group: nextcloud-vg (in this case skip step 2 and replace vg-next-data with nextcloud-vg), or added new one. This example will added new one.
-
Please MAKE A BACKUP OF DB AND DATA and other relevant folders BEFORE TO START:
-
You need to create a LVM physical volume on the partition
pvcreate /dev/sdd1
- Then you need to create volume Group (e.g. name âvg-next-dataâ)
vgcreate vg-next-data /dev/sdd1
- create the logical volume that LVM will use (e.g. name âlv-next-dataâ):
lvcreate -L 200G -n lv-next-data vg-next-data
The -L command designates the size of the logical volume, in this case 200 GB, and the -n command names the volume. Vgpool is referenced so that the lvcreate command knows what volume to get the space from.
- Format and Mount the Logical Volume
mkfs.ext4 /dev/vg-next-data/lv-next-data
mkdir /mnt/ncdata_new
mount /dev/vg-next-data/lv-next-data /mnt/ncdata_new
- Stop your nextcloud/webserver, stop your DB
- Move data from /mnt/ncdata to /mnt/ncdata_new
- Dismount /mnt/ncdata and /mnt/ncdata_new
- Mount your LVM to the old location
mount /dev/vg-next-data/lv-next-data /mnt/ncdata
- Ensure, that zfs is not mounted anymore:
lsblk
- Start your server and check if everything ok and working.
- Play with your ZFS.
P.S. after you finished you can added your sdb to the LVM as physical disk:
vgextend vg-next-data /dev/sdb1
and then simply move data from sdd to the sdb:
pvmove /dev/sdd1 /dev/sdb1
And remove sdd from the LVM:
vgreduce vg-next-data /dev/sdd1
No mounts, no issuesâŚ
I have been away for a while (some personal business, sick family members ), but i am back
I hope you are still happily married
This is what i did:
pvcreate /dev/sdd1
vgcreate vg-next-data /dev/sdd1
lvcreate -L 190G -n lv-next-data vg-next-data
mkfs.ext4 /dev/vg-next-data/lv-next-data
mkdir /mnt/ncdata_new
mount /dev/vg-next-data/lv-next-data /mnt/ncdata_new
- sudo systemctl stop apache2
- sudo systemctl stop postgresql
- sudo rsync -avP /mnt/ncdata /mnt/ncdata_new/
- umount /mnt/ncdata
- umount /mnt/ncdata_new
- mount /dev/vg-next-data/lv-next-data /mnt/ncdata
This is what lsblk shows now:
so i think i did it I do not have to do some sort of SAVE ALL right? Not that after a reboot the mounting point, points to the previous partition again
Is there a way to rename the "vgânextâdata-lvânext⌠? Just because it looks a bit ugly
Do i still have to do the âP.S.â part? I am not sure why i should add sdb to LVM as a physical disk. And why should i move the data back from sdd to sdb? Isnât the next thing to do just delete/remove sdb en sdc? And after that remove the virtual drives?
I am talking about this part:
P.S. after you finished you can added your sdb to the LVM as physical disk:
vgextend vg-next-data /dev/sdb1
and then simply move data from sdd to the sdb:
pvmove /dev/sdd1 /dev/sdb1
And remove sdd from the LVM:
vgreduce vg-next-data /dev/sdd1
No mounts, no issuesâŚ
To me it seems a bit like it is done after step 11, of course not saying you are wrong just curious
Again many thanks so far! after these final steps i am gonna clone my Nextcloud again and do this proces again in one evening. If that goes well, i will do this to my âproductionâ Nextcloud installation. (Of course not without a proper extra backup )
I have tried to skip the âP.S. partâ and reboot the VM, but then i am not able to login my user account an during the reboot i see all kind of ZFS errors. So apparently i still have to remove and links to the ZFS pool?
âP.S.â Part is only possibility to move data between the HDDs without even unmount it. E.g. when older disk dies and you can still move data to the new one.
Regarding ZFS, I belive you need to cleanup your /etc/fstab
and live only needed parts, e.g. boot
and with LVM
.
I have looked in fstab file:
But i donât know what do do here, as far as i know the nextcloudâvg-root and swap are necessary. And i am not seeing and ZFS references.
I have started my sql en apache and i got the error âmake sure .ocdata is present in main directoryâ.
So i compared with my production NC, and the user data is not in the /mnt/ncdata directory on my test nextcloud. The files are in the /mnt/ncdata/ncdata.
So somewhere down the line i made a mistake. So i need to move the files from /mnt/ncdata/ncdata to /mnt/ncdata. i moved the files with this command:
mv -v /mnt/ncdata/ncdata/* /mnt/ncdata
So i moved the files, but i am still getting an error:
datafolder is invalid
make sure .ocdata is present in main directory
Your data directory is not writable
Rights can be restored by giving root write access to the folder on the webserver
https://docs.nextcloud.com/server/20/go.php?to=admin-dir_permissions.
So i think i need to give write access to root on the new /mnt/ncdata folder. Do you agree?
Is this the right thing to do?
sudo mount -a
sudo chmod -Rf 777 /mnt/data
Hey first of all check where you data folder configured, just find config.php in your NC folder, e.g.:
grep "datadirectory" /var/www/nextcloud/config/config.php
#Outup example
'datadirectory' => '/var/nextcloud/data',
you will see where it should be, then check if .ocdata
is there:
ls -la /var/nextcloud/data/.ocdata
-rw-r----- 1 www-data www-data 0 Dec 14 09:31 /var/nextcloud/data/.ocdata
Usually you have like 660 for files and 750 for folders. Owner is your web user.
Iâm not familiar with ZFS, but documentation says you have to use something like zpool remove
to remove drives from the pool and then destroy it.
This gives me the correct result:
(COMMAND) grep âdatadirectoryâ /var/www/nextcloud/config/config.php
(RESULT) âdatadirectoryâ => â/mnt/ncdataâ,
But i cannot seem to locate the .ocdata file:
ls -la /var/nextcloud/data/.ocdata
ls -la /mnt/ncdata/.ocdata
Both gives me âNo such file or directoryâ.
But when i look at my LIVE Nextcloud in the /mnt/ncdata directory, there is also no .ocdata fileâŚ
When i search for the file .ocdata:
(COMMAND) find/ -name .ocdata
(RESULT) /mnt/ncdata/ncdata/.ocdata
So that would mean the file didnât move when i moved all the files (from /mnt/ncdata/ncdata to /mnt/ncdata). But when i âlsâ in the folder /mnt/ncdata/ncdata it doesnât show any files. Isnât that weird?
So i used âmv -v /mnt/ncdata/ncdata/.ocdata /mnt/ncdataâ . Now when i search for the .ocdata file, it shows me that the file is located in /mnt/ncdata. So that should be ok now.
When i try to open the nextcloud by browser, it only says now that the data directory is not writeable. So we went from 2 to 1 error