分类 Linux 下的文章

  1. 查看防火墙状态

    systemctl status firewalld 或者 firewall-cmd --state
  2. 临时关闭防火墙测试是否是端口问题
    
    systemctl stop firewalld

3. 开启防火墙

systemctl start firewalld


4. 增加端口

firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=12345/tcp --permanent


5. 重新加载

firewall-cmd --reload

  1. 打补丁,patch -p1 < ../linux-2.6.22.6.patch 。 -p1 这个命令参数的意思是忽略补丁文件中目录的第一个 / 之前的内容。后面参数的意思是把指定目录中的 patch 文件打到当前目录。

  2. 配置。可以使用 find -name "*.defconfig" 查找一下内核当前支持的一些 board 的配置。找到 s3c2410_defconfig 比较相近,就执行 make s3c2410_defconfig 进行配置,这时候 s3c2410_defconfig 里面的配置就写入到 .config 文件中了。然后使用 make menuconfig 在 s3c2410_defconfig 的基础上进行修改。一般内核先配置 make s3c2410_defconfig,然后编译 make menuconfig。有时候厂家会提供 config_厂家,这时候只需 cp config_厂家 .config,然后 make menuconfig 就可以了。

  3. 编译内核直接用 make,但是给 uboot 用的内核需要用 make uImage 来编译,这个和正常的内核相比,多了一个头部内容。适合给 uboot 引导使用。

  4. uboot 中烧录内核使用 k 命令,这个命令具体可以在 cmd_menu.c 中找到 k 的具体内容, usbslave 1 0x30000000, nand erase kernel, nand write.jffs2 0x30000000 kernel (filesize)。 先接受内核到 0x30000000 内存中,然后擦除 nand 中 kernel 分区,然后从 0x30000000 内存地址处读取数据,写入 nand 中的 kernel 分区,写入(filesize) 大小。

  5. 如果删除了 root 分区,那么 内核启动到一定程度的时候,就会卡在那边。

  6. 内核编译的时候,根据 .config 生成 include/linux/autoconf.h 这个里面是对各个配置生成的详细的头文件,里面的 CONFIG_ 给各个 C语言的源码使用。.config 中设置为 y 或者 m,在 autoconfig.h 中宏定义就都是 1. 而 y 和 m 的区别体现在 子目录的 makefile 里面,比如说 drivers/net/makefile。在内核子目录中的 makefile 里面,配置为 y 和 m 是不同的, obj_y+= 这个会编译到内核里面去, obj_m+= 这个会编译为模块 ko 给内核加载。 配置还会出现在 include/config/auto.conf 中。配置的 y 和 m 先在 auto.conf 中自动生成好。

make uImage 时候,首先根据 .config 生成 autoconfig.h 给源代码使用,生成 auto.conf 给 顶层 makefile 包含,给子目录的 makefile 使用。

  1. linux-版本号 / Doc / kbuild 这里面的 makefile.txt 里面有内核 makefile 的详细讲解。 如果要编译为一个模块,类似的写法是:

    obj_m += ab.o
    ab_objs := a.o b.o

    这样 a.c, b.c 两个文件就会被先编译为 a.o, b.o,然后被链接为 ab.ko 这个模块。

  2. 当使用 make uImage 的时候,会使用顶层的 makefile,顶层 makefile 里面有 include (srctree)/arch/(ARCH)/Makefile , 这样就包含了 arm 这样架构目录下面的 makefile。顶层 makefile 里面还有 include /config/auto.conf,这样就包含了配置。 uImage 的依赖是 vmlinux, vmlinux 是真正的内核文件,加上了头部之后,才是 uImage。如果直接就是 make 的话,那么就是 all,all 依赖的也是 vmlinux。 make uImage V=1 这个命令是让编译时候打印出来的信息更加详细。打印信息中的 ld -T 后面的 lds 文件是具体的链接脚本。第一个编译的文件是 arch/arm/kernel/head.o ,这个是 head.S 汇编文件,链接脚本是 arch/arm/kernel/vmlinux.lds

