linux/Documentation/translations/zh_TW/admin-guide
Linus Torvalds 617a814f14 ALong with the usual shower of singleton patches, notable patch series in
this pull request are:
 
 "Align kvrealloc() with krealloc()" from Danilo Krummrich.  Adds
 consistency to the APIs and behaviour of these two core allocation
 functions.  This also simplifies/enables Rustification.
 
 "Some cleanups for shmem" from Baolin Wang.  No functional changes - mode
 code reuse, better function naming, logic simplifications.
 
 "mm: some small page fault cleanups" from Josef Bacik.  No functional
 changes - code cleanups only.
 
 "Various memory tiering fixes" from Zi Yan.  A small fix and a little
 cleanup.
 
 "mm/swap: remove boilerplate" from Yu Zhao.  Code cleanups and
 simplifications and .text shrinkage.
 
 "Kernel stack usage histogram" from Pasha Tatashin and Shakeel Butt.  This
 is a feature, it adds new feilds to /proc/vmstat such as
 
     $ grep kstack /proc/vmstat
     kstack_1k 3
     kstack_2k 188
     kstack_4k 11391
     kstack_8k 243
     kstack_16k 0
 
 which tells us that 11391 processes used 4k of stack while none at all
 used 16k.  Useful for some system tuning things, but partivularly useful
 for "the dynamic kernel stack project".
 
 "kmemleak: support for percpu memory leak detect" from Pavel Tikhomirov.
 Teaches kmemleak to detect leaksage of percpu memory.
 
 "mm: memcg: page counters optimizations" from Roman Gushchin.  "3
 independent small optimizations of page counters".
 
 "mm: split PTE/PMD PT table Kconfig cleanups+clarifications" from David
 Hildenbrand.  Improves PTE/PMD splitlock detection, makes powerpc/8xx work
 correctly by design rather than by accident.
 
 "mm: remove arch_make_page_accessible()" from David Hildenbrand.  Some
 folio conversions which make arch_make_page_accessible() unneeded.
 
 "mm, memcg: cg2 memory{.swap,}.peak write handlers" fro David Finkel.
 Cleans up and fixes our handling of the resetting of the cgroup/process
 peak-memory-use detector.
 
 "Make core VMA operations internal and testable" from Lorenzo Stoakes.
 Rationalizaion and encapsulation of the VMA manipulation APIs.  With a
 view to better enable testing of the VMA functions, even from a
 userspace-only harness.
 
 "mm: zswap: fixes for global shrinker" from Takero Funaki.  Fix issues in
 the zswap global shrinker, resulting in improved performance.
 
 "mm: print the promo watermark in zoneinfo" from Kaiyang Zhao.  Fill in
 some missing info in /proc/zoneinfo.
 
 "mm: replace follow_page() by folio_walk" from David Hildenbrand.  Code
 cleanups and rationalizations (conversion to folio_walk()) resulting in
 the removal of follow_page().
 
 "improving dynamic zswap shrinker protection scheme" from Nhat Pham.  Some
 tuning to improve zswap's dynamic shrinker.  Significant reductions in
 swapin and improvements in performance are shown.
 
 "mm: Fix several issues with unaccepted memory" from Kirill Shutemov.
 Improvements to the new unaccepted memory feature,
 
 "mm/mprotect: Fix dax puds" from Peter Xu.  Implements mprotect on DAX
 PUDs.  This was missing, although nobody seems to have notied yet.
 
 "Introduce a store type enum for the Maple tree" from Sidhartha Kumar.
 Cleanups and modest performance improvements for the maple tree library
 code.
 
 "memcg: further decouple v1 code from v2" from Shakeel Butt.  Move more
 cgroup v1 remnants away from the v2 memcg code.
 
 "memcg: initiate deprecation of v1 features" from Shakeel Butt.  Adds
 various warnings telling users that memcg v1 features are deprecated.
 
 "mm: swap: mTHP swap allocator base on swap cluster order" from Chris Li.
 Greatly improves the success rate of the mTHP swap allocation.
 
 "mm: introduce numa_memblks" from Mike Rapoport.  Moves various disparate
 per-arch implementations of numa_memblk code into generic code.
 
 "mm: batch free swaps for zap_pte_range()" from Barry Song.  Greatly
 improves the performance of munmap() of swap-filled ptes.
 
 "support large folio swap-out and swap-in for shmem" from Baolin Wang.
 With this series we no longer split shmem large folios into simgle-page
 folios when swapping out shmem.
 
 "mm/hugetlb: alloc/free gigantic folios" from Yu Zhao.  Nice performance
 improvements and code reductions for gigantic folios.
 
 "support shmem mTHP collapse" from Baolin Wang.  Adds support for
 khugepaged's collapsing of shmem mTHP folios.
 
 "mm: Optimize mseal checks" from Pedro Falcato.  Fixes an mprotect()
 performance regression due to the addition of mseal().
 
 "Increase the number of bits available in page_type" from Matthew Wilcox.
 Increases the number of bits available in page_type!
 
 "Simplify the page flags a little" from Matthew Wilcox.  Many legacy page
 flags are now folio flags, so the page-based flags and their
 accessors/mutators can be removed.
 
 "mm: store zero pages to be swapped out in a bitmap" from Usama Arif.  An
 optimization which permits us to avoid writing/reading zero-filled zswap
 pages to backing store.
 
 "Avoid MAP_FIXED gap exposure" from Liam Howlett.  Fixes a race window
 which occurs when a MAP_FIXED operqtion is occurring during an unrelated
 vma tree walk.
 
 "mm: remove vma_merge()" from Lorenzo Stoakes.  Major rotorooting of the
 vma_merge() functionality, making ot cleaner, more testable and better
 tested.
 
 "misc fixups for DAMON {self,kunit} tests" from SeongJae Park.  Minor
 fixups of DAMON selftests and kunit tests.
 
 "mm: memory_hotplug: improve do_migrate_range()" from Kefeng Wang.  Code
 cleanups and folio conversions.
 
 "Shmem mTHP controls and stats improvements" from Ryan Roberts.  Cleanups
 for shmem controls and stats.
 
 "mm: count the number of anonymous THPs per size" from Barry Song.  Expose
 additional anon THP stats to userspace for improved tuning.
 
 "mm: finish isolate/putback_lru_page()" from Kefeng Wang: more folio
 conversions and removal of now-unused page-based APIs.
 
 "replace per-quota region priorities histogram buffer with per-context
 one" from SeongJae Park.  DAMON histogram rationalization.
 
 "Docs/damon: update GitHub repo URLs and maintainer-profile" from SeongJae
 Park.  DAMON documentation updates.
 
 "mm/vdpa: correct misuse of non-direct-reclaim __GFP_NOFAIL and improve
 related doc and warn" from Jason Wang: fixes usage of page allocator
 __GFP_NOFAIL and GFP_ATOMIC flags.
 
 "mm: split underused THPs" from Yu Zhao.  Improve THP=always policy - this
 was overprovisioning THPs in sparsely accessed memory areas.
 
 "zram: introduce custom comp backends API" frm Sergey Senozhatsky.  Add
 support for zram run-time compression algorithm tuning.
 
 "mm: Care about shadow stack guard gap when getting an unmapped area" from
 Mark Brown.  Fix up the various arch_get_unmapped_area() implementations
 to better respect guard areas.
 
 "Improve mem_cgroup_iter()" from Kinsey Ho.  Improve the reliability of
 mem_cgroup_iter() and various code cleanups.
 
 "mm: Support huge pfnmaps" from Peter Xu.  Extends the usage of huge
 pfnmap support.
 
 "resource: Fix region_intersects() vs add_memory_driver_managed()" from
 Huang Ying.  Fix a bug in region_intersects() for systems with CXL memory.
 
 "mm: hwpoison: two more poison recovery" from Kefeng Wang.  Teaches a
 couple more code paths to correctly recover from the encountering of
 poisoned memry.
 
 "mm: enable large folios swap-in support" from Barry Song.  Support the
 swapin of mTHP memory into appropriately-sized folios, rather than into
 single-page folios.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCZu1BBwAKCRDdBJ7gKXxA
 jlWNAQDYlqQLun7bgsAN4sSvi27VUuWv1q70jlMXTfmjJAvQqwD/fBFVR6IOOiw7
 AkDbKWP2k0hWPiNJBGwoqxdHHx09Xgo=
 =s0T+
 -----END PGP SIGNATURE-----

