1

Just to say, I have posted this question on the Raspberry Pi stack exchange, but I think it is a general Linux question (at least on the basic level to which my own knowledge extends), and that people in this community will be able to help with this, so I am asking it here.

I am new to managing filesystems, but am using a Raspberry Pi 3B with a 16GB SD card, and running an InfluxDB database on there. The Pi writes a datapoint every second, to the database which is just in the /home/ directory.

I have seen that it is a bad idea for the life of the SD card to be doing lots of writes, and in addition it will just fill up the space on the card after a while. Therefore I have bought an external 240GB solid state drive , and a USB to SATA adapter , and my intention was to mount the drive to /mnt/ and use it for storage of the database instead of the /home/ directory. Since I would like to sometimes unplug the drive and read the data on Windows, it would be formatted as NTFS.

However, although this would solve the issue of storage space (the SSD is plenty big enough), in that scenario I would still be using the SD card for the Raspian (Buster Lite) operating system, which would then be writing data to the SSD drive over USB.

My questions are now:

  1. Is this a bad idea?

  2. Would it make more sense to partition the SSD into 2 partitions - one foramtted as NTFS for storage, and a second, smaller one (around 10GB) formatted for Linux (should this be Ext4?) which would just hold Raspian. The data would then be collected using InfluxDB on one partition and transferred to the second one, avoiding any writes on the SD card at all.

  3. If so, what are the general steps to follow (and things to watch out for) to do this?

  4. Is there a more sensible way?

Thanks

3
  • Welcome to the site. May I then recommend that you delete your post over at RasPI SE, as cross-posting is discouraged and will lead to close votes on both sites?
    – AdminBee
    May 27, 2020 at 12:42
  • Thank you, do you have an opinion on whether this question is more relevant here or on RasPI SE?
    – teeeeee
    May 27, 2020 at 12:43
  • I think RasPI SE is better: Although the underlying question would be on topic here (with the caveat of possibly being "opinion-based"), the actual implications of having a RasPI's operating system no longer on the SD card but on an external partition (IIUC) will find more experienced contributors there.
    – AdminBee
    May 27, 2020 at 12:47

2 Answers 2

0

Yes/no answers to this are likely to be opinion based. This comes down to your requirements. What we can do is present some things to consider and let you decide.

Simple truth: SD cards wear faster than SSDs usually. SD cards are much cheaper than SSDs usually. Basically you get what you pay for. A good quality SD card should last you quite a long time (several years) running a raspberry pi as long as your applications arn't writing all day every day. But I have burned through a cheap one in a couple of months

Now why does wear bother you?
- If you are worried about spending more money on an SD the. There could be a very long debate indeed on whether you get more wear per dollar for an SD than an SSD. This might be a false economy, that's all I'm saying. - If you are worried about system uptime or the simple hastle of replacing the SD then you might want to think considered moving some of the file system.

I do run my r-pi with part of the OS moved to an extern drive. It's a bit of a pain for system recovery. I had power problems a while back yet couldn't boot without the external HD attached. I have both /home and /var mapped to my external drive as these have the highest rewrite need. I run mine as a server and I am more worried about the work I would have to do if the SD card failed. It's also because I need 2TB storage.

If you go down that route, I would suggest the entire OS (except for /boot) should go on the external disk. This makes configuration simpler and recovery much simpler. In hindsight my setup with part SD part USB hd is more hastle than its worth.

6
  • Thank you very much for your answer. The system will be left running constantly with a few writes to the database every second, and reading from it at least faster than that. I was concerned as well that the read speed would be too slow if I was reading large amounts of data back from the database. When you say "except for boot", why would we not just put boot as well together with everything else on the external drive, and forget the SD card? Do you mean leave the boot directory on the SD card?
    – teeeeee
    May 27, 2020 at 22:26
  • /boot contains firmware needed by the raspberry pi to startup and boot into Linux. I don't believe any version of raspberry pi supports loading this from a usb drive, only the internal SD. Read can be slow on usb 2. The r-pi 4 is the first with usb3 I believe. May 27, 2020 at 22:44
  • I agree that the Pi 4 is the only one with USB 3.0 ports, so yes I understand that the speed will be limited at the moment (I was considering upgrading to Pi 4 for this reason). However, I was under the impression that the Pi could boot from an external drive. For the 3B, the only caveat is that the flag program_usb_boot_mode=1 needs to be set in the /boot/config file. This must initially be done with an SD card, but after that can be removed permenantly. See here: raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/… Do you agree?
    – teeeeee
    May 28, 2020 at 9:21
  • 1
    @teeeeee I'll admit that's a new one on me, but it looks correct. I wasn't aware of the "OTP" that makes this possible. I'll read more and update my answer. May 28, 2020 at 9:26
  • Okay thanks. Actually, in the case where one already has everything running on the SD card (OS, software, settings, etc) and don't want to start again from scratch, I think this repo even makes it possible to simply clone your working SD card content into a bootable external drive github.com/billw2/rpi-clone (although the fresh installation would be preferable, I think, if one can go that route).
    – teeeeee
    May 28, 2020 at 9:40
-2

From one of the comments below (thanks Philip) most SD cards do not have wear levelling controllers. This is a fundamental difference to SSDs which (as far as I was able to find) all do wear levelling.

Having an SSD connected externally would be safer than using an SD without wear levelling when comparing the risk of wear. That said you may be find SD cards with wear levelling.

There's things you can do on the system to reduce the impact of this (such as increasing the cache size / reducing the sync rate at the risk of losing more data in an unplanned power loss).

Also size matters - a larger device allows for the levelling algorithm to reduce your writes per block.

Depending on the purpose and estimated length of service, the most likely and easier solution to your problem is "don't worry about it". Next up you can clone your OS SD into a new one periodically (every X months of use) and keep going.

7
  • Just to clarify, are you saying don't use the external drive at all? If so, this would leave me with the problem of the card just simply filling up quickly.
    – teeeeee
    May 27, 2020 at 14:04
  • Well, there's relatively large SD cards (~128GB IIRC), but that's entirely up to your storage needs. If you still need an SSD, then use one. My point (which I've not made clearly) was that SSD also has a problem with wear, so using SSD instead of SD for a particular data set isn't a solution for the wear problem.
    – Pedro
    May 27, 2020 at 14:19
  • I see, thank you, that's clear - I take your point. I would like to use the SSD since I already have it. Somthing I didn't mention in the OP is that I have a client on the Pi which is accessing the data in the database - if this client were running on an SD card and the data was on an external drive then I would be limited by the transfer speed of the SD card. Whereas if the OS (and therefore the client) was on the SSD as well then this transfer would be quicker.
    – teeeeee
    May 27, 2020 at 14:28
  • 3
    "SD cards wear as well as SSD disks do"... No they don't! They are similar concept with significantly different implementation. As cards don't often have inbuilt wear leveling technology though there are exceptions. May 27, 2020 at 14:42
  • @PhilipCouling thanks for that, I wasn't aware that SD cards by definition didn't have wear leveling. Although they're not uncommon today. I'll edit the answer.
    – Pedro
    May 27, 2020 at 14:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .