日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【Notes7】Samba/NFS服务器,Ntp,导出log,modprobe,进入ME刷bios,树莓派

發布時間:2024/4/24 编程问答 100 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Notes7】Samba/NFS服务器,Ntp,导出log,modprobe,进入ME刷bios,树莓派 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 1.Samba服務器:利用文件傳輸協議:ftp,http,SMB(Samba)
    • 1.1 隱藏共享和拒絕訪問:無法在網上鄰居看到我們所共享的文件夾,但是通過unc路徑做具體指定,我們可以訪問到該文件夾下
    • 1.2 別名:別名配置文件要自己建立
    • 1.3 免登陸名:啟用share級別(安全性最低,不需要通過用戶名認證)
    • 1.4 linux訪問windows共享目錄:掛載
  • 2.NFS服務器:linux和linux之間,也可共享給win客戶端
    • 2.1 server:改ip和將目錄共享
    • 2.2 client-linux:mount
    • 2.3 client-windows:mount
  • 3./etc/ntp.conf:restrict (什么可訪問我并可修改我的時間)10.75.92.0 mask 255.255.255.0 nomodify(nomodify不能修改,只能訪問同步走)
  • 4.導出log:filenum=$(ls -l | wc -l) ,ls -tr | head -1
  • 5.modprobe:要載入a module,但a module要求系統先載入b module時,直接用insmod掛入通常都會出現錯誤,modprobe倒是能夠知道先載入b module后才載入a module,如此相依性就會滿足
  • 6.進入ME刷bios:BIOS是一個程序,駐留在CMOS存儲器(重復可擦寫),刷寫BIOS的過程就是用新版本的BIOS文件通過專門的刷新軟件覆蓋舊版本的BIOS文件
  • 7.樹莓派:是完整個人電腦,功耗非常大(相比于沒有soc的單片機),物聯網中要性能弱,所以樹莓派只用于教學,樹莓派4性能更強并有了usb3.0口和千兆網卡,用來做NAS,但做局域網中NAS不需要這么高性能,路由器就行且功耗比樹莓派低的多
    • 7.1 系統安裝:netstat -antp,arp -a
    • 7.2 花式點亮LED:node red控制


1.Samba服務器:利用文件傳輸協議:ftp,http,SMB(Samba)

win下更改ip:本地連接右擊屬性,更改適配器。@market指market組。

如下第一行看本地源是否正常,第二行安裝samba。

如下start啟動samba。

如下設置開機自啟動。


往一個目錄中寫數據,光有samba權限是不夠的,還要結合本地權限來看,如下如果不能完成寫入操作,可能不是配置錯了,可能和系統本地權限沖突,所以為了使本地權限不受影響,如下第一行就授予本地所有目錄完全權限。gpasswd是將用戶加入組中。

如下將本地用戶轉變為samba用戶即共享用戶。通過如下轉變可實現該用戶通過客戶端訪問服務器時提供驗證標準了。


如下都是在文件末尾新添加的內容,都是逗號,writeable=no指除了下行外都不能寫。[manager]是共享名即對方能看到的網絡文件夾名稱,comment是可共享目錄的描述信息(可加可不加),valid_users指誰可以訪問。

如上保存后,如下重啟,status查看出running。

如下用管理員賬號登錄修改任何目錄沒問題,其他用戶登錄只能進去或修改自己的文件夾。



1.1 隱藏共享和拒絕訪問:無法在網上鄰居看到我們所共享的文件夾,但是通過unc路徑做具體指定,我們可以訪問到該文件夾下

windows里只需在共享文件夾名后面加一個$符號就能實現隱藏共享了。linux的samba中需修改主配置文件。如下將manager目錄做一個隱藏。


如下可將win下更改設配器將ip改變,就可訪問了。

1.2 別名:別名配置文件要自己建立




1.3 免登陸名:啟用share級別(安全性最低,不需要通過用戶名認證)


如下guest這行可換成public=yes一樣效果。

1.4 linux訪問windows共享目錄:掛載

如下右擊share文件夾屬性。

如下點擊應用后點擊確定。