Merge tag 'mm-stable-2024-09-20-02-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull MM updates from Andrew Morton:
 "Along with the usual shower of singleton patches, notable patch series
  in this pull request are:

   - "Align kvrealloc() with krealloc()" from Danilo Krummrich. Adds
     consistency to the APIs and behaviour of these two core allocation
     functions. This also simplifies/enables Rustification.

   - "Some cleanups for shmem" from Baolin Wang. No functional changes -
     mode code reuse, better function naming, logic simplifications.

   - "mm: some small page fault cleanups" from Josef Bacik. No
     functional changes - code cleanups only.

   - "Various memory tiering fixes" from Zi Yan. A small fix and a
     little cleanup.

   - "mm/swap: remove boilerplate" from Yu Zhao. Code cleanups and
     simplifications and .text shrinkage.

   - "Kernel stack usage histogram" from Pasha Tatashin and Shakeel
     Butt. This is a feature, it adds new feilds to /proc/vmstat such as

       $ grep kstack /proc/vmstat
       kstack_1k 3
       kstack_2k 188
       kstack_4k 11391
       kstack_8k 243
       kstack_16k 0

     which tells us that 11391 processes used 4k of stack while none at
     all used 16k. Useful for some system tuning things, but
     partivularly useful for "the dynamic kernel stack project".

   - "kmemleak: support for percpu memory leak detect" from Pavel
     Tikhomirov. Teaches kmemleak to detect leaksage of percpu memory.

   - "mm: memcg: page counters optimizations" from Roman Gushchin. "3
     independent small optimizations of page counters".

   - "mm: split PTE/PMD PT table Kconfig cleanups+clarifications" from
     David Hildenbrand. Improves PTE/PMD splitlock detection, makes
     powerpc/8xx work correctly by design rather than by accident.

   - "mm: remove arch_make_page_accessible()" from David Hildenbrand.
     Some folio conversions which make arch_make_page_accessible()
     unneeded.

   - "mm, memcg: cg2 memory{.swap,}.peak write handlers" fro David
     Finkel. Cleans up and fixes our handling of the resetting of the
     cgroup/process peak-memory-use detector.

   - "Make core VMA operations internal and testable" from Lorenzo
     Stoakes. Rationalizaion and encapsulation of the VMA manipulation
     APIs. With a view to better enable testing of the VMA functions,
     even from a userspace-only harness.

   - "mm: zswap: fixes for global shrinker" from Takero Funaki. Fix
     issues in the zswap global shrinker, resulting in improved
     performance.

   - "mm: print the promo watermark in zoneinfo" from Kaiyang Zhao. Fill
     in some missing info in /proc/zoneinfo.

   - "mm: replace follow_page() by folio_walk" from David Hildenbrand.
     Code cleanups and rationalizations (conversion to folio_walk())
     resulting in the removal of follow_page().

   - "improving dynamic zswap shrinker protection scheme" from Nhat
     Pham. Some tuning to improve zswap's dynamic shrinker. Significant
     reductions in swapin and improvements in performance are shown.

   - "mm: Fix several issues with unaccepted memory" from Kirill
     Shutemov. Improvements to the new unaccepted memory feature,

   - "mm/mprotect: Fix dax puds" from Peter Xu. Implements mprotect on
     DAX PUDs. This was missing, although nobody seems to have notied
     yet.

   - "Introduce a store type enum for the Maple tree" from Sidhartha
     Kumar. Cleanups and modest performance improvements for the maple
     tree library code.

   - "memcg: further decouple v1 code from v2" from Shakeel Butt. Move
     more cgroup v1 remnants away from the v2 memcg code.

   - "memcg: initiate deprecation of v1 features" from Shakeel Butt.
     Adds various warnings telling users that memcg v1 features are
     deprecated.

   - "mm: swap: mTHP swap allocator base on swap cluster order" from
     Chris Li. Greatly improves the success rate of the mTHP swap
     allocation.

   - "mm: introduce numa_memblks" from Mike Rapoport. Moves various
     disparate per-arch implementations of numa_memblk code into generic
     code.

   - "mm: batch free swaps for zap_pte_range()" from Barry Song. Greatly
     improves the performance of munmap() of swap-filled ptes.

   - "support large folio swap-out and swap-in for shmem" from Baolin
     Wang. With this series we no longer split shmem large folios into
     simgle-page folios when swapping out shmem.

   - "mm/hugetlb: alloc/free gigantic folios" from Yu Zhao. Nice
     performance improvements and code reductions for gigantic folios.

   - "support shmem mTHP collapse" from Baolin Wang. Adds support for
     khugepaged's collapsing of shmem mTHP folios.

   - "mm: Optimize mseal checks" from Pedro Falcato. Fixes an mprotect()
     performance regression due to the addition of mseal().

   - "Increase the number of bits available in page_type" from Matthew
     Wilcox. Increases the number of bits available in page_type!

   - "Simplify the page flags a little" from Matthew Wilcox. Many legacy
     page flags are now folio flags, so the page-based flags and their
     accessors/mutators can be removed.

   - "mm: store zero pages to be swapped out in a bitmap" from Usama
     Arif. An optimization which permits us to avoid writing/reading
     zero-filled zswap pages to backing store.

   - "Avoid MAP_FIXED gap exposure" from Liam Howlett. Fixes a race
     window which occurs when a MAP_FIXED operqtion is occurring during
     an unrelated vma tree walk.

   - "mm: remove vma_merge()" from Lorenzo Stoakes. Major rotorooting of
     the vma_merge() functionality, making ot cleaner, more testable and
     better tested.

   - "misc fixups for DAMON {self,kunit} tests" from SeongJae Park.
     Minor fixups of DAMON selftests and kunit tests.

   - "mm: memory_hotplug: improve do_migrate_range()" from Kefeng Wang.
     Code cleanups and folio conversions.

   - "Shmem mTHP controls and stats improvements" from Ryan Roberts.
     Cleanups for shmem controls and stats.

   - "mm: count the number of anonymous THPs per size" from Barry Song.
     Expose additional anon THP stats to userspace for improved tuning.

   - "mm: finish isolate/putback_lru_page()" from Kefeng Wang: more
     folio conversions and removal of now-unused page-based APIs.

   - "replace per-quota region priorities histogram buffer with
     per-context one" from SeongJae Park. DAMON histogram
     rationalization.

   - "Docs/damon: update GitHub repo URLs and maintainer-profile" from
     SeongJae Park. DAMON documentation updates.

   - "mm/vdpa: correct misuse of non-direct-reclaim __GFP_NOFAIL and
     improve related doc and warn" from Jason Wang: fixes usage of page
     allocator __GFP_NOFAIL and GFP_ATOMIC flags.

   - "mm: split underused THPs" from Yu Zhao. Improve THP=always policy.
     This was overprovisioning THPs in sparsely accessed memory areas.

   - "zram: introduce custom comp backends API" frm Sergey Senozhatsky.
     Add support for zram run-time compression algorithm tuning.

   - "mm: Care about shadow stack guard gap when getting an unmapped
     area" from Mark Brown. Fix up the various arch_get_unmapped_area()
     implementations to better respect guard areas.

   - "Improve mem_cgroup_iter()" from Kinsey Ho. Improve the reliability
     of mem_cgroup_iter() and various code cleanups.

   - "mm: Support huge pfnmaps" from Peter Xu. Extends the usage of huge
     pfnmap support.

   - "resource: Fix region_intersects() vs add_memory_driver_managed()"
     from Huang Ying. Fix a bug in region_intersects() for systems with
     CXL memory.

   - "mm: hwpoison: two more poison recovery" from Kefeng Wang. Teaches
     a couple more code paths to correctly recover from the encountering
     of poisoned memry.

   - "mm: enable large folios swap-in support" from Barry Song. Support
     the swapin of mTHP memory into appropriately-sized folios, rather
     than into single-page folios"

