<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="https://www.bigdick.live/feed_style.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans">
    <tabi:metadata xmlns:tabi="https://github.com/welpo/tabi">
        <tabi:base_url>https:&#x2F;&#x2F;www.bigdick.live</tabi:base_url>
        <tabi:separator>
            •
        </tabi:separator>
        <tabi:about_feeds>这是Web Feed，又称为Atom Feed，把现在的网址复制到新闻阅读器即可订阅本站文章。造访「About Feeds」来了解更多资讯。</tabi:about_feeds>
        <tabi:visit_the_site>造访网站</tabi:visit_the_site>
        <tabi:recent_posts>近期文章</tabi:recent_posts>
        <tabi:last_updated_on>更新于 $DATE</tabi:last_updated_on>
        <tabi:default_theme></tabi:default_theme>
        <tabi:post_listing_date>date</tabi:post_listing_date>
        <tabi:current_section>孙瑜</tabi:current_section>
    </tabi:metadata><link rel="extra-stylesheet" href="https://www.bigdick.live/skins/black-orange.css?h=c64b7f81e34a143cd725" /><title>孙瑜</title>
        <subtitle>孙瑜的个人首页：生物信息、数据科学、软件工程，以及公开简历、项目和文章。</subtitle>
    <link href="https://www.bigdick.live/atom.xml" rel="self" type="application/atom+xml"/>
    <link href="https://www.bigdick.live" rel="alternate" type="text/html"/>
    <generator uri="https://www.getzola.org/">Zola</generator><updated>2024-09-15T00:00:00+00:00</updated><id>https://www.bigdick.live/atom.xml</id><entry xml:lang="zh-Hans">
        <title>家用公网服务架设指引</title>
        <published>2024-09-15T00:00:00+00:00</published>
        <updated>2024-09-15T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/ipv6-public/" type="text/html"/>
        <id>https://www.bigdick.live/blog/ipv6-public/</id>
        
            <content type="html">&lt;h2 id=&quot;tai-chang-bu-kan&quot;&gt;太长不看&lt;&#x2F;h2&gt;
&lt;p&gt;大家都是有&lt;strong&gt;IPv6&lt;&#x2F;strong&gt;的公网地址的，所以：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;光猫&lt;&#x2F;strong&gt;：打开IPv6支持，桥接模式&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;路由器&lt;&#x2F;strong&gt;：native模式&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;CloudFlare（下简称CF）&lt;&#x2F;strong&gt;：
&lt;ul&gt;
&lt;li&gt;域名丢CF托管（按需决定是否走CF代理）&lt;&#x2F;li&gt;
&lt;li&gt;按需添加规则&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;设备&lt;&#x2F;strong&gt;：跑&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jeessy2&#x2F;ddns-go&quot;&gt;ddns-go&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Caddy&lt;&#x2F;strong&gt;：按需反代、自动HTTPS&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;guang-mao-pian&quot;&gt;光猫篇&lt;&#x2F;h2&gt;
&lt;p&gt;这块长话短说，先抛出一个大前提：喜欢动手折腾的同学，能接受自购企业级光猫（中兴、华为等等均可）最好，恩山论坛上有备受推崇的几个型号及各种对比，我就不赘述了。&lt;&#x2F;p&gt;
&lt;p&gt;如果你一定要坚持光猫是运营商提供服务的载体，安装&#x2F;调试&#x2F;维护它是运营商工作的一部分，我只想提两个要点：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;第一&lt;&#x2F;strong&gt;，&lt;strong&gt;投诉&lt;&#x2F;strong&gt;不能当时解决问题，但绝对是解决问题的&lt;strong&gt;唯一&lt;&#x2F;strong&gt;手段。&lt;&#x2F;p&gt;
&lt;p&gt;虽然某些运营商工作人员非常敷衍，但还是希望大家理性投诉，一个大的原则是先礼后兵，不要&lt;strong&gt;越级&lt;&#x2F;strong&gt;（投诉）：你不能让认真工作的人突然莫名其妙被领导敲打一下（甚至被扣钱），这很离谱。&lt;&#x2F;p&gt;
&lt;p&gt;经过了长达3个多月的拉锯战，问题终于得以解决&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-1-1&quot;&gt;&lt;a href=&quot;#fn-1&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;，下面列举我实际的投诉（中国联通）顺序，供大家参考：&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;先联系安装师傅（帮装宽带或者近期派工单的师傅）&lt;&#x2F;li&gt;
&lt;li&gt;（&lt;strong&gt;省级&lt;&#x2F;strong&gt;）打客服：10010&lt;&#x2F;li&gt;
&lt;li&gt;（&lt;strong&gt;总部&lt;&#x2F;strong&gt;）打集团投诉热线：10015 （&lt;strong&gt;工作时间：08:30-17:30&lt;&#x2F;strong&gt;）&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;yhssglxt.miit.gov.cn&#x2F;web&#x2F;appealInformation&quot;&gt;投诉到工信部&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;要有长期作战的准备，因为直到投诉到工信部之前，可能还是之前总联系你的几个客服（话务员）和安装师傅在和你绕来绕去，反复让你&lt;strong&gt;描述同样的问题&lt;&#x2F;strong&gt;，再复述&lt;strong&gt;完全不一致&lt;&#x2F;strong&gt;的问题给你听，或者直接问你：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;您家宽带是上不了网了是吗？&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;希望大家与人为善，因为他们也很无奈，case 来了就要接，想找技术好的人找不着。这就是GQ现状啊。&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;第二&lt;&#x2F;strong&gt;，光猫&lt;strong&gt;当换则换&lt;&#x2F;strong&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;当你申请装宽带时，如果当地运营商有陈旧的存货，而你又没有提出要求，是可能优先给你装&lt;strong&gt;旧光猫&lt;&#x2F;strong&gt;的。
这些光猫的IPv6支持形同虚设。没错，你点进去（管理员账户）有相关的设置，但只能分配一个地址给你。
然后你就可以在IPv6的海洋中遨游了：你只能访问IPv6的服务而不能提供任何服务，因为&lt;strong&gt;光猫的内置防火墙规则&lt;&#x2F;strong&gt;给你干得死死的&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-2-1&quot;&gt;&lt;a href=&quot;#fn-2&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;，又或者给设备发放地址的&lt;strong&gt;前缀有问题&lt;&#x2F;strong&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;这些光猫有些共通特点：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;设置界面中完全没有IPv6相关的防火墙设置&lt;&#x2F;li&gt;
&lt;li&gt;尚能发送WIFI信号&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-3-1&quot;&gt;&lt;a href=&quot;#fn-3&quot;&gt;3&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;lu-you-qi-pian&quot;&gt;路由器篇&lt;&#x2F;h2&gt;
&lt;h2 id=&quot;cfpian&quot;&gt;CF篇&lt;&#x2F;h2&gt;
&lt;p&gt;由于OMV没有特别爽的照片管理应用，所以我在NAS上安装了PhotoPrism（下简称&lt;strong&gt;PP&lt;&#x2F;strong&gt;）。&lt;&#x2F;p&gt;
&lt;p&gt;那么就催生了我对网络的以下几个需求：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;PP需要走HTTPS&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-4-1&quot;&gt;&lt;a href=&quot;#fn-4&quot;&gt;4&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;li&gt;
&lt;li&gt;PP最好可以通过域名访问&lt;&#x2F;li&gt;
&lt;li&gt;URL（子域名）最好容易记忆，不要有端口号等出现&lt;&#x2F;li&gt;
&lt;li&gt;HTTP请求可以被重定向到HTTPS&lt;&#x2F;li&gt;
&lt;li&gt;仅在IPv4网络环境下亦可访问&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;下面分别展开叙述。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;0-yu-ming-bang-ding-dong-tai-ipv6di-zhi&quot;&gt;0. 域名绑定动态IPv6地址&lt;&#x2F;h3&gt;
&lt;p&gt;先把域名托管到CF，这个不做赘述了。&lt;&#x2F;p&gt;
&lt;p&gt;然后开启一个&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jeessy2&#x2F;ddns-go&quot;&gt;ddns-go&lt;&#x2F;a&gt;服务：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;services&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;  ddns-go&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;    image&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value&quot;&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; jeessy&#x2F;ddns-go&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;    restart&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value&quot;&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; always&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;    network_mode&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value&quot;&gt;:&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-string&quot;&gt; &amp;quot;host&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-tag z-yaml&quot;&gt;    volumes&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;      -&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; .&#x2F;ddns-go:&#x2F;root&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Token的获取方式：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;ipv6-public&#x2F;dns_zone_token.gif&quot; alt=&quot;dns_zone_token.gif&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-zai-ipv4xia-fang-wen&quot;&gt;1. 在IPv4下访问&lt;&#x2F;h3&gt;
&lt;p&gt;这步很简单，只要让域名走CF的代理就可以。&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;ipv6-public&#x2F;proxied.png&quot; alt=&quot;proxied.png&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;CF在全球范围内运营维护了大量同时支持IPv4&#x2F;v6的边缘节点，并在其上应用负载均衡。经过这样的设置后，哪怕客户端的网络环境只支持IPv4，CF也会将其发送的请求代理到客户端附近的边缘节点上，而这些节点支持IPv6，这样就实现了&lt;code&gt;4&lt;&#x2F;code&gt; to &lt;code&gt;6&lt;&#x2F;code&gt;。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-duan-kou-ying-she&quot;&gt;2. 端口映射&lt;&#x2F;h3&gt;
&lt;blockquote&gt;
&lt;p&gt;中国联通在上游禁用了以下端口（欢迎评论补充其他情况）：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;80&lt;&#x2F;li&gt;
&lt;li&gt;443&lt;&#x2F;li&gt;
&lt;li&gt;8080&lt;&#x2F;li&gt;
&lt;li&gt;53&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;我们在&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;ipv6-public&#x2F;#1-zai-ipv4xia-fang-wen&quot;&gt;第&lt;strong&gt;1&lt;&#x2F;strong&gt;步&lt;&#x2F;a&gt;中配置域名走了CF的代理，但CF的代理仅在&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;developers.cloudflare.com&#x2F;fundamentals&#x2F;reference&#x2F;network-ports&#x2F;#network-ports-compatible-with-cloudflares-proxy&quot;&gt;特定的几个端口&lt;&#x2F;a&gt;上生效，因此只能充分利用它们。&lt;&#x2F;p&gt;
&lt;p&gt;比如，我决定用&lt;code&gt;&#x2F;photo&lt;&#x2F;code&gt;子路径指向我NAS上的PP服务，并使用CF的&lt;code&gt;2053&lt;&#x2F;code&gt;端口来代理访问PP的HTTP请求：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;操作指引&lt;&#x2F;strong&gt;：&lt;strong&gt;Dashboard&lt;&#x2F;strong&gt; → &lt;strong&gt;Rules&lt;&#x2F;strong&gt; → &lt;strong&gt;Origin Rules&lt;&#x2F;strong&gt; → &lt;strong&gt;Create rule&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;ipv6-public&#x2F;origin_rule.png&quot; alt=&quot;origin_rule&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;3-caddyfan-xiang-dai-li&quot;&gt;3. Caddy反向代理&lt;&#x2F;h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Caddy需要自行编译以增加对CF的支持，过程不再赘述，详见我&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;nas&#x2F;#caddy&quot;&gt;配置NAS的post中的对应部分&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;先去CF拿个给Caddy用的token。过程和&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;ipv6-public&#x2F;#0-yu-ming-bang-ding-dong-tai-ipv6di-zhi&quot;&gt;第&lt;strong&gt;0&lt;&#x2F;strong&gt;步&lt;&#x2F;a&gt;中描述的类似，详细配置如下：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;ipv6-public&#x2F;custom_token.png&quot; alt=&quot;custom_token&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;有了token后可以参照Caddy官方文档&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;caddyserver.com&#x2F;docs&#x2F;running#environment-variables&quot;&gt;配置daemon的环境变量&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;然后写好&lt;code&gt;&#x2F;etc&#x2F;caddy&#x2F;Caddyfile&lt;&#x2F;code&gt;：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    auto_https disable_redirects&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;nas.bigdick.live:2053 {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    reverse_proxy :2342&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    tls {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        dns cloudflare {env.CF_API_TOKEN}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里详细解释一下为什么要在Caddy中禁用自动重定向到HTTPS：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;80&lt;&#x2F;code&gt;和&lt;code&gt;443&lt;&#x2F;code&gt;端口都被运营商在上游禁用了&lt;&#x2F;li&gt;
&lt;li&gt;当然可以更改 Caddy 的 &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;caddyserver.com&#x2F;docs&#x2F;caddyfile&#x2F;options&quot;&gt;HTTP 和 HTTPS 端口&lt;&#x2F;a&gt;，但全局应用这些配置会影响到 Caddy 代理的其他服务&lt;&#x2F;li&gt;
&lt;li&gt;如果在&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;ipv6-public&#x2F;#2-duan-kou-ying-she&quot;&gt;第&lt;code&gt;2&lt;&#x2F;code&gt;步&lt;&#x2F;a&gt;中同时转发HTTP和HTTPS的请求到两个不同的端口，则需要&lt;strong&gt;两个&lt;&#x2F;strong&gt;Origin Rules，复杂且不经济&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;重启Caddy生效：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;systemctl&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; daemon-reload&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;systemctl&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; restart caddy&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;4-shi-yong-cfjiang-httpqing-qiu-zhong-ding-xiang-zhi-https&quot;&gt;4. 使用CF将HTTP请求重定向至HTTPS&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;strong&gt;操作指引&lt;&#x2F;strong&gt;：&lt;strong&gt;Dashboard&lt;&#x2F;strong&gt; → &lt;strong&gt;Rules&lt;&#x2F;strong&gt; → &lt;strong&gt;Redirect Rules&lt;&#x2F;strong&gt; → &lt;strong&gt;Create rule&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;具体的设置就很简单了，匹配规则等和Origin Rules类似，按照页面指引填写并保存即可。&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;ol&gt;
&lt;li&gt;先下单，派了个单，安装师傅说“&lt;strong&gt;正在开三中全会&lt;&#x2F;strong&gt;”，这种“敏感操作”搞不了&lt;&#x2F;li&gt;
&lt;li&gt;我说师傅您给我管理员密码我自己配置成桥接&lt;&#x2F;li&gt;
&lt;li&gt;桥接之后设备还是无法向公网提供IPv6服务，排查了路由器和操作系统的防火墙后确定是光猫问题&lt;&#x2F;li&gt;
&lt;li&gt;打10010下了个新工单，向安装师傅反映光猫IPv6防火墙不可配置问题（我说给我SSH或者Telnet方式都行了）&lt;&#x2F;li&gt;
&lt;li&gt;（我理解是）安装师傅的领导敷衍他&lt;&#x2F;li&gt;
&lt;li&gt;反复催促下安装师傅表示我们管不了，给了光猫厂家电话，说你直接问去&lt;&#x2F;li&gt;
&lt;li&gt;不知道那个厂家是不是不做了，电话打不通&lt;&#x2F;li&gt;
&lt;li&gt;开始投诉到10015&lt;&#x2F;li&gt;
&lt;li&gt;接了大概20多个回访、问询和答复电话，当中有将近10次要从头描述问题（&lt;strong&gt;您家宽带是上不了网了是吗？&lt;&#x2F;strong&gt;）&lt;&#x2F;li&gt;
&lt;li&gt;我要求提供光猫的操作手册或文档，客服又反馈去了&lt;&#x2F;li&gt;
&lt;li&gt;皮球又提到步骤&lt;strong&gt;4&lt;&#x2F;strong&gt;的安装师傅身上，他表示我家用的光猫已经全线停止使用了&lt;&#x2F;li&gt;
&lt;li&gt;我要求换光猫，所以师傅和我约了时间上门&lt;&#x2F;li&gt;
&lt;li&gt;上门后他表示改不了桥接，问我借了笔记本电脑试图&lt;code&gt;telnet&lt;&#x2F;code&gt;去获取密码，但命令都打错了，大怒，叫我再下一个工单去问管理员密码&lt;&#x2F;li&gt;
&lt;li&gt;我要来管理员密码之后终于可以自己配置了，问题最终得以解决&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn-1&quot;&gt;
&lt;p&gt;大概分享一下狗血过程： &lt;a href=&quot;#fr-1-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-2&quot;&gt;
&lt;p&gt;且每个厂家的的每个型号的光猫的SSH&#x2F;TELNET方式均不同，也不面向宽带用户提供文档，难以复用经验 &lt;a href=&quot;#fr-2-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-3&quot;&gt;
&lt;p&gt;一些运营商的新光猫早就不发送WIFI了：&lt;strong&gt;降低运营成本&lt;&#x2F;strong&gt; &lt;a href=&quot;#fr-3-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-4&quot;&gt;
&lt;p&gt;仅为PP的默认设定，但可以&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.photoprism.app&#x2F;getting-started&#x2F;config-options&#x2F;#web-server&quot;&gt;关闭HTTPS&lt;&#x2F;a&gt;。照片这种涉及隐私的数据还是最好不要明文传输，因此我选择尊重PP的这一设定 &lt;a href=&quot;#fr-4-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;section&gt;
</content>
        <summary type="html">和联通斗智斗勇的第10010天</summary>
        </entry><entry xml:lang="zh-Hans">
        <title>喂猫指北</title>
        <published>2024-07-24T00:00:00+00:00</published>
        <updated>2024-07-24T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/feeding/" type="text/html"/>
        <id>https://www.bigdick.live/blog/feeding/</id>
        
            <content type="html">&lt;p&gt;需要照料的包含两部分：&lt;strong&gt;丽塔&lt;&#x2F;strong&gt;和阳台的&lt;strong&gt;薄荷&lt;&#x2F;strong&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;约&lt;code&gt;3&lt;&#x2F;code&gt;天上去一次即可（遇到周末等请&lt;strong&gt;酌情调整&lt;&#x2F;strong&gt;）。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;li-ta-pian&quot;&gt;丽塔篇&lt;&#x2F;h2&gt;
&lt;p&gt;饮食习惯：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;打开猫粮袋子，可以看到有一个量杯：丽塔每日食量约为&lt;code&gt;1&lt;&#x2F;code&gt;杯&lt;&#x2F;li&gt;
&lt;li&gt;饮水量较大，约为白色水碗一整碗&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;由于外出时间过长，我还是用马兜（不锈钢盆）盛装了一定的水。&lt;&#x2F;p&gt;
&lt;p&gt;原则上一次添加&lt;code&gt;2&lt;&#x2F;code&gt;~&lt;code&gt;3&lt;&#x2F;code&gt;杯的猫粮，马兜里放充足的水，同时保证白色水碗装满一整碗（马兜易打翻，作为备用）即可。&lt;&#x2F;p&gt;
&lt;p&gt;如果加水时水碗或者马兜太脏，辛苦简单冲洗一下（丽塔比较挑剔）。&lt;&#x2F;p&gt;
&lt;p&gt;另外洗手间门可以保持常开（丽塔不会偷跑），如果有使用马桶，请及时冲水，以保障马桶内蓄水的清洁度（仍旧为后备）。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;bo-he-pian&quot;&gt;薄荷篇&lt;&#x2F;h2&gt;
&lt;p&gt;打开阳台门可以看到正对的花盆里有薄荷，在右手边的柜子上有一花瓶的水：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;feeding&#x2F;bottle.png&quot; alt=&quot;花瓶&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;每次喂猫时顺便浇水，大概为瓶中容积的&lt;code&gt;1&#x2F;4&lt;&#x2F;code&gt;即可。&lt;&#x2F;p&gt;
&lt;p&gt;浇水时请&lt;strong&gt;避开叶片&lt;&#x2F;strong&gt;，可以选择直接由根部淋湿或淋湿周围土壤（因水珠为凸透镜，叶片易被阳光灼伤）。&lt;&#x2F;p&gt;
&lt;p&gt;薄荷分两株，右手边为母株，左手边为我通过扦插法在近期新栽种的子株：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;feeding&#x2F;flower.png&quot; alt=&quot;薄荷&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;浇水时，请&lt;strong&gt;雨露均沾&lt;&#x2F;strong&gt;。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;shui-yuan&quot;&gt;水源&lt;&#x2F;h2&gt;
&lt;p&gt;喂猫或浇花时水不够用怎么办？请去厨房解决：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;feeding&#x2F;water.png&quot; alt=&quot;水龙头&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;图示为水龙头附带的净水器：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;开关向&lt;strong&gt;顺时针&lt;&#x2F;strong&gt;方向（图示红色箭头方向）旋转90°后打开水龙头可出净水，可为丽塔补充饮用水&lt;&#x2F;li&gt;
&lt;li&gt;在净水位置上，开关向&lt;strong&gt;逆时针&lt;&#x2F;strong&gt;方向（图示绿色箭头方向）旋转90°后（回复&lt;strong&gt;原位&lt;&#x2F;strong&gt;），打开水龙头可出自来水，可用于洗手、浇花等&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote&gt;
&lt;p&gt;由于技术原因，净水器开关位于45°的整数倍上将无法正常工作。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;&lt;strong&gt;特别注意&lt;&#x2F;strong&gt;：离开厨房时请确保厨房门已关闭。丽塔非常喜欢啃塑料袋，厨房是她的“天堂”。由于门板已受潮，可能无法关严，但请尽量用力拉紧。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;ling-shi&quot;&gt;零食&lt;&#x2F;h2&gt;
&lt;p&gt;冰柜上有果冻，请不要客气，等我回去会安排&lt;code&gt;5&lt;&#x2F;code&gt;倍浓缩什么的 :)&lt;&#x2F;p&gt;
</content>
        <summary type="html">义父！丽塔和薄荷就靠你了！</summary>
        </entry><entry xml:lang="zh-Hans">
        <title>在VirtualBox里安装macOS</title>
        <published>2024-07-07T00:00:00+00:00</published>
        <updated>2024-07-07T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/macos14-virtualbox/" type="text/html"/>
        <id>https://www.bigdick.live/blog/macos14-virtualbox/</id>
        
            <content type="html">&lt;h2 id=&quot;jing-xiang-wen-jian&quot;&gt;镜像文件&lt;&#x2F;h2&gt;