tq2440 里面需要编译的是 zImage,然后使用配套的 uboot,可以直接下载 zImage 内核并启动。 tq2440 make zImage 的时候,会提示错误 Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373. /opt/ARM/mini6410/linux/linux-2.6.38/kernel/Makefile:140: recipe for target 'kernel/timeconst.h' failed make[1]: [kernel/timeconst.h] Error 255 Makefile:916: recipe for target 'kernel' failed make: [kernel] Error 2

报错信息提示我们文件kernelkernel/timeconst.pl的第373不能使用'defined(@array)',将kernel/timeconst.pl中第373行的defined()去掉只留下@val就可以了. 考虑去掉defined(),改为: 372         @val = @{canned_values{hz}}; 373         if (!@val) { 374                 @val = compute_values($hz); 375         }

关于 zImage 和 uImage 的差别,可以参考 https://www.cnblogs.com/linhaostudy/p/6735697.html

  1. compress 目录下面的 head.S 是为了压缩内核的。如果内核过大,可以压缩内核,然后在内核前面加上自解压代码,这样组合起来变成一个小一点的内核。运行的时候,先自解压,之后再执行内核。

  2. lookup_machine_type 中的
    
    3:      .long .
         .long arch_info_begin
         .long arch_info_end

adr r3, 3b @ 让 r3 等于 标号3所在地方的物理地址。 ldmia r3, {r4, r5, r6} @ 让 r4 等于 r3 的虚拟地址,也就是 标号3 的虚拟地址, 让 r5 等于 arch_info_begin, r6 等于 arch_info_end. sub r3, r3, r4 @ r3 等于虚拟地址和物理地址之间的偏移 add r5, r5, r3 @ r5 是对应的 物理地址 add r6, r6, r3 @ r6 是对应的 物理地址。


11. head.S 中内核启动时,首先判断是否支持 cpu,然后判断是否支持 单板(这个通过 u-boot 中 执行内核的 kernel 函数调用时传入的 machine_id),然后建立页表, 使能 mmu,然后跳转 start_kernel 来处理 u-boot 传入的启动参数。

start_kernel setup_arch //解析 u-boot 传入的启动参数 setup_command_line //解析 u-boot 传入的启动参数 parse_early_param do_early_param 从 setup_start 到 setup_end,调用 early 函数。 unknown_bootoption obsolute_checksetup 从 setup_start 到 setup_end,调用非 early 函数。 rest_init kernel_init prepare_namespace mount_root 这样就能挂载根文件系统了。 init_post 这个函数里面 打开 console,然后执行 init 等应用程序


挂载根文件系统按照 u-boot 中的 boot_args 这个参数来做。 uboot 中的 boot_args 里面的 root=/dev/mtdblock3 是和 linux 中的 arch/arm/plat-s3c24xx 中的 common-smdk.c 定义的 smdk_default_nand_part[] 这个分区结构体数组对应的。

gentoo 上面修改键盘映射分为两种,一种是终端环境,一种是X环境。

终端环境

https://www.emacswiki.org/emacs/MovingTheCtrlKey https://wiki.gentoo.org/wiki/Keyboard_layout_switching 参考里面的终端部分,从 /usr/share/keymaps/i386/qwerty/ 这个文件夹里面复制 us.map,解压 gunzip .map 然后修改里面的 control 对应的码, 然后另存为 us_ptz.map,并进行压缩,gzip .map 然后放到 /usr/share/keymaps/i386/qwerty/ 这个文件夹下面。

然后修改 /etc/conf.d/keymaps 这个文件,选择修改好的文件, 然后重启keymap, rc-service keymaps restart

按键可以通过 showkey 来获得对应的键值。

X环境

https://wiki.gentoo.org/wiki/Keyboard_layout_switching https://www.charvolant.org/doug/xkb/html/index.html http://blog.csdn.net/kl28978113/article/details/47955275

使用 setxkbmap 来管理X环境键盘布局 /etc/X11/Sessions/Xsession 这个文件可以看出使用 setxkbmap来对于 键盘布局进行管理。

setxkbmap -print -verbose 10 查看当前的 keymap

/usr/share/X11/xkb/keycodes/evdev 考虑了一下,最后直接修改 keycode里面的 evdev 文件,把里面的 caps和 RCTL替换,RTN和LCTL替换。

最近 gentoo 从 17.0 更新到 17.1, 需要手动进行升级配置,使用 unsymlink-lib -p --finish 这一步的时候报错,报错如下:

/usr/lib/python-exec/python3.6/unsymlink-lib -p --finish 

... 
rm -d /usr/lib64/go/test/fixedbugs/issue5957.dir/c.go 
rm -d /usr/lib64/go/test/fixedbugs/issue5957.dir/b.go 
rm -d /usr/lib64/go/test/fixedbugs/issue5957.dir/a.go 
rm -d /usr/lib64/go/test/fixedbugs/bug437.dir/one.go 
rm -d /usr/lib64/go/test/fixedbugs/bug437.dir/x.go 
rm -d /usr/lib64/go/test/fixedbugs/bug437.dir/two.go 
Traceback (most recent call last): 
  File "/usr/lib/python-exec/python3.6/unsymlink-lib", line 819, in <module> 
    main() 
  File "/usr/lib/python-exec/python3.6/unsymlink-lib", line 782, in main 
    m.finish(pretend=args.pretend, resume=args.action.endswith('resume')) 
  File "/usr/lib/python-exec/python3.6/unsymlink-lib", line 585, in finish 
    out('rm -d {}', fp) 
  File "/usr/lib/python-exec/python3.6/unsymlink-lib", line 41, in out 
    _log(template, *args, **kwargs) 
  File "/usr/lib/python-exec/python3.6/unsymlink-lib", line 30, in _log 
    **kwargs 
UnicodeEncodeError: 'ascii' codec can't encode character '\xc4' in position 50: ordinal not in range(128) 

我的 unsymlink-lib 的版本是 15,前面的一些 bug 已经修复了,所以检查 locale 的结果,结果发现是 locale 的问题, locale 都是 "POSIX",通过修改 /etc/env.d/02locale,

LANG="en_US.UTF-8" 
LC_COLLATE="C" 

然后 env-update && source /etc/profile,就解决问题了。

转自: https://www.jianshu.com/p/85d00246d1f0

在Ubunt的基本环境(Ubuntu上的软件基础--for NAS)搭建好以后,家庭多媒体中心的任务就摆在了面前。 参考了很多资料,Emby Server看起来是最好的选择,安装的过程很简单,网上有很多的教程,重点是我自己安装后不会用,下面就重点介绍一下安装以后的几种在小米盒子上看电影的方法。

- 阅读剩余部分 -

转自: https://emby.media/community/index.php?/topic/11176-gentoo-release/

ATTENTION: If you still have the old mediabrowser-server package installed be sure to switch to emby-server as 3.0.5572.0 will be the last update to this package! Also the library path for the emby-server package moved to /var/lib/emby-server!

Good news everyone! The linux package list for the server is growing! After the first debian/ubuntu package surfaced, now the gentoo package is on its way.

To use it fire up our all time favourite layman and add the overlay megacoffee:

layman -a megacoffee

Next up you should customize some options like file type support for imagemagick and ffmpeg to suit your needs by configuring use flags. Here's an example of suggested settings, you can put it as a file in /etc/portage/package.use/emby :

# this disables libgdiplus support in mono as we don't use it
dev-lang/mono minimal

# picture format support: jpeg, png and webp are needed, everything else is optional and may depend on your photos file formats
media-gfx/imagemagick jpeg jpeg2k png webp tiff

# the q8 setting is optional and speeds up image processing, if you have other tools using imagemagick you might want to disable this
media-gfx/imagemagick q8

# these are some basic ffmpeg runtime options that should always be enabled for performance reasons
media-video/ffmpeg vdpau vpx threads

# here you should define spport for all codecs you have in your video collection!
media-video/ffmpeg aac mp3 pic theora vorbis x264 xvid webp

After that you can install the package through

emerge -avND media-tv/emby-server

As the package depends on an version of mono that gentoo still consideres to be 'unstable' and the releases are fairly fresh, the packages are still architecture masked.

