AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-56135

giovi321's questions

Martin Hope
giovi321
Asked: 2024-04-06 20:35:45 +0800 CST

解释 badblocks 的输出:什么时候该更换 microSD 卡?

  • 11

语境

我正在运行一个带有 microSD 的树莓派零,因为它是设计的。但是,对于这个特定的应用程序,我无法像通常使用树莓派那样使用只读系统。

客观的

密切关注 microSD 的健康状态(并最终以某种方式收到通知,表明需要更换 microSD)。

问题

  1. 监控 microSD 健康状态的最佳方法是什么(否,fsck因为我无法在系统运行时卸载 microSD);
  2. 就实用性和有效性而言,以下提出的方法是否是最佳解决方案?

提议的方法

我想使用badblocks输出来监视 microSD 的状态,并最终在适当的时候更换它。但什么时候该更换 microSD 呢?多少个坏块算太多?我应该查看写入错误或读取错误还是两者都查看?

我做了以下考虑:microsd 卡会自动重新分配坏块之外的数据。因此,如果 microSD 已满 80%,则有 20% 的块可能会“变坏”,但仍可保持 microSD 运行。添加一点置信区间,我们是否可以说,如果badblocks输出的坏块数量低于空闲空间块的 50%,那么使用 SD 卡仍然是安全的?

澄清:

  • 区块总数:100
  • 可用空间(以块为单位):20
  • 接受损坏的块的最大数量(或其他):10
sd-card
  • 1 个回答
  • 308 Views
Martin Hope
giovi321
Asked: 2023-09-20 18:56:44 +0800 CST

Debian 虚拟机无法连接两个网络适配器

  • 5

我正在使用 VirtualBox 运行多个 Debian 12(主机和来宾)虚拟机。突然间,今天他们开始出现连接问题(即我无法 ping 通 8.8.8.8)。我最近从 Debian 11 升级到 Debian 12。

所有虚拟机都有两个网络适配器:

  • 1个NAT网络适配器
  • 1 个仅主机网络适配器

经过一些测试,我发现删除仅主机网络适配器可以恢复连接。可能是什么问题?这就像系统忽略 NAT 网络适配器并使用没有连接的仅主机网络适配器。

我该如何调试呢?

debian
  • 1 个回答
  • 31 Views
Martin Hope
giovi321
Asked: 2023-05-17 02:03:56 +0800 CST

连接到 samba 共享时出错

  • 5

samba我在 Raspbian 11 设备上运行服务器,我正在尝试从 Ubuntu 20 设备连接到它。

当我打开文件管理器时,我可以看到 samba 共享,但是当我尝试访问它时(使用用户的登录信息homeassistant),我不断收到输入凭据的提示,就好像它们是错误的一样。

在samba服务器的日志中,我只看到如下信息:

[2023/05/16 19:54:06.537441,  0] ../../lib/param loadparm.c:1918(lpcfg_do_service_parameter)
  Global parameter security found in service section!

这是以下结果testparm:

Load smb config files from /etc/samba/smb.conf
Global parameter security found in service section!
Loaded services file OK.
Weak crypto is allowed
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

这是内容smb.conf:

# Global parameters
[global]
    log file = /var/log/samba/log.%m
    logging = file
    map to guest = Bad User
    max log size = 1000
    obey pam restrictions = Yes
    panic action = /usr/share/samba/panic-action %d
    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
    passwd program = /usr/bin/passwd %u
    server role = standalone server
    unix password sync = Yes
    idmap config * : backend = tdb


[home-assistant]
    comment = Home-assistant configuration
    create mask = 0600
    directory mask = 0700
    force user = homeassistant
    path = /home/homeassistant
    read only = No
    valid users = homeassistant

我究竟做错了什么?我在配置文件中没有看到任何“服务部分”。

samba
  • 1 个回答
  • 7 Views
Martin Hope
giovi321
Asked: 2023-04-06 17:22:27 +0800 CST

在 Debian 11 上安装 libc-bin 2.36

  • 5

