分类: Linux Development

  • logname

    A utility of coreutils, which Print the name of the current user

    Posix API: getlogin

  • 无法创建 VMFS 数据存储 music – 无法更改主机配置

    Detach the disk from vmware console

    Enable vmware SSH

    ssh login

    esxcli storage core path list

    ls -ltrh /vmfs/devices/disks/

    partedUtil getptbl “/vmfs/devices/disk/t10.ATA_____WDC_WD40EFRX2D68WT0N0_________________________WD2DWCC4ENXFK993”

    partedUtil setptbl “/vmfs/devices/disk/t10.ATA_____WDC_WD40EFRX2D68WT0N0_________________________WD2DWCC4ENXFK993” msdos

  • Web audio codec guide

    https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Audio_codecs

    Type

    audio/ogg

    codecs= FLAC

    codecs= Opus

    codecs= Vorbis

    audio/mp4

    codecs= AAC

    codecs= FLAC

    codecs= mp3

    codecs= Opus

    codecs= ALAC

    audio/wave

    audio/wav

    audio/x-wav

    audio/x-pn-wav

    audio/mp3

    audio/mpeg

    audio/webm

    codecs= Opus

    codecs= Vorbis

    audio/3gpp

    audio/3gpp2

    audio/aac

    audio/flac

    audio/x-flac

    Ogg/opus is great for music over internet:

    High quality, Simple software implementation, and Free.

    but not support by iPad/iPhone

    Mp4/AAC LC is the best selection for music over internet for Apple mobile product.

    In LAN, we can select Loseloss codec:

    Android: Ogg/FLAC

    iPad/iPhone: Mp4/ALAC

  • Creating udev rule for USB DAC

    Target:

    Create a new udev rule which will:

    Stop the Jack Daemon if DAC power off

    Start the Jack Daemon if DAC power on

    Identify USB DAC Card:

    Power on USB DAC

    Check the name of USB DAC

    ls -l /proc/asound/
    lrwxrwxrwx 1 root root 5 11月 22 17:55 AUDIO -> card2
    dr-xr-xr-x 3 root root 0 11月 16 18:43 card0
    dr-xr-xr-x 4 root root 0 11月 16 18:43 card1
    dr-xr-xr-x 4 root root 0 11月 22 17:55 card2
    -r–r–r– 1 root root 0 11月 16 16:36 cards
    -r–r–r– 1 root root 0 11月 16 18:43 devices
    lrwxrwxrwx 1 root root 5 11月 16 18:43 Generic -> card0
    -r–r–r– 1 root root 0 11月 16 18:43 hwdep
    -r–r–r– 1 root root 0 11月 16 18:43 modules
    dr-xr-xr-x 2 root root 0 11月 16 18:43 oss
    -r–r–r– 1 root root 0 11月 16 18:43 pcm

    card2 is the name of DAC Card

    ls  /sys/class/sound
    card0  card2      controlC1  hwC0D0  pcmC0D3p  pcmC1D0p  pcmC2D0p
    card1  controlC0  controlC2  hwC1D0  pcmC1D0c  pcmC2D0c  timer
    
    
    

    Get the Attr List of card2

    udevadm info /sys/class/sound/card2
    P: /devices/pci0000:00/0000:00:12.0/usb2/2-4/2-4:1.0/sound/card2
    L: 0
    E: DEVPATH=/devices/pci0000:00/0000:00:12.0/usb2/2-4/2-4:1.0/sound/card2
    E: SUBSYSTEM=sound
    E: USEC_INITIALIZED=523137960408
    E: ID_PATH=pci-0000:00:12.0-usb-0:4:1.0
    E: ID_PATH_TAG=pci-0000_00_12_0-usb-0_4_1_0
    E: ID_FOR_SEAT=sound-pci-0000_00_12_0-usb-0_4_1_0
    E: SOUND_INITIALIZED=1
    E: ID_VENDOR_FROM_DATABASE=Actions Semiconductor Co., Ltd
    E: ID_VENDOR=ACTIONS
    E: ID_VENDOR_ENC=ACTIONS
    E: ID_VENDOR_ID=10d6
    E: ID_MODEL=USB_AUDIO
    E: ID_MODEL_ENC=USB\x20AUDIO
    E: ID_MODEL_ID=dd01
    E: ID_REVISION=0100
    E: ID_SERIAL=ACTIONS_USB_AUDIO_4512482ADF0FEEEE
    E: ID_SERIAL_SHORT=4512482ADF0FEEEE
    E: ID_TYPE=audio
    E: ID_BUS=usb
    E: ID_USB_INTERFACES=:010100:010200:030000:
    E: ID_USB_INTERFACE_NUM=00
    E: ID_USB_DRIVER=snd-usb-audio
    E: ID_ID=usb-ACTIONS_USB_AUDIO_4512482ADF0FEEEE-00
    E: SYSTEMD_WANTS=sound.target
    E: TAGS=:systemd:seat:
    
    udevadm info --path=/sys/class/sound/card2 --attribute-walk
    
    looking at device '/devices/pci0000:00/0000:00:12.0/usb2/2-4/2-4:1.0/sound/card2':
        KERNEL=="card2"
        SUBSYSTEM=="sound"
        DRIVER==""
        ATTR{number}=="2"
        ATTR{id}=="AUDIO"
    
      looking at parent device '/devices/pci0000:00/0000:00:12.0/usb2/2-4/2-4:1.0':
        KERNELS=="2-4:1.0"
        SUBSYSTEMS=="usb"
        DRIVERS=="snd-usb-audio"
        ATTRS{supports_autosuspend}=="1"
        ATTRS{bInterfaceProtocol}=="00"
        ATTRS{authorized}=="1"
        ATTRS{bNumEndpoints}=="00"
        ATTRS{bInterfaceClass}=="01"
        ATTRS{bInterfaceNumber}=="00"
        ATTRS{bInterfaceSubClass}=="01"
        ATTRS{bAlternateSetting}==" 0"
    
      looking at parent device '/devices/pci0000:00/0000:00:12.0/usb2/2-4':
        KERNELS=="2-4"
        SUBSYSTEMS=="usb"
        DRIVERS=="usb"
        ATTRS{devpath}=="4"
        ATTRS{bDeviceProtocol}=="00"
        ATTRS{bmAttributes}=="c0"
        ATTRS{quirks}=="0x0"
        ATTRS{tx_lanes}=="1"
        ATTRS{product}=="USB AUDIO"
        ATTRS{busnum}=="2"
        ATTRS{bcdDevice}=="0100"
        ATTRS{bNumConfigurations}=="1"
        ATTRS{manufacturer}=="ACTIONS"
        ATTRS{bNumInterfaces}==" 4"
        ATTRS{bDeviceClass}=="00"
        ATTRS{configuration}==""
        ATTRS{maxchild}=="0"
        ATTRS{devnum}=="20"
        ATTRS{serial}=="4512482ADF0FEEEE"
        ATTRS{bMaxPower}=="300mA"
        ATTRS{idVendor}=="10d6"
        ATTRS{bDeviceSubClass}=="00"
        ATTRS{urbnum}=="25748"
        ATTRS{idProduct}=="dd01"
        ATTRS{version}==" 1.00"
        ATTRS{removable}=="unknown"
        ATTRS{authorized}=="1"
        ATTRS{bMaxPacketSize0}=="64"
        ATTRS{speed}=="12"
        ATTRS{rx_lanes}=="1"
        ATTRS{lATTRS{avoid_reset_quirk}=="0"
        ATTRS{bConfigurationValue}=="1"
    
      looking at parent device '/devices/pci0000:00/0000:00:12.0/usb2':
        KERNELS=="usb2"
        SUBSYSTEMS=="usb"DRIVERS=="usb"
        ATTRS{configuration}==""
        ATTRS{idProduct}=="0001"
        ATTRS{version}==" 1.10"
        ATTRS{tx_lanes}=="1"
        ATTRS{bNumInterfaces}==" 1"
        ATTRS{bDeviceClass}=="09"
        ATTRS{removable}=="unknown"
        ATTRS{authorized_default}=="1"
        ATTRS{bDeviceSubClass}=="00"
        ATTRS{interface_authorized_default}=="1"
        ATTRS{busnum}=="2"
        ATTRS{bDeviceProtocol}=="00"
        ATTRS{bMaxPower}=="0mA"
        ATTRS{quirks}=="0x0"
        ATTRS{speed}=="12"
        ATTRS{bcdDevice}=="0419"
        ATTRS{maxchild}=="5"
        ATTRS{idVendor}=="1d6b"
        ATTRS{devpath}=="0"
        ATTRS{manufacturer}=="Linux 4.19.0-9-amd64 ohci_hcd"
        ATTRS{avoid_reset_quirk}=="0"
        ATTRS{bMaxPacketSize0}=="64"
        ATTRS{rx_lanes}=="1"
        ATTRS{bmAttributes}=="e0"
        ATTRS{urbnum}=="511"
        ATTRS{bNumConfigurations}=="1"
        ATTRS{product}=="OHCI PCI host controller"
        ATTRS{serial}=="0000:00:12.0"
        ATTRS{bConfigurationValue}=="1"
        ATTRS{ltm_capable}=="no"
        ATTRS{devnum}=="1"
        ATTRS{authorized}=="1"
    
        
    
    # Get kernel prop
    udevadm monitor --kernel --property --subsystem-match=usb
    monitor will print the received events for:
    KERNEL - the kernel uevent
    
    KERNEL[1083.319560] add      /devices/pci0000:00/0000:00:12.0/usb2/2-4 (usb)
    ACTION=add
    DEVPATH=/devices/pci0000:00/0000:00:12.0/usb2/2-4
    SUBSYSTEM=usb
    DEVNAME=/dev/bus/usb/002/002
    DEVTYPE=usb_device
    PRODUCT=10d6/dd01/100
    TYPE=0/0/0
    BUSNUM=002
    DEVNUM=002
    SEQNUM=2112
    MAJOR=189
    MINOR=129

    Write your udev rule based on selected attrs

    cat /opt/local/libexec/udev/rules.d/99-AD-86d.rules

    ACTION=="add",SUBSYSTEM=="sound",ATTR{id}=="AUDIO",RUN+="/opt/local/bin/add_ad_86d.sh"
    ACTION=="remove",SUBSYSTEM=="usb",ATTRS{idVendor}=="10d6",ATTRS{idProduct}=="dd01",RUN+="/opt/local/bin/remove_ad_86d.sh"
  • mysql server with GTID log-bin

    Mysql Master Server:

         ARGU+=” –gtid-mode=ON “
         ARGU+=” –enforce-gtid-consistency=TRUE “
         ARGU+=” –log-slave-updates=FALSE “
         ARGU+=” –log-bin=/opt/local/data/mysqld/mysql-bin “

     

    Mysql Slave Server:

         ARGU+=” –relay_log=/opt/local/data/mysqld/relay-bin “
         ARGU+=” –read_only=on “
         ARGU+=” –skip_slave_start=on “

     

    Launch Mysl Server:

          mysqld     ${ARGU}     ${OTHER_ARGU} 

    Display Master Status:
           mysql>  show master status;

    Display Master Status:
          mysql>  show slave status;

    Display uuid:
          mysql>  show GLOBAL VARIABLES like ‘server_uuid’;

    Display gtid variable:
          mysql>  mysql> show variables like ‘%gtid%’;

     

     

     

     

     

  • Using CyberPower UPS to keep NAS data safety

    The CyberPower VALUE600ELCD UPS is supported by NUT, it can be used to switch off the NAS and computer system when main power fail, for the purpose to keep data and disk safety.

     

    NUT,  Network UPS Tools

    A suite of open source software component designed for UPS

     

    Architect of NUT:   

    Kernel:                USB HID Class driver

    User Space:       Three linux daemon design

    Driver Daemon:  usbhid_ups,   usb hid based protocol

    upsd Daemon:   API for client, including upsmon

    upsmon Daemon:   monit events from UPSD, and action by launch the pre-defined script

     

    Install NUT under ubuntu or debian:

    sudo apt-get install -y nut

     

    NUT Config  for CyberPower VALUE600ELCD

    Modify 4 config file in /etc/nut, by adding following lines

    nut.conf:

        MODE=standalone

     

    ups.conf
       [cyberpower]
         driver = usbhid-ups
         port = auto
         desc = “CP1500 AVR UPS”
         offdelay = 20
         ondelay = 0
         ignorelb
         override.battery.charge.low = 20
         override.battery.charge.warning = 40
         pollinterval = 15

    upsd.conf

        [admin]
             password = 123456
             actions = SET
             instcmds = ALL

       [upsmonuser]
            password = 123456
            upsmon master

    upsmon.conf

          MONITOR cyberpower@localhost 1 upsmon 123456 master

     

     

    • Start  or Stop   NUT driver :

                 sudo upsdrvctl start

                 sudo upsdrvctl stop

     

    • Start/Stop NUT server:

                sudo upsd

                sudo upsd -c stop

     

    • Start/Stop monit Daemon

                sudo upsmon

                sudo upsmon -c stop

     

    • Display UPS status:

                sudo upsc cyberpower@localhost

     

     

     

     

  • TOSHIBA P300 failing in 5 month

    It is reported that one harddisk is failling during boot time of PC,

    Error log:

    SMART overall-health self-assessment test result: FAILED!
    Drive failure expected in less than 24 hours. SAVE ALL DATA.
    Failed Attributes:
    ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
      5 Reallocated_Sector_Ct   0x0033   002   002   005    Pre-fail  Always   FAILING_NOW 1933

     

    Disk Model:    TOSHIBA P300 

    Supplier:         JD.com

    Purchased Date:    2021/05

    Report Date:           2021/10

    Usage:   SWAP

     

    How to check disk status:

    smartctl -H /dev/sda

    How to make disk test:

    smartctl -t long /dev/sda

    How to get disk test report:

    smartctl -l error /dev/sda

  • Reproduction Build of LFS

    To achieve the target of reproduction build, the following action should be taken:

     

    • Strip the result, via modification gcc spec file
    • Set and export the SOURCE_DATE_EPOCH environment variable, say
    SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)

     

  • LGA 1155 CPU

    E3-1290 V2                 9749
    E3-1280 V2                 9561
    E3-1270 V2                 9481
    E3-1275 V2                 9344
    E3-1240 V2                 9177
    E3-1245 V2                 9110
    E3-1230 V2                 8852
    E3-1290                      8699
    E3-1280                      8473
    E3-1275                      8348
    E3-1270                      8233
    E3-1245                      8048
    E3-1240                      7972
    E3-1230                      7907
    E3-1265L V2              7779
    E3-1235                     7680
    E3-1225 V2                6841
    E3-1220 V2                6661
    E3-1260L                   6534
    E3-1220                     6103
    E3-1265L                   6038
    E3-1225                     5917

  • debug linux daemon in remote server

    Using GNU screen + gdb utility to debug daemon software in remote machine

     

    # Launch the daemon service

    /etc/init.d/dnsproxy start

     

    # Create a screen session, say dns

    screen -dmS dns

     

    # Attach to the screen session

    screen -r dns

     

    # Launch gdb with in the session

    gdb

    attach xxxx

    c

     

    # Detach the screen session

    Ctrl+A+D

     

     

    # Debug code with gdb by Attaching to the screen session second time

    screen -r dns