Architectures that should work are x86, amd64 and arm. I haven't been able to actually test the ebuild on ARM systems, so if you happen to have an ARM based gentoo box please drop me a line if it works all right. If you feel lucky you can also try this on any number of other architectures and let me know you have any problems.

Some things to know about the package:

If you are an inexperienced linux user and try to decide what kind of linux distro you want to use: do not use gentoo just because there is a emby package! Gentoo needs a good amount of time to correctly setup and grasp, so you propably will run into problems that you cannot fix on the first run, so be prepared! It will be installed to /opt/emby-server. The data directory defaults to /var/lib/emby-server but can be changed through the configuration in /etc/conf.d/emby-server.conf The newest mono release in the official tree is 3.2.8 and architecture masked. It is mostly stable though, so don't be shy to unmask it. If you want or need a more recent version use the overlay dotnet from the official layman list. The current recommendation is to use 3.10.0, as old versions have problems with SSL connections and 3.12.0 is a bit wonky on the stability side. If you already use an systemd enabled gentoo you won't have an init script ready for use (currently only the default OpenRC is supported here). Until I have been able to setup a test environment have a look at answer #9 in this thread. For more information about the overlay and contact options apart from this forum head over to http://gentoo-overlay.megacoffee.net/ Have fun and let me know if there are problems!

All ebuilds (including the dev ebuilds) have been updated and completed up to the current release.

I plan to provide updated ebuilds within a small amount of time from official releases so you should be covered.

For the dev (9999) ebuild: there will from time to time be problems with building it. As it builds the current in development snapshot this is to be expected.

If you plan to actually use mediabrowser and not just play around with it please refrain from using that ebuild!

yes the q8 problem is a bug in the current ebuild, it will be refreshed soon. Adding the q8 useflag is encouraged (speeds up image conversion), but not a necessity.

The codecs for ffmpeg depend on what media you are trying to use with emby. I deliberately didn't force any specific formats as long as emby itself doesn't need them, to avoid cluttering systems with codecs and other libraries that are not necessary. I will update the instructions to reflect those kind of pre-install changes though.

Q8 problem fixed, and updated first post with suggested use flag definitions. Have fun everyone! :)

As a heads up: in a future revision the default programData folder will move to /var/lib/!

Edit: revision 2 of the current release is up containing the folder move!

转自: http://gentoo-overlay.megacoffee.net/

At this unofficial place, we publish some ebuilds that may (or may not) be interesting to other Gentoo users. What we serve here are

ebuilds written by ourselves ebuilds that were already in official portage but needed some small change to build newer version ebuilds that we fetched from Gentoo Bugzilla at some point ebuilds with added patches of which some may have been written by us some may have been fetched from other sources such as bug trackers ebuilds that may have been removed previously from official portage - note that these may have been removed for a reason but this is for the special cases in which you simply just need them... All these ebuilds should be considered experimental. As we collect them from other sources (in accordance to the licenses), you are of course free to copy ours as well.

How to connect your Gentoo installation

The easiest way is to use layman to connect with us.

First, get mercurial and layman if you haven't done so already:

echo app-portage/layman mercurial >>/etc/portage/package.use
emerge layman # and follow instructions for /etc/make.conf

We are now on the official layman repository list, so all you need to do is:

  1. Run layman -f once to update the repository list.
  2. Add our overlay megacoffee to your local installation by running layman -a megacoffee - you should see an output similar to this:
    # layman -a megacoffee
    * Running... # /usr/bin/hg clone http://rhodecode.megacoffee.net/gentoo-overlay/main/ /var/lib/layman/megacoffee
    requesting all changes
    adding changesets
    adding manifests
    adding file changes
    added 12 changesets with 30 changes to 22 files
    updating to branch default
    20 files updated, 0 files merged, 0 files removed, 0 files unresolved
    * Successfully added overlay "megacoffee".
  3. From now on, run layman -S whenever you want to check for updates. If you're a long-time user of our repository, you may still have added http://gentoo-overlay.megacoffee.net/repositories.xml to your /etc/layman/layman.cfg. You can safely remove that entry now that we're on the default list.

最近想用 emby-server + kodi 打造家庭播放平台, 在 gentoo 上面先尝试安装配置 emby-server.

