Save Seafile data to external hard drive

Running your own cloud with Seafile on the Raspberry Pi* is a great cost-effective way to store, manage and share your data with full control. The joy can be quickly clouded when the storage capacity of the SD card* is reached. It is obvious to use an external hard drive*. I recommend a hard drive with its own power supply.

A few lines of code are enough and your storage capacity has already been greatly increased.

First, we connect the hard drive to the Pi and identify it in the terminal with:

sudo blkid -o list -w /dev/null

You should get the following output (or similar):

device fs_type label mount point UUID
/dev/mmcblk0p1 vfat boot /boot 5203-DB74
/dev/mmcblk0p2 ext4 rootfs / 2ab3f8e1-7dc6-43f5-b0db-dd5759d51d4e
/dev/mmcblk0 (in use)                       
/dev/sda1 ext4 /mnt/cloud a219dccf-fe75-4423-8b85-ea913fe039a5

We are interested /dev/sda1 (mmcblk* is the memory card). We now format the hard drive (ATTENTION: all data will be lost!) and create the right file format directly:

sudo mkfs.ext4 /dev/sda

Then we create a mountpoint (path to the hard drive). In the example above, you can see that I have already mounted this under /mnt/cloud.

sudo mkdir /mnt/cloud #the Mountpoint you can choose freely

Now we instruct the Pi to connect the hard drive automatically when restarting. To do this, we open the fstab and insert the line at the end.

sudo nano /etc/fstab
/dev/sda1 /mnt/cloud ext4 rw 0 0

The hard drive can now be connected correctly to:

sudo mount -a

Now we create a folder on the hard drive and assign write rights for seafile:

sudo mkdir /mnt/cloud/seafile
sudo chown -R seafile:seafile /mnt/cloud/seafile

Finally, we stop Seafile, switch to the user seafile, move the data and create a symbolic link. Then start Seafile.

sudo systemctl stop seafile seahub
sudo su seafile
mv seafile-data/ /mnt/cloud/seafile
ln -s /mnt/cloud/seafile/seafile-data/ /home/seafile/seafile-data
sudo systemctl start seafile seahub

From now on, all files are located on the external hard drive*.

One thought on “Save Seafile data to external hard drive

  1. Error

    Job for seafile.service failed because the control process exited with error code.
    See “systemctl status seafile.service” and “journalctl -xe” for details.
    Job for seahub.service failed because the control process exited with error code.
    See “systemctl status seahub.service” and “journalctl -xe” for details.

    What could be?

    1. Hi Valera,

      it depends on the details you get like written if you run “systemctl status seahub.service”. I guess you started seahub as seafile user. Try to stop seahub and seafile as seafile user and switch back to your standard user and run again “sudo start seafile seahub”. Mostly this will resolve the error.

      If not, please advise more details. At which step you get the error, what is the output of the status and/or logfiles…

      1. ● seafile.service – Seafile
        Loaded: loaded (/etc/systemd/system/seafile.service; enabled; vendor preset: enabled)
        Active: failed (Result: exit-code) since Mon 2020-07-06 19:49:54 MSK; 13s ago
        Process: 1869 ExecStart=/home/seafile/seafile-server-latest/ start (code=exited, status=1/FAILURE)

        июл 06 19:49:53 raspberrypi systemd[1]: Starting Seafile…
        июл 06 19:49:54 raspberrypi[1869]: Error: there is no seafile server data directory.
        июл 06 19:49:54 raspberrypi[1869]: Have you run before this?
        июл 06 19:49:54 raspberrypi systemd[1]: seafile.service: Control process exited, code=exited, status=1/FAILURE
        июл 06 19:49:54 raspberrypi systemd[1]: seafile.service: Failed with result ‘exit-code’.
        июл 06 19:49:54 raspberrypi systemd[1]: Failed to start Seafile.

      2. Hi Valera,

        the error says what is going wrong: “Error: there is no seafile server data directory.” So you have no data directory. Please check if you set the link correct. I found an error in my instrcution for english site. I already fixed this.
        So what you have to do is following:
        sudo so seafile
        rm /home/seafile/seafile-data
        ln -s /mnt/cloud/seafile/seafile-data/ /home/seafile/seafile-data

        Please check if you have the same mount point for “/mnt/cloud/”
        Than start seafile.
        Hope this can fix your problem and sorry for my mistake in the instructions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.