lxc下如何让usb设备pass through直接到达虚机

测试的同事要在测试机上安装android studio,adb直接调试手机。 这下麻烦了,测试机实际是个lxc的容器,需要把插在宿主机usb上的手机直接过给容器。 说下做法: 首先在宿主机上执行lsusb,查出手机USB: [root@localhost]# lsusb Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 014: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II], GT-I9300 Phone [Galaxy S III], GT-P7500 [Galaxy Tab 10.1] , GT-I9500 [Galaxy S 4] Bus 001 Device 004: ID 0624:0248 Avocent Corp. Virtual Hub Bus 001 Device 005: ID 0624:0249 Avocent Corp. Virtual Keyboard/Mouse 看最长的带GT-I9100那一行,ID 04e8:6860,VendorID:ProdID,说明Vendor=04e8 ProdID=6860,记下来。 ...

2024年01月24日 · 1 分钟 · 191 字 · 八戒

Dell的idrac redfish初探

各大主板厂商纷纷支持下一代带外管理标准redfish。 其实Dell的idrac管理做的是相当好的,那么来看看对redfish的支持吧。 先看看v1都有什么命令 curl -s "https://10.16.24.15/redfish/v1" -k -u root:xxxxxxxx | jq . 结果如下: { "@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot", "@odata.id": "/redfish/v1", "@odata.type": "#ServiceRoot.v1_1_0.ServiceRoot", "AccountService": { "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/AccountService" }, "Chassis": { "@odata.id": "/redfish/v1/Chassis" }, "Description": "Root Service", "EventService": { "@odata.id": "/redfish/v1/EventService" }, "Id": "RootService", "JsonSchemas": { "@odata.id": "/redfish/v1/JSONSchemas" }, "Links": { "Sessions": { "@odata.id": "/redfish/v1/Sessions" } }, "Managers": { "@odata.id": "/redfish/v1/Managers" }, "Name": "Root Service", "Oem": { "Dell": { "@odata.type": "#DellServiceRoot.v1_0_0.ServiceRootSummary", "IsBranded": 0, "ManagerMACAddress": "50:9A:4C:82:B9:3F", "ServiceTag": "7Q9N8P2" } }, "RedfishVersion": "1.0.2", "Registries": { "@odata.id": "/redfish/v1/Registries" }, "SessionService": { "@odata.id": "/redfish/v1/SessionService" }, "Systems": { "@odata.id": "/redfish/v1/Systems" }, "Tasks": { "@odata.id": "/redfish/v1/TaskService" }, "UpdateService": { "@odata.id": "/redfish/v1/UpdateService" } } 好多服务撒,挑其中一个分支看看: curl -s "https://10.16.24.15/redfish/v1/Chassis" -k -u root:alibaba | jq . 结果如下: { "@odata.context": "/redfish/v1/$metadata#ChassisCollection.ChassisCollection", "@odata.id": "/redfish/v1/Chassis/", "@odata.type": "#ChassisCollection.ChassisCollection", "Description": "Collection of Chassis", "Members": [ { "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" }, { "@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Integrated.1-1" } ], "Members@odata.count": 2, "Name": "Chassis Collection" } 再试试Session的管理: ...

2024年01月24日 · 3 分钟 · 451 字 · 八戒

LVM调整分区大小

系统是xfs文件格式。/root空间不够了。必须对空间进行调整,悲剧的是xfs只能增加空间,不能缩减空间,必须曲线救国了。 查看一下,缺省有两个lvm的分区 /dev/mapper/centos-root 40G /dev/mapper/centos-home 20G 只能减小home分区,再增大root分区了。 先备份home分区,并缩小到2G: # yum -y install xfsdump # xfsdump -f /home.xfsdump /home please enter label for this dump session (timeout in 300 sec) -> home please enter label for media in drive 0 (timeout in 300 sec) -> home # umount /home # lvreduce -L 2G /dev/mapper/centos-home Do you really want to reduce home? [y/n]: y 然后扩充root分区: # lvextend -L +18G /dev/mapper/centos-root # xfs_growfs /dev/mapper/centos-root 最后恢复home分区 # mkfs.xfs -f /dev/mapper/centos-home # mount /home # xfsrestore -f /home.xfsdump /home 搞定 ...

