mirror of
https://github.com/YunoHost/doc.git
synced 2024-09-03 20:06:26 +02:00
External storage
This commit is contained in:
parent
46d4c063f1
commit
ea6873b9d6
4 changed files with 409 additions and 65 deletions
|
@ -416,17 +416,63 @@ Démarrez votre machine virtuelle après avoir sélectionné l'image YunoHost.
|
|||
{% if regular or virtualbox %}
|
||||
## [fa=rocket /] Lancer l’installation graphique
|
||||
|
||||
!! N.B. : L'installation effacera totalement les données sur votre disque dur !
|
||||
|
||||
Votre écran devrait ressembler à la capture ci-dessous :
|
||||
|
||||
[figure class="nomargin" caption="Capture d'écran du menu de l'ISO"]
|
||||

|
||||
[/figure]
|
||||
[ui-tabs position="top-left" active="0" theme="lite"]
|
||||
[ui-tab title="Installation classique sur un disque entier"]
|
||||
|
||||
!! N.B. : A partir du moment où vous aurez validé l'agencement du clavier, l'installation sera lancée et effacera totalement les données sur votre disque dur !
|
||||
|
||||
1. Sélectionnez `Graphical install`
|
||||
2. Sélectionnez votre langue, votre localisation et votre agencement de clavier.
|
||||
2. Sélectionnez votre langue, votre localisation, votre agencement de clavier et éventuellement votre timezone.
|
||||
3. L'installateur va ensuite télécharger les paquets requis et les installer.
|
||||
[/ui-tab]
|
||||
[ui-tab title="Installation en mode expert"]
|
||||
|
||||
Le projet YunoHost a simplifié au maximum l'installation classique afin d'éviter au plus grand nombre d'être perdu avec des questions trop techniques ou liées à des cas particuliers.
|
||||
|
||||
Avec l'installation en mode expert, vous avez plus de possibilités notamment concernant le partitionnement exact de vos supports de stockages. Vous pouvez aussi décider d'utiliser le mode classique et [ajouter vos disques après coup](/external_storage).
|
||||
|
||||
### Résumé des étapes en mode expert:
|
||||
1. Sélectionnez `Expert graphical install`
|
||||
2. Sélectionnez votre langue, votre localisation, votre agencement de clavier et éventuellement votre timezone.
|
||||
3. Partitionner vos disques. C'est à cette étape que vous pouvez configurer un RAID ou chiffrer tout ou partie du serveur.
|
||||
4. Indiquez un éventuel proxy HTTP à utiliser pour l'installation des paquets
|
||||
5. Indiquez sur quels volumes grub doit être installé
|
||||
|
||||
### A propos du partitionnement
|
||||
|
||||
De façon générale, nous recommandons d'éviter de partitionner `/var`, `/opt`, `/usr`, `/bin`, `/etc`, `/lib`, `/tmp` et `/root` sur des partitions distinctes. Ceci vous évitera des soucis de partitions pleines qui pourraient mettre en panne votre machine, faire échouer l'installation d'app, voir même altérer vos bases de données.
|
||||
|
||||
Pour des raisons de performances, il est recommandé de monter votre stockage le plus rapide (SSD) sur la racine `/`.
|
||||
|
||||
Si vous avez un ou des disques durs pour stocker les données, vous pouvez choisir de les monter sur un de ces dossiers selon votre utilisation.
|
||||
|
||||
| Chemin | Contenu |
|
||||
|--------|---|
|
||||
| `/home` | Dossiers utilisateurs accessibles via SFTP |
|
||||
| `/home/yunohost.backup/archives` | Sauvegardes YunoHost à placer idéalement ailleurs que sur les disques qui gérent les données |
|
||||
| `/home/yunohost.app` | Données lourdes des applications YunoHost (nextcloud, matrix...) |
|
||||
| `/home/yunohost.multimedia` | Données lourdes partagées entre plusieurs applications |
|
||||
| `/var/mail` | Mails des usagers |
|
||||
|
||||
Si vous souhaitez de la souplesse et ne pas avoir à (re-)dimensionner des partitions, vous pouvez aussi choisir de monter sur `/mnt/hdd` et de suivre ce [tutoriel pour monter l'ensemble de ces dossiers avec `mount --bind`](/external_storage).
|
||||
|
||||
### A propos du chiffrement
|
||||
Prenez bien en compte que si vous chiffrez tout ou partie de vos disques, vous aurez à taper la phrase de passe à chaque redémarrage de votre serveur, ce qui peut poser problème si vous n'êtes pas sur place. Il existe toutefois des solutions (assez difficiles à mettre en oeuvre) qui permettent de tapper la phrase via SSH ou via une page web (cherchez "dropbear encrypted disk").
|
||||
|
||||
### A propos du RAID
|
||||
Ne perdez pas de vue que:
|
||||
* les disques de vos RAID doivent être de marque, d'usure ou de lots distincts (surtout si ce sont des SSD)
|
||||
* un RAID 1 (même sans disque de spare) est plus fiable qu'un RAID5 d'un point de vue probabilité
|
||||
* les raid matériels sont dépendant de la carte raid, si celle-ci fait défaut il en faudra une de remplacement pour pouvoir lire et reconstruire la grappe
|
||||
|
||||
[/ui-tab]
|
||||
[/ui-tabs]
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -546,18 +546,64 @@ Start the virtual machine after selecting the YunoHost image.
|
|||
{% if regular or virtualbox %}
|
||||
## [fa=rocket /] Launch the graphical install
|
||||
|
||||
!! N.B. : The installation will totally erase the data on the server's hard drive!
|
||||
|
||||
You should see a screen like this:
|
||||
|
||||
[figure class="nomargin" caption="Preview of the ISO menu"]
|
||||

|
||||
[/figure]
|
||||
[ui-tabs position="top-left" active="0" theme="lite"]
|
||||
|
||||
[ui-tab title="Installation classique sur un disque entier"]
|
||||
|
||||
!! N.B.: Once you have validated the keyboard layout, the installation will be launched and will completely erase the data on your hard disk!
|
||||
|
||||
1. Select `Graphical install`
|
||||
2. Select your language, your location and your keyboard layout
|
||||
2. Select your language, your location, your keyboard layout, and eventually your timezone.
|
||||
3. The installer will then download and install all required packages.
|
||||
|
||||
[/ui-tab]
|
||||
[ui-tab title="Installation in expert mode"]
|
||||
|
||||
The YunoHost project simplified the classic installation as much as possible in order to avoid as many people as possible being lost with questions that are too technical or related to specific cases.
|
||||
|
||||
With the expert mode installation, you have more possibilities, especially concerning the exact partitioning of your storage media. You can also decide to use the classic mode and [add your disks afterwards](/external_storage).
|
||||
|
||||
### Summary of the steps in expert mode:
|
||||
1. Select `Expert graphical install`.
|
||||
2. Select your language, location, keyboard layout and possibly your timezone.
|
||||
3. Partition your disks. This is where you can set up a RAID or encrypt all or part of the server.
|
||||
4. Specify a possible HTTP proxy to use for the installation of the packages
|
||||
5. Specify on which volumes grub should be installed
|
||||
|
||||
### Regarding partitioning
|
||||
|
||||
In general, we recommend against partitioning `/var`, `/opt`, `/usr`, `/bin`, `/etc`, `/lib`, `/tmp` and `/root` on separate partitions. This will prevent you from having to worry about full partitions that could crash your machine, cause app installations to fail, or even corrupt your databases.
|
||||
|
||||
For performance reasons, it is recommended to mount your fastest storage (SSD) on the root `/`.
|
||||
|
||||
If you have one or more hard drives to store data, you can choose to mount it on one of these folders depending on your usage.
|
||||
|
||||
| Path | Contents |
|
||||
|--------|---|
|
||||
| `/home` | User folders accessible via SFTP |
|
||||
| `/home/yunohost.backup/archives` | YunoHost backups to be placed ideally elsewhere than on the disks that manage the data |
|
||||
| `/home/yunohost.app` | Heavy data from YunoHost applications (nextcloud, matrix...) |
|
||||
| `/home/yunohost.multimedia` | Heavy data shared between several applications |
|
||||
| `/var/mail` | User mail
|
||||
|
||||
If you want flexibility and don't want to (re)size partitions, you can also choose to mount on `/mnt/hdd` and follow this [tutorial to mount all these folders with `mount --bind`](/external_storage).
|
||||
|
||||
### About encryption
|
||||
Be aware that if you encrypt all or part of your disks, you will have to type the passphrase every time you restart your server, which can be a problem if you are not on site. There are however solutions (quite difficult to implement) that allow you to type the passphrase via SSH or via a web page (search for "dropbear encrypted disk").
|
||||
|
||||
### About RAID
|
||||
Keep in mind that:
|
||||
* the disks in your RAIDs must be of different brands, wear and tear or batches (especially if they are SSDs)
|
||||
* a RAID 1 (even without a spare) is more reliable than a RAID 5 from a probability point of view
|
||||
* hardware raids are dependent on the raid card, if the card fails you will need a replacement to read and rebuild the array
|
||||
|
||||
[/ui-tab]
|
||||
[/ui-tabs]
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
|
|
@ -5,25 +5,57 @@ taxonomy:
|
|||
category: docs
|
||||
routes:
|
||||
default: '/external_storage'
|
||||
aliases:
|
||||
- '/moving_app_folder'
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Si vous n'avez pas dédié une grande partition à `/home` avant d'installer YunoHost, et que vos applications nécessitent beaucoup d'espace disque, vous pouvez toujours ajouter un disque externe *a posteriori*.
|
||||
En dehors du système de monitoring qui s'assure que les partitions de votre système ne sont pas trop petites, YunoHost ne s'occupe pour l'instant pas de l'organisation de vos partitions et de vos disques.
|
||||
|
||||
## Avant de commencer
|
||||
Si vous vous hébergez sur une carte ARM avec une carte SD ou sur un serveur avec un petit disque SSD, vous pourriez, pour des raisons de fiabilité ou de manque de place, vouloir ajouter un ou des disques à votre serveur.
|
||||
|
||||
Les étapes à réaliser, même si elles sont relativement simples, peuvent parfois paraître techniques et nécessitent dans tous les cas **de prendre son temps**.
|
||||
! Si vous n'avez plus du tout de place sur votre serveur, vous pouvez dès à présent taper `apt clean` pour essayer d'en gagner un peu le temps de faire le ménage ou suivre les opérations qui vont suivre.
|
||||
|
||||
Vous devez également être connecté en root sur votre système, par exemple via [SSH](/ssh). (Note : en étant connecté en tant qu'utilisateur `admin`, vous pouvez passer root avec `sudo su`)
|
||||
Ci-dessous, vous trouverez des explications pour parvenir à déplacer vos données sur un disque dur de façon correcte avec un minimum d'impact vis-à-vis du fonctionnement de YunoHost. Cette opération peut se faire lors de l'installation ou, a posteriori, lorsque vos besoins de stockage ont augmenté ou lorsque vous n'avez plus confiance dans votre carte SD.
|
||||
|
||||
Il peut être utile de [faire un backup](/backup) de votre installation.
|
||||
!!! La méthode présentée ici va d'abord monter l'unique partition du disque dur, puis utiliser un ou des sous-dossiers de ce disque pour créer différents points de montage sur l'arborescence de votre système. Cette méthode est préférable à l'usage de liens symboliques, car ces derniers peuvent perturber certaines applications dont le système de sauvegarde de YunoHost. On pourrait aussi choisir de monter des partitions plutôt que des sous-dossiers, mais il est parfois difficile d'estimer à l'avance l'évolution du poids d'un dossier à l'avance.
|
||||
|
||||
Vous devez également disposer d'un disque dur supplémentaire (branché en USB ou en SATA).
|
||||
## [fa=list-alt /] Pré-requis
|
||||
|
||||
## 1. Connecter et identifier le disque
|
||||
* Avoir un peu de temps à un moment où les utilisateurs de votre serveur peuvent accepter un arrêt des services. Les étapes à réaliser, même si elles sont relativement simples, peuvent parfois paraître techniques et nécessitent dans tous les cas **de prendre son temps**.
|
||||
|
||||
Commencez par brancher ce disque dur à votre système. Il faut ensuite identifier sous quel nom est désigné le disque par le système.
|
||||
* Savoir se connecter en root sur votre système, par exemple via [SSH](/ssh). (Note : en étant connecté en tant qu'utilisateur `admin`, vous pouvez passer root avec `sudo su`)
|
||||
|
||||
* Connaître les commandes basiques `cd`, `ls`, `mkdir`, `rm`
|
||||
|
||||
* Avoir une sauvegarde au cas où ça ne se passe pas comme prévu
|
||||
|
||||
* Disposer d'un stockage supplémentaire (disque SSD, disque dur, clé USB) branché à votre serveur en USB ou en SATA
|
||||
|
||||
## 1. Identifier les dossiers à déplacer
|
||||
|
||||
La commande `ncdu /` vous permet de naviguer dans les dossiers de votre serveur afin de constater leurs tailles.
|
||||
|
||||
Ci-dessous, une explication de certains chemins qui peuvent prendre du poids avec quelques commentaires pour vous aider à réduire leur poids ou à choisir de les déplacer.
|
||||
|
||||
| Chemin | Contenu | Conseils |
|
||||
|--------|---|---|
|
||||
| `/home` | Dossiers utilisateurs accessibles via SFTP | Déplaçable sur un disque dur |
|
||||
| `/home/yunohost.backup` | Sauvegardes YunoHost | Selon votre stratégie de sauvegarde, il peut être préférable de placer ce dossier sur un disque distinct de celui où se trouvent vos données ou vos bases de données |
|
||||
| `/home/yunohost.app` | Données lourdes des applications yunohost (nextcloud, matrix...) | Déplaçable sur un disque dur |
|
||||
| `/home/yunohost.multimedia` | Données lourdes partagées entre plusieurs applications | Déplaçable sur un disque dur |
|
||||
| `/var/lib/mysql` | Base de données utilisées par les applications | A laisser idéalement sur le SSD pour des raisons de performances |
|
||||
| `/var/lib/postgresql` | Base de données utilisées par les applications | A laisser idéalement sur le SSD pour des raisons de performances |
|
||||
| `/var/mail` | Mails des usagers | Déplaçable sur un disque dur |
|
||||
| `/var/www` | Programme des applications web installées | A laisser idéalement sur le SSD pour des raisons de performances |
|
||||
| `/var/log` | Journaux des évènements (pages consultées, tentative de connexion, erreurs matériels...). | Ce dossier ne devrait pas prendre trop de place, si il gonfle rapidement, il peut s'agir d'une erreur inscrite en boucle qu'il est préférable de résoudre |
|
||||
| `/opt` | Programme et dépendance de certaines applications YunoHost. | A laisser idéalement sur le SSD pour des raisons de performances. Pour les applications nodejs il est possible de faire un peu de nettoyage des versions non utilisées. |
|
||||
| `/boot` | Noyaux et fichiers de démarrage | Ne pas déplacer sauf si vous savez ce que vous faites. Il peut arriver que trop de noyaux soient conservés, il est possible de faire du nettoyage. |
|
||||
|
||||
## 2. Connecter et identifier le disque
|
||||
|
||||
Commencez par brancher votre disque à votre système. Il faut ensuite identifier sous quel nom est désigné le disque par le système.
|
||||
|
||||
Pour cela, utilisez la commande :
|
||||
|
||||
|
@ -46,11 +78,13 @@ Ici, `mmcblk0` correspond à une carte SD de 16Go (on voit que les partitions `m
|
|||
|
||||
! [fa=exclamation-triangle /] Sur un autre système, il se peut que votre système soit installé sur `sda` et que votre disque soit alors `sdb` par exemple.
|
||||
|
||||
## 2. (Optionnel) Formater le disque
|
||||
!!! Astuce: si la taille du disque ne vous suffit pas pour le reconnaître, vous pouvez débrancher le disque lancer la commande `lsblk`, puis rebrancher le disque, lancer `lsblk` et en déduire les différences.
|
||||
|
||||
Cette opération est optionnelle si votre disque est déjà formaté.
|
||||
## 3. (Optionnel) Formater le disque
|
||||
|
||||
Créons une nouvelle partition sur le disque :
|
||||
Cette opération est optionnelle si votre disque est déjà formaté avec un système de fichiers supportés par linux (donc pas NTFS ou FAT32).
|
||||
|
||||
Créons une partition sur le disque :
|
||||
|
||||
```bash
|
||||
fdisk /dev/VOTRE_DISQUE
|
||||
|
@ -62,7 +96,7 @@ Vérifiez avec `lsblk` que vous avez bien votre disque contenant une seule parti
|
|||
|
||||
Avant de pouvoir utiliser votre disque, il doit être formaté.
|
||||
|
||||
Attention : **formater un disque implique de supprimer toutes les données inscrites dessus !** Si votre disque est déjà "propre", vous pouvez passer cette étape.
|
||||
! [fa=exclamation-triangle /] **Formater un disque implique de supprimer toutes les données inscrites dessus !**. Attention à ne pas vous tromper de nom, car cela peut avoir pour conséquence de formater un autre disque que celui voulu ! Dans l'exemple donné précédemment, il s'agissait de `/dev/sda`. Si votre disque est déjà "propre", vous pouvez passer cette étape.
|
||||
|
||||
Pour formater la partition :
|
||||
|
||||
|
@ -71,31 +105,110 @@ mkfs.ext4 /dev/VOTRE_DISQUE1
|
|||
# puis 'y' pour valider
|
||||
```
|
||||
|
||||
(Remplacez `VOTRE_DISQUE1` par le nom de la première partition sur le disque. Attention à ne pas vous tromper de nom, car cela peut avoir pour conséquence de formater un autre disque que celui voulu ! Dans l'exemple donné précédemment, il s'agissait de `sda`.)
|
||||
Remplacez `VOTRE_DISQUE1` par le nom de la première partition sur le disque par exemple `sda1`.
|
||||
|
||||
!!! Il est possible d'adapter cette étape, pour par exemple créer un volume raid 1 (disques en miroir) ou chiffrer le dossier.
|
||||
|
||||
## 3. Monter le disque
|
||||
## 4. Monter le disque
|
||||
|
||||
"Monter" un disque signifie le rendre effectivement accessible dans l'arborescence des fichiers. Nous allons choisir arbitrairement de monter le disque dans `/media/stockage` mais vous pouvez le nommer différemment (par exemple `/media/mon_disque` ...).
|
||||
Contrairement à Windows où les disques sont accessibles avec des lettres (C:/), sous linux, les disques sont rendus accessibles via l'arborescence. "Monter" un disque signifie le rendre effectivement accessible dans l'arborescence des fichiers. Nous allons choisir arbitrairement de monter le disque dans `/mnt/hdd` mais vous pouvez le nommer différemment (par exemple `/mnt/disque` ...).
|
||||
|
||||
Commençons par créer le répertoire :
|
||||
```bash
|
||||
mkdir /media/stockage
|
||||
mkdir /mnt/hdd
|
||||
```
|
||||
|
||||
Puis nous pouvons monter le disque manuellement avec :
|
||||
|
||||
```bash
|
||||
mount /dev/VOTRE_DISQUE1 /media/stockage
|
||||
mount /dev/VOTRE_DISQUE1 /mnt/hdd
|
||||
```
|
||||
|
||||
(Ici, `/dev/VOTRE_DISQUE1` correspond à la première partition sur le disque)
|
||||
|
||||
Ensuite, vous devriez pouvoir créer des fichiers dans `/media/stockage`, et, par exemple, ajouter `/media/stockage` comme périphérique externe dans Nextcloud.
|
||||
|
||||
## 4. Monter le disque automatiquement au démarrage
|
||||
## 5. Monter un dossier de /mnt/hdd sur un des dossiers dont on veut déplacer les données
|
||||
|
||||
Jusqu'ici, nous avons monté manuellement le disque. Cependant, il peut être utile de configurer le système pour qu'il monte automatiquement le disque après un démarrage.
|
||||
Ici on va considérer que vous souhaitez déplacer les grosses données des applications qui se trouvent dans `/home/yunohost.app` ainsi que les mails sur votre disque dur.
|
||||
|
||||
### 5.1 Création des sous-dossiers sur le disque
|
||||
Pour commencer, on crée un dossier dans le disque dur
|
||||
|
||||
```bash
|
||||
mkdir -p /mnt/hdd/home/yunohost.app
|
||||
mkdir -p /mnt/hdd/var/mail
|
||||
```
|
||||
|
||||
### 5.2 Passage en mode maintenance
|
||||
Puis, idéalement on passe en maintenance les applications qui pourraient être en train d'écrire des données.
|
||||
|
||||
Exemple, pour nextcloud:
|
||||
|
||||
```bash
|
||||
sudo -u nextcloud /var/www/occ maintenance:mode --on
|
||||
```
|
||||
|
||||
Exemple, pour le mail:
|
||||
|
||||
```bash
|
||||
systemctl stop postfix
|
||||
systemctl stop dovecot
|
||||
```
|
||||
|
||||
! Si vous souhaitez déplacer les base de données comme mariadb (mysql), il est impératif de stopper les services de ces bases de données sans quoi il est presque sûr que vos données seront corrompues.
|
||||
|
||||
### 5.3 Création des points de montages
|
||||
|
||||
Ensuite, on va renommer le dossier d'origine et créer un dossier vide éponyme.
|
||||
|
||||
```bash
|
||||
mv /home/yunohost.app /home/yunohost.app.bkp
|
||||
mkdir /home/yunohost.app
|
||||
mv /var/mail /var/mail.bkp
|
||||
mkdir /var/mail
|
||||
```
|
||||
|
||||
On peut alors grâce à la commande `mount --bind` monter le dossier de notre disque dur sur le nouvel emplacement vide de l'arborescence.
|
||||
|
||||
```bash
|
||||
mount --bind /mnt/hdd/home/yunohost.app /home/yunohost.app
|
||||
mount --bind /mnt/hdd/var/mail /var/mail
|
||||
```
|
||||
|
||||
### 5.4 Copie des données
|
||||
|
||||
Puis, on copie les données en conservant toutes les propriétés des dossiers et des fichiers. Cette opération peut prendre un peu de temps, avec un autre terminal, vous pourrez controler l'évolution en observant le poids associé au point de montage avec `df -h`
|
||||
|
||||
```bash
|
||||
cp -a /home/yunohost.app.bkp/. /home/yunohost.app/
|
||||
cp -a /var/mail.bkp/. /var/mail/
|
||||
```
|
||||
|
||||
Une fois que c'est fini, vérifiez avec `ls` que le contenu est bien là:
|
||||
|
||||
```bash
|
||||
ls -la /home/yunohost.app/
|
||||
ls -la /var/mail/
|
||||
```
|
||||
|
||||
### 5.5 Sortir du mode maintenance
|
||||
|
||||
A partir de là vous pouvez arréter le mode maintenance, la commande ci-dessous est à adapter selon les services que vous avez arrétés.
|
||||
|
||||
```bash
|
||||
sudo -u nextcloud /var/www/occ maintenance:mode --off
|
||||
systemctl start postfix
|
||||
systemctl start dovecot
|
||||
```
|
||||
|
||||
A partir de cette étape, vos services tournent avec leurs données sur le disque, il est donc temps de tester pour voir dans quelle mesure il y a un impact sur les performances (notamment si vus utilisez de l'USB 2.0).
|
||||
|
||||
## 6. Monter automatiquement au démarrage
|
||||
|
||||
|
||||
Jusqu'ici, nous avons monté manuellement le disque et les sous-dossiers. Cependant, il est nécessaire de configurer le système pour qu'il monte automatiquement le disque après un démarrage.
|
||||
|
||||
Si vos tests sont concluants, il faut pérenniser les points de montages, sinon dépêchez-vous de faire machine arrière en commençant par remettre en maintenance.
|
||||
|
||||
Pour commencer, trouvons l'UUID (identifiant universel) de notre disque avec :
|
||||
|
||||
|
@ -111,15 +224,28 @@ Ajoutons alors une ligne au fichier `/etc/fstab` qui gère le montage des disque
|
|||
nano /etc/fstab
|
||||
```
|
||||
|
||||
Puis on ajoute cette ligne :
|
||||
Puis on ajoute ces lignes à la fin du fichier :
|
||||
|
||||
```bash
|
||||
UUID="cea0b7ae-2fbc-4f01-8884-3cb5884c8bb7" /media/stockage ext4 defaults,nofail 0 0
|
||||
UUID="cea0b7ae-2fbc-4f01-8884-3cb5884c8bb7" /mnt/hdd ext4 defaults,nofail 0 0
|
||||
/mnt/hdd/home/yunohost.app /home/yunohost.app none defaults,bind 0 0
|
||||
/mnt/hdd/var/mail /var/mail none defaults,bind 0 0
|
||||
```
|
||||
|
||||
(il faut adapter cette ligne en fonction des informations et choix précédents)
|
||||
|
||||
Utiliser Ctrl+X puis `o` pour sauvegarder.
|
||||
|
||||
Vous pouvez ensuite tester de redémarrer le système pour voir si le disque est monté automatiquement.
|
||||
Vous pouvez ensuite tester de redémarrer le système pour vérifier si le disque et les sous-dossiers sont montés automatiquement.
|
||||
|
||||
## 7. Nettoyer les anciennes données
|
||||
Dès que votre nouveau setup est validé, vous pouvez procéder à la suppression des anciennes données issues de l'étape 6.3:
|
||||
|
||||
```bash
|
||||
rm -Rf /home/yunohost.app.bkp
|
||||
rm -Rf /var/mail.bkp
|
||||
```
|
||||
|
||||
##  Félicitations !
|
||||
|
||||
Si vous êtes arrivé jusqu'ici sans dommage, vous avez désormais un serveur qui tire parti d'un ou de plusieurs disques de stockage.
|
||||
|
|
|
@ -5,33 +5,67 @@ taxonomy:
|
|||
category: docs
|
||||
routes:
|
||||
default: '/external_storage'
|
||||
aliases:
|
||||
- '/moving_app_folder'
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
|
||||
If you did not allocate a large partition to `/home` before installing YunoHost, and that your apps require a lot of spaces, you can still add an external driver after setting up your system.
|
||||
Apart from the monitoring system that ensures that your system's partitions are not too small, YunoHost does not currently deal with the organisation of your partitions and disks.
|
||||
|
||||
## Before starting
|
||||
If you are hosting on an ARM card with an SD card or on a server with a small SSD drive, you may, for reasons of reliability or lack of space, want to add a drive or drives to your server.
|
||||
|
||||
Even though these steps are relatively simple, they may appear technical. In any case, they require you to **take your time**.
|
||||
! If you have no space left on your server at all, you can now type `apt clean` to try and save some space while you clean up or follow the steps below.
|
||||
|
||||
You should be connected as root on your server, for instance via [SSH](/ssh). (Note: being logged as `admin`, you can upgrade to `root` with the command `sudo su`)
|
||||
Below you will find explanations on how to move your data to a hard disk in a correct way with a minimum of impact on the functioning of YunoHost. This operation can be done during installation or, afterwards, when your storage needs have increased or when you no longer trust your SD card.
|
||||
|
||||
It can be useful to [create a backup](/backup) of your install before starting.
|
||||
!!! The method presented here will first mount the single partition of the hard disk, then use one or more sub-folders of this disk to create different mount points on your system tree. This method is preferable to the use of symbolic links, as the latter may interfere with some applications including the YunoHost backup system. You could also choose to mount partitions rather than subfolders, but it is sometimes difficult to estimate the weight of a folder in advance.
|
||||
|
||||
You should also have your external drive (plugged via USB or SATA).
|
||||
## [fa=list-alt /] Prerequisites
|
||||
|
||||
## 1. Connect and identify the disk
|
||||
* Have some time at a moment when your server users can accept a shutdown. The steps to be performed, even if they are relatively simple, can sometimes seem technical and require in any case **to take your time**.
|
||||
|
||||
Start by connecting your drive to the system. You shall then identify which name is used by the system to refer to the disk.
|
||||
* Know how to connect as root on your system, for example via [SSH](/ssh). (Note: while logged in as `admin`, you can root with `sudo su`)
|
||||
|
||||
You can do this with this command :
|
||||
* Know the basic commands `cd`, `ls`, `mkdir`, `rm`.
|
||||
|
||||
* Have a backup in case things don't work out as planned
|
||||
|
||||
* Have extra storage (SSD, hard drive, USB stick) connected to your server via USB or SATA
|
||||
|
||||
## 1. Identify directories to be moved
|
||||
|
||||
The `ncdu /` command allows you to browse the folders on your server to see how big they are.
|
||||
|
||||
Below is an explanation of some of the paths that can take up weight with some comments to help you reduce their weight or choose to move them.
|
||||
|
||||
| Paths | Contents | Tips |
|
||||
|--------|---|---|
|
||||
| `/home` | User folders accessible via SFTP | Moveable to a hard disk |
|
||||
| `/home/yunohost.backup` | YunoHost's backups | Depending on your backup strategy, you may want to place this folder on a separate drive from your data or databases.
|
||||
| `/home/yunohost.app` |Heavy data from yunohost applications (nextcloud, matrix...)|Moveable to a hard disk
|
||||
| `/home/yunohost.multimedia` | Heavy data shared between several applications | Moveable to a hard disk |
|
||||
| `/var/lib/mysql` | Database used by applications | Ideally leave on SSD for performance reasons |
|
||||
| `/var/lib/postgresql` | Database used by applications | Ideally leave on SSD for performance reasons | /var/mail
|
||||
| `/var/mail` | User e-mails | Movable to a hard disk |
|
||||
| `/var/www` | Program of installed web applications | Ideally leave on SSD for performance reasons |
|
||||
| `/var/log` | Event logs (pages consulted, connection attempts, hardware errors...). | This directory should not take up too much space, if it grows quickly, it may be a looping error that should be resolved.
|
||||
| `/opt` | Program and dependency of some YunoHost applications. | Ideally leave it on the SSD for performance reasons. For nodejs applications it is possible to do some cleanup of unused versions.
|
||||
| `/boot` | Kernels and boot files | Do not move unless you know what you are doing. It can happen that too many kernels are kept, it is possible to do some cleanup.
|
||||
|
||||
|
||||
## 2. Connect and identify the disk
|
||||
|
||||
Start by connecting your disk to your system. You must then identify the name under which the disk is designated by the system.
|
||||
|
||||
To do this, use the command :
|
||||
|
||||
```bash
|
||||
lsblk
|
||||
```
|
||||
|
||||
It may yield something like this :
|
||||
It may return something like :
|
||||
|
||||
```bash
|
||||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
||||
|
@ -42,85 +76,177 @@ mmcblk0 179:0 0 14.9G 0 disk
|
|||
└─mmcblk0p2 179:2 0 14.8G 0 part /
|
||||
```
|
||||
|
||||
Here, `mmcblk0` corresponds to an SD card of 16Go (the partitions `mmcblk0p1` et `mmcblk0p2` are used as the boot partition `/boot` and the system partition `/`). The external drive is `sda` which is about 1TB and has only one partition `sda1` which is not mounted (no "MOUNTPOINT").
|
||||
Here, `mmcblk0` corresponds to a 16GB SD card (you can see that the `mmcblk0p1` and `mmcblk0p2` partitions correspond to the `/boot` partition and the `/` system partition). The hard drive connected corresponds to `sda` which is about 1TB, and contains a single `sda1` partition which is not mounted (no "MOUNTPOINT").
|
||||
|
||||
! [fa=exclamation-triangle /] On a different setup, your system partition might be `sda` and so your external drive might be `sdb` for instance.
|
||||
! [fa=exclamation-triangle /] On another system, it may be that your system is installed on `sda` and your disk is then `sdb` for example.
|
||||
|
||||
## 2. (Optional) Format the disk
|
||||
!!! Tip: if the size of the disk is not enough for you to recognise it, you can unplug the disk, run the `lsblk` command, then plug the disk back in, run `lsblk` and deduce the differences.
|
||||
|
||||
This operation is optional if your disk has already been formatted.
|
||||
## 3. (Optional) Format the disk
|
||||
|
||||
First let's create a new partition on the disk :
|
||||
This operation is optional if your disk is already formatted with a file system supported by linux (so not NTFS or FAT32).
|
||||
|
||||
Let's create a partition on the disk:
|
||||
|
||||
```bash
|
||||
fdisk /dev/YOUR_DISK
|
||||
```
|
||||
|
||||
then sucessfully type `n`, `p`, `1`, `Enter`, `Enter`, then `w` to create the new partition.
|
||||
then enter `n`, `p`, `1`, `Enter`, `Enter`, and `w` successively to create a new partition.
|
||||
|
||||
Check with `lsblk` that your disk really does contain a single partition.
|
||||
Check with `lsblk` that you have your disk containing a single partition.
|
||||
|
||||
Before you can use your disk it has to be formatted.
|
||||
Before you can use your disk, it must be formatted.
|
||||
|
||||
! You should be aware that **formating a drive implies to erasing every data on it!** If your disk is already "clean", you may ignore this step.
|
||||
! [fa=exclamation-triangle /] **Formatting a disk means deleting all the data on it! Be careful not to get the name wrong, as this may result in formatting a different disk than the one you want! In the example given earlier, it was `/dev/sda`. If your disk is already "clean", you can skip this step.
|
||||
|
||||
To format the partition :
|
||||
To format the :
|
||||
|
||||
```bash
|
||||
mkfs.ext4 /dev/YOUR_DISK1
|
||||
# then 'y' to validate
|
||||
```
|
||||
|
||||
(Replace `YOUR_DISK1` by the name of the first partition on the disk. Be careful not to do any mistake here, as it can mean erasing data on your main system if you are using the wrong name ! In the previous example, the name of our disk was `sda`.)
|
||||
Replace `YOUR_DISK1` with the name of the first partition on the disk e.g. `sda1`.
|
||||
|
||||
!!! It is possible to adapt this step, for example to create a raid 1 volume (mirrored disks) or encrypt the folder.
|
||||
|
||||
## 3. Mount the disk
|
||||
## 4. Mount the disk
|
||||
|
||||
"Mounting" a disk corresponds to making it effectively accessible in the filesystem tree. Here, we choose the arbitrary name `/media/storage` but you can choose a different name (for instance, `/media/my_disk` ... ).
|
||||
Unlike Windows where disks are accessed with letters (C:/), under Linux, disks are made accessible via the file tree. "Mounting" a disk means making it effectively accessible in the file tree. We will arbitrarily choose to mount the disk in `/mnt/hdd` but you can name it differently (e.g. `/mnt/disk` ...).
|
||||
|
||||
Let's start by creating the directory :
|
||||
|
||||
```bash
|
||||
mkdir /media/storage
|
||||
mkdir /mnt/hdd
|
||||
```
|
||||
|
||||
Then we can manually mount the disk with :
|
||||
Then we can mount the disk manually with :
|
||||
|
||||
```bash
|
||||
mount /dev/YOUR_DISK1 /media/storage
|
||||
mount /dev/YOUR_DISK1 /mnt/hdd
|
||||
```
|
||||
|
||||
(Here, `/dev/YOUR_DISK1` corresponds to the first partition on the disk)
|
||||
|
||||
Next, you should be able to create files in `/media/storage`, and, for instance, add `/media/storage` as an external drive in Nextcloud.
|
||||
## 5. Mount a /mnt/hdd folder on one of the folders you want to move data from
|
||||
|
||||
## 4. Mount the disk automatically at boot
|
||||
Here we will consider that you want to move the big data of the applications which are in /home/yunohost.app and the mails on your hard disk.
|
||||
|
||||
So far, we only mounted the disk manually. But it can be nice and useful to have it being mounted automatically at each boot.
|
||||
### 5.1 Creating subfolders on the disk
|
||||
To begin with, we create a folder on the hard drive
|
||||
|
||||
Let's start by finding the UUID (universal identifier) of the disk with :
|
||||
bash
|
||||
mkdir -p /mnt/hdd/home/yunohost.app
|
||||
mkdir -p /mnt/hdd/var/mail
|
||||
```
|
||||
|
||||
### 5.2 Switching to maintenance mode
|
||||
Then, ideally, we switch to maintenance mode the applications that might be writing data.
|
||||
|
||||
Example, for nextcloud:
|
||||
|
||||
```bash
|
||||
sudo -u nextcloud /var/www/occ maintenance:mode --on
|
||||
```
|
||||
|
||||
Example, for mail:
|
||||
|
||||
```bash
|
||||
systemctl stop postfix
|
||||
systemctl stop dovecot
|
||||
```
|
||||
|
||||
! If you wish to move databases such as mariadb (mysql), it is imperative that you stop the services for these databases otherwise it is almost certain that your data will be corrupted.
|
||||
|
||||
### 5.3 Creating the mount points
|
||||
|
||||
Next, we will rename the original folder and create an empty eponymous folder.
|
||||
|
||||
```bash
|
||||
mv /home/yunohost.app /home/yunohost.app.bkp
|
||||
mkdir /home/yunohost.app
|
||||
mv /var/mail /var/mail.bkp
|
||||
mkdir /var/mail
|
||||
```
|
||||
|
||||
We can then use the `mount --bind` command to mount the folder on our hard drive to the new empty location in the tree.
|
||||
|
||||
```bash
|
||||
mount --bind /mnt/hdd/home/yunohost.app /home/yunohost.app
|
||||
mount --bind /mnt/hdd/var/mail /var/mail
|
||||
```
|
||||
|
||||
### 5.4 Copying the data
|
||||
|
||||
Next, we copy the data, keeping all the folder and file properties. This operation can take a little time, with another terminal, you can control the evolution by observing the weight associated with the mount point with `df -h`
|
||||
|
||||
```bash
|
||||
cp -a /home/yunohost.app.bkp/. /home/yunohost.app/
|
||||
cp -a /var/mail.bkp/. /var/mail/
|
||||
```
|
||||
|
||||
Once this is done, check with `ls` that the contents are there:
|
||||
|
||||
```bash
|
||||
ls -la /home/yunohost.app/
|
||||
ls -la /var/mail/
|
||||
```
|
||||
|
||||
### 5.5 Exiting maintenance mode
|
||||
|
||||
From here you can stop maintenance mode, the command below is to be adapted depending on the services you have stopped.
|
||||
|
||||
```bash
|
||||
sudo -u nextcloud /var/www/occ maintenance:mode --off
|
||||
systemctl start postfix
|
||||
systemctl start dovecot
|
||||
```
|
||||
|
||||
From this point on, your services are running with their data on disk, so it's time to test to see how much of an impact this has on performance (especially if you are using USB 2.0).
|
||||
|
||||
## 6. Automatically mount on boot
|
||||
|
||||
|
||||
So far we have manually mounted the disk and subfolders. However, it is necessary to configure the system to automatically mount the disk after a boot.
|
||||
|
||||
If your tests are successful, you should keep the mount points, otherwise you should hurry up and go back to maintenance first.
|
||||
|
||||
To begin with, let's find the UUID (universal identifier) of our disk with :
|
||||
|
||||
```bash
|
||||
blkid | grep "/dev/YOUR_DISK1:"
|
||||
# Should return something like
|
||||
# Returns something like :
|
||||
# /dev/sda1:UUID="cea0b7ae-2fbc-4f01-8884-3cb5884c8bb7" TYPE="ext4" PARTUUID="34e4b02c-02"
|
||||
```
|
||||
|
||||
Let's add a line in the file `/etc/fstab` which manages which disks are mounted at boot. We open this file with `nano` :
|
||||
Let's add a line to the `/etc/fstab` file that handles the mounting of disks at boot time. So we open the file with `nano` :
|
||||
|
||||
```bash
|
||||
nano /etc/fstab
|
||||
```
|
||||
|
||||
And add this line :
|
||||
Then add these lines to the end of the file:
|
||||
|
||||
```bash
|
||||
UUID="cea0b7ae-2fbc-4f01-8884-3cb5884c8bb7" /media/storage ext4 defaults,nofail 0 0
|
||||
UUID="cea0b7ae-2fbc-4f01-8884-3cb5884c8bb7" /mnt/hdd ext4 defaults,nofail 0 0
|
||||
/mnt/hdd/home/yunohost.app /home/yunohost.app none defaults,bind 0 0
|
||||
/mnt/hdd/var/mail /var/mail none defaults,bind 0 0
|
||||
```
|
||||
|
||||
(this line should be adapated according to previous info and choices)
|
||||
(this line must be adapted according to the previous information and choices)
|
||||
|
||||
Use Ctrl+X then `y` to save.
|
||||
|
||||
You can then reboot the system to test if the disk is mounted automatically.
|
||||
You can then try rebooting the system to check if the disk and subfolders are mounted automatically.
|
||||
|
||||
## 7. Clean up old data
|
||||
Once your new setup is validated, you can proceed to delete the old data from step 6.3:
|
||||
|
||||
```bash
|
||||
rm -Rf /home/yunohost.app.bkp
|
||||
rm -Rf /var/mail.bkp
|
||||
```
|
||||
|
||||
##  Congratulations!
|
||||
|
||||
If you have made it this far without damage, you now have a server that takes advantage of one or more storage disks.
|
||||
|
|
Loading…
Add table
Reference in a new issue