如上操作后share文件夾就有讀寫權限了。如下設置win賬號,因為默認禁止空密碼登錄。



如上準備好了文件夾和賬戶,如下cd /mnt ; mkdir win7,mount通過網絡掛載需要加參數,linux掛載后再用mount指令看下。

2.NFS服務器:linux和linux之間,也可共享給win客戶端

2.1 server:改ip和將目錄共享




如下再ip address看下ip是不是192.168.0.1。



如下192.168.0.*也可以。




如下改完也要restart重啟服務。

2.2 client-linux:mount


如下雖說給了nfs完全讀寫權限,但任何讀寫還受本身文件系統影響(win下有一個安全選項卡調節權限)。

2.3 client-windows:mount

控制面板-程序-打開或關閉windows功能。

3./etc/ntp.conf:restrict (什么可訪問我并可修改我的時間)10.75.92.0 mask 255.255.255.0 nomodify(nomodify不能修改,只能訪問同步走)


:%d刪除文件整個內容。

如下沒有加服務端地址。

如下的服務端地址不能同步。ntp.conf修改后10分鐘后才同步,主機器沒同步外網,子機器(slaver)不能同步主機器(master)。


ntp服務啟動了就不能使用ntpdate。

4.導出log:filenum=$(ls -l | wc -l) ,ls -tr | head -1

# auto_dump.sh #!/bin/bash work_path=$(pwd) conf_file_path="${work_path}/auto_dump.cfg" dst_dir_path="" search_path="/var/log"if [ $# -ne 1 ];thenprogram=$(basename "$0")echo "Usage: $program <dst_dir_path>"echo "Examples:$program /root/os_log/"exit elsedst_dir_path=$1 ficat $conf_file_path | while read conf_path_line dolast_file_path=$(basename ${conf_path_line})#last_file_path=${conf_path_line##*/}tmp=${conf_path_line%/*}last_dir_path=${tmp##*/} # network find $search_path -name $last_file_path | while read search_path_linedomkdir -p $dst_dir_pathdst_file_path=$dst_dir_path/tmp/$last_dir_path/mkdir -p $dst_file_pathcp $search_path_line $dst_file_pathdonecd $dst_dir_path/tmp/if [ ! -f $conf_path_line ];thenecho $conf_path_line" not found"fi done // auto_dump.cfg network/ip.log network/netstate.log network/route.log network/arp.log network/services.log hardware/dmidecode.log hardware/cmdline.log hardware/cpuinfo.log hardware/meminfo.log hardware/lsblk.log hardware/mount.log hardware/interrupts.log hardware/lspci.log hardware/smartctl.log hardware/modules.log hardware/version.log message/alert.log message/audit.log message/btmp.log message/crit.log message/debug.log message/dmesg.log message/err.log message/info.log message/messages.log message/notice.log message/syslog.log message/warning.log message/wtmp.log if [ -f $dst_dir_path/log.9.tar.gz ];thenrm $dst_dir_path/log.1.tar.gzfor((j=2;j<=$(($dst_dir_path_file_num-1));j++))domv $dst_dir_path/log.$j.tar.gz $dst_dir_path/log.$(($j-1)).tar.gzdonemv $dst_dir_path/log.tar.gz $dst_dir_path/log.9.tar.gz fiif [ -f $dst_dir_path/log.tar.gz ] && [ ! -f $dst_dir_path/log.9.tar.gz ];thenfor((i=1;i<=$(($dst_dir_path_file_num-1));i++))do if [ -f $dst_dir_path/log.$i.tar.gz ];thencontinuefimv $dst_dir_path/log.tar.gz $dst_dir_path/log.$i.tar.gzbreakdone fii=0 filenum=0 for i in $(ls) doif [ -f $i ]thenlet filenum+=1fiif [ $filenum==10 ];thenrm `ls -tr $(find . -type f -name "log_*") | head -1`breakfi doneif [ -f $dst_dir_path/log.tar ];thenmv $dst_dir_path/log.tar $dst_dir_path/log_$(date "+%Y-%m-%d_%H:%M:%S")_bak.tar fi