我需要libc-bin在 Debian 11 上从当前的稳定版本升级到 2.36。我尝试通过从下载 .deb 包来做到这一点http://ftp.us.debian.org/debian/pool/main/g/glibc/libc-bin_2.36-8_amd64.deb,但是当我安装它时dpkg --install package.deb,我无法使用,apt install因为它要求我运行apt --fix-broken install以及何时运行我这样做了,它破坏了一些基本的包并告诉我dpkg: warning: 'ldconfig' not found in PATH or not executable。在那之后,我无法通过 apt install或 via安装任何其他东西dpkg --install package.deb。

我怎样才能在libc-bin 2.36不中断apt且不切换到不稳定频道的情况下安装?

debian
  • 1 个回答
  • 24 Views
Martin Hope
giovi321
Asked: 2023-04-04 23:41:18 +0800 CST

在 Debian 11 上安装、升级、修复时 Apt 返回错误

  • 5

我遇到了以下问题apt:每当我尝试时upgrade,install或者--fix-broken,我都会收到错误消息,并且没有任何升级、安装或修复。

下面是我得到的错误示例。

root@server:~$ apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libicu63 libperl5.28 libreadline7
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "it_IT.UTF-8",
    LC_MONETARY = "it_IT.UTF-8",
    LC_ADDRESS = "it_IT.UTF-8",
    LC_TELEPHONE = "it_IT.UTF-8",
    LC_NAME = "it_IT.UTF-8",
    LC_MEASUREMENT = "it_IT.UTF-8",
    LC_IDENTIFICATION = "it_IT.UTF-8",
    LC_NUMERIC = "it_IT.UTF-8",
    LC_PAPER = "it_IT.UTF-8",
    LANG = "C"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Can't exec "locale": No such file or directory at /usr/share/perl5/Debconf/Encoding.pm line 16.
Use of uninitialized value $Debconf::Encoding::charmap in scalar chomp at /usr/share/perl5/Debconf/Encoding.pm line 17.
Setting up initramfs-tools (0.140) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.140) ...
update-initramfs: Generating /boot/initrd.img-5.10.0-21-amd64
E: no ldd around - install libc-bin
update-initramfs: failed for /boot/initrd.img-5.10.0-21-amd64 with 1.
dpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess returned 
error exit status 1
Errors were encountered while processing:
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

附加信息:

root@server:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/root/work/bin

附加信息 2:

root@server:~$ apt install libc-bin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libc-bin : Depends: libc6 (< 2.32) but 2.36-8 is to be installed
E: Unable to correct problems, you have held broken packages.

我也跑过:dpkg --install libc-bin_2.36-8_amd64.deb

附加信息 3:

root@server:~$ apt install locales
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
 locales : Depends: libc-bin (> 2.31) but it is not going to be installed
           Depends: debconf (>= 0.5) but it is not going to be installed or
                    debconf-2.0
E: Unable to correct problems, you have held broken packages.
root@server:~$ apt install libc-bin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libc-bin is already the newest version (2.36-8).
The following packages were automatically installed and are no longer required:
  libicu63 libperl5.28 libreadline7
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@server:~$ ldd --version ldd
ldd (Debian GLIBC 2.36-8) 2.36
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

附加信息 4:

root@server:~$ apt policy
Package files:
 100 /var/lib/dpkg/status
     release a=now
 100 http://ftp.debian.org/debian bullseye-backports/non-free amd64 Packages
     release o=Debian Backports,a=bullseye-backports,n=bullseye-backports,l=Debian Backports,c=non-free,b=amd64
     origin ftp.debian.org
 100 http://ftp.debian.org/debian bullseye-backports/contrib amd64 Packages
     release o=Debian Backports,a=bullseye-backports,n=bullseye-backports,l=Debian Backports,c=contrib,b=amd64
     origin ftp.debian.org
 100 http://ftp.debian.org/debian bullseye-backports/main amd64 Packages
     release o=Debian Backports,a=bullseye-backports,n=bullseye-backports,l=Debian Backports,c=main,b=amd64
     origin ftp.debian.org
 500 http://security.debian.org/debian-security bullseye-security/main amd64 Packages
     release v=11,o=Debian,a=stable-security,n=bullseye-security,l=Debian-Security,c=main,b=amd64
     origin security.debian.org
 500 http://deb.debian.org/debian bullseye-updates/main amd64 Packages
     release v=11-updates,o=Debian,a=stable-updates,n=bullseye-updates,l=Debian,c=main,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian bullseye/non-free amd64 Packages
     release v=11.6,o=Debian,a=stable,n=bullseye,l=Debian,c=non-free,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian bullseye/contrib amd64 Packages
     release v=11.6,o=Debian,a=stable,n=bullseye,l=Debian,c=contrib,b=amd64
     origin deb.debian.org
 500 http://deb.debian.org/debian bullseye/main amd64 Packages
     release v=11.6,o=Debian,a=stable,n=bullseye,l=Debian,c=main,b=amd64
     origin deb.debian.org
