包含 Linux 标签的文章

Linux 查看 flash 分区命令

/proc/mtd 可以显示出所有挂载和未挂载的分区,但不显示文件系统类型。 cat /proc/mtd mtd0: 00080000 00020000 "MLO" mtd1: 00200000 00020000 "U-Boot" mtd2: 00580000 00020000 "Kernel" mtd3: 00800000 00020000 "File System" mtd4: 07000000 00020000 "app" df 可以查看已经挂载的分区和文件系统类型。 df -a Filesystem 1K-blocks Used Available Use% Mounted on ubi0:rootfs 4584 4576 8 100% / devtmpfs 127488 0 127488 0% /dev ramfs 0 0 0 0% /var ramfs 0 0 0 0% /tmp proc 0 0 0 0% /proc sysfs 0 0 0 0% /sys devpts 0 0 0 0% /dev/pts tmpfs 127592 0 127592 0% /dev/shm ubi1_0 89796 32 89764 0% /app fdisk 可以显示出所有挂载和未挂载的分区,但不显示文件系统类型。 fdisk -l Disk /dev/mtdblock0: 0 MB, 524288 bytes 255 heads, 63 sectors/track, 0 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/mtdblock0 doesn't contain a valid partition table Disk /dev/mtdblock1: 2 MB, 2097152 bytes 255 heads, 63 sectors/track, 0 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/mtdblock1 doesn't contain a valid partition table Disk /dev/mtdblock2: 5 MB, 5767168 bytes 255 heads, 63 sectors/track, 0 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/mtdblock2 doesn't contain a valid partition table Disk /dev/mtdblock3: 8 MB, 8388608 bytes 255 heads, 63 sectors/track, 1 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/mtdblock3 doesn't contain a valid partition table Disk /dev/mtdblock4: 117 MB, 117440512 bytes 255 heads, 63 sectors/track, 14 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/mtdblock4 doesn't contain a valid partition tabl...

Ubuntu 14.04 升级到 16.04

1、查看当前版本 lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.04 Codename: trusty 2、执行更新命令 apt-get update && apt-get dist-upgrade 3、重启系统 reboot 4、升级系统 将源改为 16.04 的源 do-release-upgrade 5、验证升级完成 lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.5 LTS Release: 16.04 Codename: xenia...

非 Docker 方式安装 GitLab