&lt;p&gt;可能我姿势不对，Sonoma是万万不行的，最后还是装了High Sierra。&lt;&#x2F;p&gt;
&lt;p&gt;我们只能用ISO：&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;ia800409.us.archive.org&#x2F;28&#x2F;items&#x2F;mac-os-high-sierra-10.13_202204&#x2F;macOS%20HighSierra%2010.13.iso&quot;&gt;下载链接&lt;&#x2F;a&gt;（可能会失效，如果瓜了可以留言，我尝试传一份到其他地方）。&lt;&#x2F;p&gt;
&lt;p&gt;关于ISO和DMG的区别，以及如何从官方的DMG制作ISO镜像，可以参照&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;iboysoft.com&#x2F;howto&#x2F;macos-sonoma-iso.html&quot;&gt;这篇post&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;chuang-jian-xu-ni-ji&quot;&gt;创建虚拟机&lt;&#x2F;h2&gt;
&lt;p&gt;下载安装最新的VirtualBox，不赘述了，但注意还要安装&lt;strong&gt;Extension Pack&lt;&#x2F;strong&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;然后用头先的镜像文件创建虚拟机：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;macos14-virtualbox&#x2F;new.png&quot; alt=&quot;new.png&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;下面是一些关键设置。芯片组一定要选&lt;strong&gt;ICH9&lt;&#x2F;strong&gt;，并&lt;strong&gt;启用EFI&lt;&#x2F;strong&gt;：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;macos14-virtualbox&#x2F;system.png&quot; alt=&quot;system.png&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;至少给128M的显存，并且尽量&lt;strong&gt;启用3D加速&lt;&#x2F;strong&gt;：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;macos14-virtualbox&#x2F;display.png&quot; alt=&quot;display.png&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;还需要一些额外配置，需要先完全退出VirtualBox，然后&lt;strong&gt;以管理员权限运行&lt;&#x2F;strong&gt;PowerShell或者终端，定位到VirtualBox安装的位置（默认是下面的位置），执行几条命令：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;cd &amp;quot;C:\Program Files\Oracle\VirtualBox\&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;VBoxManage.exe modifyvm &amp;quot;VM NAME&amp;quot; --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;VBoxManage setextradata &amp;quot;VM NAME&amp;quot; &amp;quot;VBoxInternal&#x2F;Devices&#x2F;efi&#x2F;0&#x2F;Config&#x2F;DmiSystemProduct&amp;quot; &amp;quot;iMac19,3&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;VBoxManage setextradata &amp;quot;VM NAME&amp;quot; &amp;quot;VBoxInternal&#x2F;Devices&#x2F;efi&#x2F;0&#x2F;Config&#x2F;DmiSystemVersion&amp;quot; &amp;quot;1.0&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;VBoxManage setextradata &amp;quot;VM NAME&amp;quot; &amp;quot;VBoxInternal&#x2F;Devices&#x2F;efi&#x2F;0&#x2F;Config&#x2F;DmiBoardProduct&amp;quot; &amp;quot;Iloveapple&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;VBoxManage setextradata &amp;quot;VM NAME&amp;quot; &amp;quot;VBoxInternal&#x2F;Devices&#x2F;smc&#x2F;0&#x2F;Config&#x2F;DeviceKey&amp;quot; &amp;quot;ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;VBoxManage setextradata &amp;quot;VM NAME&amp;quot; &amp;quot;VBoxInternal&#x2F;Devices&#x2F;smc&#x2F;0&#x2F;Config&#x2F;GetKeyFromRealSMC&amp;quot; 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;当中的&lt;code&gt;&quot;VM NAME&quot;&lt;&#x2F;code&gt;替换成创建虚拟机时设置的名字即可。&lt;&#x2F;p&gt;
&lt;p&gt;然后重新打开VirtualBox的界面，选中头先创建的苹果虚拟机，尝试安装系统&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-1-1&quot;&gt;&lt;a href=&quot;#fn-1&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;接下来还可能遇到一个恶心的问题，我忘了截图，大概是说程序已损坏，这个时候要断开host的网络，关掉时间自动同步，手动设置时间到2017年（High Sierra发行的年份）。&lt;&#x2F;p&gt;
&lt;p&gt;效果图：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;macos14-virtualbox&#x2F;success.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;折腾一圈下来觉得用起来太卡了，刚好手边还有一台CPU和集显适配的小电脑，还是决定搞一个黑苹果。&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.&#x2F;VBoxManage setextradata &amp;quot;VM NAME&amp;quot; &amp;quot;VBoxInternal&#x2F;Devices&#x2F;smc&#x2F;0&#x2F;Config&#x2F;GetKeyFromRealSMC&amp;quot; 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;后可以正常启动了。&lt;&#x2F;p&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn-1&quot;&gt;
&lt;p&gt;可能会出现如下图的报错：
&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;macos14-virtualbox&#x2F;smc_error.png&quot; alt=&quot;smc_error.png&quot; &#x2F;&gt;
&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;VFIO&#x2F;comments&#x2F;tkqsx4&#x2F;comment&#x2F;kc78it0&#x2F;&quot;&gt;据说&lt;&#x2F;a&gt;是BIOS中Hyper-V设置的问题（也可能直接就不支持Hyper-V），我暂时没时间验证，改成 &lt;a href=&quot;#fr-1-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;section&gt;
</content>
        <summary type="html">穷人没有苹果，却要调试苹果的程序，太痛苦了</summary>
        </entry><entry xml:lang="zh-Hans">
        <title>家用NAS配置指北</title>
        <published>2024-06-13T00:00:00+00:00</published>
        <updated>2024-06-13T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/nas/" type="text/html"/>
        <id>https://www.bigdick.live/blog/nas/</id>
        
            <content type="html">&lt;h2 id=&quot;jian-yi-cai-liao&quot;&gt;建议材料&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;类别&lt;&#x2F;th&gt;&lt;th&gt;型号&lt;&#x2F;th&gt;&lt;th&gt;理由&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;ospei-zhi&quot;&gt;OS配置&lt;&#x2F;h2&gt;
&lt;p&gt;OMV安装完毕后，暂时不要在UI里更新系统。尽管安装过程可能按照指引已经配置了国内的Apt源，但有些（比如Debian Security）未覆盖到，会导致&lt;code&gt;apt update&lt;&#x2F;code&gt;等速度非常慢。&lt;&#x2F;p&gt;
&lt;p&gt;因此建议先&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;help.mirrors.cernet.edu.cn&#x2F;OpenMediaVault&#x2F;&quot;&gt;配置镜像&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;rong-qi-yun-xing-huan-jing&quot;&gt;容器运行环境&lt;&#x2F;h2&gt;
&lt;p&gt;为方便管理容器和Docker Compose部署的服务等，还是要装一下&lt;code&gt;openmediavault-compose&lt;&#x2F;code&gt;这个插件。&lt;&#x2F;p&gt;
&lt;p&gt;官方文档建议先安装OMV-Extras，然后就可以在界面里操作安装Docker CE。但事实上两者并无强绑定关系。&lt;&#x2F;p&gt;
&lt;p&gt;虽然但是，如果添加了OMV-Extras的源，在界面中可以方便查看各种插件的安装状态，会提供一定的方便。还是鼓励装一下：&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;涉及GayHub的资源，最好还是加个反代来用，这里我选了&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;kkgithub.com&quot;&gt;https:&#x2F;&#x2F;kkgithub.com&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;wget&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -O - https:&#x2F;&#x2F;kkgithub.com&#x2F;OpenMediaVault-Plugin-Developers&#x2F;packages&#x2F;raw&#x2F;master&#x2F;install&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; sed&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-string&quot;&gt; &amp;#39;s&#x2F;github&#x2F;kkgithub&#x2F;g&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; bash&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里装完就装完了，在国内就别指望用它来装Docker等等。&lt;&#x2F;p&gt;
&lt;p&gt;接下来，就是使用国内的Docker CE镜像来安装Docker。装好后设置镜像&#x2F;反代方便拉取images。&lt;&#x2F;p&gt;
&lt;p&gt;最后来到&lt;code&gt;openmediavault-compose&lt;&#x2F;code&gt;插件：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;apt&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; install openmediavault-compose&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;另外，一些插件（比如&lt;code&gt;openmediavault-photoprism&lt;&#x2F;code&gt;）用到Podman。&lt;&#x2F;p&gt;
&lt;p&gt;但照旧要&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;podman.io&#x2F;docs&#x2F;installation#registriesconf&quot;&gt;配置国内镜像&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;wen-jian-xi-tong&quot;&gt;文件系统&lt;&#x2F;h2&gt;
&lt;p&gt;文件系统我选了Btrfs&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-1-1&quot;&gt;&lt;a href=&quot;#fn-1&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;我认为Btrfs是拥抱未来的文件系统，虽然当下尚有很多缺陷（比如社区报告的RAID5&#x2F;6不稳定等），但把RAID、LVM等功能集成到文件系统中是大势所趋。&lt;&#x2F;p&gt;
&lt;p&gt;虽然使用它自带的RAID0&#x2F;1&#x2F;10或者&lt;code&gt;DUP&lt;&#x2F;code&gt;模式都是安全的，但我嫌弃这些方案：要么磁盘利用率低，要么不安全。&lt;&#x2F;p&gt;
&lt;p&gt;所以最后还是用&lt;code&gt;openmediavault-md&lt;&#x2F;code&gt;做了软RAID。然后Btrfs在RAID后的卷上创建，模式选了&lt;code&gt;Single&lt;&#x2F;code&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;但默认的挂载参数不够理想。最后采取了如下设置&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-2-1&quot;&gt;&lt;a href=&quot;#fn-2&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;omv-env&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-punctuation z-definition z-string&quot;&gt; set -- OMV_FSTAB_MNTOPS_BTRFS &amp;quot;defaults,nofail,compress=zstd,autodefrag,noatime&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;monit&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; restart omv-engined&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;omv-salt&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; stage run prepare&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;omv-salt&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; stage run deploy&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;bcachehuan-cun&quot;&gt;bcache缓存&lt;&#x2F;h2&gt;
&lt;blockquote&gt;
&lt;p&gt;我是使用了一段时间才苟到一块NVMe做缓存盘的。如果文件系统上有数据，理应先&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;wiki.omv-extras.org&#x2F;doku.php?id=omv7:utilities_maint_backup#full_disk_mirroring_backup_with_rsync&quot;&gt;备份全盘&lt;&#x2F;a&gt;。&lt;br &#x2F;&gt;
理论上用&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;g2p&#x2F;blocks&quot;&gt;blocks&lt;&#x2F;a&gt;工具直接转换也是可以的，但依赖环境看着很吓人。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;que-ren-ssdde-erase-block-size&quot;&gt;确认SSD的erase block size&lt;&#x2F;h3&gt;
&lt;p&gt;创建高速缓存的时候尽量还是尊重一下SSD固有的erase block size，这样可以减少&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Write_amplification&quot;&gt;write amplification&lt;&#x2F;a&gt;现象的发生。但多数SSD的参数规格中并未提及这点，如果不想将就，可以用&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;bradfa&#x2F;flashbench&quot;&gt;flashbench&lt;&#x2F;a&gt;工具去猜。&lt;&#x2F;p&gt;
&lt;p&gt;安装flashbench：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;apt&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; install flashbench&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;猜：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 建议先写入一定量的随机数据，猜起来准一些&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# dd if=&#x2F;dev&#x2F;urandom of=&#x2F;dev&#x2F;nvme1n1 bs=4096 status=progress&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;flashbench&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -a &#x2F;dev&#x2F;nvme1n1  --blocksize=1024&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;在我的case里，虽然pattern不甚明显，还是值得参考的：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;nas&#x2F;pattern.png&quot; alt=&quot;pattern&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;pei-zhi-huan-cun&quot;&gt;配置缓存&lt;&#x2F;h3&gt;
&lt;p&gt;bcache已经并入内核很久了，但还是需要安装&lt;code&gt;bcache-tools&lt;&#x2F;code&gt;来配置：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;apt&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; install bcache-tools&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;先擦除文件系统，若出现&lt;code&gt;Device or resource busy&lt;&#x2F;code&gt;错误请参照&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;nas&#x2F;#device-or-resource-busy&quot;&gt;这节&lt;&#x2F;a&gt;：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;wipefs&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -a &#x2F;dev&#x2F;md0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;wipefs&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -a &#x2F;dev&#x2F;nvme1n1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;然后格式化后端和缓存设备&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-3-1&quot;&gt;&lt;a href=&quot;#fn-3&quot;&gt;3&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 这里会创建&#x2F;dev&#x2F;bcache0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;make-bcache&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; --data-offset 1290240k -B &#x2F;dev&#x2F;md0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;make-bcache&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; --bucket 4M -C &#x2F;dev&#x2F;nvme1n1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;搞定后检查一下uuid，并将其绑定至&lt;code&gt;&#x2F;dev&#x2F;bcache0&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;bcache-super-show&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;dev&#x2F;nvme1n1&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; grep&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; cset&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; 9b72f96d-7e85-4fd3-a78f-a283504b938c&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;sys&#x2F;block&#x2F;bcache0&#x2F;bcache&#x2F;attach&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;hou-xu-pei-zhi&quot;&gt;后续配置&lt;&#x2F;h3&gt;
&lt;p&gt;到这里就可以在UI中创建Btrfs分区并且挂载了。&lt;&#x2F;p&gt;
&lt;p&gt;检查状态：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;sys&#x2F;block&#x2F;bcache0&#x2F;bcache&#x2F;state&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;如果返回内容是&lt;code&gt;clean&lt;&#x2F;code&gt;，说明一切正常。&lt;&#x2F;p&gt;
&lt;p&gt;修改为只用于读缓存：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; writearound&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;sys&#x2F;block&#x2F;bcache0&#x2F;bcache&#x2F;cache_mode&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;device-or-resource-busy&quot;&gt;Device or resource busy&lt;&#x2F;h3&gt;
&lt;p&gt;进行配置过程中常见&lt;code&gt;Device or resource busy&lt;&#x2F;code&gt;错误。针对不同的对象，有不同的处理方式。&lt;&#x2F;p&gt;
&lt;h4 id=&quot;gao-su-huan-cun-pan&quot;&gt;高速缓存盘&lt;&#x2F;h4&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;sys&#x2F;fs&#x2F;bcache&#x2F;9b72f96d-7e85-4fd3-a78f-a283504b938c&#x2F;unregister&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h4 id=&quot;hou-duan-di-su-pan&quot;&gt;后端低速盘&lt;&#x2F;h4&gt;
&lt;p&gt;在擦除文件系统之前，后端低速盘往往已经挂载并有服务相关联，首先要先停止服务并解挂载。&lt;&#x2F;p&gt;
&lt;p&gt;如果盘已经被配置作为bcache后端，则需要先停掉：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;sys&#x2F;block&#x2F;bcache0&#x2F;bcache&#x2F;stop&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;xin-jian-yong-hu&quot;&gt;新建用户&lt;&#x2F;h2&gt;
&lt;p&gt;在新建好的Btrfs分区上创建一个&lt;code&gt;home&lt;&#x2F;code&gt;目录作为用户的家目录。&lt;&#x2F;p&gt;
&lt;p&gt;新建用户时不选择用户组，则默认会赋予一个&lt;code&gt;users&lt;&#x2F;code&gt;的组，一般来讲权限足够用。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;photoprism&quot;&gt;PhotoPrism&lt;&#x2F;h2&gt;
&lt;p&gt;PhotoPrism（下简称&lt;strong&gt;PP&lt;&#x2F;strong&gt;）虽然可以在UI里选择&lt;code&gt;openmediavault-podman&lt;&#x2F;code&gt;安装，但事实上由于连接速度的问题，&lt;code&gt;podman pull&lt;&#x2F;code&gt;拉取images的过程会非常长且在UI里没有正常的进度显示。&lt;&#x2F;p&gt;
&lt;p&gt;这会大大增长（心理上的）不确定性，因此还是建议命令行安装：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;apt&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; install openmediavault-photoprism&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;安装完毕后可以在UI中设置将其启动起来，建议按照&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.photoprism.app&#x2F;getting-started&#x2F;nas&#x2F;openmediavault&#x2F;&quot;&gt;官方文档&lt;&#x2F;a&gt;中截图方式设置（目录需预先创建）：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;docs.photoprism.app&#x2F;getting-started&#x2F;img&#x2F;omv_photoprism_plugin_ui.png&quot; alt=&quot;omv_photoprism_plugin_ui.png&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;caddy&quot;&gt;Caddy&lt;&#x2F;h2&gt;
&lt;p&gt;PP如果想在公网访问需要通过SSL加密的连接，我选用Caddy来做反代。&lt;&#x2F;p&gt;
&lt;p&gt;这里因为PP已经在Podman下跑起来了，最理想的路线就是在host上直接跑Caddy&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-4-1&quot;&gt;&lt;a href=&quot;#fn-4&quot;&gt;4&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;定制Caddy（带&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;caddy-dns&#x2F;cloudflare&quot;&gt;CF插件&lt;&#x2F;a&gt;去编译）：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 苟一下七牛云的CDN&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;go&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; env -w GO111MODULE=on&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;go&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; env -w  GOPROXY=https:&#x2F;&#x2F;goproxy.cn,direct&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;xcaddy&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; build --with github.com&#x2F;caddy-dns&#x2F;cloudflare&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;然后就可以删掉Go了：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;rm&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -rf &#x2F;usr&#x2F;local&#x2F;go&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; &amp;amp;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; rm&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -rf ~&#x2F;go&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt;*&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;为了使Caddy能提供稳定的代理，可以按照&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;caddyserver.com&#x2F;docs&#x2F;running#linux-service&quot;&gt;官方文档&lt;&#x2F;a&gt;创建service。&lt;&#x2F;p&gt;
&lt;p&gt;最后，为了让PP能够正确处理web请求，需要将配置好的地址绑定上：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;omv-env&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-punctuation z-definition z-string&quot;&gt; set -- OMV_PHOTOPRISM_APP_CONTAINER_START_OPTIONS &amp;quot;-e PHOTOPRISM_SITE_URL=http:&#x2F;&#x2F;localhost:2342&#x2F;photo&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;omv-salt&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; stage run prepare&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;omv-salt&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; deploy run photoprism&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;hr &#x2F;&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;mdadm&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -D &#x2F;dev&#x2F;mdX&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; grep&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; Chunk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;如果RAID是通过其他方式创建的，那么可以参考&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.kernel.org&#x2F;admin-guide&#x2F;bcache.html#troubleshooting-performance&quot;&gt;内核文档&lt;&#x2F;a&gt;里的叙述去计算这个数值。&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;当然也可以把PP和Caddy都用Docker跑，把&lt;code&gt;podman build&lt;&#x2F;code&gt;替换成&lt;code&gt;docker build&lt;&#x2F;code&gt;就可以，但OMV既然已经提供了插件，就费事自己去抄作业&#x2F;改作业了。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;也可以在制作镜像时用代理：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;Dockerfile&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;docker&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; caddy:builder-alpine &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword&quot;&gt;AS&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; builder&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;RUN&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; xcaddy build \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-source&quot;&gt;    --with github.com&#x2F;caddy-dns&#x2F;cloudflare&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; caddy:alpine&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;COPY&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; --from=builder &#x2F;usr&#x2F;bin&#x2F;caddy &#x2F;usr&#x2F;bin&#x2F;caddy&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;podman&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; build&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string z-punctuation z-definition z-string&quot;&gt;    --build-arg &amp;quot;HTTP_PROXY=http:&#x2F;&#x2F;192.168.31.151:7890&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string z-punctuation z-definition z-string&quot;&gt;    --build-arg &amp;quot;HTTPS_PROXY=http:&#x2F;&#x2F;192.168.31.151:7890&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string z-punctuation z-definition z-string&quot;&gt;    --build-arg &amp;quot;NO_PROXY=localhost,127.0.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;    -t caddy:cf .&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;由于同个 pod 间的网络才是互通的（可参考 &lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.podman.io&#x2F;en&#x2F;latest&#x2F;markdown&#x2F;podman-pod.1.html&quot;&gt;Podman pod 文档&lt;&#x2F;a&gt;），所以先确认已经跑起来的&lt;code&gt;photoprism-app&lt;&#x2F;code&gt;属于哪个 pod：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;podman&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; ps --pod&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;然后尝试在&lt;code&gt;photoprism&lt;&#x2F;code&gt;这个pod里启动Caddy：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;podman&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; run -d --pod photoprism --name photoprism_caddy&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;    -v caddy_data:&#x2F;data&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;    -v caddy_config:&#x2F;config&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;    -v&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-variable z-source&quot;&gt; $PWD&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt;&#x2F;Caddyfile:&#x2F;etc&#x2F;caddy&#x2F;Caddyfile&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;    -e CF_API_TOKEN=the_fucking_token&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-character z-escape&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-string&quot;&gt;    caddy:cf&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;到这里就不对劲了，因为同一 pod 中的所有容器共享端口映射规则，我们没办法为 Caddy 指定新的映射规则，也就意味着没有端口给它用了，那还转发个锤子的host流量，这条路走不通。&lt;&#x2F;p&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn-1&quot;&gt;
&lt;p&gt;各文件系统对比：&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Comparison_of_file_systems&quot;&gt;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Comparison_of_file_systems&lt;&#x2F;a&gt; &lt;a href=&quot;#fr-1-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-2&quot;&gt;
&lt;p&gt;OMV的文件系统环境变量：&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.openmediavault.org&#x2F;en&#x2F;stable&#x2F;various&#x2F;fs_env_vars.html&quot;&gt;https:&#x2F;&#x2F;docs.openmediavault.org&#x2F;en&#x2F;stable&#x2F;various&#x2F;fs_env_vars.html&lt;&#x2F;a&gt;&lt;br &#x2F;&gt;
Btrfs挂载选项：&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;btrfs.readthedocs.io&#x2F;en&#x2F;latest&#x2F;btrfs-man5.html#mount-options&quot;&gt;https:&#x2F;&#x2F;btrfs.readthedocs.io&#x2F;en&#x2F;latest&#x2F;btrfs-man5.html#mount-options&lt;&#x2F;a&gt; &lt;a href=&quot;#fr-2-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-3&quot;&gt;
&lt;p&gt;如果全程按照本文配置，那就没必要在意&lt;code&gt;--data-offset&lt;&#x2F;code&gt;的值了。&lt;br &#x2F;&gt;
这是因为OMV中通过UI创建的RAID5的stripe size默认是&lt;code&gt;512&lt;&#x2F;code&gt;k。可以通过如下命令查看： &lt;a href=&quot;#fr-3-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-4&quot;&gt;
&lt;p&gt;我有设想和尝试过把Caddy也放在容器里运行，直接的想法就是由于Podman和Docker的容器网络互不联通，所以需要将Caddy也用Podman跑起来。 &lt;a href=&quot;#fr-4-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;section&gt;
</content>
        <summary type="html">基于OMV7</summary>
        </entry><entry xml:lang="zh-Hans">
        <title>涠洲岛出行</title>
        <published>2024-02-29T00:00:00+00:00</published>
        <updated>2024-02-29T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/weizhou-island/" type="text/html"/>
        <id>https://www.bigdick.live/blog/weizhou-island/</id>
        
            <content type="html">&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;手机用户&lt;&#x2F;strong&gt;建议安装&lt;em&gt;百度地图&lt;&#x2F;em&gt;app后使用浏览器访问，效果更佳。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;gu-ding-shi-jian-biao&quot;&gt;固定时间表&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;qu-cheng-3yue-1ri&quot;&gt;去程（&lt;code&gt;3&lt;&#x2F;code&gt;月&lt;code&gt;1&lt;&#x2F;code&gt;日）&lt;&#x2F;h3&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;位置变化&lt;&#x2F;th&gt;&lt;th&gt;时间&lt;&#x2F;th&gt;&lt;th&gt;交通工具&lt;&#x2F;th&gt;&lt;th&gt;班次&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E8%B4%A2%E6%99%BA%E5%A4%A7%E5%8E%A6&amp;amp;destination=%E5%B9%BF%E5%B7%9E%E7%99%BD%E4%BA%91%E5%9B%BD%E9%99%85%E6%9C%BA%E5%9C%BA-T2%E8%88%AA%E7%AB%99%E6%A5%BC&amp;amp;mode=transit&amp;amp;region=%E5%B9%BF%E5%B7%9E&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;公司 ➡ 机场（T2航站楼）&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;20:00 ➡ 21:10&lt;&#x2F;td&gt;&lt;td&gt;👣 + 🚇&lt;&#x2F;td&gt;&lt;td&gt;地铁3号线北延段&lt;&#x2F;td&gt;&lt;td&gt;步行和等车时间已计入&lt;br&#x2F;&gt;上车前请确认为&lt;strong&gt;机场北&lt;&#x2F;strong&gt;方向&lt;&#x2F;br&gt;无婴幼儿可顺延&lt;code&gt;0.5&lt;&#x2F;code&gt;-&lt;code&gt;1&lt;&#x2F;code&gt;小时&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;广州 ➡ 北海&lt;&#x2F;td&gt;&lt;td&gt;23:10 ➡ 00:35&lt;&#x2F;td&gt;&lt;td&gt;🛫&lt;&#x2F;td&gt;&lt;td&gt;南航&lt;strong&gt;CZ3353&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;身份证（出生医学证明）&lt;br&#x2F;&gt;行李&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h3 id=&quot;qu-cheng-3yue-2ri&quot;&gt;去程（&lt;code&gt;3&lt;&#x2F;code&gt;月&lt;code&gt;2&lt;&#x2F;code&gt;日）&lt;&#x2F;h3&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;位置变化&lt;&#x2F;th&gt;&lt;th&gt;时间&lt;&#x2F;th&gt;&lt;th&gt;交通工具&lt;&#x2F;th&gt;&lt;th&gt;班次&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E7%A6%8F%E6%88%90%E6%9C%BA%E5%9C%BA&amp;amp;destination=%E5%8C%97%E6%B5%B7%E6%B5%B7%E4%B9%90%E5%AE%BE%E9%A6%86&amp;amp;mode=driving&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;机场 ➡ 海乐宾馆&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;🤷&lt;&#x2F;td&gt;&lt;td&gt;🚕&lt;&#x2F;td&gt;&lt;td&gt;-&lt;&#x2F;td&gt;&lt;td&gt;带齐行李物品&lt;br&#x2F;&gt;可开导航确保安全&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E6%B5%B7%E4%B9%90%E5%AE%BE%E9%A6%86&amp;amp;destination=%E5%8C%97%E6%B5%B7%E5%9B%BD%E9%99%85%E5%AE%A2%E8%BF%90%E6%B8%AF&amp;amp;mode=driving&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;海乐宾馆 ➡ 北海国际客运港&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;8:30 ➡ 8:50&lt;&#x2F;td&gt;&lt;td&gt;🚕&lt;&#x2F;td&gt;&lt;td&gt;-&lt;&#x2F;td&gt;&lt;td&gt;带齐行李物品&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;北海 ➡ 涠洲&lt;&#x2F;td&gt;&lt;td&gt;9:20 ➡ 11:10&lt;&#x2F;td&gt;&lt;td&gt;&lt;em&gt;观光&lt;&#x2F;em&gt;🚢&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;北游15&lt;&#x2F;strong&gt;&lt;br&#x2F;&gt;&lt;strong&gt;BW0007&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;晕船可坐&lt;strong&gt;船尾&lt;&#x2F;strong&gt;座位&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;涠洲岛西角码头 ➡ 艾尚日落海景酒店&lt;&#x2F;td&gt;&lt;td&gt;🤷&lt;&#x2F;td&gt;&lt;td&gt;酒店专车&lt;&#x2F;td&gt;&lt;td&gt;-&lt;&#x2F;td&gt;&lt;td&gt;带齐行李物品&lt;br&#x2F;&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E5%B8%82%E6%B6%A0%E6%B4%B2%E5%B2%9B%E8%A5%BF%E8%A7%92%E7%A0%81%E5%A4%B4&amp;amp;destination=%E6%B6%A0%E6%B4%B2%E5%B2%9B%E8%89%BE%E5%B0%9A%E6%97%A5%E8%90%BD%E6%B5%B7%E6%99%AF%E9%85%92%E5%BA%97&amp;amp;mode=driving&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;备用路线&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h3 id=&quot;fan-cheng-3yue-4ri&quot;&gt;返程（&lt;code&gt;3&lt;&#x2F;code&gt;月&lt;code&gt;4&lt;&#x2F;code&gt;日）&lt;&#x2F;h3&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;位置变化&lt;&#x2F;th&gt;&lt;th&gt;时间&lt;&#x2F;th&gt;&lt;th&gt;交通工具&lt;&#x2F;th&gt;&lt;th&gt;班次&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;艾尚日落海景酒店 ➡ 涠洲岛西角码头&lt;&#x2F;td&gt;&lt;td&gt;9:30 ➡ 9:50&lt;&#x2F;td&gt;&lt;td&gt;酒店专车&lt;&#x2F;td&gt;&lt;td&gt;-&lt;&#x2F;td&gt;&lt;td&gt;带齐行李物品&lt;br&#x2F;&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E6%B6%A0%E6%B4%B2%E5%B2%9B%E8%89%BE%E5%B0%9A%E6%97%A5%E8%90%BD%E6%B5%B7%E6%99%AF%E9%85%92%E5%BA%97&amp;amp;destination=%E5%8C%97%E6%B5%B7%E5%B8%82%E6%B6%A0%E6%B4%B2%E5%B2%9B%E8%A5%BF%E8%A7%92%E7%A0%81%E5%A4%B4&amp;amp;mode=driving&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;备用路线&lt;&#x2F;a&gt;&lt;br&#x2F;&gt;酒店&lt;strong&gt;含早&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;涠洲 ➡ 北海&lt;&#x2F;td&gt;&lt;td&gt;10:20 ➡ 11:40&lt;&#x2F;td&gt;&lt;td&gt;&lt;em&gt;快速&lt;&#x2F;em&gt;🚢&lt;&#x2F;td&gt;&lt;td&gt;🤷&lt;&#x2F;td&gt;&lt;td&gt;晕船可坐&lt;strong&gt;船尾&lt;&#x2F;strong&gt;座位&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E5%9B%BD%E9%99%85%E5%AE%A2%E8%BF%90%E6%B8%AF-3%E5%8F%B7%E9%97%A8&amp;amp;destination=%E5%8C%97%E6%B5%B7%E5%B8%82%E8%B6%8A%E4%B9%A1%E5%B0%8F%E5%8E%A8(%E8%80%81%E7%A0%81%E5%A4%B4%E5%BA%97)&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;北海国际客运港 ➡ 越乡小厨（老码头店）&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;🤷&lt;&#x2F;td&gt;&lt;td&gt;👣&lt;&#x2F;td&gt;&lt;td&gt;-&lt;&#x2F;td&gt;&lt;td&gt;需&lt;strong&gt;提前定位&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E5%B8%82%E8%B6%8A%E4%B9%A1%E5%B0%8F%E5%8E%A8(%E8%80%81%E7%A0%81%E5%A4%B4%E5%BA%97)&amp;amp;destination=%E5%8C%97%E6%B5%B7%E7%AB%99-%E8%BF%9B%E7%AB%99%E5%8F%A3&amp;amp;mode=driving&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;越乡小厨（老码头店） ➡ 北海站&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;13:30 ➡ 13:50&lt;&#x2F;td&gt;&lt;td&gt;🚕&lt;&#x2F;td&gt;&lt;td&gt;-&lt;&#x2F;td&gt;&lt;td&gt;1. 打印&lt;strong&gt;报销凭证&lt;&#x2F;strong&gt;&lt;br&#x2F;&gt;2. 过安检&lt;br&#x2F;&gt;3. 在&lt;strong&gt;进站口&lt;&#x2F;strong&gt;候车&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;北海 ➡ 广州&lt;&#x2F;td&gt;&lt;td&gt;14:46 ➡ 19:59&lt;&#x2F;td&gt;&lt;td&gt;🚝&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;D3724&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;需拿&lt;strong&gt;报销凭证&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;gan-fan-zhi-nan&quot;&gt;干饭指南&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;3yue-2ri-zao-can&quot;&gt;&lt;code&gt;3&lt;&#x2F;code&gt;月&lt;code&gt;2&lt;&#x2F;code&gt;日 早餐&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;strong&gt;空腹&lt;&#x2F;strong&gt;或&lt;strong&gt;吃太饱&lt;&#x2F;strong&gt;上船都极易加重晕船。建议派出家眷觅食并带回酒店，以下为一些精心挑选出来的可选铺子，涉及以下因素：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;步行距离&lt;&#x2F;strong&gt;（时间）：打车买早餐不确定性太大&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;开铺时间&lt;&#x2F;strong&gt;：去码头需要尽量在8:30左右出发，太晚开铺的不考虑，带⚠️标记较为临界，请慎重考虑&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;口碑&lt;&#x2F;strong&gt;：大众点评分数、评价以及是否上榜（不计&lt;em&gt;环境&lt;&#x2F;em&gt;和&lt;em&gt;服务&lt;&#x2F;em&gt;榜）&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;店名&lt;&#x2F;th&gt;&lt;th&gt;菜品&lt;&#x2F;th&gt;&lt;th&gt;往返时间（距离）&lt;&#x2F;th&gt;&lt;th&gt;开铺时间&lt;&#x2F;th&gt;&lt;th&gt;是否上榜&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E6%B5%B7%E4%B9%90%E5%AE%BE%E9%A6%86&amp;amp;destination=%E4%BE%A8%E8%B6%8A%E4%B8%96%E5%AE%B6%E8%B6%8A%E5%8D%97%E5%8D%B7%E7%B2%89&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;侨越世家越南卷粉&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;炸春卷&lt;br&#x2F;&gt;卷粉&lt;br&#x2F;&gt;虾饼&lt;br&#x2F;&gt;墨鱼丸&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;18&lt;&#x2F;code&gt;分钟（&lt;code&gt;550&lt;&#x2F;code&gt;米）&lt;&#x2F;td&gt;&lt;td&gt;⚠️08:00&lt;&#x2F;td&gt;&lt;td&gt;❌&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=21.432081,109.128791&amp;amp;destination=21.429187,109.130952&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;周记蟹仔粉&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;海鲜&#x2F;鱼丸蟹仔粉&lt;br&#x2F;&gt;越南春卷&lt;br&#x2F;&gt;墨鱼饼&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;18&lt;&#x2F;code&gt;分钟（&lt;code&gt;560&lt;&#x2F;code&gt;米）&lt;&#x2F;td&gt;&lt;td&gt;07:00&lt;&#x2F;td&gt;&lt;td&gt;✔️&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E6%B5%B7%E4%B9%90%E5%AE%BE%E9%A6%86&amp;amp;destination=%E6%8B%BE%E8%9E%BA%E8%AE%B0%E6%A1%82%E6%9F%B3%E8%9E%BA%E8%9B%B3%E7%B2%89(%E4%BE%A8%E6%B8%AF%E9%A3%8E%E6%83%85%E8%A1%97%E5%BA%97)&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;拾螺记桂柳螺蛳粉&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;螺蛳粉&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;12&lt;&#x2F;code&gt;分钟（&lt;code&gt;380&lt;&#x2F;code&gt;米）&lt;&#x2F;td&gt;&lt;td&gt;⚠️08:00&lt;&#x2F;td&gt;&lt;td&gt;❌&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E6%B5%B7%E4%B9%90%E5%AE%BE%E9%A6%86&amp;amp;destination=%E5%93%81%E8%B6%8A%E8%B6%8A%E5%8D%97%E9%B8%A1%E7%B2%89%E7%89%9B%E9%AA%A8%E6%B1%A4%E7%B2%89&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;品越越南鸡粉牛骨汤粉&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;什锦粉&lt;br&#x2F;&gt;牛腩粉&lt;br&#x2F;&gt;特色脆肉云吞&lt;br&#x2F;&gt;墨鱼饼&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;14&lt;&#x2F;code&gt;分钟（&lt;code&gt;420&lt;&#x2F;code&gt;米）&lt;&#x2F;td&gt;&lt;td&gt;07:00&lt;&#x2F;td&gt;&lt;td&gt;✔️&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%8C%97%E6%B5%B7%E6%B5%B7%E4%B9%90%E5%AE%BE%E9%A6%86&amp;amp;destination=%E8%B4%B9%E5%A7%90%E6%AD%A3%E5%AE%97%E8%9F%B9%E4%BB%94%E7%B2%89%E5%BA%97&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;费姐正宗蟹仔粉店&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;蟹仔粉&lt;br&#x2F;&gt;牛肉粉&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;12&lt;&#x2F;code&gt;分钟（&lt;code&gt;360&lt;&#x2F;code&gt;米）&lt;&#x2F;td&gt;&lt;td&gt;07:00&lt;&#x2F;td&gt;&lt;td&gt;✔️&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;dao-shang-tui-jian-you-wan-lu-xian&quot;&gt;岛上推荐游玩路线&lt;&#x2F;h2&gt;