2024年01月24日 · 1 分钟 · 85 字 · 八戒

F5-bigip的SSL每秒传输(TPS)限制

公司用到了SSL的泛域名证书,网站整体套上了HTTPS,然后最前面是F5做SSL的卸载。 麻烦也来了,F5的SSL Transactions Per Second (TPS) 是有license的,首先检查一下吧 tmsh show sys license detail | grep -i perf_SSL_total_TPS perf_SSL_total_TPS [500] 显示是500 还得查查有几个核心 tmsh show sys tmm-info global | grep -i 'TMM count' TMM Count 4 4个核心 那么每秒SSL的TPS限制就是 500X4=2000 超过2000就得去增加license了。

2024年01月24日 · 1 分钟 · 37 字 · 八戒

两台不同系统上Jenkins的联动

场景是这样的,有两台jenkins。一台是正常安装在linux上的,另外一台是在macos上的。 在macos上的这台,装了有xcode和android studio,负责ipa和apk的自动打包。 而在linux上jenkins则是主jenkins,负责很多项目的打包。 这样两台的目标就都很明确,麻烦的是需要来回登录来构建项目,那么有没有方法从第一台上直接调用第二台的项目进行构建呢? 当然可以,直接发个带Token的url到第二台就可以。 这个不是本文的重点,本文重点,源码是Git的build过程,jenkins装了Git parameter插件后支持选tag进行building。 这样如果两台都这么来一下,实际是在两台都git check了一下,然后开始build,这对于第一台来说,毫无必要。 第一台主jenkins的任务就是看看git项目中都有什么tag,然后把tag发链接给第二台即可,没必要check的。 而第二台也不去看tag,直接从git中checkout出第一台传过来的tag版本,进行构造,这样最省资源。 那么,怎么让第一台只查看tag呢? 万能的groovy大法: def gettags = "git ls-remote -t git@git.coding.net:doabc/app-abc.git".execute() def tags = [] def t1 = [] gettags.text.eachLine {tags.add(it)} for(i in tags) t1.add(i.split()[1].replaceAll('\\^\\{\\}', '').replaceAll('refs/tags/', '')) t1 = t1.unique() return t1 注意上面,groovy和git的证书需要都事先配好。

2024年01月24日 · 1 分钟 · 43 字 · 八戒

配置postfix转发局域网邮件以及邮件黑洞

配置postfix允许自由转发内网的邮件,就改一个地方即可,添加允许发送的内网网段: vi /etc/postfix/main.cf ... mynetworks = 127.0.0.0/8, 172.16.0.0/16 ... 配置黑洞,所有邮件都接受,然后drop丢掉 relayhost = relay_transport = relay relay_domains = static:ALL smtpd_end_of_data_restrictions = check_client_access static:discard 当然,也可以把这些邮件都给送到amavis去,训练它识别垃圾邮件 测试邮件发送的命令: echo "body of your email" | mail -s "This is a Subject os version" -r "abc@kindlefan.xin" test@abc.com 注意:CentOS和Ubuntu默认居然都没有mail这条命令的话 yum install mailx apt-get install bsd-mailx

2024年01月24日 · 1 分钟 · 48 字 · 八戒

Ext4分区的缩小

缩小/ 的ext4分区步骤如下: 首先查看分区是什么文件类型 file -sL /dev/sd* /dev/sda: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x2044148, GRUB version 0.94; partition 1: ID=0x82, starthead 32, startsector 2048, 8388608 sectors; partition 2: ID=0x83, active, starthead 75, startsector 8390656, 411039744 sectors, code offset 0x48 /dev/sda1: Linux/i386 swap file (new style) 1 (4K pages) size 1048575 pages /dev/sda2: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (large files) (huge files) 能看出来sda1是交换分区,那么要缩的分区是/dev/sda2,文件类型是ext4 ok,先确保虚机内/分区只占到5G,然后最好重新拷贝一下qcow2文件,把文件到弄到前面5G中。 然后修改一下kvm虚机配置,先加个iso进入rescue模式 virsh edit xxx 把boot顺序从hd改成cdrom ... <boot dev='hd'/> <boot dev='cdrom'/> ... <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/export/kvm/iso/CentOS-7-x86_64-NetInstall-1708.iso'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> ... 系统启动,进入cdrom安装,选择Troubleshooting ...