5.modprobe:要載入a module,但a module要求系統先載入b module時,直接用insmod掛入通常都會出現錯誤,modprobe倒是能夠知道先載入b module后才載入a module,如此相依性就會滿足

insmod cpld_hq.ko(ko是kernel module,lsmod cpld_hq,rmmod cpld_hq)生成如下文件夾,sys_cpld在cpld_hq.c里命名,前面路徑在內核指定。

# setup.py #! /usr/bin/python# /sys/bus/i2c/devices/i2c-0/0-0056/eeprom # driver: 24lc64t。 addr:0x50。 bus:/sys/bus/i2c/devices/i2c-%d。 # bus_number:15。 devdir:0-0056import os, sys, subprocess, stringdef new_device(driver, addr, bus, devdir):if not os.path.exists(os.path.join(bus, devdir)):try:with open("%s/new_device" % bus, "w") as f:f.write("%s 0x%x\n" % (driver, addr))except Exception, e:print "Unexpected error initialize device %s:0x%x:%s: %s" % (driver, addr, bus, e)else:print("Device %s:%x:%s already exists." % (driver, addr, bus))def new_i2c_device(driver, addr, bus_number):bus = '/sys/bus/i2c/devices/i2c-%d' % bus_numberdevdir = "%d-%4.4x" % (bus_number, addr) # 4.4 = 0.4 = .4 取四位,前面不夠補0return new_device(driver, addr, bus, devdir)def baseconfig():print("Initialize EEPROM driver")# tlv eeprom devicenew_i2c_device('24lc64t', 0x56, 0)# Baseboard eeprom devicenew_i2c_device('24lc64t', 0x50, 15)# BMC eeprom devicenew_i2c_device('24lc64t', 0x51, 15)# switchboard eeprom devicenew_i2c_device('24lc64t', 0x52, 15)# SFP+/QSFPDD eepromfor y in range(32):new_i2c_device('optoe1',0x50,37+y)def main():baseconfig()if __name__ == "__main__":sys.exit(main()) # check_port_tx_rx_setup.sh #!/bin/bash if [ $# != 1 ] ; thenecho "Please input the retry number"echo "Usage:./check_port_tx_rx_setup.sh 'retry number'"exit 1; ficd /home/test/Desktop/port_nrz_test/fpga_prog echo "Checking the Port link status...." ./linkstatus.sh | grep "link is failed" | awk -F ' ' '{print $4}' > tmp mkdir -p /home/test/Desktop/port_nrz_test/log/link_log if test -s tmp;thenfor((i=1;i<=$1;i++));do./linkstatus.sh | grep "link is failed" | awk -F ' ' '{print $4}' > tmpcat tmp | while read linedocd /home/test/Desktop/0915/ali_fpga/software/user/cli/devmemecho "Retry to setup the port $line"case $line in1)./0_All_100G_NRZ_RX_ADAPT.sh > /home/test/Desktop/port_nrz_test/log/link_log/0_All_100G_NRZ_RX_ADAPT.log;;2)./1_All_100G_NRZ_RX_ADAPT.sh > /home/test/Desktop/port_nrz_test/log/link_log/1_All_100G_NRZ_RX_ADAPT.log ;;esacdonedone elseecho "test ok" fi

i2cset -f -y 0 0x0d 0x40 0x40,寫文件SYSCPLD_SYSFS_DIR=“/sys/bus/i2c/devices/0-000d”

6.進入ME刷bios:BIOS是一個程序,駐留在CMOS存儲器(重復可擦寫),刷寫BIOS的過程就是用新版本的BIOS文件通過專門的刷新軟件覆蓋舊版本的BIOS文件

