fuhui 发布的文章

hyper添加nvdia虚拟显卡

#如虚拟机名称为win10
Set-VM -Name "win10" -AutomaticStopAction TurnOff
Set-VM -GuestControlledCacheTypes $true -VMName "win10"

# 设置MMIO,总的io映射内存,我们直接设置为32GB(通用大小),出现其他问题再扩大即可
Set-VM -LowMemoryMappedIoSpace 1Gb -VMName "win10"
Set-VM -HighMemoryMappedIoSpace 32Gb -VMName "win10"

# 添加虚拟化,
Add-VMGpuPartitionAdapter -VMName "win10"

# 指定显卡添加,这个显卡ID通过Get-VMHostPartitionableGpu命令获取到的“Name”字段值
# 注意,低版本的window10是无法使用这个命令指定的
# Add-VMGpuPartitionAdapter -VMName "win10" -InstancePath "显卡ID"
# 例如我的显卡ID是:\\?\PCI#VEN_10DE&DEV_1F91&SUBSYS_1AB11043&REV_A1#4&1885b93c&0&0008#{064092b3-625e-43bf-9eb5-dc845897dd59}\GPUPARAV


# 添加后,设置自动配置显卡
Set-VMGpuPartitionAdapter -VMName "win10"


# 删除虚拟显卡的分配,配置错误可重新来
Remove-VMGpuPartitionAdapter -VMName "win10"


我们先复制物理机系统的
C:\Windows\System32\nvapi64.dll
放到虚拟机的:
C:\Windows\System32\nvapi64.dll

再复制物理机中的
C:\Windows\System32\DriverStore\FileRepository
目录中以nv开头的文件夹到虚拟机中的
C:\Windows\System32\HostDriverStore\FileRepository
目录下,其中HostDriverStore\FileRepository目录需要自己创建:
重启虚拟机即可

windows vpn l2tp/ipsec 服务器位于nat设备后导致客户端连不上

https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-l2tp-ipsec-server-behind-nat-t-device

1.服务器改注册表
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PolicyAgent
AssumeUDPEncapsulationContextOnSendRule DWORD (32-bit) 2

2.客户端电脑改注册表
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RasMan\Parameters
ProhibitIPSec DWORD (32-bit) 1
AllowL2TPWeakCrypto DWORD (32-bit) 1
重启电脑

docker编译openwrt

docker run -it --name ubuntu ubunt:22.04 bash

apt update
apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc-s1 libc6-dev-i386 subversion flex uglifyjs gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils libelf-dev autoconf automake libtool autopoint device-tree-compiler ccache xsltproc rename antlr3 gperf curl screen upx-ucl jq wget curl rsync sudo
useradd -m -g sudo -s /bin/bash openwrt 
passwd openwrt
su openwrt
cd ~ 

git clone -b master https://github.com/openwrt/openwrt.git
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
make -j1 V=s

添加第三方插件

cd ..
mkdir openwrt-package
git init
git remote add -f origin https://github.com/hoofa/openwrt-packages.git
git config core.sparsecheckout true
vi .git/info/sparse-checkout

k3screenctrl
luci-app-bypass
lua-neturl
tcping
chinadns-ng
lua-maxminddb
shadowsocksr-libev
simple-obfs
v2ray-plugin
trojan-plus
naiveproxy
hysteria
redsocks2
microsocks
git pull origin master
cd ../openwrt
echo "src-link custom /home/openwrt/openwrt-package" >>feeds.conf.default
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
make -j1 V=s

menuconfig时在Image configuration --> Separate feed respositories里,取消enable feed custom


修改默认ip vi package/base-files/files/bin/config_generate
修改wifi vi package/kernel/mac80211/files/lib/wifi/mac80211.sh
修改root密码 vi package/base-files/files/etc/shadow
修改时区及NTP vi package/base-files/files/bin/config_generate

./files/ 里的文件会覆盖到编译后的镜像里,可用这个方法将 /etc/opkg/distfeeds.conf 里的 downloads.openwrt.org 替换成 mirrors.aliyun.com/openwrt
详见 https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem#custom_files


解决编译后与官方源内核版本不一致

  1. cat "官方的内核md5" > vermagic
  2. vi include/kernel-defaults.mk
    注释掉 grep '=[ym]' $(LINUX_DIR)/.config.set | LC_ALL=C sort | $(MKHASH) md5 > $(LINUX_DIR)/.vermagic
    改为 cp $(TOPDIR)/vermagic $(LINUX_DIR)/.vermagic
  3. vi package/kernel/linux/Makefile
    注释掉 STAMP_BUILT:=$(STAMP_BUILT)_$(shell $(SCRIPT_DIR)/kconfig.pl $(LINUX_DIR)/.config | $(MKHASH) md5)
    改为 STAMP_BUILT:=$(STAMP_BUILT)_$(shell cat $(LINUX_DIR)/.vermagic)

时区修改见
https://openwrt.org/start?id=zh/docs/guide-user/base-system/system_configuration#%E6%97%B6%E5%8C%BA


挂u盘相关 block-mount,blockd
kmod-fs-ext4,kmod-fs-vfat,kmod-fs-ntfs,kmod-fs-exfat
kmod-usb-storage/storage extra,kmod-usb-storage-uas, kmod-usb2/usb3
samba4-libs,luci-app-samba4,luci-i18n-samba4-zh-cn
blkid,hdparam,lsblk
ntfs-3g-utils,mount-utils

ln -s /usr/bin/ntfs-3g /sbin/mount.ntfs

debian11 优化

1.启用 rc.local,见上一篇
2.显示文件夹颜色
vi /root/.bashrc ,去掉注释

export LS_OPTIONS='--color=auto'
eval "$(dircolors)"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

3.vi 右键成了visual,不能复制
vi /usr/share/vim/vim82/defaults.vim
在mouse=a的=前面加个-

if has('mouse')
set mouse-=a
endif

4.docker-compose不是最新

apt remove docker-compose --purge
curl -L "https://github.com/docker/compose/releases/download/2.5.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose