-
-
Save willwhui/861bf7eaa713935cf9ce2b1f3cd919e7 to your computer and use it in GitHub Desktop.
Ubuntu14.04-20.04 |
sd卡在休眠之后就不再识别了
无效的方法:
https://www.reddit.com/r/linuxmint/comments/3ydoxs/unable_to_detect_builtin_sd_card_reader/
sudo vi /etc/default/tlp
为USB_BLACKLIST添加sd card reader(通过lsusb)可以得到编号
然后重启
蓝牙耳机声音卡顿
原因:给耳机的声音缓存不够
解决方案:设置一个适合的缓存
可用的方案:
# .sh file
# display info
pactl list | grep -Pzo '.*bluez_card(.*\n)*'
# set buffer time
sudo pactl set-port-latency-offset bluez_card.XX_XX_XX_XX_XX_XX headphone-output 100
echo ">>>>>> wait for reconnect: <<<<<<"
sudo service bluetooth restart
echo ">>>>>> *** reconnect in 3 seconds *** <<<<<<"
sleep 1
echo ">>>>>> ** reconnect in 2 seconds ** <<<<<<"
sleep 1
echo ">>>>>> * reconnect in 1 second * <<<<<<"
# reconnect
sudo bluetoothctl connect XX:XX:XX:XX:XX:XX
# display info
pactl list | grep -Pzo '.*bluez_card(.*\n)*'
参见:
https://askubuntu.com/questions/475987/a2dp-on-pulseaudio-terrible-choppy-skipping-audio
As none of the other answers worked on my system (Ubuntu 18.04 LTS on a 2012 MacBook Air), I found my solution on the german ubuntuusers wiki. English summary of the german instructions:
The choppy output might be caused by the A2DP implementation, and how it buffers sound before encoding it. For me, changing this buffer's size solved the choppy sound problem. You need to perform three steps:
Find necessary info about the bluetooth device (while it is connected!)
pactl list | grep -Pzo '.*bluez_card(.*\n)*'
The output should be something like
Name: bluez_card.28_11_A5_84_B6_F9
Driver: module-bluez5-device.c
...
Ports:
speaker-output: Speaker (priority: 0, latency offset: 0 usec, available)
Part of profile(s): a2dp_sink, headset_head_unit
speaker-input: Bluetooth Input (priority: 0, latency offset: 0 usec, not available)
Part of profile(s): headset_head_unit
We see that the buffers have currently 0 latency. In the next step, you will need the NAME and PORT of your output. In this example, these are bluez_card.28_11_A5_84_B6_F9 and speaker-output, respectively.
Set the buffer size (latency) of your card to a suitable value with this command pattern:
pactl set-port-latency-offset <NAME> <PORT> <BUFFER_SIZE_MICROSECONDS>
The latency unit of the following command is microseconds, so I'm using a 50 millisecond buffer for my command here:
pactl set-port-latency-offset bluez_card.28_11_A5_84_B6_F9 speaker-output 50000
Restart your bluetooth service to apply your change
sudo service bluetooth restart
As there is usually no documentation about this, you may have to experiment with higher or lower buffer values. Many people people posted their working latencies in the comments to this answer. Check them out for guidance on the latency value.
合盖后先 sleep再hibernate
综合起来这样做,运行:
sudo vi /etc/systemd/sleep.conf
打开这个配置文件后,
去掉AllowSuspendThenHibernate=yes
的注释(不过,按道理说默认是yes,应该不用去掉也可以工作)
去掉#HibernateDelaySec=10min
一行的注释,改为:
HibernateDelaySec=600
表示suspend后,10分钟之后开始hibernate
运行:
sudo vi /etc/systemd/logind.conf
修改里面的几行为:
HandleLidSwitch=suspend-then-hibernate
HandleLidSwitchExternalPower=suspend-then-hibernate
HandleLidSwitchDocked=suspend-then-hibernate
然后重启对应的服务:
systemctl restart systemd-logind.service
如果现在测试一下hibernate功能的话,会发现:
从休眠状态恢复后,并非休眠前的情况,而是类似于关机重启。
解决之前,为了防止后续的操作导致启动失败,可以先做个准备,让系统启动菜单显示几秒钟,在/etc/default/grub
文件中做如下更改:
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=2
接下来,开始操作解决休眠恢复无效的方案。
参见这里
上文配置过程中会出现如下警告:
update-initramfs: Generating /boot/initrd.img-5.4.0-100-generic
W: initramfs-tools configuration sets RESUME=UUID=b355eafd-25fb-4934-9c3c-1ca6071659c2
W: but no matching swap device is available.
...
根据这里的说明,是因为文件etc/initramfs-tools/conf.d/resume
中的设置是不必要的,删除或注释调它
#RESUME=UUID=b355eafd-25fb-4934-9c3c-1ca6071659c2 resume_offset=3487744
重新运行
sudo update-initramfs -c -k all
然后重启,测试hibernate功能,看是否成功
sudo systemctl hibernate
注:必须保证有足够大的swapfile,增大swapfile的做法参考这里
注:目前建议的swapfile大小参见这里
注:如果swapfile太小,将无法进入hibernate状态,sudo systemctl suspend-then-hibernate
和 sudo systemctl hibernate
等方法都将不可用,因为不够将内存和已经交换到swapfile的数据同时写入swapfile
mount一个分区,创建swap文件
在安装ubuntu之前特地划分了一个分区做swap,但是不知道为什么没有被系统用上。
手动mount:
首先通过disks应用程序查看,发现划分的分区是处于完全未使用状态。
选中它,添加一个分区,并格式化为ext4。
得到了/dev/sda5
然后建立目录/swap
并参照这里进行如下操作,开机自动挂载:
sudo gedit /etc/fstab
在文件中添加一行:
/dev/sda5 /swap ext4 defaults 0 2
重启。
命令行运行df,可见分区已经挂载在/swap目录
(但不知为什么sudo fdisk -l看不到/dev/sda5)
接着创建swap文件:
按照这里的说明:
采取快速创建的方式,并启动时加载
文章中提到,如果是VPS,应该将swappiness降低到0,减少交换的机会以避免运行过慢。