# BMC_BIOS_change.py# $interface = "1.0" import time import sys import os import SecureCRTdef boot_os():crt.Screen.WaitForString("localhost login:")crt.Screen.Send("admin" +chr(13))time.sleep (1)crt.Screen.WaitForString("Password: ")crt.Screen.Send("admin" +chr(13))time.sleep (1)crt.Screen.WaitForString("admin@localhost:~$")crt.Screen.Send("sudo su" +chr(13))time.sleep (1)crt.Screen.WaitForString("root@localhost:/home/admin# ")crt.Screen.Send("dmidecode -t 0" +chr(13)) # 查看BIOS信息time.sleep (1)def Checkinfo1():crt.Screen.WaitForString("root@localhost:/home/admin#",1)crt.Screen.Send("lspci |grep -i eth" +chr(13))time.sleep (1)crt.Screen.WaitForString("root@localhost:/home/admin#",1)crt.Screen.Send("lspci |grep -i 07:00.0" +chr(13))time.sleep (2)crt.Screen.WaitForString("root@localhost:/home/admin#")crt.Screen.Send("lsblk |grep -i sda" +chr(13))time.sleep (2)#############切換到BMC下###############crt.Screen.WaitForString("root@localhost:/home/admin#")crt.Screen.Send("\025"+"\022"+"\024"+"1 \r")crt.Screen.SendSpecial("VT_KEYPAD_ENTER")time.sleep (5)# crt.Screen.WaitForString("bmc-oob. login:")# crt.Screen.Send("root" +chr(13))# crt.Screen.WaitForString("Password:")# crt.Screen.Send("0penBmc" +chr(13))crt.Screen.WaitForString("root@bmc-oob:~#")crt.Screen.Send("boot_info.sh all" +chr(13))time.sleep (2)crt.Screen.Send("boot_info.sh reset bios master" +chr(13))crt.Screen.WaitForString("root@bmc-oob:~#")time.sleep (90)#############切換到Sonic下###############crt.Screen.WaitForString("root@bmc-oob:~#")crt.Screen.Send("\025"+"\022"+"\024"+"0 \r")crt.Screen.SendSpecial("VT_KEYPAD_ENTER")time.sleep (1)def Checkinfo2():crt.Screen.WaitForString("root@localhost:/home/admin#",1)crt.Screen.Send("lspci |grep -i eth" +chr(13))time.sleep (1)crt.Screen.WaitForString("root@localhost:/home/admin#",1)crt.Screen.Send("lspci |grep -i 07:00.0" +chr(13))time.sleep (2)crt.Screen.WaitForString("root@localhost:/home/admin#")crt.Screen.Send("lsblk |grep -i sda" +chr(13))time.sleep (2)#############切換到BMC下###############crt.Screen.WaitForString("root@localhost:/home/admin#")crt.Screen.Send("\025"+"\022"+"\024"+"1 \r")crt.Screen.SendSpecial("VT_KEYPAD_ENTER")time.sleep (1)crt.Screen.WaitForString("root@bmc-oob:~#")crt.Screen.Send("boot_info.sh all" +chr(13))time.sleep (2)crt.Screen.Send("boot_info.sh reset bios slave" +chr(13))crt.Screen.WaitForString("root@bmc-oob:~#")time.sleep (90)#############切換到Sonic下###############crt.Screen.WaitForString("root@bmc-oob:~#")crt.Screen.Send("\025"+"\022"+"\024"+"0 \r")crt.Screen.SendSpecial("VT_KEYPAD_ENTER")time.sleep (1)def Checkinfo3():crt.Screen.WaitForString("root@localhost:/home/admin#",1)crt.Screen.Send("lspci |grep -i eth" +chr(13))time.sleep (1)crt.Screen.WaitForString("root@localhost:/home/admin#",1)crt.Screen.Send("lspci |grep -i 07:00.0" +chr(13))time.sleep (2)crt.Screen.WaitForString("root@localhost:/home/admin#")crt.Screen.Send("lsblk |grep -i sda" +chr(13))time.sleep (2)#############切換到BMC下###############crt.Screen.WaitForString("root@localhost:/home/admin#")crt.Screen.Send("\025"+"\022"+"\024"+"1 \r")crt.Screen.SendSpecial("VT_KEYPAD_ENTER")time.sleep (1)crt.Screen.WaitForString("bmc-oob. login:")crt.Screen.Send("root" +chr(13))crt.Screen.WaitForString("Password:")crt.Screen.Send("0penBmc" +chr(13))crt.Screen.WaitForString("root@bmc-oob:~#")crt.Screen.Send("/var/log/./util.sh" +chr(13)) #####################time.sleep (2)def Main():crt.Screen.Synchronous = Truefor i in range (0,200):boot_os()time.sleep (2)Checkinfo1()boot_os()Checkinfo2()Checkinfo3()time.sleep (2) Main() # util.sh #!/bin/sh i=1 while(( $i<=3 )) doipmitool -b 1 -t 0x2c raw 0x2e 0xdf 0x57 0x01 0x00 0x01 #進入ME恢復模式ret=$(/usr/bin/ipmitool -b 1 -t 0x2c raw 6 1 | awk -F " " '{print $15}') #查詢ME狀態if [ "$ret" = "00" ]; thenlogger -p user.info "Enter ME recovery mode successfully"spi_util.sh write BIOS1 imagebreakfiif [ "$ret" != "00" ]; thenlogger -p user.info "Three times to enter ME recovery mode failed"continuefi donei=1 while(( $i<=3 )) doipmitool -b 1 -t 0x2c raw 6 2 #退出ME ret=$(/usr/bin/ipmitool -b 1 -t 0x2c raw 6 1 | awk -F " " '{print $15}') #查詢ME狀態if [ "$ret" != "00" ]; thenlogger -p user.info "Exit ME recovery mode successfully"breakfiif [ "$ret" = "00" ]; thenlogger -p user.info "Three times to exit ME recovery mode failed"continuefi done exit