GitLab 是一个基于 Git 的代码托管与协作平台,可以实现代码的版本管理、代码的审阅、问题追踪等功能。它是一个开源的、管理代码的全流程解决方案,用户可以通过其提供的 Web 界面轻松地管理代码仓库、代码版本、任务列表、CI/CD 等。 GitLab 不仅仅是一个代码托管平台,还提供了许多其他的功能,如代码审查、问题追踪、Wiki、持续集成和交付等。其中,代码审查是 GitLab 最突出的功能之一,它可以让团队成员在代码合并之前对代码进行评审和讨论,确保代码的质量和一致性。此外,GitLab 还支持多人协作开发,用户可以通过它方便地与团队成员进行代码共享和协作开发。它还提供了强大的问题追踪功能,可以让团队成员轻松地跟踪和解决问题。 安装 CentOS 7 安装和配置必要的依赖: yum install policycoreutils openssh-server openssh-clients systemctl enable sshd systemctl start sshd yum -y install postfix systemctl enable postfix systemctl start postfix firewall-cmd --permanent --add-service=http systemctl reload firewalld 获取并安装软件包: yum 方式安装: vim /etc/yum.repos.d/gitlab-ce.repo [gitlab-ce] name=gitlab-ce baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7 repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key yum makecache yum -y install gitlab-ce 或直接安装 rpm 包: wget http://mirror.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.5.1-ce.0.el7.x86_64.rpm sudo rpm -i gitlab-ce-8.5.1-ce.0.el7.x86_64.rpm Ubuntu curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null sudo vim /etc/apt/sources.list.d/gitlab-ce.list deb https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu trusty main sudo apt-get update sudo apt-get install gitlab-ce=10.1.3-ce.0 配置 创建仓库位置 sudo mkdir -p /data/git-data sudo chown -R git:git /data/git-data 创建备份位置 sudo mkdir -p /backups/gitlab sudo chown -R git:git /backups/gitlab 修改配置文件 sudo vim /etc/gitlab/gitlab.rb external_url "https://192.168.1.223:8888" git_data_dir "/data/git-data" //// gitlab10 git_data_dirs({ "default" => { "path" => "/data/git-data" } }) /////////////////////////////// gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.mculoop.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "gitlab@mculoop.com" gitlab_rails['smtp_password'] = "***" gitlab_rails['smtp_domain'] = "smtp.mculoop.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['gitlab_email_from'] = "gitlab@mculoop.com" user["git_user_email"] = "gitlab@mculoop.com" #nginx['redirect_http_to_https'] = true ##注意:8.5.1版本 redirect_http_to_https 不能打开,否则会提示:no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking #nginx['redirect_http_to_https_port'] = 8888 nginx['ssl_certificate'] = "/data/ssl/localhost.crt" nginx['ssl_certificate_key'] = "/data/ssl/localhost.key" gitlab_rails['backup_path'] = '/backups/gitlab' 防火墙放端口 firewall-cmd --permanent --add-port=8888/tcp systemctl restart firewalld 配置并运行 gitlab-ctl reconfigure  #每次配置后都运行这个命令 好了,已经可以访问了。 默认用户名及密码: Username: root Password: 5iveL!fe 其他命令 重启命令: gitlab-ctl restart 查看运行情况命令: gitlab-ctl status 备份: sudo gitlab-ctl stop unicorn sudo gitlab-ctl stop sidekiq sudo gitlab-ctl stop nginx sudo gitlab-rake gitlab:backup:create sudo gitlab-ctl restart 定时备份: crontab -e 0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create #凌晨2点执行备份 #格式:minute hour day month dayofweek command 从备份恢复: # 停止相关数据连接服务 sudo gitlab-ctl stop unicorn sudo gitlab-ctl stop sidekiq # 从1393513186编号备份中恢复 gitlab-rake gitlab:backup:restore BACKUP=1515653671_2018_01_11_10.3.3 # 启动Gitlab gitlab-ctl restart 升级 Gitlab: 如果是用 yum 方式安装的,只需执行 yum install gitlab-ce 即可。 如果是用下载的 rpm 安装包安装的,升级过程: wget http://mirror.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.5.3-ce.0.el7.x86_64.rpm rpm -Uvh gitlab-ce-8.5.3-ce.0.el7.x86_64.rpm Ubuntu 下的与 CentOS 下的类...

Debian Xfce4 VNC 服务

1、安装服务: apt-get install vnc4server 2、设置密码: vncpasswd 3、停止服务 vncserver -kill :1 Killing Xtigervnc process ID 12510... success! 4、编辑 xstartup vi ~/.vnc/xstartup #!/bin/sh unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS vncconfig -iconic & xfce4-session & 5、启动服务 vncserver :1 -localhost n...

BusyBox inittab 文件介绍

