Reduce writing to sd card in raspberry pi (raspbian stretch lite)

Hi!

recently installed nextcloud 12 on my (first) raspberry pi. So far, everything is working smoothly! But since I’d like to reduce writecycles to the sd card, I have the following question:

  • when uploading files to my nextcloud (data directory is an external usb wd-labs HDD), iostat -m reports quite a large amount of data being written to the sdcard, although I already have mounted /var/tmp in RAM, have mounted a swap partition on an usb-stick and /var/logs are being written to the usb-stick as well (to another partition than the swap partition, obviously). If I upload 1 GB of photos, the amount of data written to sd-card (mmcblk0) will be almost as much as the amount of data written to the usb HDD.

Maybe someone can point me in the right direction. df reports no increase in used space, so I tried to mount /var/tmp in RAM, but as I said, this helps nothing… The goal is to find the process that temporarily uses sd card space.

Thanks!

Try to disable request buffering. If you use nginx add this line to the php block of your server configuration:
fastcgi_request_buffering off;

…using apache2 on raspbian (debian) stretch. Any idea how to do this in this environment? And will it reduce perfomance? I’m pretty impressed by the perfomance the Raspberry Pi 3B has.

You’d have likely been better off installing raspbian to your HDD and putting a redirect on the SD card TBH.

Thanks! But I thought that having the OS on the SD card might let the HDD sleep more often, and therefore increase its lifespan and save electricity.

… at the cost of burning up more SD cards. Swings and roundabouts :slight_smile:

For me the best way was the NextcloudPi image for berryboot. That will reduce the write to the SDcard. But the Raspi has still the problem that usb and LAN is running at the same data bus …

I tried nextcloudpi, but it didn’t work as expected in my setup. There must be a way to reduce the writes to the SD card, some people run their entire pi with a read-only filesystem, right? I’ll try to find the find the location of stored files and try to mount that in RAM.

As I suggested try NextcloudPI with berryboot. That are two special Images. You have to write the berryboot to the sdcard and boot it. Then you will have a couple of options, one of that is to install a special Image to Stick or HDD, for that you need the special Nextcloudpi Image. After setup, the complete Linux incl. Swap etc and Nextcloud is running at the HDD and if that is an SSD it might be a little bit faster.

https://github.com/nextcloud/nextcloudpi/wiki/How-to-install-NextCloudPi-on-an-external-drive-using-Berryboot.

Edit: because SSD, running from HDD is very much faster, but since the Raspi Hardware is using the same Chip/Bus, or whatever you name it, for the USB Port and the LAN Port, there is a Bottleneck. In my Case I have ~180.000 MP3 via LAN and for that at the End it was to slow for me.
But everything else is very good.
If you try berryboot, you have to do a long left Mouse Click to find the option for import an image otherwise you can load Debian or other OS, from where you can setup your own nextcloud.
but the main benefit is, so far i know, the sdcard is only used for booting and every thing else is running at HDD

Good Luck