Pinned packages:
debian
  • 1 个回答
  • 30 Views
Martin Hope
giovi321
Asked: 2023-01-18 03:25:27 +0800 CST

无法创建新的系统服务

  • 5

我正在尝试在 raspbian 11 上创建一个新的 systemd 服务,但出现以下错误:

sysctl: cannot stat /proc/sys/homeassistant@homeassistant/service: No such file or directory
sysctl: cannot stat /proc/sys/start: No such file or directory

以下是重现我的错误的步骤:

nano /etc/systemd/system/[email protected]

文件内容:

[Unit]
Description=Home Assistant
After=network-online.target mariadb.service

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass -c "/home/%i/.homeassistant"
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target

启用服务:

sysctl [email protected] enable

我收到的输出:

sysctl: cannot stat /proc/sys/homeassistant@homeassistant/service: No such file or directory
sysctl: cannot stat /proc/sys/start: No such file or directory
systemd
  • 1 个回答
  • 23 Views
Martin Hope
giovi321
Asked: 2021-12-12 05:57:51 +0800 CST

lsblk 和 df 之间的磁盘大小不匹配

  • 1

我最近用一组两个 4TB raid 1 磁盘升级了两个 soft raid1 2TB 磁盘。(请参阅用更大的磁盘替换软 RAID1 LUKS 磁盘)该指南很棒,但是我发现自己的大小有两个不同的结果,我不知道是否相信df -h。

请专注于驱动器/dev/mapper/backup又名/media/backupmd4

root@SRVR:~$ df -h
Filesystem          Size  Used Avail Use% Mounted on
udev                 13G     0   13G   0% /dev
tmpfs               2.6G  888K  2.6G   1% /run
/dev/md127          117G  8.3G  103G   8% /
tmpfs                13G  4.0K   13G   1% /dev/shm
tmpfs               5.0M     0  5.0M   0% /run/lock
/dev/mapper/4tb     3.6T  2.3T  1.2T  67% /media/4tb
/dev/mapper/3tb     2.7T  855G  1.8T  33% /media/3tb
/dev/mapper/vm      1.8T   97G  1.7T   6% /media/vm
/dev/mapper/backup  1.8T  1.5T  238G  87% /media/backup

或相信lsblk:

root@SRVR:~$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda            8:0    0   3.6T  0 disk  
`-sda1         8:1    0   3.6T  0 part  
  `-md4        9:4    0   3.6T  0 raid1 
    `-4tb    253:1    0   3.6T  0 crypt /media/4tb
sdb            8:16   0   3.6T  0 disk  
`-sdb1         8:17   0   3.6T  0 part  
  `-md4        9:4    0   3.6T  0 raid1 
    `-4tb    253:1    0   3.6T  0 crypt /media/4tb
sdc            8:32   0 119.2G  0 disk  
`-sdc1         8:33   0 119.2G  0 part  
  `-md127      9:127  0 119.2G  0 raid1 /
sdd            8:48   0 119.2G  0 disk  
`-sdd1         8:49   0 119.2G  0 part  
  `-md127      9:127  0 119.2G  0 raid1 /
sde            8:64   0 465.8G  0 disk  
`-sde1         8:65   0 465.8G  0 part  
  `-md0        9:0    0 465.6G  0 raid1 
sdf            8:80   0   2.7T  0 disk  
`-sdf1         8:81   0   2.7T  0 part  
  `-3tb      253:2    0   2.7T  0 crypt /media/3tb
sdg            8:96   1   1.8T  0 disk  
`-sdg1         8:97   1   1.8T  0 part  
  `-md1        9:1    0   1.8T  0 raid1 
    `-vm     253:3    0   1.8T  0 crypt /media/vm
sdh            8:112  1   3.6T  0 disk  
`-sdh1         8:113  1   3.6T  0 part  
  `-md2        9:2    0   3.6T  0 raid1 
    `-backup 253:0    0   3.6T  0 crypt /media/backup
