1.工具安装
1.1 安装git (git version)
sudo apt install git
repo配置
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=~/bin:$PATH更换REPO_URL,避免拉取code卡主
vim bin/repo
把里面的
REPO_URL = ‘https://gerrit.googlesource.com/git-repo’
修改成
REPO_URL = ‘https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/’
1.2 安装jdk8
1)更新软件包列表:
sudo apt-get update
2)安装openjdk-8-jdk:
sudo apt-get install openjdk-8-jdk
3)查看java版本,看看是否安装成功:
java -version
#切换java
sudo update-alternatives --config java
sudo update-alternatives --config javac
1.3.编译报错
问题1
FAILED: out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-parser.c /bin/bash -c "prebuilts/build-tools/linux-x86/bin/bison -d --defines=out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-parser.h -o out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-parser.c external/dtc/dtc-parser.y" external/dtc/dtc-parser.y: conflicts: 3 shift/reduce FAILED: out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-lexer.c /bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/dtc-lexer.c external/dtc/dtc-lexer.l" flex-2.5.39: fatal internal error, exec of /usr/bin/m4 failed
#解决
sudo apt-get install bison
sudo apt-get install g++-multilib gcc-multilib lib32ncurses5-dev lib32z1-dev
问题2
Can't locate Switch.pm in @INC (you may need to install the Switch module)
#解决
sudo apt-get install libswitch-perl libxml2-utils
问题3
/media/mydisk/changyuchun/workspace/ma_t1y_android/kernel-4.4/scripts/extract-cert.c:21:25: fatal error: openssl/bio.h: No such file or directory compilation terminated. scripts/Makefile.host:91: recipe for target 'scripts/extract-cert' failed
#解决
sudo apt-get install libssl-dev
问题4 (ubuntu 16.04版本)
java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached [ 10% 1743/17199] build out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/dex-hiddenapi/classes.dex [ 10% 1744/17199] Target Java: out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes-full-debug.jar FAILED: out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes-full-debug.jar /bin/bash -c "(rm -f out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes-full-debug.jar ) && (rm -rf out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/anno ) && (mkdir -p out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/ ) && (mkdir -p out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/anno ) && (if [ -s out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/java-source-list ] ; then out/soong/host/linux-x86/bin/soong_javac_wrapper prebuilts/jdk/jdk9/linux-x86/bin/javac -Xmaxerrs 9999999 -encoding UTF-8 -sourcepath \"\" -g -XDskipDuplicateBridges=true -XDstringConcat=inline -encoding UTF-8 -bootclasspath out/target/common/obj/JAVA_LIBRARIES/core-oj_intermediates/classes-header.jar:out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes-header.jar:out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes-header.jar:out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-header.jar:out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes-header.jar:out/target/common/obj/JAVA_LIBRARIES/core-lambda-stubs_intermediates/classes-header.jar -d out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes -s out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/anno -source 1.8 -target 1.8 \\@out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/java-source-list || ( rm -rf out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes ; exit 41 ) fi ) && (prebuilts/jdk/jdk9/linux-x86/bin/jar -cf out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes-full-debug.jar @<(find out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes -type f | sort | build/soong/scripts/jar-args.sh out/target/common/obj/JAVA_LIBRARIES/Mtk-SystemUI-tags_intermediates/classes; echo \"-C out/empty .\") )" [1.131s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 4k, detached. # # There is insufficient memory for the Java Runtime Environment to continue. # Cannot create worker GC thread. Out of system resources. # An error report file with more information is saved as: # /media/mydisk/changyuchun/workspace/ma_t1y_android/hs_err_pid41325.log [ 10% 1745/17199] Proguard: out/target/common/obj/APPS/CompanionDeviceManager_intermediates/classes-proguard.jar
#解决
make -j32 编译(尝试 j128 j64 会报错,j48 可以编译过)
sudo apt-get install openjdk-8-jdk 覆盖安装jdk后make -j64可以编译过。
--多方排插猜测和ubuntu有关,换18.04.4测试OK(make -j128编译通过)
问题5
ninja: fatal: posix_spawn: Resource temporarily unavailable 09:52:31 ninja failed with: exit status 1
#解决
重启服务器
问题6
/bin/bash: make: command not found
#解决
sudo apt-get install gcc automake autoconf libtool make
问题7
/bin/sh: 1: lz4c: not found arch/arm64/boot/Makefile:42: recipe for target 'arch/arm64/boot/Image.lz4' failed make[1]: *** [arch/arm64/boot/Image.lz4] Error 1 arch/arm64/Makefile:116: recipe for target 'Image.lz4' failed
#解决
sudo apt-get install liblz4-tool
2. Ubuntu下添加用户
2.1 新建名称为 company 的组(cat /etc/group) 如果已创建请忽略
sudo groupadd company2.2 新建用户 changyuchun, 自动创建主目录 /media/company/mydisk/changyuchun, 指定组为 company(指定的组必须已存在)
sudo useradd -md /media/company/mydisk/changyuchun -g company changyuchun2.3 修改用户密码
sudo passwd changyuchun2.4 passwd后面添加/bin/bash
sudo vim /etc/passwd
changyuchun:x:1001:1000::/media/company/mydisk/changyuchun:/bin/bash2.5 添加用户所在组
sudo usermod -aG company changyuchun
company adm sudo cdrom dip plugdev lpadmin sambashare
经测试,所在以下组即可:
company@company:~$ groups changyuchun
changyuchun : company sambashare2.6 删除用户
sudo deluser changyuchun
遇到问题:
Could not chdir to home directory /home/xxx:Permission denied
说明:工作目录权限不够导致的(/media/company/mydisk 需要赋予777权限,并且root:root)
注:目前装机系统挂载目录/media/company/mydisk,挂载目录可以不用这么长。
company@company:~$ ls -al /media/
total 12
drwxrwxrwx 3 root root 4096 5月 5 17:35 .
drwxr-xr-x 24 root root 4096 4月 22 07:06 ..
drwxrwxrwx+ 3 root root 4096 4月 21 14:29 company
3.samba安装和权限配置(参考:http://t.zoukankan.com/huxiaoyun90-p-4060233.html)
1.安装samba
sudo apt-get install samba samba-common2.配置用户工作目录(配置文件末尾追加)
security = user 时,
注释掉以下:
#map to guest = bad user
#usershare allow guests = yescat /etc/samba/smb.conf
[changyuchun]
path = /media/company/mydisk/changyuchun
read only = no
public = no
guest ok = no
valid users = changyuchun3.将linux系统已存在用户 username(例)加入到 Samba 用户数据库
sudo smbpasswd -a changyuchun4.重启smbd服务后生效
sudo service smbd restart
4.其他记录参考
##key_load_public: invalid format 怎么办?
执行修复公钥命令,解决问题(前提是私钥是OK的)
ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub
#查看cpu核数
cat /proc/cpuinfo | grep -i 'processor' | wc -l
128
#查看内存槽的数目,哪个槽位插了内存以及每个内存槽位现在的内存大小
sudo dmidecode|grep -P -A5 "Memory\s+Device"|grep Size|grep -v Range
Size: 32 GB
Size: 32 GB
Size: 32 GB
Size: 32 GB
Size: 32 GB
Size: 32 GB
Size: 32 GB
Size: 32 GB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
#查看磁盘信息
sudo blkid
/dev/sda: LABEL="mydisk" UUID="fcfd8b9a-807f-4a25-b541-5a6971b15b42" TYPE="ext4"
/dev/sdb1: UUID="F2C1-D3FB" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="043c911c-a1ca-477f-bf94-67397e1a5e28"
/dev/sdb2: UUID="c0f68a23-f84c-4a4a-adec-ee7d710ea698" TYPE="ext4" PARTUUID="a6df4eec-0eeb-4aa4-8304-02942c4b0d08"
/dev/sdb3: UUID="a873c751-5576-4ab5-9830-c1c7fe8f14a3" TYPE="swap" PARTUUID="d789afa8-0a34-4891-a17a-f62886edc47d"
/dev/sdb4: UUID="f3977701-80f5-43ac-88b6-111b63a9200a" TYPE="ext4" PARTUUID="246a8717-5113-4525-bab0-784110004ee4"
# 挂载分区 https://www.meiwen.com.cn/subject/gxmujqtx.html //使用parted解决大于2T的磁盘分区
sudo mkdir -p /media/company/mydisk
sudo mount /dev/sda /media/company/mydisk# 设置开机自动挂载磁盘
sudo vim /etc/fstab
company@company:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdb2 during installation
UUID=c0f68a23-f84c-4a4a-adec-ee7d710ea698 / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sdb1 during installation
UUID=F2C1-D3FB /boot/efi vfat umask=0077 0 1
# /home was on /dev/sdb4 during installation
UUID=f3977701-80f5-43ac-88b6-111b63a9200a /home ext4 defaults 0 2
# swap was on /dev/sdb3 during installation
UUID=a873c751-5576-4ab5-9830-c1c7fe8f14a3 none swap sw 0 0
# /mydisk was on /dev/sda during installation
UUID=fcfd8b9a-807f-4a25-b541-5a6971b15b42 /media/company/mydisk ext4 defaults 0 0