2024年01月24日 · 1 分钟 · 145 字 · 八戒

CentOS下做无线AP热点

自己的笔记本是装了个CentOS的系统,然后上面跑了个Vmware,又装了Win10,然后接两个屏幕,小的是linux跑gnome,大的是Win10屏幕,这样干活的。 路由更是混乱无比,网卡有tun0 / wlan0 / eth0 ,没有弄br0,这是大前提。如果弄br0的话,得改一堆东西。 这样的话wlan0无线网卡不联网就空闲了,于是想把无线网卡做AP共享出来,给手机用,做法真是比较复杂,弄了2天才弄好,网上的教程都是莫名啊,不太适合CentOS。 其实就是安装hostpapd,把做法记录一下: 首先不想改动已有的网络,那么桥接这条路就彻底断了,只能在无线网卡上做DHCP+NAT一条路了。 先检查网络: lspci -k | grep -A 3 -i "network" 03:00.0 Network controller: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter (rev 01) Subsystem: Lite-On Communications Inc Device 0662 Kernel driver in use: ath9k Kernel modules: ath9k 看到自己的网卡驱动是ath9k,再看看模块 modinfo ath9k | grep 'depend' depends: mac80211,ath9k_hw,ath9k_common,cfg80211,ath mac80211, cfg80211看到这个就放心了,driver就是nl80211 再确认一下,里面有* AP 字样这样就没问题了: iw list|grep -A8 "Supported interface modes:" Supported interface modes: * IBSS * managed * AP * AP/VLAN * WDS * monitor * P2P-client * P2P-GO 首先看看自己的无线网卡物理地址,30:10:B3:6A:22:AA记下来 ...

2024年01月23日 · 2 分钟 · 290 字 · 八戒

给老旧的CentOS系统设置yum源

前同事N年前买了个linode的主机,一直用,系统是CentOS 5.6 x86_64的。 现在想在上面装个软件,结果yum失效了,重装系统不可能,只能找个旧的yum源设置一下了。 源: http://vault.centos.org ,找到子目录 cat /etc/yum.repos.d/base.repo [base] name=base baseurl=http://vault.centos.org/5.6/os/x86_64/ gpgcheck=0 enabled=1 最后清掉一下缓存就可以了 yum clean all

2024年01月23日 · 1 分钟 · 18 字 · 八戒

MySQL的备份网络优化

公司的MySQL服务器定时在凌晨4:00准时开始备份。 结果是会触发报警,net流量增高,cpu增高,磁盘io增高,这个是属于正常的,如何避免触发警报呢? 有4种方法: 一、优化io和cpu,让备份写磁盘的速度降下来,平稳的写入 nice -n 10 ionice -c2 -n 7 /usr/bin/mysqldump -S /var/lib/mysql/mysql.sock -uroot --single-transaction --quick\ --triggers -R --hex-blob --log-error=$db.log --databases $db > $basedir/$backdir/$db.sql 二、加快备份速度,多线程,让报警触发之前就结束备份 COMMIT_COUNT=0 COMMIT_LIMIT=10 for DB in `cat ListOfDatabases.txt` do mysqldump -h... -u... -p... --hex-blob --routines --triggers ${DB} | gzip > ${DB}.sql.gz & (( COMMIT_COUNT++ )) if [ ${COMMIT_COUNT} -eq ${COMMIT_LIMIT} ] then COMMIT_COUNT=0 wait fi done if [ ${COMMIT_COUNT} -gt 0 ] then wait fi 三、用cstream来控制流速 -t = throughput in bytes/sec 1000000是一兆,每秒只允许写一兆 mysqldump --single-transaction --quick -u <USER> -p<PASS> <Database> | cstream -t 1000000 > backup.sql 四、用pv来控制流速 –rate-limit Limit the transfer to a maximum of RATE bytes per second. 单位可以是:1k 1m 1g 1t ...

2024年01月23日 · 1 分钟 · 118 字 · 八戒