French version in the second post
Hello YunoHost users.
You need to know how to ssh to your server and do basic command line operations. Your spare disk is empty.
The data directory of each storage intensive app is in its own partition. The main avantage is that such app can’t eat all the storage space of the server. A positive side effect is that everything stays where it is supposed to, ensuring that future app upgrades won’t be affected. The negative side effect is that you have to monitor the storage space for each partition.
For the purpose of this tutorial, everything is shown on a VM with a fresh yunohost image installed, upgraded to the last stable version (4.3). In your case, host name, devices names will be different. Adjust commands accordingly. I use the case of an additional disk.
If you installed yunohost over Debian, you might have to install LVM.
One disk scenario
If you intend to do this with only one disk, you have to install yunohost in expert mode to use a custom partitioning scheme (create a big empty partition beside the system partition). The choice of using LVM for other parts of the system is outside the scope of this tutorial (but it is what the yunohost image does).
If you’re not doing this on a fresh install, backup your whole server, unless you know what you are doing with your partitions (backing up app data might suffice).
Quick introduction on LVM
Read this if you don't know LVM
For the purpose of this tutorial, you can imagine Volume Groups (VG) as virtual disks and Logical Volumes (LV) as virtual partitions. VG are built on Physical Volumes (PV). PV can be disks or partitions (or anything that pretends to be a disk).
In this tutorial, feel free to use
lvs at any time to inspect the state of LVM, it will help you understand what is happening.
SSH to your server and become root.
ssh admin@yuno4 sudo su -
If your additional disk is not already plugged-in, it is a good time to have a look at your block devices.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom vda 254:0 0 20G 0 disk ├─vda1 254:1 0 243M 0 part /boot ├─vda2 254:2 0 1K 0 part └─vda5 254:5 0 19.8G 0 part ├─system-root 253:0 0 18.8G 0 lvm / └─system-swap 253:1 0 976M 0 lvm [SWAP]
Plug your disk (be it USB enclosure, SATA drive, optional storage for your vps…) and come back.
Your new disk is the one that wasn’t here before, in my case
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 1024M 0 rom vda 254:0 0 20G 0 disk ├─vda1 254:1 0 243M 0 part /boot ├─vda2 254:2 0 1K 0 part └─vda5 254:5 0 19.8G 0 part ├─system-root 253:0 0 18.8G 0 lvm / └─system-swap 253:1 0 976M 0 lvm [SWAP] vdb 254:16 0 200G 0 disk
One disk scenario
Your target is a big unmounted partition, in my case it would be vdaX. Use that partition name instead of
vdb in the next step.
Now, we prepare the disk for LVM. Be sure to use the right device or you will lose your yunohost instance (system+data)
If your new disk is not empty, this is where you lost all data
pvcreate /dev/vdb pvs
PV VG Fmt Attr PSize PFree /dev/vda5 system lvm2 a-- <19.76g 0 /dev/vdb lvm2 --- 200.00g 200.00g
You can see two physical volumes (PV),
/dev/vda5 that was created at installation and
/dev/vdb. Add your new PV to the VG.
vgextend system /dev/vdb
In case LVM is not used on your system
Create the VG instead of extending it:
vgcreate system /dev/vdb
At this point, you are ready to install your apps. I will demonstrate with nextcloud, adapt the path for any other app. For apps that don’t need much space, skip this step and install the usual way.
First, we create a LV for the app data. You can be very conservative, since the purpose of all this is to be able to expand it when needed. We format the LV and mount it where the nextcloud data directory will be.
lvcreate -n nextcloud -L 5G system mkfs.ext4 /dev/system/nextcloud mkdir -p /home/yunohost.app/nextcloud/data mount /dev/system/nextcloud /home/yunohost.app/nextcloud/data
You need to add the following line to
/etc/fstab so the mount is persistent.
/dev/system/nextcloud /home/yunohost.app/nextcloud/data ext4 defaults 0 2
Now you can install nextcloud.
In case you are on an already running nextcloud instance
You have to:
- mount the partition to a temporary location (
- stop your app
- move everything from
mount /dev/system/nextcloud /home/yunohost.app/nextcloud/data
- start your app
You now have several apps filling-up their own dedicated partition.
When one of your apps needs more space, you just extend its partition to give it more room:
lvextend -L+5G --resizefs system/nextcloud
The day the VG is full, just plug another disk and add it to the VG:
pvcreate /dev/vdc vgextend system /dev/vdc
The lazy way
Now that you know what you are doing, you can skip the
pvcreate commands, vgextend will take care of it for you.
If all this is too complicated, you can skip the whole dedicated partition part and just extend the root partition, but you lose the ability to prevent the root partition to be clogged by the apps.