&lt;blockquote&gt;
&lt;p&gt;已做路线规划，建议在控制好时间的前提下按顺序游玩。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;3yue-2ri-xia-wu&quot;&gt;&lt;code&gt;3&lt;&#x2F;code&gt;月&lt;code&gt;2&lt;&#x2F;code&gt;日 下午&lt;&#x2F;h3&gt;
&lt;blockquote&gt;
&lt;p&gt;从酒店出发，到日落后（晚饭前）。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h4 id=&quot;biao-zhi-yan-chang&quot;&gt;标志广场&lt;&#x2F;h4&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;&#x2F;th&gt;&lt;th&gt;路程&lt;&#x2F;th&gt;&lt;th&gt;游玩时间&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E6%B6%A0%E6%B4%B2%E5%B2%9B%E8%89%BE%E5%B0%9A%E6%97%A5%E8%90%BD%E6%B5%B7%E6%99%AF%E9%85%92%E5%BA%97&amp;amp;destination=%E5%88%9A%E5%93%A5%E6%B7%B1%E5%A4%9C%E7%83%A7%E7%83%A4&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;酒店 ➡ 标志广场&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;4&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;20&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;打卡点&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h4 id=&quot;ke-xuan-hai-shang-yun-dong-ji-di&quot;&gt;（可选）海上运动基地&lt;&#x2F;h4&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;&#x2F;th&gt;&lt;th&gt;路程&lt;&#x2F;th&gt;&lt;th&gt;游玩时间&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%88%9A%E5%93%A5%E6%B7%B1%E5%A4%9C%E7%83%A7%E7%83%A4&amp;amp;destination=%E6%B5%B7%E4%B8%8A%E8%BF%90%E5%8A%A8%E5%9F%BA%E5%9C%B0&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;标志广场 ➡ 海上运动基地&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;4&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;🤷&lt;&#x2F;td&gt;&lt;td&gt;打卡点&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h4 id=&quot;tian-zhu-jiao-tang&quot;&gt;天主教堂&lt;&#x2F;h4&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;&#x2F;th&gt;&lt;th&gt;路程&lt;&#x2F;th&gt;&lt;th&gt;游玩时间&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E5%88%9A%E5%93%A5%E6%B7%B1%E5%A4%9C%E7%83%A7%E7%83%A4&amp;amp;destination=%E6%B6%A0%E6%B4%B2%E7%9B%9B%E5%A1%98%E5%A4%A9%E4%B8%BB%E6%95%99%E5%A0%82&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;标志广场 ➡ 天主教堂&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;31&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;30&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;打卡点&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;&lt;strong&gt;拍照机位&lt;&#x2F;strong&gt;：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;后院木门&lt;&#x2F;li&gt;
&lt;li&gt;后院黄色走廊房子&lt;&#x2F;li&gt;
&lt;li&gt;拱形玫瑰铁门&lt;&#x2F;li&gt;
&lt;li&gt;玫瑰瀑布楼梯台阶&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;strong&gt;建议着装&lt;&#x2F;strong&gt;：浅色或者咖色的复古连衣裙&lt;&#x2F;p&gt;
&lt;h4 id=&quot;jian-yi-qing-tian-xian-ren-zhang-xiang-kuang&quot;&gt;（建议晴天）仙人掌相框&lt;&#x2F;h4&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;&#x2F;th&gt;&lt;th&gt;路程&lt;&#x2F;th&gt;&lt;th&gt;游玩时间&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E6%B6%A0%E6%B4%B2%E7%9B%9B%E5%A1%98%E5%A4%A9%E4%B8%BB%E6%95%99%E5%A0%82&amp;amp;destination=%E4%B8%8A%E5%90%8E%E8%83%8C%E5%A1%98%E6%9D%91-%E5%85%AC%E4%BA%A4%E7%AB%99&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;天主教堂 ➡ 上后背塘村&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;25&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;10&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;打卡点&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;weizhou-island&#x2F;img&#x2F;%E4%BB%99%E4%BA%BA%E6%8E%8C%E5%A2%99%E8%B7%AF%E7%BA%BF.png&quot; alt=&quot;仙人掌墙路线&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h4 id=&quot;jian-yi-qing-tian-lan-qiao&quot;&gt;（建议晴天）蓝桥&lt;&#x2F;h4&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;&#x2F;th&gt;&lt;th&gt;路程&lt;&#x2F;th&gt;&lt;th&gt;游玩时间&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E4%B8%8A%E5%90%8E%E8%83%8C%E5%A1%98%E6%9D%91-%E5%85%AC%E4%BA%A4%E7%AB%99&amp;amp;destination=%E8%93%9D%E6%A1%A5&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;上后背塘村 ➡ 蓝桥&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;7&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;20&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;打卡点&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h4 id=&quot;ri-luo-shi-luo-kou-hai-tan&quot;&gt;（日落）石螺口海滩&lt;&#x2F;h4&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;&#x2F;th&gt;&lt;th&gt;路程&lt;&#x2F;th&gt;&lt;th&gt;游玩时间&lt;&#x2F;th&gt;&lt;th&gt;备注&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E6%B6%A0%E6%B4%B2%E5%B2%9B%E8%93%9D%E6%A1%A5&amp;amp;destination=%E7%9F%B3%E8%9E%BA%E5%8F%A3%E6%B5%B7%E6%BB%A9&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;蓝桥 ➡ 石螺口海滩&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;30&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;约&lt;code&gt;30&lt;&#x2F;code&gt;分钟&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;18:48&lt;&#x2F;strong&gt;日落&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h3 id=&quot;3yue-3ri&quot;&gt;&lt;code&gt;3&lt;&#x2F;code&gt;月&lt;code&gt;3&lt;&#x2F;code&gt;日&lt;&#x2F;h3&gt;
&lt;p&gt;由于集体活动不确定，仅列举大概游览顺序：&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;（日出）贝壳沙滩景区：日出时间为&lt;strong&gt;07:02&lt;&#x2F;strong&gt;，但有&lt;code&gt;27&lt;&#x2F;code&gt;%的概率降雨&lt;&#x2F;li&gt;
&lt;li&gt;火山公园&lt;&#x2F;li&gt;
&lt;li&gt;仙人掌相框（二刷，看天气及前日完成度）&lt;&#x2F;li&gt;
&lt;li&gt;蓝桥（二刷，看天气及前日完成度）&lt;&#x2F;li&gt;
&lt;li&gt;（日落）滴水丹屏：日落时间为&lt;strong&gt;18:48&lt;&#x2F;strong&gt;，作为&lt;em&gt;石螺口海滩&lt;&#x2F;em&gt;的替代日落景点&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3 id=&quot;3yue-4ri&quot;&gt;&lt;code&gt;3&lt;&#x2F;code&gt;月&lt;code&gt;4&lt;&#x2F;code&gt;日&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;4&lt;&#x2F;code&gt;日日出时间为&lt;strong&gt;07:01&lt;&#x2F;strong&gt;，气温明显回暖，降雨概率仅为&lt;code&gt;1&lt;&#x2F;code&gt;%，可考虑去五彩滩景区看日出：&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;路线&lt;&#x2F;th&gt;&lt;th&gt;时间&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E6%B6%A0%E6%B4%B2%E5%B2%9B%E8%89%BE%E5%B0%9A%E6%97%A5%E8%90%BD%E6%B5%B7%E6%99%AF%E9%85%92%E5%BA%97&amp;amp;destination=%E4%BA%94%E5%BD%A9%E6%BB%A9%E6%99%AF%E5%8C%BA&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;酒店 ➡ 五彩滩景区&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;06:30 ➡ 06:55&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;http:&#x2F;&#x2F;api.map.baidu.com&#x2F;direction?origin=%E4%BA%94%E5%BD%A9%E6%BB%A9%E6%99%AF%E5%8C%BA&amp;amp;destination=%E6%B6%A0%E6%B4%B2%E5%B2%9B%E8%89%BE%E5%B0%9A%E6%97%A5%E8%90%BD%E6%B5%B7%E6%99%AF%E9%85%92%E5%BA%97&amp;amp;mode=walking&amp;amp;region=%E5%8C%97%E6%B5%B7%E5%B8%82&amp;amp;output=html&amp;amp;src=webapp.sctmes.travel&quot;&gt;五彩滩景区 ➡ 酒店&lt;&#x2F;a&gt;&lt;&#x2F;td&gt;&lt;td&gt;07:30 ➡ 07:55&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
</content>
        <summary type="html">我们一家跟随公司去涠洲岛旅行的大致计划和记录。</summary>
        </entry><entry xml:lang="zh-Hans">
        <title>Rust单片机编程：用一块STM32板发送http请求</title>
        <published>2024-01-29T00:00:00+00:00</published>
        <updated>2024-01-29T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/stm32f407-http/" type="text/html"/>
        <id>https://www.bigdick.live/blog/stm32f407-http/</id>
        
            <content type="html">&lt;blockquote&gt;
