报错环境
设备:安卓手机
运行应用:ZeroTermux v0.118.38.1( termux也一致 )
系统:termux中使用国光大佬脚本安装的Ubuntu 18.04.6 LTS
架构:aarch64
内核版本:4.14.186-perf-ga9792052ef2e
报错情况
使用命令(在root用户情况下):
ps
出现了如下报错:
Error: /proc must be mounted
To mount /proc at boot you need an /etc/fstab line like:
proc /proc proc defaults
In the meantime, run "mount proc /proc -t proc"
包括安装宝塔面板时也出现了该报错
解决方案
参考b站文章:Termux 上装 GNU/Linux 报错“Error: /proc must be mounted” - 哔哩哔哩 (bilibili.com)
伪造/proc分区下的五个文件,分别为locdavg,stat,uptime,version,vmstat这五个文件
先在/data/data/com.termux目录下创建这五个文件,例如:
cd /data/data/com.termux
注意:使用前先退回到Termux自带的原生系统(使用"exit"命令退出)
然后写入内容:
locdavg 文件
echo '0.12 0.07 0.02 2/165 765' > ./locdavg
stat 文件
echo -e 'cpu 1957 0 2877 93280 262 342 254 87 0 0\ncpu0 31 0 226 12027 82 10 4 9 0 0\ncpu1 45 0 664 11144 21 263 233 12 0 0\ncpu2 494 0 537 11283 27 10 3 8 0 0\ncpu3 359 0 234 11723 24 26 5 7 0 0\ncpu4 295 0 268 11772 10 12 2 12 0 0\ncpu5 270 0 251 11833 15 3 1 10 0 0\ncpu6 430 0 520 11386 30 8 1 12 0 0\ncpu7 30 0 172 12108 50 8 1 13 0 0\nintr 127541 38 290 0 0 0 0 4 0 1 0 0 25329 258 0 5777 277 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\nctxt 14022\nbtime 1680020856\nprocesses 772\nprocs_running 2\nprocs_blocked 0\nsoftirq 75663 0 5903 6 25375 10774 0 243 11685 0 21677' > ./stat
uptime 文件
echo '124.08 932.80' > ./uptime
version 文件
echo 'Linux version 版本 (proot@termux) (gcc (GCC) 编译信息)' > ./version
vmstat 文件
echo -e '0\nallocstall_normal 0\nallocstall_movable 0\nallocstall_device 0\npgskip_dma 0\npgskip_dma32 0\npgskip_normal 0\npgskip_movable 0\npgskip_device 0\npgfree 3077011\npgactivate 0\npgdeactivate 0\npglazyfree 0\npgfault 176973\npgmajfault 488\npglazyfreed 0\npgrefill 0\npgreuse 19230\npgsteal_kswapd 0\npgsteal_direct 0\npgsteal_khugepaged 0\npgdemote_kswapd 0\npgdemote_direct 0\npgdemote_khugepaged 0\npgscan_kswapd 0\npgscan_direct 0\npgscan_khugepaged 0\npgscan_direct_throttle 0\npgscan_anon 0\npgscan_file 0\npgsteal_anon 0\npgsteal_file 0\nzone_reclaim_failed 0\npginodesteal 0\nslabs_scanned 0\nkswapd_inodesteal 0\nkswapd_low_wmark_hit_quickly 0\nkswapd_high_wmark_hit_quickly 0\npageoutrun 0\npgrotated 0\ndrop_pagecache 0\ndrop_slab 0\noom_kill 0\nnuma_pte_updates 0\nnuma_huge_pte_updates 0\nnuma_hint_faults 0\nnuma_hint_faults_local 0\nnuma_pages_migrated 0\npgmigrate_success 0\npgmigrate_fail 0\nthp_migration_success 0\nthp_migration_fail 0\nthp_migration_split 0\ncompact_migrate_scanned 0\ncompact_free_scanned 0\ncompact_isolated 0\ncompact_stall 0\ncompact_fail 0\ncompact_success 0\ncompact_daemon_wake 0\ncompact_daemon_migrate_scanned 0\ncompact_daemon_free_scanned 0\nhtlb_buddy_alloc_success 0\nhtlb_buddy_alloc_fail 0\ncma_alloc_success 0\ncma_alloc_fail 0\nunevictable_pgs_culled 27002\nunevictable_pgs_scanned 0\nunevictable_pgs_rescued 744\nunevictable_pgs_mlocked 744\nunevictable_pgs_munlocked 744\nunevictable_pgs_cleared 0\nunevictable_pgs_stranded 0\nthp_fault_alloc 13\nthp_fault_fallback 0\nthp_fault_fallback_charge 0\nthp_collapse_alloc 4\nthp_collapse_alloc_failed 0\nthp_file_alloc 0\nthp_file_fallback 0\nthp_file_fallback_charge 0\nthp_file_mapped 0\nthp_split_page 0\nthp_split_page_failed 0\nthp_deferred_split_page 1\nthp_split_pmd 1\nthp_scan_exceed_none_pte 0\nthp_scan_exceed_swap_pte 0\nthp_scan_exceed_share_pte 0\nthp_split_pud 0\nthp_zero_page_alloc 0\nthp_zero_page_alloc_failed 0\nthp_swpout 0\nthp_swpout_fallback 0\nballoon_inflate 0\nballoon_deflate 0\nballoon_migrate 0\nswap_ra 0\nswap_ra_hit 0\nksm_swpin_copy 0\ncow_ksm 0\nzswpin 0\nzswpout 0\ndirect_map_level2_splits 29\ndirect_map_level3_splits 0\nnr_unstable 0' > ./vmstat
然后就在proot启动脚本中添加挂载选项:
结构-b 文件路径:/proc/文件名
例:-b /data/data/com.termux/stat:/proc/stat
以国光大佬脚本制作的系统为例:
sed -i '15a command+=" -b /data/data/com.termux/uptime:/proc/uptime"\ncommand+=" -b /data/data/com.termux/vmstat:/proc/vmstat"\ncommand+=" -b /data/data/com.termux/version:/proc/version"\ncommand+=" -b /data/data/com.termux/stat:/proc/stat"\ncommand+=" -b /data/data/com.termux/loadavg:/proc/locdavg"' ~/Termux-Linux/Ubuntu/start-ubuntu.sh
然后重新弄进入Ubuntu系统中即可解决挂载proc分区的问题
特别感谢
在此特别感谢b站用户@XihiMoe的文章:
Termux 上装 GNU/Linux 报错“Error: /proc must be mounted” - 哔哩哔哩 (bilibili.com)