除了基本的命令之外,BusyBox 还支持 init 功能,如同其它的 init 一样,BusyBox 的 init 也是完成系统的初始化工作,关机前的工作等等,我们知道在 Linux 的内核被载入之后,机器就把控制权转交给内核,内核启之后做了一些工作,然后找到根文件系统里面的 init 程序,并执行它。init 进程会依次进行以下工作: 为 init 设置信号处理过程; 初始化控制台; 剖析 /etc/inittab 文件; 执行系统初始化命令行,缺省情况下会使用 /etc/init.d/rcS; 执行所有导致 init 暂停的 inittab 命令(动作类型:wait); 执行所有仅执行一次的 inittab命令(动作类型:once); 一旦完成以上工作,init 进程便会循环执行以下进程: 执行所有终止时必须重新启动的 inittab 命令(动作类型:respawn) 执行所有终止时必须重新启动但启动前必须询问用户的 inittab 命令(动作类型:askfirst) 初始化控制台之后,BusyBox 会检查 /etc/inittab 文件是否存在,如果此文件不存在,BusyBox 会使用缺省的 inittab 配置,它主要为系统重引导,系统挂起以及 init 重启动设置缺省的动作,此外它还会为四个虚拟控制台(tty1 到 tty4)设置启动 shell 的动作。如果未建立这些设备文件,BusyBox 会报错。 Busybox 的 init 进程在初始化的时候会查看是否有 /etc/inittab 文件,如果有则解析它。 inittab 文件中每一行的格式如下所示: id:runlevel_ignored:action:command id:对 BusyBox 而言,id 用来指定启动进程的控制终端。如果省略,则使用与 init 进程一样的控制终端。 runlevel_ignored:对于 Busybox init 程序,这个字段没有意义,可以省略。 action:表示 init 程序如何控制这个子进程: action 说明 sysinit 为 init 提供初始化命令脚本的路径 wait 告诉 init 必须等到相应的进程完成之后才能继续执行 once 仅执行相应的进程一次,而且不会等待它执行完成 respawn 每当 init 进程监测到该进程终止时,重新启动该它 askfirst 与 respawn 类似,不过 init 进程先输出 “Please press Enter to actvie this console”,等用户输入回车键之后才启动子进程 shutdown 当系统关机(halt/reboot)时,执行相应的进程 restart 当 init 重新启动时(restart init when a QUIT is received),执行相应的进程,通常此处所执行的进程就是 init 本身 ctrlaltdel 当按下 Ctrl + Alt + Delete 组合键时,执行相应的进程 process:要执行的程序,它可以是可执行程序,也可以是脚本 实例: # Note: BusyBox init works just fine without an inittab. If no inittab is # found, it has the following default behavior: # ::sysinit:/etc/init.d/rcS # ::askfirst:/bin/sh # ::ctrlaltdel:/sbin/reboot # ::shutdown:/sbin/swapoff -a # ::shutdown:/bin/umount -a -r # ::restart:/sbin/init # tty2::askfirst:/bin/sh # tty3::askfirst:/bin/sh # tty4::askfirst:/bin/sh # # Boot-time system configuration/initialization script. # This is run first except when booting in single-user mode. # ::sysinit:/etc/init.d/rcS # /bin/sh invocations on selected ttys # # Note below that we prefix the shell commands with a "-" to indicate to the # shell that it is supposed to be a login shell. Normally this is handled by # login, but since we are bypassing login in this case, BusyBox lets you do # this yourself... # # Start an "askfirst" shell on the console (whatever that may be) ::askfirst:-/bin/sh # Start an "askfirst" shell on /dev/tty2-4 tty2::askfirst:-/bin/sh tty3::askfirst:-/bin/sh tty4::askfirst:-/bin/sh # /sbin/getty invocations for selected ttys tty4::respawn:/sbin/getty 38400 tty5 tty5::respawn:/sbin/getty 38400 tty6 # Example of how to put a getty on a serial line (for a terminal) #::respawn:/sbin/getty -L ttyS0 9600 vt100 #::respawn:/sbin/getty -L ttyS1 9600 vt100 # # Example how to put a getty on a modem line. #::respawn:/sbin/getty 57600 ttyS2 # Stuff to do when restarting the init process ::restart:/sbin/init # Stuff to do before rebooting ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r ::shutdown:/sbin/swapoff -...

9G25 使用 Buildroot 创建 rootfs

