Skip to main content

Search: #linux

有的没的
  1. 才学习到了swap不仅仅是存在硬盘或者rom里的文件,也有可能是zram。

    zram是在ram中划走一部分并且进行压缩。一般可以提供划走空间的1.5~2倍空间。所以是牺牲cpu性能扩展了内存。

    看了一下armbian默认开的是zram,不是文件swap。默认会划走ram的50%

    之前寻思着比较伤害rom,看来是我误解了。

    一般是在/etc/default/armbian-zram-config来配置


    #linux
  2. armbian 关闭 swap:

    1. 确认一下swapon --show,看一下 swapfile 位置,后面删掉
    2. sudo swapoff -a
    3. 去删掉 swapfile
    4. 去/etc/default/armbian-zram-config 中,设置 swap=false

    关掉 swap 对 emmc 好,armbian 默认开 zram,swapiness 还是 100,swap 优先级非常高。具体的参数可以看一下 armbian-zram-config 这个文件。


    #linux #programming
  3. 查看emmc健康度的两种方式


    eMMC 存储在 linux 上被挂载为块设备,一般通过 /dev/mmcblk* 访问。

    1. mmc-utils 工具

    $ mmc extcsd read /dev/mmcblk2
    =============================================
      Extended CSD rev 1.8 (MMC 5.1)
    =============================================
    
    ...
    $ mmc extcsd read /dev/mmcblk2 | grep -iE 'life|eof'
    eMMC Life Time Estimation A [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]: 0x01
    eMMC Life Time Estimation B [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]: 0x01
    eMMC Pre EOL information [EXT_CSD_PRE_EOL_INFO]: 0x01
    


    2. /sys/class/block 源文件

    Android 上可能没有 mmc 工具,可以通过 /sys/class 查询设备的各种信息。

    # 需要 root 权限
    $ cat /sys/class/block/mmcblk2/device/pre_eol_info
    0x01
    $ cat /sys/class/block/mmcblk2/device/life_time
    0x01 0x01
    


    关键字段\_健康度
    ---------

    1. DEVICE\_LIFE\_TIME\_EST\_TYP

    越小越好,分为 A/B 字段,代表 SLC/MLC 寿命。

    | Value | Description |
    | --- | --- |
    | 0x00 | Not defined |
    | 0x01 | 0%~10% device life time used |
    | 0x02 | 10%~20% device life time used |
    | 0x03 | 20%~30% device life time used |
    | 0x04 | 30%~40% device life time used |
    | 0x05 | 40%~50% device life time used |
    | 0x06 | 50%~60% device life time used |
    | 0x07 | 60%~70% device life time used |
    | 0x08 | 70%~80% device life time used |
    | 0x09 | 80%~90% device life time used |
    | 0x0A | 90%~100% device life time used |
    | 0x0B | Exceeded its maximum estimated device life time |
    | Others | Reserved |

    2. PRE\_EOL\_INFO

    | Value | Pre-EOL Info | Description |
    | --- | --- | --- |
    | 0x00 | Not defined | |
    | 0x01 | Normal | Normal |
    | 0x02 | Warning | Consumed 80% of reserved block |
    | 0x03 | Urgent | |
    | 0x04~0xFF | Reserved | |


    #tech #linux