&lt;p&gt;本文多处参考了&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.rust-embedded.org&#x2F;book&#x2F;&quot;&gt;The Embedded Rust Book&lt;&#x2F;a&gt;，建议对Rust嵌入式开发尚不熟悉的同学反复观看这本书。&lt;br &#x2F;&gt;
由于例子使用的开发板为&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.rust-embedded.org&#x2F;book&#x2F;intro&#x2F;hardware.html#stm32f3discovery-the-f3&quot;&gt;STM32F3DISCOVERY&lt;&#x2F;a&gt;，与&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;#shi-yan-cai-liao&quot;&gt;我们的&lt;&#x2F;a&gt;有一定区别，因此各种操作与书中提及多有出入，&lt;strong&gt;以本文为准&lt;&#x2F;strong&gt;。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;shi-yan-cai-liao&quot;&gt;实验材料&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;一块STM32F407板，板载WIFI模块（ESP8266）&lt;&#x2F;li&gt;
&lt;li&gt;服务器：Ubuntu 22.04.1，非常多的USB 3.0&#x2F;3.1接口，无图形界面&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;huan-jing-pei-zhi&quot;&gt;环境配置&lt;&#x2F;h2&gt;
&lt;p&gt;在一切开始之前，首先使用合适的Type-C线将服务器的任一USB口与板子的CMSIS-DAP接口连接。&lt;&#x2F;p&gt;
&lt;p&gt;基本的编译、烧写和调试（仿真等）环境可以参照&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.rust-embedded.org&#x2F;book&#x2F;intro&#x2F;install&#x2F;linux.html&quot;&gt;这一章节&lt;&#x2F;a&gt;配置，此处仅列举需要修改的步骤和有必要补充的信息：&lt;&#x2F;p&gt;
&lt;h3 id=&quot;zi-ding-yi-udevgui-ze&quot;&gt;自定义&lt;code&gt;udev&lt;&#x2F;code&gt;规则&lt;&#x2F;h3&gt;
&lt;blockquote&gt;
&lt;p&gt;注意：这一小节与&lt;em&gt;The Embedded Rust Book&lt;&#x2F;em&gt;出入非常大&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;我们希望OpenOCD等在不需要root权限的情况下就可以自由与开发板通讯，因此需要自定义&lt;code&gt;udev&lt;&#x2F;code&gt;的规则。运行&lt;code&gt;lsusb&lt;&#x2F;code&gt;命令列出USB设备信息，我们可能获得类似如下的内容：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Bus 002 Device 002: ID 174c:3074 ASMedia Technology Inc. ASM1074 SuperSpeed hub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Bus 001 Device 007: ID c251:f001 Keil Software, Inc. CMSIS-DAP&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Bus 001 Device 002: ID 174c:2074 ASMedia Technology Inc. ASM1074 High-Speed hub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里注意&lt;strong&gt;行末&lt;&#x2F;strong&gt;设备名为&lt;code&gt;CMSIS-DAP&lt;&#x2F;code&gt;的设备即为我们的板子&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-1-1&quot;&gt;&lt;a href=&quot;#fn-1&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;。我们以这行为例，解读一下&lt;code&gt;lsusb&lt;&#x2F;code&gt;返回内容的含义：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Bus 001&lt;&#x2F;strong&gt;：表示设备连接到&lt;code&gt;001&lt;&#x2F;code&gt;号总线&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Device 007&lt;&#x2F;strong&gt;：表示这是连接到该总线上的第&lt;code&gt;007&lt;&#x2F;code&gt;号设备&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;ID c251:f001&lt;&#x2F;strong&gt;: 这里的ID分为两部分：第一部分是&lt;code&gt;idVendor&lt;&#x2F;code&gt;（设备产商），值为&lt;code&gt;c251&lt;&#x2F;code&gt;;第二部分为&lt;code&gt;idProduct&lt;&#x2F;code&gt;（设备类型编号），值为&lt;code&gt;f001&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;有了&lt;code&gt;idVendor&lt;&#x2F;code&gt;和&lt;code&gt;idProduct&lt;&#x2F;code&gt;，接下来我们需要在&lt;code&gt;&#x2F;etc&#x2F;udev&#x2F;rules.d&#x2F;70-st-link.rules&lt;&#x2F;code&gt;文件里追加一行（若无文件则新建）&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-2-1&quot;&gt;&lt;a href=&quot;#fn-2&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# OWNER的值请填写开发者自己使用的用户名&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ATTRS{idVendor}==&amp;quot;c251&amp;quot;, ATTRS{idProduct}==&amp;quot;f001&amp;quot;, OWNER=&amp;quot;ysun&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;写好规则后使用下述命令应用（&lt;strong&gt;无需拔掉设备重新插上&lt;&#x2F;strong&gt;）：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 这里的action参数至关重要&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 如果不指定它的值为change，内核会通知udev将所有设备都认作新设备&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 这可能有非常恶劣的影响&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; udevadm control --reload-rules&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; &amp;amp;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; udevadm trigger --action=change&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;bian-yi-an-zhuang-openocd&quot;&gt;编译安装OpenOCD&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;em&gt;The Embedded Rust Book&lt;&#x2F;em&gt;中的指引为&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.rust-embedded.org&#x2F;book&#x2F;intro&#x2F;install&#x2F;linux.html#packages&quot;&gt;使用包管理器直接安装OpenOCD&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;但对于某些情况，比如我们的Ubuntu 22.04.1，通过&lt;code&gt;apt&lt;&#x2F;code&gt;安装的OpenOCD为v0.11.0版本。&lt;&#x2F;p&gt;
&lt;p&gt;这一版对STM32F4x系列的支持还比较糟糕，因此&lt;strong&gt;墙裂建议&lt;&#x2F;strong&gt;手动编译一下最新的OpenOCD以防止犯病：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 安装（编译时）必需依赖&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; apt install libtool libhidapi-dev libusb-1.0-0-dev&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;git&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; clone https:&#x2F;&#x2F;github.com&#x2F;openocd-org&#x2F;openocd.git&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; &amp;amp;&amp;amp;&lt;&#x2F;span&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt; cd&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; openocd&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;.&#x2F;configure&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; --enable-cmsis-dap&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;make&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; make install&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;huan-jing-yan-zheng&quot;&gt;环境验证&lt;&#x2F;h3&gt;
&lt;p&gt;为检验工具和驱动是否已被正确配置，我们需要验证OpenOCD能否正常工作（与板上自带的ST-Link调试硬件通信）。在项目根目录下创建&lt;code&gt;openocd.cfg&lt;&#x2F;code&gt;文件，并写入:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# 设备接口配置文件&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;source [find interface&#x2F;cmsis-dap.cfg]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# 理论上udev规则配置好可以自动获取到，若不能则可以手动指定：&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# cmsis_dap_vid_pid 0xc251 0xf001&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# 这是一个历史遗留问题，其实是CMSIS-DAP v2 bulk interface自动检测的bug&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# 对于一些v1的设备会误被判做是v2，导致通信失败，详见这个commit：&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# https:&#x2F;&#x2F;github.com&#x2F;openocd-org&#x2F;openocd&#x2F;commit&#x2F;3da0c2504c14ea0736b973fa0b5085c42a9c6ce8&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# 该bug在v0.12.0被修复，对之前的版本可以加上下面这行&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# cmsis_dap_backend hid&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# 目标芯片配置文件&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;source [find target&#x2F;stm32f4x.cfg]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;此时，运行&lt;code&gt;openocd&lt;&#x2F;code&gt;，应该会有类似输出：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Open On-Chip Debugger 0.11.0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Licensed under GNU GPL v2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;For bug reports, read&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        http:&#x2F;&#x2F;openocd.org&#x2F;doc&#x2F;doxygen&#x2F;bugs.html&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : auto-selecting first available session transport &amp;quot;swd&amp;quot;. To override use &amp;#39;transport select &amp;lt;transport&amp;gt;&amp;#39;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : Listening on port 6666 for tcl connections&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : Listening on port 4444 for telnet connections&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : CMSIS-DAP: SWD  Supported&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : CMSIS-DAP: FW Version = ħŮ�Ƽ�&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : CMSIS-DAP: Interface Initialised (SWD)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : SWCLK&#x2F;TCK = 1 SWDIO&#x2F;TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : CMSIS-DAP: Interface ready&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : clock speed 2000 kHz&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : SWD DPIDR 0x2ba01477&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : starting gdb server for stm32f4x.cpu on 3333&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Info : Listening on port 3333 for gdb connections&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;并且程序阻塞住了控制台。&lt;&#x2F;p&gt;
&lt;p&gt;至此环境配置完毕。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;fang-zhen&quot;&gt;仿真&lt;&#x2F;h2&gt;
&lt;blockquote&gt;
&lt;p&gt;在开始仿真调试前，建议先用&lt;code&gt;cargo-generate&lt;&#x2F;code&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.rust-embedded.org&#x2F;book&#x2F;start&#x2F;qemu.html#using-cargo-generate&quot;&gt;从模板仓库开始初始化一个实验项目&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;仿真大致操作与&lt;em&gt;The Embedded Rust Book&lt;&#x2F;em&gt;无异，但由于我们的板子是STM32F4x，故QEMU的参数要做一定调整。&lt;&#x2F;p&gt;
&lt;p&gt;比如，&lt;code&gt;.cargo&#x2F;config.toml&lt;&#x2F;code&gt;中需要增加这些内容：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;toml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt;target.thumbv7em-none-eabihf&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-source&quot;&gt;runner&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-string&quot;&gt; &amp;quot;qemu-system-arm -cpu cortex-m4 -machine netduinoplus2 -nographic -semihosting-config enable=on,target=native -kernel&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;[&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt;build&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-source&quot;&gt;target&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-separator z-key-value&quot;&gt; =&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-string&quot;&gt; &amp;quot;thumbv7em-none-eabihf&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;然后就可以正常仿真了（会隐式地以上述参数调用QEMU）：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;cargo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; run --example hello --release&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;如果需要用GDB调试，只需要将启动QEMU的参数如上述&lt;code&gt;.cargo&#x2F;config.toml&lt;&#x2F;code&gt;文件中替换即可。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;shang-ying-jian&quot;&gt;上硬件&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;nei-cun-bu-ju&quot;&gt;内存布局&lt;&#x2F;h3&gt;
&lt;p&gt;这部分最重要的就是搞清楚板子的内存布局，要确定Flash和SRAM的起始点和长度以确保编译和运行时的行为正确。&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;主要参照 ST 的 RM0090 文档（Rev 19）。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h4 id=&quot;tai-chang-bu-kan&quot;&gt;太长不看&lt;&#x2F;h4&gt;
&lt;p&gt;在项目根目录的memory.x文件中，写入：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MEMORY&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;* NOTE 1 K = 1 KiBi = 1024 bytes *&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;* TODO Adjust these memory regions to match your device memory layout *&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &#x2F;* These values correspond to the LM3S6965, one of the few devices QEMU can emulate *&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  FLASH : ORIGIN = 0x08000000, LENGTH = 512K&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  RAM : ORIGIN = 0x20000000, LENGTH = 128K&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;详细依据见下文。&lt;&#x2F;p&gt;
&lt;h4 id=&quot;flashbu-ju&quot;&gt;Flash布局&lt;&#x2F;h4&gt;
&lt;p&gt;架构图在第&lt;strong&gt;73&lt;&#x2F;strong&gt;页：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;img&#x2F;flash_arch.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;我们可以看到，从interface到memory是一条总线连接的，即主内存在使用上是不分区的，即Flash的长度应为&lt;strong&gt;所有Sector的大小之和&lt;&#x2F;strong&gt;。为了提升性能，对指令码和数据码各自有对应的cache，但不影响主内存的分布。&lt;&#x2F;p&gt;
&lt;p&gt;因此参照表&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-3-1&quot;&gt;&lt;a href=&quot;#fn-3&quot;&gt;3&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;img&#x2F;flash_table.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;del&gt;Flash应为从&lt;code&gt;0x08000000&lt;&#x2F;code&gt;开始，到&lt;code&gt;0x080FFFFF&lt;&#x2F;code&gt;结束。用末尾减去开头，刚好是&lt;code&gt;1024&lt;&#x2F;code&gt;K。&lt;&#x2F;del&gt;&lt;&#x2F;p&gt;
&lt;p&gt;但上述其实不过是对最高配置的介绍，并非所有的STM32F40x都有高达&lt;code&gt;1&lt;&#x2F;code&gt;M的实际Flash大小，具体仍要参照型号。&lt;&#x2F;p&gt;
&lt;p&gt;由于我们的板子的详细型号是STM32F407VET6，因此Flash只有&lt;code&gt;512&lt;&#x2F;code&gt;K。&lt;&#x2F;p&gt;
&lt;h4 id=&quot;srambu-ju&quot;&gt;SRAM布局&lt;&#x2F;h4&gt;
&lt;p&gt;参照第&lt;strong&gt;68&lt;&#x2F;strong&gt;页的描述：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;img&#x2F;SRAM.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;由于我们的板子不存在SRAM3，所以SRAM的起始地址应为&lt;code&gt;0x20000000&lt;&#x2F;code&gt;。Backup SRAM只在特殊的电压条件下才会被调用，&lt;del&gt;因此SRAM的长度应标注为&lt;code&gt;192&lt;&#x2F;code&gt;K&lt;&#x2F;del&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;但在编译时，还应结合板子的整体架构考虑：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;img&#x2F;system_architecture.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;在文字描述中高达&lt;code&gt;192&lt;&#x2F;code&gt;K的“系统”SRAM当中其实还包含了只能经由D-bus主线直接与MCU通信的、大小为&lt;code&gt;64&lt;&#x2F;code&gt;K的CCM内存。&lt;&#x2F;p&gt;
&lt;p&gt;因此实际&lt;strong&gt;在编译时可以声明的内存大小&lt;&#x2F;strong&gt;只有&lt;code&gt;192&lt;&#x2F;code&gt; - &lt;code&gt;64&lt;&#x2F;code&gt; = &lt;code&gt;128&lt;&#x2F;code&gt;K。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;esp8266pian&quot;&gt;ESP8266篇&lt;&#x2F;h2&gt;
&lt;p&gt;待续。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;qi-ta-xuan-ze&quot;&gt;其他选择&lt;&#x2F;h2&gt;
&lt;p&gt;STM32CubeIDE 也许是不错的一体化集成开发环境。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;chang-jian-wen-ti&quot;&gt;常见问题&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;0-wei-shen-me-yi-jing-cha-zai-usbshang-liao-dan-lsusbkan-bu-dao-ban-zi&quot;&gt;0. 为什么已经插在USB上了，但&lt;code&gt;lsusb&lt;&#x2F;code&gt;看不到板子？&lt;&#x2F;h3&gt;
&lt;p&gt;可能接错到USB-Slave接口上了。可以用&lt;code&gt;sudo dmesg&lt;&#x2F;code&gt;查看详细日志：
&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;img&#x2F;dmesg_err.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-shi-yong-gdbdiao-shi-shi-chu-xian-nei-cun-cuo-wu&quot;&gt;1. 使用GDB调试时出现内存错误&lt;&#x2F;h3&gt;
&lt;p&gt;如果内存布局设置错误或有严重的编程失误导致内存错误，可能会在OpenOCD输出中看到类似如下报错：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Error: Failed to read memory at 0x2002ffd0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;同时GDB也会反馈类似内容：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;0x080013aa in cortex_m_rt::HardFault_ (ef=0x0) at src&#x2F;lib.rs:563&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;563             atomic::compiler_fence(Ordering::SeqCst);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;可能板子被锁住：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;img&#x2F;lockup.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;出现这种情况时，请首先&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;#srambu-ju&quot;&gt;确认内存布局正确&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;注意，更改&lt;code&gt;memory.x&lt;&#x2F;code&gt;文件后需要重新&lt;code&gt;cargo build&lt;&#x2F;code&gt;，这点在The Embedded Rust Book中&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;docs.rust-embedded.org&#x2F;book&#x2F;start&#x2F;hardware.html#configuring&quot;&gt;也有提及&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;另外，建议使用&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;#bian-yi-an-zhuang-openocd&quot;&gt;最新版本的OpenOCD&lt;&#x2F;a&gt;，可能在重新开启OpenOCD进程或烧写程序（GDB的&lt;code&gt;load&lt;&#x2F;code&gt;指令）时自动解锁。&lt;&#x2F;p&gt;
&lt;p&gt;如果仍被锁住，则可按照如下步骤处理：&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;开启一个&lt;code&gt;openocd&lt;&#x2F;code&gt;进程与板子连接&lt;&#x2F;li&gt;
&lt;li&gt;在另外一个终端里使用&lt;code&gt;telnet&lt;&#x2F;code&gt;与&lt;code&gt;openocd&lt;&#x2F;code&gt;通讯：&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;telnet&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; localhost&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 4444&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;在telnet提示符下尝试解锁：&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;stm32f4x unlock 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;如果顺利的话，会出现如下提示：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;stm32f2x unlocked.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;INFO: a reset or power cycle is required for the new settings to take effect.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ol start=&quot;4&quot;&gt;
&lt;li&gt;在telnet提示符下继续输入&lt;code&gt;shutdown&lt;&#x2F;code&gt;，然后将板子断电再通电。&lt;&#x2F;li&gt;
&lt;li&gt;如果上述过程无效，尝试在telnet提示符下使用下面的命令彻底擦除Flash存储中的内容：&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;stm32f4x mass_erase 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;然后重复第&lt;strong&gt;4&lt;&#x2F;strong&gt;步。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-cargo-buildbao-cuo-cannot-find-linker-script-memory-x&quot;&gt;2. &lt;code&gt;cargo build&lt;&#x2F;code&gt;报错：cannot find linker script memory.x&lt;&#x2F;h3&gt;
&lt;p&gt;无论当前项目是否有子crates、目录如何组织，&lt;code&gt;memory.x&lt;&#x2F;code&gt;必须位于项目的根目录下（和最外层的&lt;code&gt;Cargo.toml&lt;&#x2F;code&gt;同级）&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-4-1&quot;&gt;&lt;a href=&quot;#fn-4&quot;&gt;4&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;确实有一种特殊情况可以不提供&lt;code&gt;memory.x&lt;&#x2F;code&gt;文件：项目代码中直接引入了BSC (Board Support Crate)，比如&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;stm32f3-discovery&quot;&gt;stm32f3-discovery&lt;&#x2F;a&gt;。除此之外，使用属于其他抽象级别的crates都必须为&lt;code&gt;cortex-m-rt&lt;&#x2F;code&gt;的编译提供&lt;code&gt;memory.x&lt;&#x2F;code&gt;&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-5-1&quot;&gt;&lt;a href=&quot;#fn-5&quot;&gt;5&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;blog&#x2F;stm32f407-http&#x2F;img&#x2F;dmesg.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn-1&quot;&gt;
&lt;p&gt;这里只看到&lt;code&gt;CMSIS-DAP&lt;&#x2F;code&gt;，没有看到STM32相关的信息。&lt;code&gt;sudo dmesg&lt;&#x2F;code&gt;可以在日志中看到细节： &lt;a href=&quot;#fr-1-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-2&quot;&gt;
&lt;p&gt;这里文件名不是必需为&lt;code&gt;70-st-link.rules&lt;&#x2F;code&gt;，但建议前缀的数字要大于&lt;code&gt;50&lt;&#x2F;code&gt;，否则有可能覆写操作系统的一些默认规则。
有关&lt;code&gt;udev&lt;&#x2F;code&gt;规则语法，可参照&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;man7.org&#x2F;linux&#x2F;man-pages&#x2F;man7&#x2F;udev.7.html&quot;&gt;&lt;code&gt;udev(7)&lt;&#x2F;code&gt;手册&lt;&#x2F;a&gt;。 &lt;a href=&quot;#fr-2-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-3&quot;&gt;
&lt;p&gt;头几个sector的大小比较小是因为许多板子并未达到&lt;code&gt;1&lt;&#x2F;code&gt;M的Flash大小，因此只有头几个sector，后面较大的则被舍弃了。&lt;br &#x2F;&gt;
这样的设计使得不同型号的板之间的sector布局尽量保持一致，程序移植的兼容性比较好。 &lt;a href=&quot;#fr-3-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-4&quot;&gt;
&lt;p&gt;https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;cargo&#x2F;issues&#x2F;9537 &lt;a href=&quot;#fr-4-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li id=&quot;fn-5&quot;&gt;
&lt;p&gt;https:&#x2F;&#x2F;docs.rust-embedded.org&#x2F;book&#x2F;start&#x2F;registers.html#memory-mapped-registers &lt;a href=&quot;#fr-5-1&quot;&gt;↩&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;section&gt;
</content>
        <summary type="html">记录从0开始在STM32F407上编写Rust实现HTTP GET。</summary>
        </entry><entry xml:lang="zh-Hans">
        <title>省二生娃指北</title>
        <published>2023-01-10T00:00:00+00:00</published>
        <updated>2023-01-10T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/birth/" type="text/html"/>
        <id>https://www.bigdick.live/blog/birth/</id>
        
            <content type="html">&lt;blockquote&gt;