* tag 'mm-stable-2024-09-20-02-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (416 commits)
  zram: free secondary algorithms names
  uprobes: turn xol_area->pages[2] into xol_area->page
  uprobes: introduce the global struct vm_special_mapping xol_mapping
  Revert "uprobes: use vm_special_mapping close() functionality"
  mm: support large folios swap-in for sync io devices
  mm: add nr argument in mem_cgroup_swapin_uncharge_swap() helper to support large folios
  mm: fix swap_read_folio_zeromap() for large folios with partial zeromap
  mm/debug_vm_pgtable: Use pxdp_get() for accessing page table entries
  set_memory: add __must_check to generic stubs
  mm/vma: return the exact errno in vms_gather_munmap_vmas()
  memcg: cleanup with !CONFIG_MEMCG_V1
  mm/show_mem.c: report alloc tags in human readable units
  mm: support poison recovery from copy_present_page()
  mm: support poison recovery from do_cow_fault()
  resource, kunit: add test case for region_intersects()
  resource: make alloc_free_mem_region() works for iomem_resource
  mm: z3fold: deprecate CONFIG_Z3FOLD
  vfio/pci: implement huge_fault support
  mm/arm64: support large pfn mappings
  mm/x86: support large pfn mappings
  ...
2024-09-21 07:29:05 -07:00
..
mm Docs/damon: use damonitor GitHub organization instead of awslabs 2024-09-09 16:39:00 -07:00
bootconfig.rst docs/zh_TW: update contents for zh_TW 2023-10-11 16:47:27 -06:00
bug-bisect.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
bug-hunting.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
clearing-warn-once.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
cpu-load.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
cputopology.rst docs/zh_TW: update contents for zh_TW 2023-10-11 16:47:27 -06:00
index.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
init.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
lockup-watchdogs.rst docs/zh_TW: update contents for zh_TW 2023-10-11 16:47:27 -06:00
README.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
reporting-issues.rst docs/zh_CN: update the translation of security-bugs 2024-09-05 14:40:29 -06:00
reporting-regressions.rst docs/zh_TW: update contents for zh_TW 2023-10-11 16:47:27 -06:00
security-bugs.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
sysrq.rst docs/zh_TW: update contents for zh_TW 2023-10-11 16:47:27 -06:00
tainted-kernels.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00
unicode.rst docs/zh_TW: replace my email address 2023-11-17 08:57:11 -07:00

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. SPDX-License-Identifier: GPL-2.0