首先, 使用 megacoffee 这个 overlay, 这个上面支持 systemd 前的最后版本是 media-tv/emby-server/emby-server-3.2.70.0-r1.ebuild. 但是这个 overlay 使用 mercurial, 所以使用以下命令: vim /etc/portage/package.use/layman

app-portage/layman mercurial

然后, 安装 layman

emerge layman

然后 添加 overlay

layman -f
layman -a megacoffee
layman -S

其中 Run layman -f once to update the repository list, run layman -S whenever you want to check for updates.

然后按照下面的内容, 对应添加到 package.use 中去:

# this disables libgdiplus support in mono as we don't use it
dev-lang/mono minimal

# picture format support: jpeg, png and webp are needed, everything else is optional and may depend on your photos file formats
media-gfx/imagemagick jpeg jpeg2k png webp tiff

# the q8 setting is optional and speeds up image processing, if you have other tools using imagemagick you might want to disable this
media-gfx/imagemagick q8

# these are some basic ffmpeg runtime options that should always be enabled for performance reasons
media-video/ffmpeg vdpau vpx threads

# here you should define spport for all codecs you have in your video collection!
media-video/ffmpeg aac mp3 pic theora vorbis x264 xvid webp

然后, 安装 emby-server

emerge -avND media-tv/emby-server

可以使用下面语句启动 emby-server

rc-service emby-server start

使用下面语句开机自启动 emby-server

rc-update add emby-server default

启动 emby-server 之后, 使用浏览器进行配置, 输入 http://localhost:8096/web/wizardstart.html 进入配置界面. 安装顺序配置完成之后, 使用 http://localhost:8096/web/home.html 进入主界面.

emby-server 配置好以后, 在客户端的 kodi 中也需要配置. kodi 中需要安装 emby 的插件. 安装Emby Server插件的办法: Add-ons -> Add-on browser -> Install from repository -> All repositories -> Video add-ons -> 往下翻到E开头,就会找到Emby, 然后等待安装完成即可.

今天在更新系统的时候,提示 virtualbox-bin 从原始地址下载不了,经过一番摸索,通过下面的方式即可正常安装。

http://download.virtualbox.org/virtualbox/5.2.26/ 通过 上面这个网址找到你要下载的 virtualbox 版本, 选择后缀 .amd64.run 的来下载。下载可以使用 aria2c 来下载,下载完成之后,把 run 文件放入 /usr/portage/distfiles 文件夹即可。

再次安装,提示下载 pack 失败,从上面网页找到 Oracle_VM_VirtualBox_Extension_Pack-5.2.26-128414.vbox-extpack 类似这个下载下来。然后把文件名修改,去掉 vbox-extpack, 增加 tar.gz,变成 Oracle_VM_VirtualBox_Extension_Pack-5.2.26-128414.tar.gz,这个文件也放入到 /usr/portage/distfiles 即可。

这样再次安装就没有问题了。

转自: https://www.ibm.com/support/knowledgecenter/en/linuxonibm/com.ibm.linux.z.lgdd/lgdd_r_hibkernelparameter.html

You configure the suspend and resume support by adding parameters to the kernel parameter line.

Read syntax diagramSkip visual syntax diagram suspend and resume kernel parameter syntax

-resume=--+---------------------+--+-----------+->< '- no_console_suspend-' '- noresume-'

where:

resume=

specifies the standard device node of the swap partition with the data that is required for resuming the Linux instance.

no_console_suspend

prevents Linux consoles from being suspended early in the suspend process. Without this parameter, you cannot see the kernel messages that are issued by the suspend process.

noresume

boots the kernel without resuming a previously suspended Linux instance. Add this parameter to circumvent the resume process, for example, if the data written by the previous suspend process is damaged.

Example

To use a partition /dev/disk/by-path/ccw-0.0.2f50-part1 as the swap partition and prevent Linux consoles from being suspended early in the suspend process specify:

resume=/dev/disk/by-path/ccw-0.0.2f50-part1 no_console_suspend

The example uses a "by-path" definition of the disk to ensure that the correct device is used, for example, after a reboot.