&lt;p&gt;本文已搁置：由于做这篇笔记期间大娃已出世，它对本人的意义已经有限。暂时不考虑继续更新，除非准备二胎。也欢迎读者发起PR补全。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;fmt.h5.xeknow.com&#x2F;sl&#x2F;3N7tq9&quot;&gt;点击观看原视频&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;shi-pin-guan-jian-shi-jian&quot;&gt;视频关键时间&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;时间   &lt;&#x2F;th&gt;&lt;th&gt;摘要&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;5’20&lt;&#x2F;td&gt;&lt;td&gt;开场&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;8’20&lt;&#x2F;td&gt;&lt;td&gt;产前准备要点&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;&#x2F;td&gt;&lt;td&gt;了解分娩过程&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;&#x2F;td&gt;&lt;td&gt;家属如何陪伴分娩&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;&#x2F;td&gt;&lt;td&gt;分娩镇痛的方法及效果对比&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;&#x2F;td&gt;&lt;td&gt;入院办理流程和注意事项&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;jian-ce&quot;&gt;监测&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;tai-er-jian-ce&quot;&gt;胎儿监测&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;zi-shu-tai-dong&quot;&gt;自数胎动&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;每日固定时间早、中、晚各数胎动&lt;code&gt;1&lt;&#x2F;code&gt;小时，胎动总和乘以&lt;code&gt;4&lt;&#x2F;code&gt;即&lt;code&gt;12&lt;&#x2F;code&gt;小时胎动&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;≥ &lt;code&gt;6&lt;&#x2F;code&gt;次&#x2F;&lt;code&gt;2&lt;&#x2F;code&gt;小时&lt;&#x2F;strong&gt;为正常&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;&amp;lt; &lt;code&gt;6&lt;&#x2F;code&gt;次&#x2F;&lt;code&gt;2&lt;&#x2F;code&gt;小时&lt;&#x2F;strong&gt;或&lt;strong&gt;减少&lt;code&gt;50%&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt;，提示胎儿&lt;strong&gt;缺氧&lt;&#x2F;strong&gt;可能，应&lt;strong&gt;及时就诊&lt;&#x2F;strong&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote&gt;
&lt;p&gt;初产妇（第一胎）一般&lt;code&gt;18&lt;&#x2F;code&gt;周左右感应到胎动。&lt;&#x2F;p&gt;
&lt;p&gt;经产妇（生育过的）约&lt;code&gt;13&lt;&#x2F;code&gt;~&lt;code&gt;16&lt;&#x2F;code&gt;周即可感应到胎动。&lt;&#x2F;p&gt;
&lt;p&gt;早餐、中午和晚餐后至睡前以及半夜BB会比较活跃。&lt;&#x2F;p&gt;
&lt;p&gt;深呼吸（&lt;strong&gt;鼻子吸满气、嘴小口慢慢呼出&lt;&#x2F;strong&gt;）可缓解缺氧，发烧（新冠感染）或BB踢得厉害适用。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h4 id=&quot;chao-sheng-jian-cha&quot;&gt;超声检查&lt;&#x2F;h4&gt;
&lt;p&gt;医生根据孕周计算后开单、超声科根据孕周排期，对胎儿及其附属物进行的不同目的的检查。&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;检查类型   &lt;&#x2F;th&gt;&lt;th&gt;检查时间   &lt;&#x2F;th&gt;&lt;th&gt;检查目的&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;NT检查&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;9&lt;&#x2F;code&gt;~&lt;code&gt;13&lt;&#x2F;code&gt;周&lt;code&gt;+6&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;排除颈项透明层增厚（染色体异常）&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;四维彩超&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;18&lt;&#x2F;code&gt;~&lt;code&gt;28&lt;&#x2F;code&gt;周&lt;&#x2F;td&gt;&lt;td&gt;大排畸&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;B超&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;32&lt;&#x2F;code&gt;-&lt;code&gt;34&lt;&#x2F;code&gt;周&lt;&#x2F;td&gt;&lt;td&gt;检查羊水量和胎盘功能&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;B超&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;36+&lt;&#x2F;code&gt;周&lt;&#x2F;td&gt;&lt;td&gt;胎盘成熟度、羊水情况和脐带绕颈等&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h4 id=&quot;tai-xin-jian-ce&quot;&gt;胎心监测&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;36&lt;&#x2F;code&gt;周开始，&lt;strong&gt;每周&lt;&#x2F;strong&gt;检查一次&lt;&#x2F;li&gt;
&lt;li&gt;正常胎心率为110~160次&#x2F;分，需要医生判读结果&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;40&lt;&#x2F;code&gt;周之后&lt;code&gt;3&lt;&#x2F;code&gt;天检查一次&lt;&#x2F;li&gt;
&lt;li&gt;有妊娠期并发症（如高血压、糖尿病等）可能医生会酌情考虑提前（约&lt;code&gt;32&lt;&#x2F;code&gt;周）进行胎心监测&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3 id=&quot;yun-fu-jian-ce&quot;&gt;孕妇监测&lt;&#x2F;h3&gt;
&lt;h4 id=&quot;ti-zhong-zeng-jia&quot;&gt;体重增加&lt;&#x2F;h4&gt;
&lt;blockquote&gt;
&lt;p&gt;建议晨起后解完大小便称重，需排除衣物影响，以便于更精确监控体重变化。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;建议体重增长对照表：&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;孕前体重情况   &lt;&#x2F;th&gt;&lt;th&gt;建议孕期体重增长&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;过重&lt;&#x2F;td&gt;&lt;td&gt;应增加&lt;code&gt;7&lt;&#x2F;code&gt;~&lt;code&gt;12&lt;&#x2F;code&gt;kg&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;适中&lt;&#x2F;td&gt;&lt;td&gt;应增加&lt;code&gt;12&lt;&#x2F;code&gt;~&lt;code&gt;16&lt;&#x2F;code&gt;kg&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;过轻&lt;&#x2F;td&gt;&lt;td&gt;应增加&lt;code&gt;13&lt;&#x2F;code&gt;~&lt;code&gt;18&lt;&#x2F;code&gt;kg&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;blockquote&gt;
&lt;p&gt;标准体重可参考&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;zh.wikipedia.org&#x2F;zh-hans&#x2F;%E8%BA%AB%E9%AB%94%E8%B3%AA%E9%87%8F%E6%8C%87%E6%95%B8&quot;&gt;BMI指数&lt;&#x2F;a&gt;。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;理想状况下，平均增加&lt;code&gt;0.3&lt;&#x2F;code&gt;~&lt;code&gt;0.4&lt;&#x2F;code&gt;kg&#x2F;周，妊娠晚期不应超过&lt;code&gt;0.5&lt;&#x2F;code&gt;kg&#x2F;周。&lt;&#x2F;p&gt;
&lt;p&gt;异常情况请及时就医：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;阴道出血、阴道流水、下腹阵痛（&lt;code&gt;60&lt;&#x2F;code&gt;分钟超过&lt;code&gt;8&lt;&#x2F;code&gt;次）&lt;&#x2F;li&gt;
&lt;li&gt;头痛、头晕、眼花等不适（有妊娠期高血压、妊娠期糖尿病等尤为常见）&lt;&#x2F;li&gt;
&lt;li&gt;下肢明显水肿（垫高仍无法缓解）&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;blockquote&gt;
&lt;p&gt;如何区分阴道流水和“漏尿”？&lt;&#x2F;p&gt;
&lt;p&gt;有些孕妇，尤其是经产妇，可能由于恢复不佳等身体条件影响，容易“漏尿”，这时可以尝试提肛（和忍大便同样的发力方式），如果这个时候仍不断有水流出，则需高度警惕是羊水早破的情况，应及时就诊。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;下腹阵痛时如何辨别是否是子宫收缩？&lt;&#x2F;p&gt;
&lt;p&gt;出现频繁阵痛时，可将手触及下腹部，如果腹壁和额头的硬度接近，则需高度警惕是子宫收缩，应及时就诊。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;如何区分宫缩和假宫缩？&lt;&#x2F;p&gt;
&lt;p&gt;孕中晚期常常出现假宫缩。即孕妇发生体位变化（比如坐姿改为站姿或者翻身等）后，可以感到子宫一阵收缩，但稍作休息后症状很快消失。&lt;&#x2F;p&gt;
&lt;p&gt;但有些情况收缩比较频繁，且总持续时间达到30分钟以上，则需要高度警惕，此为临产先兆，应及时就诊。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;营养&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;少食多餐（5~6餐每天，一日内总营养素的摄入量不变）&lt;&#x2F;li&gt;
&lt;li&gt;避免刺激性和产气食物&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;运动&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;锻炼盆底肌：Waff运动&lt;&#x2F;li&gt;
&lt;li&gt;减少会阴侧切：适当会阴按摩&lt;&#x2F;li&gt;
&lt;li&gt;凯格尔运动：即“缩肛”运动，一缩一松为一个回合。制造忍尿的感觉，维持约10秒钟，放松休息10秒；一次可以做10个回合，一天做5~6次。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;侧切&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;BB大小&lt;&#x2F;li&gt;
&lt;li&gt;产力强弱&lt;&#x2F;li&gt;
&lt;li&gt;产程时间长短&lt;&#x2F;li&gt;
&lt;li&gt;产妇疲劳程度&lt;&#x2F;li&gt;
&lt;li&gt;胎儿有无异常&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;助产士会根据上述因素综合判断是否需要会阴侧切。&lt;&#x2F;p&gt;
</content>
        <summary type="html">（在广东省第二人民医院）生娃的注意事项（时效有限）</summary>
        </entry><entry xml:lang="zh-Hans">
        <title>如何克服开启中大代理后访问外网资源失败的问题</title>
        <published>2018-12-22T00:00:00+00:00</published>
        <updated>2018-12-22T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/sysu-proxy-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/sysu-proxy-zh/</id>
        
            <content type="html">&lt;p&gt;中大的睿智代理，一直有这个&lt;strong&gt;用了代理就没办法访问任何校外互联网资源&lt;&#x2F;strong&gt;的奇奇怪怪的毛病。对于一个经常需要在家工作的计算狗而言，这实在太不友好了。这里详细记录一下使用超低系统资源（&amp;lt;50MB RAM， CPU占用≈0%）解决这个问题。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;zhi-xie&quot;&gt;致谢&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;感谢德华君提供这个野路子以及过程中的指导&lt;&#x2F;li&gt;
&lt;li&gt;感谢Nick湿胸借用上网账号&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;da-zhi-si-lu&quot;&gt;大致思路&lt;&#x2F;h2&gt;
&lt;p&gt;不清楚是NAT啊，还是DNS服务更改的问题，总之这个代理只要使用了，再想使用互联网的资源就崩了，因此克服这个问题的唯一办法就是，&lt;strong&gt;在访问外网的时候关掉代理&lt;&#x2F;strong&gt;。但是Windows下通过IE浏览器登录代理，使用的是EasyConnect客户端，断了似乎就是断了，网页再认证还需要&lt;strong&gt;输入验证码&lt;&#x2F;strong&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;所以需要曲线救国，即&lt;strong&gt;访问外网资源的时候不走代理直接连接&lt;&#x2F;strong&gt;。咦？这和我们科学上网的需求好相似！你总不想打开国内页面的时候也绕路走你的国外VPS吧！那么为什么不用shadowsocks解决这个问题呢？&lt;&#x2F;p&gt;
&lt;p&gt;因此最后解决问题的路线就是：&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;虚拟机内开启学校代理并开启服务&lt;&#x2F;li&gt;
&lt;li&gt;虚拟机上架设shadowsocks server端并开启服务&lt;&#x2F;li&gt;
&lt;li&gt;本机使用shadowsocks client&lt;&#x2F;li&gt;
&lt;li&gt;本地使用校内代理的两种情况：
&lt;ul&gt;
&lt;li&gt;对于网页（比如RStudio server）使用Chrome浏览器的SwitchyOmega插件&lt;&#x2F;li&gt;
&lt;li&gt;SSH和SFTP连接直接使用配置了代理的Xshell和Xftp&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h2 id=&quot;an-zhuang-xu-ni-ji&quot;&gt;安装虚拟机&lt;&#x2F;h2&gt;
&lt;p&gt;先下载一个虚拟机程序，建议用VM Virtualbox，虽然据说VMware的硬件兼容好点，但是我的目的简单，只是在后台run一个Linux用来使用代理而已，因此这个轻量级的软件比较适合。操作系统使用Ubuntu Server 18.04：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;我们不需要图形界面&lt;&#x2F;li&gt;
&lt;li&gt;Ubuntu的LTS是最稳定的Server操作系统之一&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;虚拟机的配置上，RAM可以随便给个100M+（不会真的用完的，host消耗很小），硬盘就用那个vdi文件动态分配就好，那么大小也就无所谓了（理论上动态分配会稍微影响点IO性能，但是和我们的主题无关）。&lt;&#x2F;p&gt;
&lt;p&gt;命令行安装操作系统可能有点蛋疼，但是基本上也是一路选下一步就可以的。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;xu-ni-ji-linuxpei-zhi&quot;&gt;虚拟机Linux配置&lt;&#x2F;h2&gt;
&lt;p&gt;这个时候，还是先装好Xshell吧，不要头铁：没有SSH，你就这样在终端里面，你&lt;strong&gt;连一个普通命令的&lt;code&gt;--help&lt;&#x2F;code&gt;返回内容都浏览不全&lt;&#x2F;strong&gt;；想复制个URL却发现&lt;strong&gt;没得复制粘贴&lt;&#x2F;strong&gt;，浑身难受。Ubuntu Server默认是开了22端口的，也开启了sshd服务，所以&lt;code&gt;ifconfig&lt;&#x2F;code&gt;查到IP直接就可以连了。虚拟机的网络设置可以有以下两种策略：&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;桥接模式：和host在一个网段&lt;&#x2F;li&gt;
&lt;li&gt;NAT模式：需要端口映射，在本例中，你至少需要映射22端口用作ssh，再映射一个shadowsocks用的端口。&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;搞定了之后，就陆陆续续安装一下必要工具：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; apt-get update&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; apt-get dist-upgrade&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; apt install openconnect&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; apt-get install python-pip&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; pip install shadowsocks&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;使用openconnect需要一个厉害的配置文件vpnc-script，可以用&lt;code&gt;wget&lt;&#x2F;code&gt;从&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;gitlab.com&#x2F;openconnect&#x2F;vpnc-scripts&#x2F;-&#x2F;raw&#x2F;master&#x2F;vpnc-script&quot;&gt;这里&lt;&#x2F;a&gt;下载。你应该到现在为止没有切换过当前tty的工作目录，那漂亮啊，就下载到这吧，用起来也方便…&lt;&#x2F;p&gt;
&lt;p&gt;然后开启openconnect服务：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; openconnect -b --no-dtls --script ~&#x2F;vpnc-script https:&#x2F;&#x2F;ocvpn.sysu.edu.cn --servercert sha256:a0cc6612c7310494b31ad62e76255373f056ac128c8489ac58562f6fe57ae8e9&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;--servercert&lt;&#x2F;code&gt;参数值是双鸭山大学提供的证书。你可以不加上这个参数，但是它会逼着你加上。&lt;&#x2F;p&gt;
&lt;p&gt;输入用户名和密码，程序会返回一个PID之后在后台运行。&lt;&#x2F;p&gt;
&lt;p&gt;接下来开启shadowsocks服务：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; ssserver -p&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 2333&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -k&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 930829&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -m rc4-md5 -d start&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;我比较懒，就直接这样开启SS服务而不是写配置文件了：&lt;code&gt;-p&lt;&#x2F;code&gt;是端口；&lt;code&gt;-k&lt;&#x2F;code&gt;是密码我用了自己生日，你们可以随意；&lt;code&gt;-m&lt;&#x2F;code&gt;是加密方法，我X我和我虚拟机连接我丝毫不虚，选个复杂度低的速度快点负荷小点；&lt;code&gt;-d&lt;&#x2F;code&gt;如果替换成stop就是停止服务。&lt;&#x2F;p&gt;
&lt;p&gt;在Ubuntu Server 18.04上，你可能会遇到这样一个错误：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# 此处省略99999行&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;AttributeError: &#x2F;usr&#x2F;lib&#x2F;x86_64-linux-gnu&#x2F;libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这是由于在openssl 1.1.0中废弃了 &lt;code&gt;EVP_CIPHER_CTX_cleanup()&lt;&#x2F;code&gt; 函数而引入了 &lt;code&gt;EVE_CIPHER_CTX_reset()&lt;&#x2F;code&gt; 函数所导致的。&lt;&#x2F;p&gt;
&lt;p&gt;解决方式也是简单，直接找到使用的openssl.py文件（&lt;strong&gt;我省略的那部分异常信息里就有它的位置&lt;&#x2F;strong&gt;），把里面的所有cleanup字样全部替换为reset，就舒服了。直接&lt;code&gt;vim&lt;&#x2F;code&gt;里面批量替换，别问我怎么操作，问就是不告诉你。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;wo-yao-zen-me-shi-yong-xu-ni-ji-li-mian-de-dai-li-ni&quot;&gt;我要怎么使用虚拟机里面的代理呢&lt;&#x2F;h2&gt;
&lt;p&gt;首先，你需要&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;shadowsocks&#x2F;shadowsocks-windows&quot;&gt;shadowsocks client&lt;&#x2F;a&gt;来把代理服务器的shadowsocks协议转发为socks5协议。你可能需要在两个不同的目录运行两个独立的shadowsocks进程（端口各自不同），以方便同时使用科学上网和虚拟机中架设的中大代理。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;fang-wen-wang-ye&quot;&gt;访问网页&lt;&#x2F;h3&gt;
&lt;p&gt;比如RStudio server，比如hugo的预览，都是要访问内网网页的。使用Chrome浏览器的SwitchyOmega插件，可以妥善解决这个问题。记得在auto switch里面，将使用中大代理的情景模式的触发条件&lt;strong&gt;用带有通配符的IP设置为同一网段&lt;&#x2F;strong&gt;。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;shi-yong-sshlian-jie&quot;&gt;使用SSH连接&lt;&#x2F;h3&gt;
&lt;p&gt;在Xshell的连接属性里面设置好使用代理（注意端口）。&lt;&#x2F;p&gt;
&lt;p&gt;至此，科学上网&#x2F;直连&#x2F;中大代理可以和睦相处了。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;bu-chong&quot;&gt;补充&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;wo-xu-yao-yi-ge-service&quot;&gt;我需要一个service&lt;&#x2F;h3&gt;
&lt;p&gt;理想状态下，应该是虚拟机开机自动运行这个openconnect命令的，然后如果崩溃可以自动恢复，所以要把它做成一个service的形式比较好。Ubuntu的这些service一般在&lt;code&gt;&#x2F;lib&#x2F;systemd&#x2F;system&#x2F;&lt;&#x2F;code&gt;，所以在这里面操作吧：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;lib&#x2F;systemd&#x2F;system&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; touch sysu-proxy.service&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;然后填内容进去：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[Unit]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Description=sysu-proxy&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;After=network.target&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;StartLimitIntervalSec=0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;StartLimitAction=reboot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[Service]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Type=simple&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Restart=always&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;RestartSec=1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;User=ysun&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ExecStart=&#x2F;bin&#x2F;echo &amp;#39;passwd&amp;#39; | &#x2F;usr&#x2F;sbin&#x2F;openconnect --no-dtls --script ~&#x2F;vpnc-script https:&#x2F;&#x2F;ocvpn.sysu.edu.cn --servercert sha256:a0cc6612c7310494b31ad62e76255373f056ac128c8489ac58562f6fe57ae8e9 -u username&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[Install]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;WantedBy=multi-user.target&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里面要解释一下的：&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Restart=always&lt;&#x2F;code&gt;可以保证进程挂了就自动重新运行&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;RestartSec=1&lt;&#x2F;code&gt;一旦挂了，它就会不断尝试重新运行，那么为了防止某些特定情况下一直重新运行增加服务器负载，还是间隔设置久一点好点（间隔为1秒）&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;ExecStart=...&lt;&#x2F;code&gt;对于需要交互式输入密码的，可以用这个技巧，通过管道将特定字符传过去&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;StartLimitIntervalSec=0&lt;&#x2F;code&gt;是防止放弃重新运行的。理论上是这样：还有一个参数值，比如&lt;code&gt;StartLimitBurst=5&lt;&#x2F;code&gt;，同时再有&lt;code&gt;StartLimitIntervalSec=10&lt;&#x2F;code&gt;的话呢，那么就如果在10秒内失败了5次，就放弃运行了（何弃疗！）防止这个情况发生就可以这样设置为0&lt;&#x2F;li&gt;
&lt;li&gt;其实&lt;code&gt;[Unit]&lt;&#x2F;code&gt;还可以加上&lt;code&gt;StartLimitAction=reboot&lt;&#x2F;code&gt;如果上面设置不是0，崩了，还是可以通过这个方式重启操作系统&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;好了，接下来就很舒服了：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl enable sysu-proxy.service&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl daemon-reload&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl restart sysu-proxy.service&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
        </entry><entry xml:lang="zh-Hans">
        <title>如何高效批量下载一整个BioProject&#x2F;Study的数据？</title>
        <published>2018-12-21T00:00:00+00:00</published>
        <updated>2018-12-21T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/enapi-liang-xia-zai-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/enapi-liang-xia-zai-zh/</id>
        
            <content type="html">&lt;p&gt;以&lt;em&gt;DRA005150&lt;&#x2F;em&gt;这个accession为例：&lt;&#x2F;p&gt;