.. include:: ../disclaimer-zh_TW.rst

:Original: Documentation/admin-guide/README.rst

:譯者:

 吳想成 Wu XiangCheng <bobwxc@email.cn>
 胡皓文 Hu Haowen <2023002089@link.tyut.edu.cn>

Linux內核6.x版本 <http://kernel.org/>
=========================================

以下是Linux版本6的發行註記。仔細閱讀它們
它們會告訴你這些都是什麼,解釋如何安裝內核,以及遇到問題時該如何做。

什麼是Linux
---------------

  Linux是Unix操作系統的克隆版本由Linus Torvalds在一個鬆散的網絡黑客
  Hacker無貶義團隊的幫助下從頭開始編寫。它旨在實現兼容POSIX和
  單一UNIX規範。

  它具有在現代成熟的Unix中應當具有的所有功能包括真正的多任務處理、虛擬內存、
  共享庫、按需加載、共享的寫時拷貝COW可執行文件、恰當的內存管理以及包括
  IPv4和IPv6在內的複合網絡棧。

  Linux在GNU通用公共許可證版本2GNU GPLv2下分發詳見隨附的COPYING文件。

它能在什麼樣的硬件上運行?
-----------------------------

  雖然Linux最初是爲32位的x86 PC機386或更高版本開發的但今天它也能運行在
  至少Compaq Alpha AXP、Sun SPARC與UltraSPARC、Motorola 68000、PowerPC、
  PowerPC64、ARM、Hitachi SuperH、Cell、IBM S/390、MIPS、HP PA-RISC、Intel 
  IA-64、DEC VAX、AMD x86-64 Xtensa和ARC架構上。

  Linux很容易移植到大多數通用的32位或64位體系架構只要它們有一個分頁內存管理
  單元PMMU和一個移植的GNU C編譯器gccGNU Compiler CollectionGCC的一
  部分。Linux也被移植到許多沒有PMMU的體系架構中儘管功能顯然受到了一定的
  限制。
  Linux也被移植到了其自己上。現在可以將內核作爲用戶空間應用程序運行——這被
  稱爲用戶模式LinuxUML。