7.樹莓派:是完整個人電腦,功耗非常大(相比于沒有soc的單片機),物聯網中要性能弱,所以樹莓派只用于教學,樹莓派4性能更強并有了usb3.0口和千兆網卡,用來做NAS,但做局域網中NAS不需要這么高性能,路由器就行且功耗比樹莓派低的多

7.1 系統安裝:netstat -antp,arp -a

1.內存卡插入讀卡器再插入電腦的usb接口,將u盤格式化為FAT32格式。如果右擊格式化沒有FAT32,用格式化fat32工具:http://www.ridgecrop.demon.co.uk/guiformat.exe。樹莓派系統官網:https://www.raspberrypi.org/downloads/raspbian/。下載完系統(1.9G),用寫盤工具(https://www.balena.io/etcher/或win32diskimager)將系統寫入u盤,寫完后不要格式化其他盤。

2.樹莓派插上內存卡,接上網線或連上wifi(連wifi,eth0信息為空,因為沒有連接網線,wlan0顯示內網ip)用ifconfig查看網絡。service ssh start開啟ssh服務,樹莓派默認用戶名pi,密碼raspberry,sudo netstat -antp可查看到當前有22端口即ssh端口被監聽,這時可關閉顯示器。

3.用自己電腦上的putty/xshell/securecrt新建一個ssh連接,pi@樹莓派內網ip,可登錄樹莓派。如果忘了樹莓派內網ip,可用win下cmd中輸入arp -a查看局域網下所有ip和mac對應。

4.樹莓派網線和要訪問的機器網線插在同一個小型交換機上(如果是網口需要先連自己電腦瀏覽器認證網口)并且樹莓派的串口連接機器,本電腦就可以連接樹莓派再通過picocom -b 115200 /dev/ttyUSB0連接到機器。如果沒有樹莓派,本電腦插上機器的串口線(一端USB口,一端網口)后在設備管理器里看到COM號右擊添加驅動,下載并安裝驅動。serial,comx,115200。

5.如下打開樹莓派自帶的圖像化界面。



win端需安裝vnc viewer。

6.如下點擊樹莓派自帶的node red啟動。

7.2 花式點亮LED:node red控制



1.如下左邊拖進一個gpio和兩個inject。inject中選擇數字1和0。

如下gpio中選擇GPIO04-7管腳。點擊右邊部署按鈕。

2.如下設置閃爍效果,0這個inject也要如下設置。

3.如下通過http接口實現小燈的亮滅。

如下action為on的話賦值為0。

如下點亮小燈,將on改為off,燈熄滅。

總結

以上是生活随笔為你收集整理的【Notes7】Samba/NFS服务器,Ntp,导出log,modprobe,进入ME刷bios,树莓派的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。