&lt;p&gt;先按&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;ena-docs.readthedocs.io&#x2F;en&#x2F;latest&#x2F;retrieval&#x2F;file-download.html&quot;&gt;ENA下载说明&lt;&#x2F;a&gt;打开ENA Browser，search这个字段（右上角），在出现的结果右侧选&lt;em&gt;Study&lt;&#x2F;em&gt;，点进去，下方&lt;em&gt;Download&lt;&#x2F;em&gt;字样这行最右侧有一个&lt;em&gt;TEXT&lt;&#x2F;em&gt;，将此文件下载后上传到服务器某目录下，然后执行：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 这里下载到的文件名为PRJDB5190.txt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# aria2是多线程下载工具，会自动使用适量CPU核心占满带宽或IO&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# cut为了从数据metadata切割出URL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# tr将其分割为按行的记录&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# sed为每行URL添加上FTP协议（否则aria2不识别）&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# tail去掉header&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# aria2c接受一个文件作为批量下载列表，这里使用标准输入&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;cut&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -f10 PRJDB5190.txt&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; tr&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-string z-string&quot;&gt; &amp;#39;;&amp;#39; &amp;#39;\n&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; sed&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-punctuation z-definition z-string&quot;&gt; -e &amp;#39;s#^#ftp:&#x2F;&#x2F;#&amp;#39;&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; tail&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -n +2&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; aria2c&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -i -&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
        </entry><entry xml:lang="zh-Hans">
        <title>Circos安装很痛苦？教你两句命令解决所有依赖</title>
        <published>2018-09-01T00:00:00+00:00</published>
        <updated>2018-09-01T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/circosan-zhuang-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/circosan-zhuang-zh/</id>
        
            <content type="html">&lt;p&gt;之前听很多人吐槽说安装Circos费劲，各种Perl库装不上，装上了又找不到，今天让我来为大家介绍正确的体位：&lt;&#x2F;p&gt;
&lt;p&gt;下载&#x2F;解压Circos，并将其主程序添加到&lt;code&gt;$PATH&lt;&#x2F;code&gt;之后，是可以使用&lt;code&gt;circos -modules&lt;&#x2F;code&gt;来自动检查其perl依赖是否满足的，其输出大概为这样：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ok       1.50 Carp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ok       0.39 Clone&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;missing            Config::General&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ok       3.74 Cwd&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ok      2.170 Data::Dumper&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;... (此处省略65536字hhhhh)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;好的！不要慌！先&lt;code&gt;su&lt;&#x2F;code&gt;一下切到管理员账户下，然后&lt;code&gt;echo &#x27;yes&#x27; | cpan App::cpanminus&lt;&#x2F;code&gt;把cpanm装上。什么？你不是管理员？那你喊狗管理帮你装Circos不就好了…&lt;&#x2F;p&gt;
&lt;p&gt;然后&lt;code&gt;exit&lt;&#x2F;code&gt;回到自己的用户下，&lt;code&gt;circos -modules | perl -anE&#x27;print qq{$F[1] } if &#x2F;^miss&#x2F; }{ say&#x27; | cpanm&lt;&#x2F;code&gt;，然后去泡个茶。&lt;&#x2F;p&gt;
&lt;p&gt;回来你会吃了一精，所有缺少的模块都装好了。再运行&lt;code&gt;circos -modules&lt;&#x2F;code&gt;看看…嗯？还是都是miss？没关系，是@INC缓存没更新的缘故。去一个新的tty试一下，一切正常。&lt;&#x2F;p&gt;
&lt;p&gt;好，这样成功解决了Circos的棘手的安装问题。祝各位生活性福美满。&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>Teamviewer命令行</title>
        <published>2018-08-12T00:00:00+00:00</published>
        <updated>2018-08-12T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/teamviewerming-ling-xing-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/teamviewerming-ling-xing-zh/</id>
        
            <content type="html">&lt;p&gt;新安装了服务器的操作系统，然后不想爬上爬下接个显示器（实验室的服务器放在月亮之上），要怎么样才能完全从命令行配置好teamviewer？&lt;&#x2F;p&gt;
&lt;p&gt;先安装：&lt;code&gt;aurman -S teamviewer&lt;&#x2F;code&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;然后，参照&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;en&#x2F;blog&#x2F;working-on-linux&#x2F;&quot;&gt;之前的日记&lt;&#x2F;a&gt;中记载的做法，将teamviewer的daemon设置好。&lt;&#x2F;p&gt;
&lt;p&gt;为了显示teamviewer的ID，先得有个密码。否则出于安全考虑，是不会显示ID的：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; teamviewer --passwd yourpasswd&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这样再&lt;code&gt;sudo teamviewer --info&lt;&#x2F;code&gt;就能看到ID了。&lt;&#x2F;p&gt;
&lt;p&gt;拿到了ID和密码，就能直接连接啦~&lt;&#x2F;p&gt;
&lt;p&gt;好了，接下来，我又吃精地发现一个问题，连接持续了几秒钟而已，挂了；再连接，连不上…我滚去一台局域网内的电脑在终端内尝试&lt;code&gt;teamviewer&lt;&#x2F;code&gt;，发现：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Init...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CheckCPU: SSE2 support: yes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Checking setup...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Launching TeamViewer ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Launching TeamViewer GUI ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Aborted (core dumped)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;折腾了很久，终于找到了一个解决办法：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;sudo nano &#x2F;opt&#x2F;teamviewer&#x2F;config&#x2F;global.conf&lt;&#x2F;code&gt;加上以下两行配置：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[int32] EulaAccepted = 1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;[int32] EulaAcceptedRevision = 6&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;再重启daemon服务，可以了！&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>aurman在操作系统更新之后不能用了？</title>
        <published>2018-08-08T00:00:00+00:00</published>
        <updated>2018-08-08T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/geng-xin-hou-aurmanbu-neng-yong-liao-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/geng-xin-hou-aurmanbu-neng-yong-liao-zh/</id>
        
            <content type="html">&lt;p&gt;2018年8月7日，星期二，天气晴（广州有哪天是不下一阵雨的？）&lt;&#x2F;p&gt;
&lt;p&gt;早上睡醒一如既往地挂代理，开终端，&lt;code&gt;aurman -Syu&lt;&#x2F;code&gt;，然后忽然想装一个pbzip2，我就吃精地发现，aurman不能用了？WTF！&lt;&#x2F;p&gt;
&lt;p&gt;异常信息大概长这样：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Traceback (most recent call last):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  File &amp;quot;&#x2F;usr&#x2F;bin&#x2F;aurman&amp;quot;, line 6, in &amp;lt;module&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    from pkg_resources import load_entry_point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  File &amp;quot;&#x2F;usr&#x2F;lib&#x2F;python3.6&#x2F;site-packages&#x2F;pkg_resources&#x2F;__init__.py&amp;quot;, line 3095, in &amp;lt;module&amp;gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    @_call_aside&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  File &amp;quot;&#x2F;usr&#x2F;lib&#x2F;python3.6&#x2F;site-packages&#x2F;pkg_resources&#x2F;__init__.py&amp;quot;, line 3079, in _call_aside&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    f(*args, **kwargs)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  File &amp;quot;&#x2F;usr&#x2F;lib&#x2F;python3.6&#x2F;site-packages&#x2F;pkg_resources&#x2F;__init__.py&amp;quot;, line 3108, in _initialize_master_working_set&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    working_set = WorkingSet._build_master()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  File &amp;quot;&#x2F;usr&#x2F;lib&#x2F;python3.6&#x2F;site-packages&#x2F;pkg_resources&#x2F;__init__.py&amp;quot;, line 570, in _build_master&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ws.require(__requires__)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  File &amp;quot;&#x2F;usr&#x2F;lib&#x2F;python3.6&#x2F;site-packages&#x2F;pkg_resources&#x2F;__init__.py&amp;quot;, line 888, in require&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    needed = self.resolve(parse_requirements(requirements))&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  File &amp;quot;&#x2F;usr&#x2F;lib&#x2F;python3.6&#x2F;site-packages&#x2F;pkg_resources&#x2F;__init__.py&amp;quot;, line 774, in resolve&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    raise DistributionNotFound(req, requirers)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pkg_resources.DistributionNotFound: The &amp;#39;aurman==2.17.1&amp;#39; distribution was not found and is required by the application&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;好了，看到这个我就明白了，一定是Python做了大版本更新，aurman作为一个纯python的包管理器，躺枪！&lt;&#x2F;p&gt;
&lt;p&gt;（喜欢滚动更新？啪！）&lt;&#x2F;p&gt;
&lt;p&gt;赶紧去社区兜了一圈，发现aurman的作者已经火速更新了源码（其实还不是就改个数字嘛摔），然后更新了AUR上的snapshot，我们只要重装一下aurman就什么问题都没有了。&lt;&#x2F;p&gt;
&lt;p&gt;所以去AUR下载了snapshot文件，解压缩拿到PKGBUILD，正当我&lt;code&gt;makepkg -sci&lt;&#x2F;code&gt;的时候，又凉凉了！&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;==&amp;gt; Verifying source file signatures with gpg...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    aurman_sources git repo ... FAILED (unknown public key 465022E743D71E39)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;==&amp;gt; ERROR: One or more PGP signatures could not be verified!&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;好嘛好嘛。签名问题。既然我确定我的PKGBUILD是正规途径下载搞到的，那无所谓咯，我&lt;code&gt;gpg --recv-key 465022E743D71E39&lt;&#x2F;code&gt;添进来就是:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;gpg: keyserver receive failed: Server indicated a failure&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;作为一个国内玩家，我已经看了不下1000000000000000000000次这种异常信息了（误）&lt;&#x2F;p&gt;
&lt;p&gt;然后再&lt;code&gt;makepkg -sci&lt;&#x2F;code&gt;，完成package build之后，会自动调用pacman -U去替换当前版本。然后aurman就可以正常使用了。&lt;&#x2F;p&gt;
&lt;p&gt;再回去看看，&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;polygamma&#x2F;aurman&#x2F;issues&#x2F;178&quot;&gt;aurman的作者已经不胜其扰了&lt;&#x2F;a&gt;，我真同情你…为什么你不多找点我这样的用户…&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>因为硬盘Block不够，导致操作系统不能更新是要有多蛋疼？</title>
        <published>2018-07-18T00:00:00+00:00</published>
        <updated>2018-07-18T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/blockbu-gou-cao-zuo-xi-tong-bu-neng-geng-xin-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/blockbu-gou-cao-zuo-xi-tong-bu-neng-geng-xin-zh/</id>
        
            <content type="html">&lt;p&gt;喏，众所周知，ArchLinux那是要每天睡醒了就&lt;code&gt;aur -Syu&lt;&#x2F;code&gt;一轮压压惊的，然后齐胖胖的服务器已经两周多（至少）没更新过，我感觉药丸，赶紧更新去，然后我就傻眼了：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: Partition &#x2F; too full: 225715 blocks needed, 130394 blocks free&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;error: failed to commit transaction (not enough free disk space)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Errors occurred, no packages were upgraded.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;啊？&lt;&#x2F;p&gt;
&lt;p&gt;关于什么是blocks，就不多解释了，鸟哥里面写的很清楚。基本上发生这样的问题，可能有两种原因：&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;硬盘格式化的时候，block设置得过大了。一般来说是4KB，使用者在对硬盘格式化的时候应该根据服务器的用途设计好block的大小。比如如果是邮件服务器等文件普遍比较小的，那么用较大的block势必导致硬盘空间的浪费；&lt;&#x2F;li&gt;
&lt;li&gt;出现了一堆特别特别小的文件。也许是日志文件或者其他？这就不得而知了。&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;我们的服务器是一般用途，所以格式化用的也是默认参数（当然是做了4K对齐的），因此应该不会出现第一条问题。所以切到root之后，看了一下究竟是哪里比较大：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;du&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -hsx&lt;&#x2F;span&gt;&lt;span class=&quot;z-variable&quot;&gt; *&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; sort&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -rh&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; |&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; head&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; -10&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;输出是这样的：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;du: cannot access &amp;#39;proc&#x2F;39956&#x2F;task&#x2F;39956&#x2F;fd&#x2F;4&amp;#39;: No such file or directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;du: cannot access &amp;#39;proc&#x2F;39956&#x2F;task&#x2F;39956&#x2F;fdinfo&#x2F;4&amp;#39;: No such file or directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;du: cannot access &amp;#39;proc&#x2F;39956&#x2F;fd&#x2F;4&amp;#39;: No such file or directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;du: cannot access &amp;#39;proc&#x2F;39956&#x2F;fdinfo&#x2F;4&amp;#39;: No such file or directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;2.8T    backup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;2.6T    data&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;2.5T    data2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;15G     home&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;7.5G    var&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;7.1G    usr&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;3.4G    opt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;52M     boot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;14M     etc&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;13M     tmp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;那些什么cannot access的就不管了，是内存中的进程缓存并非完全实时的缘故。
至于下面的内容，就很奇怪了。前三个是挂载在其他硬盘上的，&lt;code&gt;&#x2F;home&lt;&#x2F;code&gt;的大小也还算正常（此前我单独检查过用户目录），那么最可疑的就是&lt;code&gt;&#x2F;var&lt;&#x2F;code&gt;和&lt;code&gt;&#x2F;usr&lt;&#x2F;code&gt;两个了。&lt;&#x2F;p&gt;
&lt;p&gt;就这样一层一层检查下去，发现&lt;code&gt;&#x2F;var&#x2F;cache&lt;&#x2F;code&gt;里的缓存也挺多的（感谢齐胖胖提醒），然后就用&lt;code&gt;pacman -Sc&lt;&#x2F;code&gt;做个清理了。&lt;&#x2F;p&gt;
&lt;p&gt;然后就可以了。&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>对Levey-Jennings质控图和Westgard多规则质控方法的理解</title>
        <published>2018-07-16T00:00:00+00:00</published>
        <updated>2018-07-16T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/ljhe-westgard-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/ljhe-westgard-zh/</id>
        
            <content type="html">&lt;p&gt;&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;LJ_westgard_1.jpg&quot; alt=&quot;&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;LJ_westgard_2.jpg&quot; alt=&quot;&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;LJ_westgard_3.jpg&quot; alt=&quot;&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;LJ_westgard_4.jpg&quot; alt=&quot;&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;LJ_westgard_5.jpg&quot; alt=&quot;&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;LJ_westgard_6.jpg&quot; alt=&quot;&quot; &#x2F;&gt;
&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;LJ_westgard_7.jpg&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
</content>
        <summary type="html">朋友对这两个质控方法有兴趣，我就也看了看...</summary>
        </entry><entry xml:lang="zh-Hans">
        <title>用R完成SVM和ANN模型预测并评估</title>
        <published>2018-07-16T00:00:00+00:00</published>
        <updated>2018-07-16T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/svm-ann-model-evaluation-r/" type="text/html"/>
        <id>https://www.bigdick.live/blog/svm-ann-model-evaluation-r/</id>
        
            <content type="html">&lt;p&gt;SVM和ANN就早有耳闻了，无奈R里面的轮子真是乱。难得最近有心情了，利用空余时间把这个项目重新用caret撸一遍。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;shu-ju-yu-chu-li&quot;&gt;数据预处理&lt;&#x2F;h2&gt;
&lt;p&gt;这个数据长这个蛋样的（&lt;code&gt;str()&lt;&#x2F;code&gt;的结果）：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Classes ‘data.table’ and &amp;#39;data.frame&amp;#39;:	164 obs. of  18 variables:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ SampleID: int  10086901 10086902 10086924 10086934 10042716 10042715 10042718 10042719 10042732 10042733 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ PEDF    : int  107635 136455 130085 106695 110565 131440 83305 178960 579090 117355 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ SP-B    : num  61.4 61.4 61.4 928.2 558 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ Galectin: num  67.1 85.7 124 94.2 69.8 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ FTL     : num  1327 750 2065 1914 1563 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ AKAP4   : num  2701 2286 2147 2640 885 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ LUM     : num  109 0 83.3 92.7 56.7 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ COL     : num  1469 864 1012 1644 1104 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ MASP1   : int  282690 409725 240220 523840 245555 139960 15405 632280 2198900 440850 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ ITG-b1  : num  257 185 255 462 186 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ PTPRJ   : num  351.5 328.9 446.9 41.2 417.3 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ Gelsolin: num  1273 798 758 864 665 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ TSP-1   : num  463900 216520 191805 256615 222151 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ ZYX     : num  502 439 541 664 204 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ CD163   : num  40.8 46.8 43.3 58.6 59.3 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ FDA     : num  186 164 152 288 233 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ PC      : num  528 335 321 337 244 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; $ Status  : int  0 0 0 1 1 1 1 1 1 1 ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt; - attr(*, &amp;quot;.internal.selfref&amp;quot;)=&amp;lt;externalptr&amp;gt; &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;svmpian&quot;&gt;SVM篇&lt;&#x2F;h2&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>记一次修服务器的蛋疼过程</title>
        <published>2018-07-12T00:00:00+00:00</published>
        <updated>2018-07-12T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/xiu-fu-wu-qi-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/xiu-fu-wu-qi-zh/</id>
        
            <content type="html">&lt;p&gt;昨天早上来到实验室，发现putty断了。重连一下，连不上。瞄了一眼服务器，卧槽，关机了？
然后我就试着开机，但是开不了。故障灯常亮，看来是坏了。&lt;&#x2F;p&gt;
&lt;p&gt;我就把它拆开，拔下内存，用橡皮擦擦金手指，然后再四周围清理一圈，通电，还是不行。&lt;&#x2F;p&gt;
&lt;p&gt;只插一两条？还是不行。&lt;&#x2F;p&gt;
&lt;p&gt;仔细观察一下电源，发现电源风扇一直是转几秒钟然后就停下来。似乎没有收到主板的启动信号，所以一直在通电-断电-通电？&lt;&#x2F;p&gt;
&lt;p&gt;主板上也确实有故障灯亮起。看来真的是坏了。&lt;&#x2F;p&gt;
&lt;p&gt;但是我不是专业维修师傅呀，我连个用来替换的主板都没有。于是报修。&lt;&#x2F;p&gt;
&lt;p&gt;先找一条长长的网线，把服务器后身有一个IMM接口（就是一个特别的网线接口）和我的台式机以LAN方式连接到一起。&lt;&#x2F;p&gt;
&lt;p&gt;然后工程师告知，服务器在局域网内的IP是192.168.70.125。那我先在本地连接属性里把我台式机的IP设置为同一网段，比如192.168.70.2，方便两台电脑的通信：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;%E5%90%8C%E4%B8%80%E7%BD%91%E6%AE%B5.png&quot; alt=&quot;这TM不就在配置路由器一样么摔&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;这个时候，打开浏览器访问192.168.70.125，自动地跳转到了一个类似https:&#x2F;&#x2F;192.168.70.125&#x2F;designs&#x2F;imm&#x2F;index.php 的URL，要求用户信息来登录：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%86%85%E7%BD%AEweb-server%E7%99%BB%E5%BD%95%E7%95%8C%E9%9D%A2.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;由此看来，应该是主板上内置的一个小模块，烧进了这样一个微型的web server，不依赖操作系统，因此只要连接了电源，就算主板无法工作，无法进入操作系统，也可以工作（只是响应真的好慢）。输入工程师提供的用户名USERID，密码PASSW0RD，进入系统，看到如下诊断信息：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;%E8%AF%8A%E6%96%AD%E7%95%8C%E9%9D%A2.png&quot; alt=&quot;&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;这就很难受了。power那项可以忽略，因为我只是调试用，RPS只接了其中一块电源。但是由这个信息来看，主板坏了千真万确…&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>R包安装和更新等相关问题</title>
        <published>2018-07-03T00:00:00+00:00</published>
        <updated>2018-07-03T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/rbao-xiang-guan-wen-ti-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/rbao-xiang-guan-wen-ti-zh/</id>
        
            <content type="html">&lt;p&gt;R的生态环境近几年越来越好，但是包管理系统始终…反正我自己是遇到好多坑。又没有Maven那种，很难受。就在这里记录一下大坑们和解决办法吧…&lt;&#x2F;p&gt;