tar -jxvf buildroot-2017.02.tar.bz2 make at91sam9g20dfc_defconfig make menuconfig Target options ---> Enable VFP extension support Build options ---> Mirrors and Download locations ---> 修改几处源为国内的源,以加快下载速度 │ │ () Primary download site │ │ │ │ (http://sources.buildroot.net) Backup download site │ │ │ │ (http://mirrors.ustc.edu.cn/kernel.org) Kernel.org mirror │ │ │ │ (http://mirrors.ustc.edu.cn/gnu) GNU Software mirror │ │ │ │ (http://rocks.moonscript.org) LuaRocks mirror │ │ │ │ (http://mirrors.ustc.edu.cn/CPAN) CPAN mirror (Perl packages) 工具链配置 Toolchain ---> Toolchain type (Buildroot toolchain) (buildroot) custom toolchain vendor name C library (glibc) Kernel Headers (Linux 3.2.x kernel headers) 版本至少与实际使用的内核的版本一样老才可以,否则启动的时候会提示: FATAL: kernel too old Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00 查看 busybox 支持的 Linux 版本:file busybox | grep Linux glibc version (2.23) Binutils Version (binutils 2.26.1) GCC compiler Version (gcc 5.x) Enable C++ support 注:在使用 Buildroot 自己编译的 toolchian 之前我使用过 gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabi 作为外部 Toolchain,但是遇到了问题,编译的 rootfs 在启动的时候报错: Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 网上说问题可能是 Kernel 与 rootfs 在编译的时候没有同时开启 EABI,但我检查(readelf -hA vmlinux busybox)的结果是都开启了。会不会是浮点数的问题?配置的都是 soft float,也没问题。最后发现是 rootfs 指令集用的是 ARMv7-a,而 CPU 是 AT91SAM9G25(ARM926EJ-S(ARM9)),支持的指令集是 ARMv5t。单 buildroot 中没找到向外部 GCC 传递 CFLAGS(-march=armv5t)的配置,于是放弃使用外部工具链。 System configuration ---> /dev management (Dynamic using devtmpfs + eudev) 不选 Run a getty (login prompt) after boot (具体行为后续再 inittab 中改) (eth0) Network interface to configure through DHCP Kernel ---> 不选择编译 Kernel Target packages ---> Show packages that are also provided by busybox Shell and utilities ---> bash Debugging, profiling and benchmark ---> gdb Compressors and decompressors ---> bzip2 gzip Networking applications ---> pppd Bootloaders ---> 不选 如果需要额外配置 busybox,使用:make busybox-menuconfig ,这里使用默认配置 编译系统: make -j4 会在 dl 文件夹放置下载到的源码,在 output/image 中生成 rootfs.tar mkdir rootfs sudo tar -xvf rootfs.tar -C rootfs 添加 10_usbkey.rules 到 /etc/udev/rules.d /etc/profile export LD_LIBRARY_PATH=/qtlib /etc/inittab ttyS0::respawn:/bin/login -f root /etc/init.d/S10udev 修改 udevadm trigger --type=devices --action=add 为 udevadm trigger --type=devices 创建 /qtlib 把 QT 的部分动态库库放进去。 将 linux-ppp-scripts_v1.2 的文件放到相应的位置 sudo ./mkubifsimage rootfs/ ubifs.img 发现的问题: 在启动初始化时,执行 init.d/S10udev 中的 udevadm trigger --type=devices --action=add 时,会出现错误信息: UBI error: ubi_open_volume: cannot open device 0, volume 0, error -16 (估计是操作 /dev/mtd8 时出现的错误,因为 cat /dev/mtd8 时会出现同样的错误信息) cat /proc/mtd dev: size erasesize name mtd0: 00040000 00020000 "bootstrap" mtd1: 00080000 00020000 "uboot" mtd2: 00040000 00020000 "env" mtd3: 00040000 00020000 "env_redundant" mtd4: 00040000 00020000 "spare" mtd5: 00080000 00020000 "dtb" mtd6: 00600000 00020000 "kernel" mtd7: 0f800000 00020000 "rootfs" mtd8: 0eb68000 0001f000 "rootfs" 为什么会有两个 rootfs 呢?mtd8 是怎么来的,留待以后研究。 暂时的解决对策是: 去掉此行中的 --action=a...

把 qt 库加入 rootfs 并制作 UBIFS 镜像

解压 rootfs: sudo tar -zxvf rootfs.tar.gz -C rootfs 添加 10_usbkey.rules到 /etc/udev/rules.d(自动挂载,非必须) 编辑 /etc/profile,加入: export LD_LIBRARY_PATH=/qtlib 编辑 /etc/inittab,加入: ttyO0::respawn:/bin/login -f root 实现自动登陆(非必要) 创建 /qtlib 把 QT 的部分动态库库放进去。 制作镜像: sudo ./mkfs.ubifs -F -r rootfs -m 2048 -e 126976 -c 1866 -o ubifs.img ./ubinize -o ubi.img -m 2048 -p 128KiB -s 2048 -O 2048 ubinize-256M.cf...