sdi            8:128  1   1.8T  0 disk  
`-sdi1         8:129  1   1.8T  0 part  
  `-md1        9:1    0   1.8T  0 raid1 
    `-vm     253:3    0   1.8T  0 crypt /media/vm
sdj            8:144  1   3.6T  0 disk  
`-sdj1         8:145  1   3.6T  0 part  
  `-md2        9:2    0   3.6T  0 raid1 
    `-backup 253:0    0   3.6T  0 crypt /media/backup

并相信mdadm:

root@SRVR:~$ mdadm -D /dev/md4
/dev/md4:
           Version : 1.2
     Creation Time : Tue Oct 20 00:17:12 2020
        Raid Level : raid1
        Array Size : 3906885440 (3725.90 GiB 4000.65 GB)
     Used Dev Size : 3906885440 (3725.90 GiB 4000.65 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Fri Dec 10 16:00:12 2021
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : bitmap

              Name : GC01SRVR:4  (local to host GC01SRVR)
              UUID : 18dfa172:e97bd6ce:9e379633:0e8a0f28
            Events : 57617

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
debian hard-disk
  • 1 个回答
  • 167 Views
Martin Hope
giovi321
Asked: 2021-11-22 04:46:43 +0800 CST

用更大的磁盘替换软 RAID1 LUKS 磁盘

  • 0

我打算用两个相同的(4TB 磁盘)替换两个软 RAID1 磁盘(2TB)。当前磁盘配置有运行 debian 11 的软 RAID 1。这些磁盘不是 root。

我的计划是用一个新的 4TB 磁盘替换(支持热交换)一个 2TB 磁盘,然后等待磁盘与 mdadm 同步(我什至不知道该怎么做,但我想我会谷歌它)。同步结束后,我计划使用剩余的 2TB 磁盘进行相同的热交换,将其替换为另一个新的 4TB 磁盘,然后等待 mdadm 完成同步。

在这一点上,我仍然(希望)发现自己有两个需要扩大的 2TB 分区的 LUKS 磁盘。这个操作很麻烦,但我以前在笔记本电脑上做过,但从来没有使用 RAID1 配置。

  1. 你觉得我的计划有意义吗?
  2. 您能否就如何扩大 RAID 1 LUKS 分区(即我计划的最后一步)提供一些指导?
  3. 还有其他更聪明的选择吗?

根据评论中的要求,以下是以下输出lsblk:

root@server:~$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda            8:0    0   3.6T  0 disk  
`-sda1         8:1    0   3.6T  0 part  
  `-md4        9:4    0   3.6T  0 raid1 
    `-4tb    253:1    0   3.6T  0 crypt /media/4tb
sdb            8:16   0   3.6T  0 disk  
`-sdb1         8:17   0   3.6T  0 part  
  `-md4        9:4    0   3.6T  0 raid1 
    `-4tb    253:1    0   3.6T  0 crypt /media/4tb
sdc            8:32   0 119.2G  0 disk  
`-sdc1         8:33   0 119.2G  0 part  
  `-md127      9:127  0 119.2G  0 raid1 /
sdd            8:48   0 119.2G  0 disk  
`-sdd1         8:49   0 119.2G  0 part  
  `-md127      9:127  0 119.2G  0 raid1 /
sde            8:64   0 465.8G  0 disk  
`-sde1         8:65   0 465.8G  0 part  
  `-md0        9:0    0 465.6G  0 raid1 
sdf            8:80   0   2.7T  0 disk  
`-sdf1         8:81   0   2.7T  0 part  
  `-3tb      253:2    0   2.7T  0 crypt /media/3tb
sdg            8:96   1 931.5G  0 disk  
`-sdg1         8:97   1 931.5G  0 part  
  `-md1        9:1    0 931.4G  0 raid1 
    `-vm     253:3    0 931.4G  0 crypt /media/vm
sdh            8:112  1   1.8T  0 disk  
`-sdh1         8:113  1   1.8T  0 part  
  `-md2        9:2    0   1.8T  0 raid1 
    `-backup 253:0    0   1.8T  0 crypt /media/backup
sdi            8:128  1 931.5G  0 disk  
`-sdi1         8:129  1 931.5G  0 part  
  `-md1        9:1    0 931.4G  0 raid1 
    `-vm     253:3    0 931.4G  0 crypt /media/vm
sdj            8:144  1   1.8T  0 disk  
`-sdj1         8:145  1   1.8T  0 part  
  `-md2        9:2    0   1.8T  0 raid1 
    `-backup 253:0    0   1.8T  0 crypt /media/backup
debian hard-disk
  • 1 个回答
  • 176 Views
Martin Hope
giovi321
Asked: 2021-11-20 14:03:21 +0800 CST

Samba 共享显示错误的磁盘可用空间

  • 0

我有一台虚拟机,用于在家中共享 samba。它将数据存储在主机的共享文件夹中。在主机和来宾计算机上,此特定(和其他)驱动器的总空间和可用空间都正确显示。主机和来宾机器正在运行 Debian 11。

但是,当我尝试从笔记本电脑将文件复制到 samba 共享时,它说只有 16GB 可用空间(实际上是 1.4TB 可用空间),我被迫使用 FTP 连接。笔记本电脑运行的是 Ubuntu 20。

我可以尝试的只是我在 stackechange 上找到的内容,其中提到将这两行添加到配置中

   dfree command = /usr/local/samba/bin/dfree
   allocation roundup size = 4096

我做了,但没有成功。

如果需要,下面是我的 smb.conf 文件。

#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which 
# are not shown in this example
#
# Some options that are often worth tuning have been included as
# commented-out examples in this file.
#  - When such options are commented with ";", the proposed setting
#    differs from the default Samba behaviour
#  - When commented with "#", the proposed setting is the default
#    behaviour of Samba but the option is considered important
#    enough to be mentioned here
#
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic 
# errors. 

#======================= Global Settings =======================

[global]

   dfree command = /usr/local/samba/bin/dfree
   allocation roundup size = 4096
## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP

#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
   interfaces = enp0s9

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine iss: cannot access '/usr/local/samba/bin': No such file or directory

根@GC01fileSRVR:~$

# not protected by a firewall or is a firewall itself.  However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
   bind interfaces only = yes



#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# that connects
   log file = /var/log/samba/log.%m

# Cap the size of the individual log files (in KiB).
   max log size = 1000

# We want Samba to only log to /var/log/samba/log.{smbd,nmbd}.
# Append syslog@1 if you want important messages to be sent to syslog too.
   logging = file

# Do something sensible when Samba crashes: mail the admin a backtrace
   panic action = /usr/share/samba/panic-action %d


####### Authentication #######

# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller". 
#
# Most people will want "standalone server" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
   server role = standalone server

   obey pam restrictions = yes

# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
   unix password sync = yes

# For Unix password sync to work on a Debian GNU/Linux system, the following
# parameters must be set (thanks to Ian Kahan <<[email protected]> for
# sending the correct chat script for the passwd program in Debian Sarge).
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

# This boolean controls whether PAM will be used for password changes
# when requested by an SMB client instead of the program listed in
# 'passwd program'. The default is 'no'.
   pam password change = yes

# This option controls how unsuccessful authentication attempts are mapped
# to anonymous connections
   map to guest = bad user

########## Domains ###########

#
# The following settings only takes effect if 'server role = primary
# classic domain controller', 'server role = backup domain controller'
# or 'domain logons' is set 
#

# It specifies the location of the user's
# profile directory from the client point of view) The following
# required a [profiles] share to be setup on the samba server (see
# below)
;   logon path = \\%N\profiles\%U
# Another common choice is storing the profile in the user's home directory
# (this is Samba's default)
#   logon path = \\%N\%U\profile

# The following setting only takes effect if 'domain logons' is set
# It specifies the location of a user's home directory (from the client
# point of view)
;   logon drive = H:
#   logon home = \\%N\%U

# The following setting only takes effect if 'domain logons' is set
# It specifies the script to run during logon. The script must be stored
# in the [netlogon] share
# NOTE: Must be store in 'DOS' file format convention
;   logon script = logon.cmd

# This allows Unix users to be created on the domain controller via the SAMR
# RPC pipe.  The example command creates a user account with a disabled Unix
# password; please adapt to your needs
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u

# This allows machine accounts to be created on the domain controller via the 
# SAMR RPC pipe.  
# The following assumes a "machines" group exists on the system
; add machine script  = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u

# This allows Unix groups to be created on the domain controller via the SAMR
# RPC pipe.  
; add group script = /usr/sbin/addgroup --force-badname %g

############ Misc ############

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting
;   include = /home/samba/etc/smb.conf.%m

# Some defaults for winbind (make sure you're not using the ranges
# for something else.)
;   idmap config * :              backend = tdb
;   idmap config * :              range   = 3000-7999
;   idmap config YOURDOMAINHERE : backend = tdb
;   idmap config YOURDOMAINHERE : range   = 100000-999999
;   template shell = /bin/bash

# Setup usershare options to enable non-root users to share folders
# with the net usershare command.

# Maximum number of usershare. 0 means that usershare is disabled.
#   usershare max shares = 100

# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
   usershare allow guests = yes

#======================= Share Definitions =======================

[MediaServer]
   comment = Home Directories
   browseable = yes
   path = /media
   guest ok = no
   read only = no
   create mask = 0600
   directory mask = 0700
   security = user
   encrypt passwords = yes

跑步

ls /usr/local/samba/bin

返回

ls: cannot access '/usr/local/samba/bin': No such file or directory

跑步

whereis samba

返回

samba: /usr/sbin/samba /usr/lib/x86_64-linux-gnu/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz

一些日志:

[2021/11/21 15:21:23.198342,  2] ../../source3/smbd/reply.c:747(reply_special)
  netbios connect: local=192.168.1.159 remote=gc01pc, name type = 0
networking debian
  • 1 个回答
  • 1365 Views
Martin Hope
giovi321
Asked: 2021-11-20 10:54:58 +0800 CST

试图将复杂的 bash 字符串放入 mqtt 消息中

  • 0

我正在尝试拟合以下字符串的输出(这是一个简单的数字)

df -hl | grep '/dev/mapper/4tb' | awk '{;percent+=$5;} END{print percent}' | column -t

进入以下 mqtt 消息

mosquitto_pub -h 192.168.1.1 -p 1883 -u user -P password -t disk_usage/4tb -m *[here sould go the output of the previous command]*

我已经尝试了以下脚本及其许多变体(不同的引号和括号等),但我仍然无法弄清楚。

#!/bin/sh
var1='{df -hl | grep '/dev/mapper/4tb' | awk '{;percent+=$5;} END{print percent}' | column -t}'
echo $var1

mosquitto_pub -h 192.168.1.65 -p 1883 -u mqtt -P mqtt_password -t GC01SRVR/disk_usage -m "{\"Content\": $var1}"
bash shell-script
  • 1 个回答
  • 66 Views
Martin Hope
giovi321
Asked: 2019-12-10 10:24:16 +0800 CST

如何使用 systemd 连续运行脚本

  • 1

我编写了一个非常简单的脚本 ( checkaudio.sh),它从 mqtt 主题的文件中发布消息。我希望脚本连续运行(即使每一秒我都会很高兴)。我首先尝试使用 cron,这在技术上是可行的,但作为一种解决方案是“肮脏的”(多个 cron 作业,每个作业延迟 1 秒)。

我已经尝试过systemd及其timer功能。我对systemd不是很精通,这就是我想出的:

/etc/systemd/system/[email protected]内容:

[Unit]
Description=Announce every second

[Install]
WantedBy=default.target

[Service]
Type=oneshot
ExecStart=/root/checkaudio.sh

/etc/systemd/system/[email protected]内容:

[Timer]
OnUnitActiveSec=1s
AccuracySec=1ms
[email protected]

我通过 激活了上面的两个systemctl enable。一切都运行顺利,直到我重新启动系统并且我无法再启用/etc/systemd/system/[email protected]。我收到以下错误:

The unit files have no installation config (WantedBy, RequiredBy, Also, Alias
settings in the [Install] section, and DefaultInstance for template units).
This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
   .wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
   a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
   D-Bus, udev, scripted systemctl call, ...).
4) In case of template units, the unit is meant to be enabled with some
   instance name specified.

我究竟做错了什么?有没有更好的方法来实现我连续运行脚本的初始目标?

systemd systemd-timer
  • 1 个回答
  • 877 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve