gpt4 book ai didi

raspberry-pi - 带有 Raspbian Linux for ARM (Plate Raspberry Pi) 的 sd 卡能用多久?

转载 作者:行者123 更新时间:2023-12-03 17:50:44 25 4
gpt4 key购买 nike

工作人员,这个问题适用于相信 Debian linux,更准确地说是 Raspbian 的任何人,这是一个在 Raspberry Pi 板上运行的版本:

树莓派的所有用户都应该知道:操作系统安装在 SD 卡上。而且问题是SD卡是闪存,这种类型的内存只支持有限数量的写操作。

我想知道Raspbian是否在空闲时写入SD卡。如果发生这种情况,我该如何禁用?

我找到了这个:

Tips for running Linux on a flash device by David Härdeman

If you are running your NSLU2 on a USB flash key, there are a number of things you might want to do in order to reduce the wear and tear on the underlying flash device (as it only supports a limited number of writes).

Note: this document currently describes Debian etch (4.0) and needs to be updated to Debian squeeze (6.0) and Debian wheezy (7.0). Some of the hints may still apply, but some may not.

The ext3 filesystem per default writes metadata changes every five seconds to disk. This can be increased by mounting the root filesystem with the commit=N parameter which tells the kernel to delay writes to every N seconds.

The kernel writes a new atime for each file that has been read which generates one write for each read. This can be disabled by mounting the filesystem with the noatime option. Both of the above can be done by adding e.g. noatime,commit=120,... to /etc/fstab. This can also be done on an already mounted filesystem by running the command:

mount -o remount,noatime,commit=120 /

The system will run updatedb every day which creates a database of all files on the system for use with the locate command. This will also put some stress on the filesystem, so you might want to disable it by adding

exit 0

early in the /etc/cron.daily/find script.

syslogd will in the default installation sync a lot of log files to disk directly after logging some new information. You might want to change /etc/syslog.conf so that every filename starts with a - (minus) which means that writes are not synced immediately (which increases the risk that some log messages are lost if your system crashes). For example, a line such as:

kern.* /var/log/kern.log

would be changed to:

kern.* -/var/log/kern.log

You also might want to disable some classes of messages altogether by logging them to /dev/null instead, see syslog.conf(5) for details.

In addition, syslogd likes to write -- MARK -- lines to log files every 20 minutes to show that syslog is still running. This can be disabled by changing SYSLOGD in /etc/default/syslogd so that it reads

SYSLOGD="-m 0"

After you've made any changes, you need to restart syslogd by running

/etc/init.d/syslogd restart

If you have a swap partition or swap file on the flash device, you might want to move it to a different part of the disk every now and then to make sure that different parts of the disk gets hit by the frequent writes that it can generate. For a swap file this can be done by creating a new swap file before you remove the old one.

If you have a swap partition or swap file stored on the flash device, you can make sure that it is used as little as possible by setting /proc/sys/vm/swappiness to zero.

The kernel also has a setting known as laptop_mode, which makes it delay writes to disk (initially intended to allow laptop disks to spin down while not in use, hence the name). A number of files under /proc/sys/vm/ controls how this works:

/proc/sys/vm/laptop_mode: How many seconds after a read should a writeout of changed files start (this is based on the assumption that a read will cause an otherwise spun down disk to spin up again).

/proc/sys/vm/dirty_writeback_centisecs: How often the kernel should check if there is "dirty" (changed) data to write out to disk (in centiseconds).

/proc/sys/vm/dirty_expire_centisecs: How old "dirty" data should be before the kernel considers it old enough to be written to disk. It is in general a good idea to set this to the same value as dirty_writeback_centisecs above.

/proc/sys/vm/dirty_ratio: The maximum amount of memory (in percent) to be used to store dirty data before the process that generates the data will be forced to write it out. Setting this to a high value should not be a problem as writeouts will also occur if the system is low on memory.

/proc/sys/vm/dirty_background_ratio: The lower amount of memory (in percent) where a writeout of dirty data to disk is allowed to stop. This should be quite a bit lower than the above dirty_ratio to allow the kernel to write out chunks of dirty data in one go.

All of the above kernel parameters can be tuned by using a custom init script, such as this example script. Store it to e.g. /etc/init.d/kernel-params, make it executable with

chmod a+x /etc/init.d/kernel-params

and make sure it is executed by running

update-rc.d kernel-params defaults

Note: Most of these settings reduce the number of writes to disk by increasing memory usage. This increases the risk for out of memory situations (which can trigger the dreaded OOM killer in the kernel). This can even happen when there is free memory available (for example when the kernel needs to allocate more than one contiguous page and there are only fragmented free pages available).

As with any tweaks, you are advised to keep a close eye on the amount of free memory and adapt the tweaks (e.g. by using less aggressive caching and increasing the swappiness) depending on your workload.

This article has been contributed by David Härdeman

Go back to the Debian on NSLU2 page.



http://www.cyrius.com/debian/nslu2/linux-on-flash/

有人有更多提示吗?

最佳答案

我一直在使用各种 raspberry pi 设置,到目前为止还没有遇到 SD 卡问题(手指交叉)。话虽如此,但有一些证据表明 SD 卡生命周期相关问题

快速谷歌搜索确实显示了更多提示:

  • 越大越好 - 减少特定部分的负载
  • 写入 ram 以获取临时信息
  • 仅将引导分区存储在 SD 卡上,而将操作系统留在 USB 驱动器上

  • ( http://www.makeuseof.com/tag/extend-life-raspberry-pis-sd-card/ )

    无论如何,听到有人在 SD 卡生命周期上有覆盆子簇或类似的东西会很有趣!
    ( https://resin.io/blog/what-would-you-do-with-a-120-raspberry-pi-cluster/ )

    关于raspberry-pi - 带有 Raspbian Linux for ARM (Plate Raspberry Pi) 的 sd 卡能用多久?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22341626/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com