文檔
-----
因特網上和書籍上都有大量的電子文檔既有Linux專屬文檔也有與一般UNIX問題相關
的文檔。我建議在任何Linux FTP站點上查找LDPLinux文檔項目書籍的文檔子目錄。
本自述文件並不是關於系統的文檔:有更好的可用資源。

 - 因特網上和書籍上都有大量的電子文檔既有Linux專屬文檔也有與普通
   UNIX問題相關的文檔。我建議在任何有LDPLinux文檔項目書籍的Linux FTP
   站點上查找文檔子目錄。本自述文件並不是關於系統的文檔:有更好的可用資源。

 - 文檔/子目錄中有各種自述文件:例如,這些文件通常包含一些特定驅動程序的
   內核安裝說明。請閱讀
   :ref:`Documentation/process/changes.rst <changes>` 文件,它包含了升級內核
   可能會導致的問題的相關信息。

安裝內核源代碼
---------------

 - 如果您要安裝完整的源代碼請把內核tar檔案包放在您有權限的目錄中例如您
   的主目錄)並將其解包::

     xz -cd linux-6.x.tar.xz | tar xvf -

   將“X”替換成最新內核的版本號。

   【不要】使用 /usr/src/linux 目錄!這裏有一組庫頭文件使用的內核頭文件
   (通常是不完整的)。它們應該與庫匹配,而不是被內核的變化搞得一團糟。

 - 您還可以通過打補丁在6.x版本之間升級。補丁以xz格式分發。要通過打補丁進行
   安裝請獲取所有較新的補丁文件進入內核源代碼linux-6.x的目錄並
   執行::

     xz -cd ../patch-6.x.xz | patch -p1

   請【按順序】替換所有大於當前源代碼樹版本的“x”這樣就可以了。您可能想要
   刪除備份文件文件名類似xxx~ 或 xxx.orig),並確保沒有失敗的補丁(文件名
   類似xxx# 或 xxx.rej。如果有不是你就是我犯了錯誤。

   與6.x內核的補丁不同6.x.y內核也稱爲穩定版內核的補丁不是增量的而是
   直接應用於基本的6.x內核。例如如果您的基本內核是6.0並且希望應用6.0.3
   補丁則不應先應用6.0.1和6.0.2的補丁。類似地如果您運行的是6.0.2內核,
   並且希望跳轉到6.0.3那麼在應用6.0.3補丁之前必須首先撤銷6.0.2補丁
   即patch -R。更多關於這方面的內容請閱讀
   :ref:`Documentation/process/applying-patches.rst <applying_patches>` 。

   或者,腳本 patch-kernel 可以用來自動化這個過程。它能確定當前內核版本並
   應用找到的所有補丁::

     linux/scripts/patch-kernel linux

   上面命令中的第一個參數是內核源代碼的位置。補丁是在當前目錄應用的,但是
   可以將另一個目錄指定爲第二個參數。

 - 確保沒有過時的 .o 文件和依賴項::

     cd linux
     make mrproper

   現在您應該已經正確安裝了源代碼。

軟件要求
---------

   編譯和運行6.x內核需要各種軟件包的最新版本。請參考
   :ref:`Documentation/process/changes.rst <changes>`
   來了解最低版本要求以及如何升級軟件包。請注意,使用過舊版本的這些包可能會
   導致很難追蹤的間接錯誤,因此不要以爲在生成或操作過程中出現明顯問題時可以
   只更新包。

爲內核建立目錄
---------------

   編譯內核時,默認情況下所有輸出文件都將與內核源代碼放在一起。使用
   ``make O=output/dir`` 選項可以爲輸出文件(包括 .config指定備用位置。
   例如::

     kernel source code: /usr/src/linux-6.x
     build directory:    /home/name/build/kernel

   要配置和構建內核,請使用::

     cd /usr/src/linux-6.x
     make O=/home/name/build/kernel menuconfig
     make O=/home/name/build/kernel
     sudo make O=/home/name/build/kernel modules_install install

   請注意:如果使用了 ``O=output/dir`` 選項那麼它必須用於make的所有調用。

配置內核
---------

   即使只升級一個小版本,也不要跳過此步驟。每個版本中都會添加新的配置選項,
   如果配置文件沒有按預定設置,就會出現奇怪的問題。如果您想以最少的工作量
   將現有配置升級到新版本,請使用 ``make oldconfig`` ,它只會詢問您新配置
   選項的答案。

 - 其他配置命令包括::

     "make config"      純文本界面。

     "make menuconfig"  基於文本的彩色菜單、選項列表和對話框。

     "make nconfig"     增強的基於文本的彩色菜單。

     "make xconfig"     基於Qt的配置工具。

     "make gconfig"     基於GTK+的配置工具。

     "make oldconfig"   基於現有的 ./.config 文件選擇所有選項,並詢問
                        新配置選項。

     "make olddefconfig"
                        類似上一個,但不詢問直接將新選項設置爲默認值。

     "make defconfig"   根據體系架構使用arch/$arch/defconfig或
                        arch/$arch/configs/${PLATFORM}_defconfig中的
                        默認選項值創建./.config文件。

     "make ${PLATFORM}_defconfig"
                        使用arch/$arch/configs/${PLATFORM}_defconfig中
                        的默認選項值創建一個./.config文件。
                        用“make help”來獲取您體系架構中所有可用平臺的列表。

     "make allyesconfig"
                        通過儘可能將選項值設置爲“y”創建一個
                        ./.config文件。

     "make allmodconfig"
                        通過儘可能將選項值設置爲“m”創建一個
                        ./.config文件。

     "make allnoconfig" 通過儘可能將選項值設置爲“n”創建一個
                        ./.config文件。

     "make randconfig"  通過隨機設置選項值來創建./.config文件。

     "make localmodconfig" 基於當前配置和加載的模塊lsmod創建配置。禁用
                           已加載的模塊不需要的任何模塊選項。

                           要爲另一臺計算機創建localmodconfig請將該計算機
                           的lsmod存儲到一個文件中並將其作爲lsmod參數傳入。

                           此外通過在參數LMC_KEEP中指定模塊的路徑可以將
                           模塊保留在某些文件夾或kconfig文件中。

                   target$ lsmod > /tmp/mylsmod
                   target$ scp /tmp/mylsmod host:/tmp

                   host$ make LSMOD=/tmp/mylsmod \
                           LMC_KEEP="drivers/usb:drivers/gpu:fs" \
                           localmodconfig

                           上述方法在交叉編譯時也適用。

     "make localyesconfig" 與localmodconfig類似只是它會將所有模塊選項轉換
                           爲內置(=y。你可以同時通過LMC_KEEP保留模塊。

     "make kvm_guest.config"
                        爲kvm客戶機內核支持啓用其他選項。

     "make xen.config"  爲xen dom0客戶機內核支持啓用其他選項。

     "make tinyconfig"  配置儘可能小的內核。

   更多關於使用Linux內核配置工具的信息見文檔
   Documentation/kbuild/kconfig.rst。

 - ``make config`` 注意事項:

    - 包含不必要的驅動程序會使內核變大,並且在某些情況下會導致問題:
      探測不存在的控制器卡可能會混淆其他控制器。

    - 如果存在協處理器,則編譯了數學仿真的內核仍將使用協處理器:在
      這種情況下,數學仿真永遠不會被使用。內核會稍微大一點,但不管
      是否有數學協處理器,都可以在不同的機器上工作。

    - “kernel hacking”配置細節通常會導致更大或更慢的內核或兩者
      兼而有之),甚至可以通過配置一些例程來主動嘗試破壞壞代碼以發現
      內核問題從而降低內核的穩定性kmalloc())。因此,您可能應該
      用於研究“開發”、“實驗”或“調試”特性相關問題。

編譯內核
---------

 - 確保您至少有gcc 5.1可用。
   有關更多信息,請參閱 :ref:`Documentation/process/changes.rst <changes>` 。

 - 執行 ``make`` 來創建壓縮內核映像。如果您安裝了lilo以適配內核makefile
   那麼也可以進行 ``make install`` 但是您可能需要先檢查特定的lilo設置。

   實際安裝必須以root身份執行但任何正常構建都不需要。
   無須徒然使用root身份。

 - 如果您將內核的任何部分配置爲模塊,那麼還必須執行 ``make modules_install`` 。

 - 詳細的內核編譯/生成輸出:

   通常,內核構建系統在相當安靜的模式下運行(但不是完全安靜)。但是有時您或
   其他內核開發人員需要看到編譯、鏈接或其他命令的執行過程。爲此,可使用
   “verbose詳細”構建模式。
   向 ``make`` 命令傳遞 ``V=1`` 來實現,例如::

     make V=1 all

   如需構建系統也給出內個目標重建的願意,請使用 ``V=2`` 。默認爲 ``V=0`` 。

 - 準備一個備份內核以防出錯。對於開發版本尤其如此,因爲每個新版本都包含
   尚未調試的新代碼。也要確保保留與該內核對應的模塊的備份。如果要安裝
   與工作內核版本號相同的新內核,請在進行 ``make modules_install`` 安裝
   之前備份modules目錄。

   或者在編譯之前使用內核配置選項“LOCALVERSION”向常規內核版本附加
   一個唯一的後綴。LOCALVERSION可以在“General Setup”菜單中設置。

 - 爲了引導新內核,您需要將內核映像(例如編譯後的
   .../linux/arch/x86/boot/bzImage複製到常規可引導內核的位置。

 - 不再支持在沒有LILO等啓動裝載程序幫助的情況下直接從軟盤引導內核。

   如果從硬盤引導Linux很可能使用LILO它使用/etc/lilo.conf文件中
   指定的內核映像文件。內核映像文件通常是/vmlinuz、/boot/vmlinuz、
   /bzImage或/boot/bzImage。使用新內核前請保存舊映像的副本並複製
   新映像覆蓋舊映像。然後您【必須重新運行LILO】來更新加載映射否則
   將無法啓動新的內核映像。

   重新安裝LILO通常需要運行/sbin/LILO。您可能希望編輯/etc/lilo.conf
   文件爲舊內核映像指定一個條目(例如/vmlinux.old)防止新的不能正常
   工作。有關更多信息請參閱LILO文檔。

   重新安裝LILO之後您應該就已經準備好了。關閉系統重新啓動盡情
   享受吧!

   如果需要更改內核映像中的默認根設備、視頻模式等,請在適當的地方使用
   啓動裝載程序的引導選項。無需重新編譯內核即可更改這些參數。

 - 使用新內核重新啓動並享受它吧。

若遇到問題
-----------

如果您發現了一些可能由於內核缺陷所導致的問題,請參閱:
Documentation/translations/zh_CN/admin-guide/reporting-issues.rst 。

想要理解內核錯誤報告,請參閱:
Documentation/translations/zh_CN/admin-guide/bug-hunting.rst 。

更多用GDB調試內核的信息請參閱
Documentation/translations/zh_CN/dev-tools/gdb-kernel-debugging.rst
和 Documentation/dev-tools/kgdb.rst 。