&lt;h2 id=&quot;geng-xin-xiang-guan&quot;&gt;更新相关&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;rgeng-xin-zhi-hou-chu-xian-error-package-was-installed-by-an-r-version-with-different-internals-it-needs-to-be-reinstalled-for-use-with-this-r-version&quot;&gt;R更新之后出现：Error: package * was installed by an R version with different internals; it needs to be reinstalled for use with this R version&lt;&#x2F;h3&gt;
&lt;p&gt;R大版本更新（3.4.3 -&amp;gt; 3.5）之后好多R包不能用了，报错信息如上。重装了一个，又会发现还有其他的包也有这种提示，子子孙孙无穷尽也…&lt;&#x2F;p&gt;
&lt;p&gt;解决方案：运行&lt;code&gt;update.packages(checkBuilt=TRUE, ask=FALSE)&lt;&#x2F;code&gt;将有必要更新的一股脑更新了去。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;an-zhuang-xiang-guan&quot;&gt;安装相关&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;shi-yong-devtools-install-github-bao-cuo-error-setting-certificate-verify-locations&quot;&gt;使用&lt;code&gt;devtools::install_github()&lt;&#x2F;code&gt;报错：error setting certificate verify locations&lt;&#x2F;h3&gt;
&lt;p&gt;详细如下：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Installation failed: error setting certificate verify locations:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  CAfile: microsoft-r-cacert.pem&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  CApath: none&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;解决方案：&lt;code&gt;install.packages(c(&quot;curl&quot;, &quot;httr&quot;))&lt;&#x2F;code&gt;，期间如果需要重启RSession会出提示。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;shi-yong-devtools-install-github-bao-cuo-biocinstalleran-zhuang-bu-shang&quot;&gt;使用&lt;code&gt;devtools::install_github()&lt;&#x2F;code&gt;报错BiocInstaller安装不上&lt;&#x2F;h3&gt;
&lt;p&gt;详细如下：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Downloading GitHub repo bioinformatist&#x2F;LncPipeReporter@master&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;from URL https:&#x2F;&#x2F;api.github.com&#x2F;repos&#x2F;bioinformatist&#x2F;LncPipeReporter&#x2F;zipball&#x2F;master&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Installing LncPipeReporter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;#39;BiocInstaller&amp;#39; must be installed to install Bioconductor packages.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Would you like to install it? This will source &amp;lt;https:&#x2F;&#x2F;bioconductor.org&#x2F;biocLite.R&amp;gt;.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;1: Yes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;2: No&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这个时候玩家一般会天真的选1，然后就发现：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Installation failed: cannot open the connection to &amp;#39;https:&#x2F;&#x2F;bioconductor.org&#x2F;biocLite.R&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Warning message:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;In file(filename, &amp;quot;r&amp;quot;, encoding = encoding) :&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  URL &amp;#39;https:&#x2F;&#x2F;bioconductor.org&#x2F;biocLite.R&amp;#39;: status was &amp;#39;Problem with the SSL CA cert (path? access rights?)&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;先提供一个简单的解法，只要&lt;code&gt;source(&#x27;http:&#x2F;&#x2F;bioconductor.org&#x2F;biocLite.R&#x27;)&lt;&#x2F;code&gt;之后重新运行&lt;code&gt;devtools::install_github()&lt;&#x2F;code&gt;安装包就无痛了。&lt;&#x2F;p&gt;
&lt;p&gt;注意到我只是&lt;strong&gt;把https改成了http&lt;&#x2F;strong&gt;，究竟影响了什么？&lt;&#x2F;p&gt;
&lt;p&gt;这就要提到一个历史遗留问题了：&lt;&#x2F;p&gt;
&lt;p&gt;devtools包历来都是用Linux自带的curl作为下载工具的，这点我有提过&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;r-lib&#x2F;devtools&#x2F;issues&#x2F;1641&quot;&gt;issue&lt;&#x2F;a&gt;，希望换成别的更高效的工具。但是从祖师爷Handley的回复看来，应该用curl也只是权宜之计，将来会有基于R的这样一个工具出来，那我就释怀了。&lt;&#x2F;p&gt;
&lt;p&gt;curl去访问下载https链接，是需要&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;curl.haxx.se&#x2F;docs&#x2F;caextract.html&quot;&gt;证书&lt;&#x2F;a&gt;的！&lt;&#x2F;p&gt;
&lt;p&gt;我很奇怪，按说应该是有的呀，所以&lt;code&gt;curl-config --ca&lt;&#x2F;code&gt;了一下，发现在&lt;code&gt;&#x2F;opt&#x2F;anaconda&#x2F;ssl&#x2F;cacert.pem&lt;&#x2F;code&gt;。啊啊啊？&lt;&#x2F;p&gt;
&lt;p&gt;这个时候我想起来，服务器上装过Anaconda，之后为了方便大家使用conda等安装常用的生物信息分析工具，我就把&lt;code&gt;&#x2F;opt&#x2F;anaconda&#x2F;bin&lt;&#x2F;code&gt;加入&lt;code&gt;PATH&lt;&#x2F;code&gt;了。然后其也带有一个低版本（真的是很旧）的curl，将操作系统本身的curl覆盖了。&lt;&#x2F;p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;Anaconda官方是非常不建议将&lt;code&gt;bin&lt;&#x2F;code&gt;目录加入&lt;code&gt;PATH&lt;&#x2F;code&gt;的，因为会有大量系统工具被覆盖（文件没有被替换，只是默认调用的都是Anaconda提供的版本）。Anaconda提供的这些binary文件也通常不会是最新的，因为它的哲学是“提供稳定可用的发行版”。但是这一“稳定”也许会和操作系统的使用相冲突。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;意识到这个问题，我先短暂地将&lt;code&gt;&#x2F;opt&#x2F;anaconda&#x2F;bin&lt;&#x2F;code&gt;从&lt;code&gt;PATH&lt;&#x2F;code&gt;中移除了。然后再去尝试安装，发现还是同样的报错。这个时候我就有一定程度的不适了。
我服务器上使用的R是MRO，MRO其实是提供了证书的（比如我的在&lt;code&gt;&#x2F;usr&#x2F;lib&#x2F;R&#x2F;lib&#x2F;microsoft-r-cacert.pem&lt;&#x2F;code&gt;），我以为是MRO的bug，它调用curl的时候找不到这个证书，于是我天真地&lt;code&gt;Sys.setenv(CURL_CA_BUNDLE = &quot;&#x2F;usr&#x2F;lib&#x2F;R&#x2F;lib&#x2F;microsoft-r-cacert.pem&quot;)&lt;&#x2F;code&gt;指定了一下这个位置，结果发现还是不行。&lt;&#x2F;p&gt;
&lt;p&gt;这个时候我忽然想到，我的操作系统是Manjaro，更新太快导致curl和MRO内提供的证书版本不符。&lt;&#x2F;p&gt;
&lt;p&gt;看来还是用回Anaconda的旧版本curl+旧版本证书吧。&lt;&#x2F;p&gt;
&lt;p&gt;所以再把它写回&lt;code&gt;PATH&lt;&#x2F;code&gt;里面，然后&lt;code&gt;Sys.setenv(CURL_CA_BUNDLE = &quot;&#x2F;opt&#x2F;anaconda&#x2F;ssl&#x2F;cacert.pem&quot;)&lt;&#x2F;code&gt;。终于能用了！&lt;&#x2F;p&gt;
&lt;p&gt;最后，如果是国内玩家，一直出现下述字样的话，还是改成http吧…&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Installation failed: cannot open the connection to &amp;#39;https:&#x2F;&#x2F;bioconductor.org&#x2F;biocLite.R&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Warning message:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;In file(filename, &amp;quot;r&amp;quot;, encoding = encoding) :&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  URL &amp;#39;https:&#x2F;&#x2F;bioconductor.org&#x2F;biocLite.R&amp;#39;: status was &amp;#39;Timeout was reached&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h3 id=&quot;rjavage-chong-bu-shu-fu&quot;&gt;rJava各种不舒服&lt;&#x2F;h3&gt;
&lt;p&gt;还是要先确认一下Java有妥善安装（&lt;code&gt;java --version&lt;&#x2F;code&gt;），然后&lt;code&gt;sudo R CMD javareconf&lt;&#x2F;code&gt;一下，记住里面的版本信息；&lt;&#x2F;p&gt;
&lt;p&gt;然后加载使用到rJava的包还是有可能报出以下异常的：&lt;code&gt;libjvm.so: cannot open shared object file: No such file or directory&lt;&#x2F;code&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;这个时候想到可能是编译安装的时候，&lt;code&gt;ld&lt;&#x2F;code&gt;没做好，程序找不到动态链接库了。然后先&lt;code&gt;sudo find &#x2F;usr -name libjvm.so&lt;&#x2F;code&gt;找一下，比如我这里是这样的结果：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;usr&#x2F;lib&#x2F;jvm&#x2F;java-8-openjdk&#x2F;jre&#x2F;lib&#x2F;amd64&#x2F;server&#x2F;libjvm.so&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;那就把这个路径（不包括&lt;code&gt;.so&lt;&#x2F;code&gt;文件名），加入&lt;code&gt;&#x2F;etc&#x2F;ld.so.conf&lt;&#x2F;code&gt;里面去（当然有的用户的server上可能搞了n多个版本的java，那就要依靠版本号啊路径啊这些信息对应上了），然后&lt;code&gt;sudo &#x2F;sbin&#x2F;ldconfig&lt;&#x2F;code&gt;一下，解决~&lt;&#x2F;p&gt;
&lt;h3 id=&quot;igraphbao-cuo-at-optimal-modularity-c-85-glpk-is-not-available-unimplemented-function-call&quot;&gt;igraph报错：At optimal_modularity.c:85 : GLPK is not available, Unimplemented function call&lt;&#x2F;h3&gt;
&lt;p&gt;先尝试&lt;code&gt;install.packages(&quot;Rglpk&quot;)&lt;&#x2F;code&gt;，然后发现又出现了&lt;code&gt;&#x2F;bin&#x2F;sh: line 0: cd: GLPK: No such file or directory&lt;&#x2F;code&gt;这种奇奇怪怪的错误，我用的是Arch Linux，就直接&lt;code&gt;aurman -S glpk&lt;&#x2F;code&gt;解决掉了。其他distribution应该也是对应补上相应工具就好。&lt;&#x2F;p&gt;
&lt;h3 id=&quot;rstudiochu-shi-hua-yi-zhi-beng-kui-r-encountered-a-fatal-error-unexpected-exception-mutex-creation-failed&quot;&gt;RStudio初始化一直崩溃：R encountered a fatal error.: Unexpected exception: Mutex creation failed&lt;&#x2F;h3&gt;
&lt;p&gt;重启deamon进程也无效。仔细阅读了异常信息之后，发现还&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;r-lib&#x2F;later&#x2F;issues&#x2F;45&quot;&gt;是官方库later的锅&lt;&#x2F;a&gt;。在别的distribution中也许不会暴露出来，但是由于Arch是滚动更新的，emmmm…&lt;&#x2F;p&gt;
&lt;p&gt;尝试&lt;code&gt;install.packages(&#x27;later&#x27;)&lt;&#x2F;code&gt;重装一下，果然还是不行（废话当然不行了）：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sh: line 1: 13260 Aborted                 (core dumped) &amp;#39;&#x2F;usr&#x2F;lib&#x2F;R&#x2F;bin&#x2F;R&amp;#39; --no-save --slave 2&amp;gt;&amp;amp;1 &amp;lt; &amp;#39;&#x2F;tmp&#x2F;RtmpWwYeNo&#x2F;file339a4cc056e4&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;terminate called after throwing an instance of &amp;#39;std::runtime_error&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  what():  Mutex creation failed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ERROR: loading failed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;* removing ‘&#x2F;home&#x2F;ysun&#x2F;R&#x2F;x86_64-pc-linux-gnu-library&#x2F;3.5&#x2F;later’&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;* restoring previous ‘&#x2F;home&#x2F;ysun&#x2F;R&#x2F;x86_64-pc-linux-gnu-library&#x2F;3.5&#x2F;later’&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;The downloaded source packages are in&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        ‘&#x2F;tmp&#x2F;Rtmpr0Mde8&#x2F;downloaded_packages’&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Warning message:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;In install.packages(&amp;quot;later&amp;quot;) :&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  installation of package ‘later’ had non-zero exit status&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这个时候，官方跳出来补救了，在开发版本中更新了，那么&lt;code&gt;devtools::install_github(&quot;r-lib&#x2F;later&quot;)&lt;&#x2F;code&gt;就修复了。&lt;&#x2F;p&gt;
&lt;p&gt;只能说用Arch的都是奉献家…&lt;&#x2F;p&gt;
&lt;h3 id=&quot;install-packages-de-shi-hou-bao-cuo-curl-60-ssl-certificate-problem-certificate-has-expired&quot;&gt;install.packages()的时候报错：curl: (60) SSL certificate problem: certificate has expired&lt;&#x2F;h3&gt;
&lt;p&gt;折腾了半天，最终发现不是本地的问题，直接&lt;code&gt;chooseCRANmirror()&lt;&#x2F;code&gt;换个镜像就好了。&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>如何不方不盲地恢复Linux下误删的文件</title>
        <published>2018-07-02T00:00:00+00:00</published>
        <updated>2018-07-02T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/linuxhui-fu-wu-shan-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/linuxhui-fu-wu-shan-zh/</id>
        
            <content type="html">&lt;h2 id=&quot;bei-ju-de-yuan-you&quot;&gt;杯具的缘由&lt;&#x2F;h2&gt;
&lt;p&gt;太久没回来广州，没用实验室的服务器写东西、算东西。刚刚清用户目录的时候，误删了一个目录，全是过年期间跑数据的中间结果，WTF，有点high。
众所周知，如果没做alias的话，Linux是没有“回收站”这个说法的。也就是说，比如我这样&lt;code&gt;rm -rf workflow&lt;&#x2F;code&gt;把这个叫做workflow的目录删了，那么删了就是删了，那就是彻底删除了。
虽然说按照专业素养，我是肯定有命令啊、参数啊和环境等等的记录的。然鹅算力和时间才是最贵的，平白无故让我再来一轮，我肯定不开心啊！
然后我就想到，老衲其实是可以把它恢复的！&lt;&#x2F;p&gt;
&lt;h2 id=&quot;wo-wei-shen-me-neng-hui-fu-che-di-shan-chu-de-wen-jian&quot;&gt;我为什么能恢复“彻底删除”的文件&lt;&#x2F;h2&gt;
&lt;p&gt;这样，就要提到Linux的文件删除原理了。在Windows下面，删个大文件那是要很久的。但是在Linux下面，由于所谓的删除只是将存储文件的inode和blocks标记为未使用，所以删除是一件甚至根本察觉不到时间流逝的行为！
也就是说，数据其实并未被彻底从硬盘抹去（什么？你说你删除是用&lt;code&gt;dd&lt;&#x2F;code&gt;命令去删的？呵呵呵呵…），只是这块硬盘空间已经被标记为空闲了，其他进程分分钟可以覆盖上面的数据，也就是删除了。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;qiang-jiu-guo-cheng&quot;&gt;抢救过程&lt;&#x2F;h2&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;其实这里有必要提一句，Linux是不会删除进程尚在使用的文件的。所以如果有进程还在使用误删的文件，用&lt;code&gt;lsof&lt;&#x2F;code&gt;配合&lt;code&gt;grep&lt;&#x2F;code&gt;可以很容易将其恢复，具体细节不属于本文记录范围，不详细说了。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote class=&quot;markdown-alert-warning&quot;&gt;
&lt;p&gt;为了防止这块盘再有什么厉害的读&#x2F;写，覆盖了这些“已删除”的文件占用的磁盘空间，是要马上解挂载的。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;挂载之前，我做了一件好事，用&lt;code&gt;ls -di &#x2F;home&#x2F;ysun&lt;&#x2F;code&gt;查看了我目录的inode（说出来你们可能不信，我是编剧，这是一个伟大的伏笔）。服务器上&lt;code&gt;&#x2F;home&lt;&#x2F;code&gt;是挂载到另外一块硬盘（整一个分区）&lt;code&gt;&#x2F;dev&#x2F;sdb1&lt;&#x2F;code&gt;上的。想要&lt;code&gt;umount &#x2F;home&lt;&#x2F;code&gt;，发现不行，设备忙。这个时候可以用&lt;code&gt;fuser -km &#x2F;home&lt;&#x2F;code&gt;强制kill掉占用了&lt;code&gt;&#x2F;home&lt;&#x2F;code&gt;的进程。这个时候就可以解挂载了，然后我用putty开的终端就消失了（因为ssh连接也被kill了）。&lt;&#x2F;p&gt;
&lt;p&gt;为了方便接下来的操作，是想用root登录的。然鹅，发现root居然不可以用ssh登录，顿觉有点不适。又重新用普通用户修改了&lt;code&gt;&#x2F;etc&#x2F;ssh&#x2F;sshd_config&lt;&#x2F;code&gt;的内容，将&lt;code&gt;PermitRootLogin without-password&lt;&#x2F;code&gt;中的&lt;code&gt;without-password&lt;&#x2F;code&gt;改为&lt;code&gt;yes&lt;&#x2F;code&gt;，再用&lt;code&gt;sudo systemctl restart sshd.service&lt;&#x2F;code&gt;重启一下ssh服务，可以了。&lt;&#x2F;p&gt;
&lt;p&gt;上网搜了一圈，一些比较多人用的工具，比如ext3grep，已经不适用与ext4文件系统了。先尝试了extundelete，但是两年多没维护的工具了，各种和现有的软件包冲突，各种Segment Fault，各种Core Dumped（卧槽居然押韵）。冲突就算了，我想把冲突的包降级都不成，那么旧的版本人家都不保留了。去GitHub找了其他人fork过去修改的版本，发现还是跟不上底层库更新的脚步，不好使。&lt;&#x2F;p&gt;
&lt;p&gt;然后就转向了ext4magic。先安装：&lt;code&gt;aurman -S ext4magic&lt;&#x2F;code&gt;。&lt;&#x2F;p&gt;
&lt;p&gt;安装好了之后，先&lt;code&gt;ext4magic &#x2F;dev&#x2F;sdb1 -I 50331649&lt;&#x2F;code&gt;（这串数字就是上文的伏笔了嗯），看看我中午睿智地做了什么:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;ext4magic.png&quot; alt=&quot;ext4magic的输出&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;卧槽，辣眼睛啊！就这么给删了…删了…了…&lt;&#x2F;p&gt;
&lt;p&gt;这个时候，我以迅雷不及掩耳到铃儿响叮当之势掏出了一个小本本，记下了这个被误删的目录的inode值，57606262。
然后&lt;code&gt;ext4magic &#x2F;dev&#x2F;sdb1 -r -I 57606262  -d &#x2F;root&lt;&#x2F;code&gt;尝试恢复：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;%E6%96%87%E4%BB%B6%E6%81%A2%E5%A4%8D%E7%BB%93%E6%9E%9C.png&quot; alt=&quot;文件恢复&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;舒服了啊！
赶紧挂载上硬盘&lt;code&gt;mv&lt;&#x2F;code&gt;走…&lt;&#x2F;p&gt;
&lt;blockquote class=&quot;markdown-alert-note&quot;&gt;
&lt;p&gt;理论上讲，是可以用参数指定时间戳（关于什么是时间戳，那要追溯到1970年了，请百度）来指定时间范围查看文件增删记录的。但是不知道为什么在extundelete里好用，在ext4magic里就瓦特了。比如想获取今天（如果你是好久之后才看到你可能不知道哪天是今天hhhhh）下午2点50的时间戳，那么就&lt;code&gt;date -d &quot;2018-07-02 14:50:00&quot; +&quot;%s&quot;&lt;&#x2F;code&gt;，然后终端内得到的一串数字就是了。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;zong-jie&quot;&gt;总结&lt;&#x2F;h2&gt;
&lt;ol&gt;
&lt;li&gt;Linux没有回收站，可以的话，还是做个alias。我以前也认为“TMD这么蠢的事情我会做吗，不存在的”，然后今天不记得了目录的内容，脑子一热就GG了；&lt;&#x2F;li&gt;
&lt;li&gt;发生意外时，不要慌，虽然自己手贱踩了雷，对操作系统的理解又深刻了一层，长远看来，还是值得的；&lt;&#x2F;li&gt;
&lt;li&gt;还是Linux好啊，辣鸡Windows，动辄要收费**；&lt;&#x2F;li&gt;
&lt;li&gt;Linux果然是好；&lt;&#x2F;li&gt;
&lt;li&gt;Linux真是好啊！&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>Git该如何免密码提交？</title>
        <published>2018-06-27T00:00:00+00:00</published>
        <updated>2018-06-27T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/gitmian-mi-ma-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/gitmian-mi-ma-zh/</id>
        
            <content type="html">&lt;p&gt;早年的时候比较迷，看到GitHub上的ssh key和repo的ssh地址总是傻傻不知道有什么用…然后使用GitLab的private仓库的时候因为强制要求使用ssh key感到很迷茫（因为在GitHub根本用不起）（什么？Student Pack？）（什么？不知道5个根本不够用吗2333333）。今天终于抽点时间解释一下来给后人看。&lt;&#x2F;p&gt;
&lt;p&gt;直到前阵子幡然醒悟，md老子这么久以来为什么一直在用账号密码提交代码？&lt;&#x2F;p&gt;
&lt;p&gt;本文中就不以CMD举例了，反正看这个东西的人，你肯定有一个git bash，这比CMD好用n倍，那么命令都是一样的。&lt;&#x2F;p&gt;
&lt;p&gt;先查看当前用户有已经生成的ssh公钥吗：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; ~&#x2F;.ssh&#x2F;id_rsa.pub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;如果没有，从头生成一个：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;ssh-keygen&lt;&#x2F;span&gt;&lt;span class=&quot;z-string z-punctuation z-definition z-string&quot;&gt; -C &amp;quot;你可以写邮箱，但是无所谓，不加这个参数都无所谓&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;嗯，就是这么简单，对于普通用户而言，什么&lt;code&gt;-t&lt;&#x2F;code&gt;啊&lt;code&gt;-b&lt;&#x2F;code&gt;啊，忘了它们吧。
中间还会提示你选个路径&#x2F;文件名去存放这个key，无所谓，默认最好了，方便。
中间还会提示你输入一个“短语”，我去你*的短语，这就是密码啊…这个可能得找个小本本悄悄记下来了hhhhh，一路回车，然后再来一轮：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; ~&#x2F;.ssh&#x2F;id_rsa.pub&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;是不是有内容了！是不是敲厉害！默默把标准输出复制下来吧！&lt;&#x2F;p&gt;
&lt;p&gt;然后去GitHub（当然GitLab什么的同理啦）找到设置再找到SSH key那项，选择New（账户设置啊，别去repo设置玩半天），把之前复制的内容贴进去。写个妥善的Title（比如这是你何年何月何日在何地结缘的电脑，网吧什么的你还是别搞什么SSH key这种幺蛾子了），让自己记住是干嘛用的。&lt;&#x2F;p&gt;
&lt;p&gt;好了，这个时候估计你就会和以前的我一样开始玩蛋：
兴高采烈地push了一波发现输入账号和密码的提示又出来了！
因为你其实之前就是通过https方式访问repo的，改成ssh就好了，比如这样：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;git&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; remote rm origin&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;git&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; remote add origin git@你那个仓库的地址（详见下图）.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;当然，如果你之前没有clone过仓库，那就直接从git地址克隆就没毛病了。&lt;&#x2F;p&gt;
&lt;p&gt;之后再push就无痛了。&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>如何优雅地在Linux操作系统下用CPU挖矿</title>
        <published>2018-05-31T00:00:00+00:00</published>
        <updated>2018-05-31T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/wa-kuang-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/wa-kuang-zh/</id>
        
            <content type="html">&lt;p&gt;这是一篇“散文”，记录一下最近用CPU挖矿的曲折的折腾过程。&lt;&#x2F;p&gt;
&lt;p&gt;首先先来BB一下动机：手里是有一台PC的，没错，你没看错，一台普通台式机，其实无法通过这件事为我带来任何收益，但是出于对区块链的浓厚兴趣，我出手了。&lt;&#x2F;p&gt;
&lt;p&gt;我瞄准的币种是&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;karbo.io&#x2F;&quot;&gt;Karbo&lt;&#x2F;a&gt;（卡博币），那么为什么选这个呢，因为很多币（比如比特币）用CPU已然挖不动了。随着全网算力的提升，一些热门币种陆陆续续被大量计算出来，现如今计算的难度越来越大，对应的挖矿设备已经经历了CPU -&amp;gt; GPU -&amp;gt; 专用矿机这个历程。我不是专门的挖矿大户，顶多算是兴趣爱好者，当然能从中获利我也很开心。这个币现在很贱，之前更贱。坦白讲，最近几个月的一些涨幅才让我对其升值有了一定的信心。虚拟货币现在很多，这里面存在一个矛盾：如果玩的人少，市场不活跃，币就没有价值；如果玩的人太多，矿工会大量涌入，之后就重复了比特币的历程，又是一般玩家玩不起的了（不信可以去试试，个体户买一台矿机，挖几年能挖出一枚比特币哦）。我认为Karbo刚刚处在这样一个合适的阶段，所以选择了它。&lt;&#x2F;p&gt;
&lt;p&gt;挖矿，首先要有一个钱包。钱包很容易弄，懒得写了。&lt;&#x2F;p&gt;
&lt;p&gt;然后就是一个很有趣的问题，挖矿，其实本质上就是算hash值。那么这个计算的程序，也就是挖矿程序用什么好呢？我搜索了一圈，似乎&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;fireice-uk&#x2F;xmr-stak&quot;&gt;xmr-stak&lt;&#x2F;a&gt;还是比较科学的，支持CPU&#x2F;A卡&#x2F;N卡，支持Windows&#x2F;Linux&#x2F;macOS，支持的币种多，口碑也不错，算是挖矿程序里的佼佼者了。&lt;&#x2F;p&gt;
&lt;p&gt;很遗憾，截至我书写这篇日记的时候，软件的docker镜像并不可用，否则应该是很方便的。编译安装比较中规中矩，作者在文档里给出了常见的Linux distribution的对应命令，也不想多说了。重点谈一个坑：&lt;&#x2F;p&gt;
&lt;p&gt;国际惯例，挖矿工具的作者，是会从计算过程中“抽水”的。一般来讲，默认会抽2%，xmr-stak也是采用了这个值。这个2%，其实就是每计算100分钟，其中有两分钟是为作者的钱包计算&#x2F;提交hash值，可以理解为是一种持续捐献、鼓励和支持作者继续开发的团结友爱的行为。作者在此处体现出了充分的人道主义精神，指出了源码中控制捐献比例的变量的位置，允许用户在编译程序之前自行修改：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;fireice-uk&#x2F;xmr-stak&#x2F;blob&#x2F;c0ab1734332d6472225d8ac7394f6fcba71aabc9&#x2F;xmrstak&#x2F;donate-level.hpp&quot;&gt;xmrstak&#x2F;donate-level.hpp&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-storage z-type&quot;&gt;constexpr double&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; fDevDonationLevel &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 2.0&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; &#x2F;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 100.0&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;一个中规中矩的double类型常量，看起来没什么不妥。可是这个时候我的好奇心膨胀了，我很关心作者是如何实现这个捐献的逻辑的。另外也有一个疑问：对于完全不捐献的人，会怎样处理，真的颗粒无收吗？假如人人都在编译之前手动修改了源码中这个常量的值为0.0，那么程序岂不是白写了…&lt;&#x2F;p&gt;
&lt;p&gt;于是我搜索了整个代码仓库内含有&lt;code&gt;fDevDonationLevel&lt;&#x2F;code&gt;常量的代码，发现了一些端倪。先看这一部分：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;fireice-uk&#x2F;xmr-stak&#x2F;blob&#x2F;26a5d65f12b2f19a0a3ece39a2bc64718796367b&#x2F;xmrstak&#x2F;misc&#x2F;executor.hpp&quot;&gt;xmrstak&#x2F;misc&#x2F;executor.hpp&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;cpp&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;&#x2F;&#x2F; Dev donation time period in seconds. 100 minutes by default.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;&#x2F;&#x2F; We will divide up this period according to the config setting&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-storage z-type&quot;&gt;constexpr static size_t&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; iDevDonatePeriod &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 100&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; *&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 60&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-storage z-type&quot;&gt;inline bool&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt; is_dev_time&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;{&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;    &#x2F;&#x2F;Add 2 seconds to compensate for connect&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-storage z-modifier z-storage z-type&quot;&gt;    constexpr size_t&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; dev_portion &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;= static_cast&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;size_t&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-storage z-type&quot;&gt;double&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt;iDevDonatePeriod&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; *&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; fDevDonationLevel &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;+&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 2.&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;    if&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;(&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt;dev_portion &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-numeric&quot;&gt; 12&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt; &#x2F;&#x2F;No point in bothering with less than 10s&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;        return&lt;&#x2F;span&gt;&lt;span class=&quot;z-constant z-language z-false&quot;&gt; false&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-keyword&quot;&gt;    return&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;get_timestamp&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;()&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; -&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; dev_timestamp&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;)&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; %&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; iDevDonatePeriod &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;&amp;gt;=&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt; (&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt;iDevDonatePeriod &lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt;-&lt;&#x2F;span&gt;&lt;span class=&quot;z-source&quot;&gt; dev_portion&lt;&#x2F;span&gt;&lt;span class=&quot;z-punctuation&quot;&gt;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation&quot;&gt;};&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;is_dev_time()&lt;&#x2F;code&gt;是一个返回值为bool类型的函数。作者将每100分钟看作一份，然后从中抽出以百分比计数的若干分钟来作为捐献。这里计算了一个&lt;code&gt;dev_portion&lt;&#x2F;code&gt;变量：&lt;code&gt;iDevDonatePeriod&lt;&#x2F;code&gt;常量将这一百分钟换算为秒，之后将其与&lt;code&gt;fDevDonationLevel&lt;&#x2F;code&gt;（用户决定的捐献比例）相乘，再加2（姑且可以认为这是为了方便计算，小数点是为了方便double类型相加）。然后我留意到下面有一个&lt;code&gt;if&lt;&#x2F;code&gt;分支，对于这个值小于12（每100分钟，也就是6000秒内，捐献给作者的计算时间低于10，因为之前加了2），函数将直接返回一个&lt;code&gt;false&lt;&#x2F;code&gt;。那么这个&lt;code&gt;false&lt;&#x2F;code&gt;的返回值又有什么用呢？我继续搜索了调用函数&lt;code&gt;is_dev_time()&lt;&#x2F;code&gt;的代码，发现了这样&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;fireice-uk&#x2F;xmr-stak&#x2F;blob&#x2F;c0ab1734332d6472225d8ac7394f6fcba71aabc9&#x2F;xmrstak&#x2F;misc&#x2F;executor.cpp&quot;&gt;一处&lt;&#x2F;a&gt;，看完作者复杂的矿池切换逻辑，瞬间觉得后背一凉，想了下还是保留一点“良知”，适当调低了捐献比例（我是觉得2%有点高），编译，通过。&lt;&#x2F;p&gt;
&lt;p&gt;运行的时候，开始遇到了错误：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;MEMORY ALLOC FAILED: mmap failed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这个好说，只要&lt;code&gt;sudo sysctl -w vm.nr_hugepages=128&lt;&#x2F;code&gt;就解决了。&lt;&#x2F;p&gt;
&lt;p&gt;万事俱备，只欠开挖。开挖之前，是想把进程做点手脚的。理由很简单，被人发现在挖矿就不好了，就变成了挖社会主义墙脚，薅社会主义羊毛。想隐藏进程，首先就要深刻理解常见进程查看工具，比如&lt;code&gt;top&lt;&#x2F;code&gt;、&lt;code&gt;ps&lt;&#x2F;code&gt;和&lt;code&gt;lsof&lt;&#x2F;code&gt;这些的原理。这里要用到一个超强的系统挖掘工具，叫做&lt;code&gt;sysdig&lt;&#x2F;code&gt;，它不仅仅在监控细节上更“深入”，甚至还能对容器（比如docker）等进行监控。使用&lt;code&gt;sysdig&lt;&#x2F;code&gt;监控&lt;code&gt;ps&lt;&#x2F;code&gt;时可以看到&lt;code&gt;ps&lt;&#x2F;code&gt;的大概工作原理：&lt;&#x2F;p&gt;
&lt;p&gt;用一些底层的函数，比如&lt;code&gt;openat()&lt;&#x2F;code&gt;和&lt;code&gt;getdents()&lt;&#x2F;code&gt;去解析&lt;code&gt;&#x2F;proc&lt;&#x2F;code&gt;目录的内容。比如在终端内运行&lt;code&gt;ls &#x2F;proc&lt;&#x2F;code&gt;，可以看到如下输出：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;proc%E7%9B%AE%E5%BD%95%E7%9A%84%E5%86%85%E5%AE%B9.png&quot; alt=&quot;&#x2F;proc目录内容&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;这些数字就是对应每个进程的PID。每个进程在创建伊始，都会在&lt;code&gt;&#x2F;proc&lt;&#x2F;code&gt;下生成这样的一个目录，里面保存了很多信息。如果你是一只生信狗，看这篇日记的时候就应该想到，当你提交了一条任务，跑了很久都没跑完，以至于你都不记得当初把它提交时用的命令行参数了，怎么办？别担心，只要&lt;code&gt;cat &#x2F;proc&#x2F;PID&#x2F;cmdline&lt;&#x2F;code&gt;就可以看到万恶♂之源（误）：&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;legacy-assets&#x2F;my-website&#x2F;img&#x2F;post_img&#x2F;cmdline%E7%9A%84%E5%86%85%E5%AE%B9.png&quot; alt=&quot;cmdline的内容&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;看来这里52329这个进程，就是一个sftp服务。除此之外，还可以查看进程状态、一些统计信息等等。&lt;&#x2F;p&gt;
&lt;p&gt;然鹅，虽然知道了&lt;code&gt;ps&lt;&#x2F;code&gt;这些程序是这样的工作原理，但是其实&lt;code&gt;openat()&lt;&#x2F;code&gt;和&lt;code&gt;getdents()&lt;&#x2F;code&gt;也不是根源，它们也要调用更为底层的C标准库（&lt;code&gt;libc&lt;&#x2F;code&gt;），里面提供了两个函数：&lt;code&gt;opendir()&lt;&#x2F;code&gt;和&lt;code&gt;readdir()&lt;&#x2F;code&gt;。到目前为止，把进程藏起来大概可以有这样几个思路：&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;对类似SELinux这样的子系统做手脚。但是并不推荐，首先不好改，其次，服务器管理员可能一早就睿智地把它关了。&lt;&#x2F;li&gt;
&lt;li&gt;把&lt;code&gt;top&lt;&#x2F;code&gt;、&lt;code&gt;ps&lt;&#x2F;code&gt;和&lt;code&gt;lsof&lt;&#x2F;code&gt;这些程序的二进制可执行文件改了。这个切实可行，但是你就要去改源码。有几个类似的工具，就改几次，它更新，你再去改…再编译。有点蠢。&lt;&#x2F;li&gt;
&lt;li&gt;改掉&lt;code&gt;libc&lt;&#x2F;code&gt;。既然大家都在用&lt;code&gt;libc&lt;&#x2F;code&gt;的&lt;code&gt;readdir()&lt;&#x2F;code&gt;，不如就一次性把这里改掉，让它查看不到某些进程在&lt;code&gt;&#x2F;proc&lt;&#x2F;code&gt;里面的内容就好了。&lt;&#x2F;li&gt;
&lt;li&gt;直接修改内核对诸如&lt;code&gt;getdents()&lt;&#x2F;code&gt;函数的调用方式。&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;这里利用一下Linux的预加载动态链接库的特性。捣鼓一个假的&lt;code&gt;readdir()&lt;&#x2F;code&gt;函数出来，加入操作系统的预加载列表内。之后再调用系统的&lt;code&gt;readdir()&lt;&#x2F;code&gt;函数的时候，由于函数签名相同，早就已经被覆盖掉，是一个假的&lt;code&gt;readdir()&lt;&#x2F;code&gt;了。逻辑也很简单，发现进程名称和设定的一致，就&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;gianlucaborello&#x2F;libprocesshider&#x2F;blob&#x2F;890e3cf3f8cf3d2edf214c7ac1275b7c3ced15a9&#x2F;processhider.c&quot;&gt;跳过&lt;&#x2F;a&gt;。这里借用一下人家的轮子：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 先克隆下来&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;git&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; clone git@github.com:gianlucaborello&#x2F;libprocesshider.git&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; libprocesshider&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 编译&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;make&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 把编译好的动态链接库放好&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; mv libprocesshider.so &#x2F;usr&#x2F;local&#x2F;lib&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 加入预加载列表&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 这一行要用root账户添加&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-support z-function z-builtin&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;usr&#x2F;local&#x2F;lib&#x2F;libprocesshider.so&lt;&#x2F;span&gt;&lt;span class=&quot;z-keyword z-operator&quot;&gt; &amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; &#x2F;etc&#x2F;ld.so.preload&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;自此，随便挖，别人根本不知道电费流向了哪里。&lt;&#x2F;p&gt;
&lt;p&gt;本来昨天写到这是结束了的，然鹅我意识到一个蛋疼的问题。老子自己都查不到这个进程的PID，kill不掉啊！
只能用睿智的sysdig去解决了！于是&lt;code&gt;aurman -S sysdig&lt;&#x2F;code&gt;尝试安装，发现：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(1&#x2F;2) Install DKMS modules&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;==&amp;gt; Unable to install module sysdig&#x2F;0.21.0 for kernel 4.14.48-2-MANJARO: Missing kernel headers.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这个其实不影响…但是也确实可以&lt;code&gt;aurman -S linux414-headers&lt;&#x2F;code&gt;修复一下。
然后使用sysdig查看CPU占用最多的进程：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; sysdig -c topprocs_cpu&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;CPU%                Process             PID&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;--------------------------------------------------------------------------------&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10212&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10197&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10203&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10204&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10185&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10189&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10214&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10196&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10216&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;100.03%             &amp;lt;NA&amp;gt;                10206&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;这里是比较迂回了…因为PID确实被隐藏了…但是也不用担心，kill掉一个就全死了…大刀一挥死一片鬼子啊…
舒服了舒服了…&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>如何优雅地在Linux操作系统下翻墙（客户端篇）</title>
        <published>2018-05-29T00:00:00+00:00</published>
        <updated>2018-05-29T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/blog/linuxfan-qiang-zh/" type="text/html"/>
        <id>https://www.bigdick.live/blog/linuxfan-qiang-zh/</id>
        
            <content type="html">&lt;p&gt;本文主要介绍如何在Arch Linux下部署client端的SS，考虑到主要也是国人才有这种需求，就直接丢中文版blog了。&lt;&#x2F;p&gt;
&lt;p&gt;废话少说，&lt;code&gt;shadowsocks-libev&lt;&#x2F;code&gt;是C语言编写的轻量版的SS。先安装：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; pacman -S shadowsocks-libev&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;写好配置文件（具体写法就见&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;en&#x2F;blog&#x2F;break-through-gfw&#x2F;&quot;&gt;英文版教程&lt;&#x2F;a&gt;吧，几乎一致的）：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; mkdir &#x2F;etc&#x2F;shadowsocks&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 我理你用nano还是vim还是个什么鬼，就编辑一下文本文件嘛&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 做人呢，最紧要是开心&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; vim &#x2F;etc&#x2F;shadowsocks&#x2F;config.json&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;使用&lt;code&gt;systemctl&lt;&#x2F;code&gt;管理ss的daemon进程（这个在介绍&lt;a href=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;en&#x2F;blog&#x2F;working-on-linux&#x2F;&quot;&gt;Manjaro Linux的使用&lt;&#x2F;a&gt;的时候提过）：&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo z-code&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-punctuation z-definition z-comment z-comment&quot;&gt;# 配置文件的前缀名为config，因此此处为@config&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl enable shadowsocks-libev@config&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl daemon-reload&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-entity z-name z-function&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span class=&quot;z-string&quot;&gt; systemctl start shadowsocks-libev@config&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;最后，使用&lt;code&gt;proxychains-ng&lt;&#x2F;code&gt;做socks5转发。&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;插嘴一句，本身就是齐胖胖他们医院的网络爆炸，所以只好搞这样一出来安装RStudio Server。没想到回到博士课题组修电脑还是用到了hhhhh&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;先用命令&lt;code&gt;sudo pacman -S proxychains-ng&lt;&#x2F;code&gt;安装，然后同样也要写配置，就很简单了，直接&lt;code&gt;sudo vim &#x2F;etc&#x2F;proxychains.conf&lt;&#x2F;code&gt;编辑，把原来&lt;code&gt;[ProxyList]&lt;&#x2F;code&gt;下面的内容去掉，加上&lt;code&gt;socks5 127.0.0.1 1080&lt;&#x2F;code&gt;。&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;proxychains-ng的输出非常烦躁…如果觉得眼睛花，在刚刚的配置文件里面有一行&lt;code&gt;quietmode&lt;&#x2F;code&gt;，把前面的注释取消掉就好了。&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;接下来就是使用了。只要在需要使用代理的命令前面加上&lt;code&gt;proxychains4&lt;&#x2F;code&gt;就可以，比如&lt;code&gt;proxychains4 aurman -S rstudio-server-bin&lt;&#x2F;code&gt;这样。&lt;&#x2F;p&gt;
</content>
        </entry><entry xml:lang="zh-Hans">
        <title>Dota2 自动化脚本</title>
        <published>2016-05-21T00:00:00+00:00</published>
        <updated>2016-05-21T00:00:00+00:00</updated>
        <author>
            <name>孙瑜</name>
        </author>
        <link rel="alternate" href="https://www.bigdick.live/projects/dota2-automation-scripts/" type="text/html"/>
        <id>https://www.bigdick.live/projects/dota2-automation-scripts/</id>
        
            <content type="html">&lt;p&gt;这是 2016 年留下的两个 Dota2 自动化小脚本，按当时状态保留，不作为当前维护的工具。&lt;&#x2F;p&gt;
&lt;h2 id=&quot;xiang-mu-nei-rong&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#xiang-mu-nei-rong&quot; aria-label=&quot;Anchor link for: xiang-mu-nei-rong&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
项目内容&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;bioinformatist&#x2F;bioinformatist.github.io&#x2F;blob&#x2F;main&#x2F;static&#x2F;archives&#x2F;legacy-dota2-automation&#x2F;dota2_lumbering_challenge.py&quot;&gt;Dota2 伐木挑战自动点击脚本&lt;&#x2F;a&gt;：Windows &#x2F; Python 脚本，监听 &lt;code&gt;Ctrl+C&lt;&#x2F;code&gt; 后在固定屏幕区域随机点击 &lt;code&gt;60&lt;&#x2F;code&gt; 秒。&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a class=&quot;external&quot; rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;bioinformatist&#x2F;bioinformatist.github.io&#x2F;blob&#x2F;main&#x2F;static&#x2F;archives&#x2F;legacy-dota2-automation&#x2F;auto_spectate.sh&quot;&gt;Dota2 Source 2 自动观战脚本&lt;&#x2F;a&gt;：Linux &#x2F; X11 脚本，通过 &lt;code&gt;xdotool&lt;&#x2F;code&gt; 激活 Dota2 窗口并定时点击观战入口。&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;fa-mu-tiao-zhan&quot;&gt;&lt;a class=&quot;header-anchor no-hover-padding&quot; href=&quot;#fa-mu-tiao-zhan&quot; aria-label=&quot;Anchor link for: fa-mu-tiao-zhan&quot;&gt;&lt;span class=&quot;link-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
伐木挑战&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;projects&#x2F;dota2-automation-scripts&#x2F;chopping.gif&quot; alt=&quot;自动砍树演示&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;核心思路很直接：键盘触发之后，在游戏区域内模拟鼠标点击。&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;https:&#x2F;&#x2F;www.bigdick.live&#x2F;projects&#x2F;dota2-automation-scripts&#x2F;chopping_result.png&quot; alt=&quot;砍树结果&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
</content>
        <summary type="html">2016 年留下的两个 Dota2 自动化小脚本：伐木挑战自动点击和 Source 2 自动观战。</summary>
        </entry>
</feed>
