Systemd ui ไบนารี ตัวเลือก


systemd เป็นชุดของการสร้างพื้นฐานสำหรับระบบลีนุกซ์ มีระบบจัดการบริการที่ทำงานเป็น PID 1 และเริ่มต้นระบบที่เหลืออยู่ systemd ให้ความสามารถแบบขนานก้าวร้าวใช้ซ็อกเก็ตและการเปิดใช้งาน D-Bus สำหรับการเริ่มต้นบริการเสนอการเริ่มต้นของ daemons ตามต้องการติดตามกระบวนการต่างๆโดยใช้กลุ่มควบคุม Linux รักษาจุดเมานท์และ automount และใช้ตรรกะการควบคุมบริการที่ขึ้นกับการพึ่งพาการทำธุรกรรมอย่างละเอียด systemd สนับสนุนสคริปต์ init SysV และ LSB และทำงานแทน sysvinit ส่วนอื่น ๆ รวมถึง daemon การเข้าระบบสาธารณูปโภคเพื่อควบคุมการกำหนดค่าระบบพื้นฐานเช่นชื่อโฮสต์วันที่ตำแหน่งที่ตั้งรักษารายชื่อผู้ใช้ที่เข้าสู่ระบบและเรียกใช้คอนเทนเนอร์และเครื่องเสมือนบัญชีระบบไดเรกทอรีรันไทม์และการตั้งค่าและ daemons เพื่อจัดการเครือข่ายที่เรียบง่าย การกำหนดค่าการซิงโครไนซ์เวลาเครือข่ายการส่งต่อบันทึกและการแก้ปัญหาชื่อ หมายเหตุ: สำหรับคำอธิบายโดยละเอียดว่าเหตุใด Arch จึงย้ายไปที่ systemd ดูโพสต์ฟอรัมนี้ การใช้งาน systemctl พื้นฐานคำสั่งหลักที่ใช้ในการ introspect และ control system คือ systemctl บางส่วนของการใช้งานมีการตรวจสอบสถานะของระบบและการจัดการระบบและบริการ ดู man systemctl สำหรับรายละเอียดเพิ่มเติม คำแนะนำ: คุณสามารถใช้คำสั่ง systemctl ทั้งหมดต่อไปนี้ได้โดยใช้สวิตช์โฮสต์ผู้ใช้ - h เพื่อควบคุมอินสแตนซ์ systemd บนเครื่องระยะไกล นี้จะใช้ SSH เพื่อเชื่อมต่อกับอินสแตนซ์ systemd ระยะไกล systemadm เป็นส่วนต่อหน้าแบบกราฟิกอย่างเป็นทางการสำหรับ systemctl และมีอยู่ในแพคเกจ systemd-ui ผู้ใช้พลาสม่าสามารถติดตั้ง systemd-kcm เป็นแบบกราฟิกด้านหน้าสำหรับ systemctl หลังจากติดตั้งโมดูลแล้วจะมีการเพิ่มภายใต้การดูแลระบบ การวิเคราะห์สถานะของระบบแสดงสถานะระบบโดยใช้: รายการที่เรียกใช้หน่วย: รายการหน่วยที่ล้มเหลว: ไฟล์หน่วยที่มีอยู่สามารถมองเห็นได้ใน usrlibsystemsystem และ etcsystemdsystem (หลังมีความสำคัญ) แสดงรายการไฟล์หน่วยที่ติดตั้งด้วย: การใช้หน่วยหน่วยอาจเป็นเช่นบริการ (.service) จุดเชื่อมต่อ (.mount) อุปกรณ์ (.device) หรือซ็อกเก็ต (.socket) เมื่อใช้ systemctl โดยทั่วไปคุณต้องระบุชื่อที่สมบูรณ์ของไฟล์หน่วยรวมทั้งส่วนต่อท้ายเช่น sshd. socket มี แต่รูปแบบสั้น ๆ ไม่กี่เมื่อระบุหน่วยในคำสั่ง systemctl ต่อไปนี้: ถ้าคุณไม่ได้ระบุส่วนต่อท้าย systemctl จะถือว่าบริการ ตัวอย่างเช่น netctl และ netctl. service มีค่าเท่ากับ จุดเมาท์จะถูกแปลเป็นหน่วยที่เหมาะสมโดยอัตโนมัติ ตัวอย่างเช่นการระบุบ้านจะเท่ากับ home. mount คล้ายกับจุดเชื่อมต่ออุปกรณ์จะถูกแปลโดยอัตโนมัติในชุดอุปกรณ์. devsda2 ซึ่งเทียบเท่ากับ dev-sda2.device ดู man systemd. unit สำหรับรายละเอียด หมายเหตุ: ชื่อหน่วยบางส่วนมีเครื่องหมาย (เช่นชื่อสตริงบริการ): หมายความว่าเป็นอินสแตนซ์ของเทมเพลตหน่วยซึ่งชื่อไฟล์จริงไม่ได้มีส่วนของสตริง (เช่น name. service) สตริงที่เรียกว่าตัวระบุอินสแตนซ์ และคล้ายกับอาร์กิวเมนต์ที่ถูกส่งผ่านไปยังเทมเพลตเทมเพลตเมื่อเรียกด้วยคำสั่ง systemctl: ในไฟล์ unit จะแทน i specifier เพื่อให้ถูกต้องมากยิ่งขึ้นก่อนที่จะพยายามสร้างหน่วยเทมเพลต name. suffix systemd จะค้นหาหน่วยที่มีชื่อไฟล์ namestring. suffix อย่างถูกต้องแม้ว่าจะมีการปะทะกันแบบแผนเช่นการปะทะกันเกิดขึ้นไม่บ่อยนั่นคือไฟล์ยูนิทที่มีเครื่องหมายหมายถึงมากที่สุด เป็นเทมเพลต นอกจากนี้ถ้าหน่วยเทมเพลตถูกเรียกใช้โดยไม่มีตัวระบุอินสแตนซ์จะล้มเหลวเนื่องจากไม่สามารถใช้ตัวระบุ i ได้ คำแนะนำ: คำสั่งต่อไปนี้ส่วนใหญ่จะทำงานถ้ามีการระบุหลายหน่วยโปรดดู man systemctl สำหรับข้อมูลเพิ่มเติม สามารถใช้สวิตช์ - now นี้ร่วมกับ enable ปิดการใช้งาน และหน้ากากเพื่อเริ่มต้นหยุดหรือสวมหน้ากากหน่วยทันทีแทนที่จะใช้เวลาบูตถัดไป แพคเกจอาจมีหน่วยงานเพื่อวัตถุประสงค์ที่แตกต่างกัน ถ้าคุณเพิ่งติดตั้งแพคเกจ pacman - qql package grep - Fe. service - e. socket สามารถใช้เพื่อตรวจสอบและค้นหาได้ เริ่มหน่วยทันที: หยุดหน่วยทันที: ขอให้หน่วยโหลดการกำหนดค่าใหม่: แสดงสถานะของหน่วยรวมถึงว่ากำลังทำงานอยู่หรือไม่: ตรวจสอบว่ามีการเปิดใช้งานหน่วยหรือไม่: เปิดใช้งานหน่วยที่จะเริ่มต้น bootup ปิดใช้งานหน่วยที่จะไม่เริ่มทำงานระหว่างการบูตเครื่อง: ทำหน้ากากยูนิทเพื่อทำให้ไม่สามารถเริ่มต้นได้: แสดงหน้าคู่มือที่เชื่อมโยงกับหน่วย (ต้องรองรับไฟล์หน่วย): Reload systemd สแกนหาหน่วยใหม่หรือเปลี่ยน การจัดการพลังงานเป็นสิ่งจำเป็นสำหรับการจัดการพลังงานในฐานะผู้ใช้ที่ไม่ได้รับสิทธิพิเศษ ถ้าคุณอยู่ในเซสชันผู้ใช้ systemd-logind ภายในและไม่มีเซสชันอื่นทำงานคำสั่งต่อไปนี้จะทำงานโดยไม่มีสิทธิ์ของ root ถ้าไม่ (ตัวอย่างเช่นเนื่องจากผู้ใช้รายอื่นถูกบันทึกลงใน tty) systemd จะถามรหัสผ่าน root โดยอัตโนมัติ ปิดระบบและปิดระบบใหม่: ปิดเครื่องและปิดระบบ: ระงับระบบ: วางระบบลงในโหมดไฮเบอร์เนต: วางระบบลงในสถานะไฮบริดสลีป (หรือระงับการทำงาน): เขียนไฟล์หน่วยไวยากรณ์ของ systemd s ไฟล์หน่วยงานได้รับแรงบันดาลใจจาก XDG Desktop Entry Specification. desktop files ซึ่งได้รับแรงบันดาลใจจากไฟล์. iini ของ Microsoft Windows ไฟล์หน่วยจะถูกโหลดจากสองตำแหน่ง จากลำดับความสำคัญต่ำสุดไปจนถึงสูงสุดคือ usrlibsystemdsystem หน่วยที่มาจากชุดติดตั้งระบบอื่น ๆ หน่วยที่ติดตั้งโดยผู้ดูแลระบบหมายเหตุ: เส้นทางการโหลดแตกต่างไปจากเดิมอย่างสิ้นเชิงเมื่อเรียกใช้ systemd ในโหมดผู้ใช้ ชื่อหน่วย systemd สามารถประกอบด้วยอักขระที่เป็นตัวเลขและตัวอักษรและตัวเลข ASCII ขีดล่างเท่านั้น อักขระอื่น ๆ ทั้งหมดต้องถูกแทนที่ด้วย C หนี x2d สไตล์ C ดู man systemd. unit และ man systemd-escape สำหรับข้อมูลเพิ่มเติม ดูหน่วยที่ติดตั้งโดยแพคเกจของคุณสำหรับตัวอย่างเช่นเดียวกับส่วนตัวอย่างคำอธิบายประกอบของ man systemd. service เคล็ดลับ: ความคิดเห็นที่เพิ่มไว้ล่วงหน้าอาจใช้ในไฟล์หน่วยได้เช่นกัน แต่เฉพาะในบรรทัดใหม่เท่านั้น อย่าใช้ความคิดเห็นในบรรทัดสุดท้ายหลังจากพารามิเตอร์ systemd หรือเครื่องจะไม่สามารถเปิดใช้งานได้ จัดการกับ dependencies ด้วย systemd dependencies สามารถแก้ไขได้โดยการออกแบบแฟ้มหน่วยอย่างถูกต้อง กรณีทั่วไปที่สุดคือหน่วย A ต้องการให้หน่วย B ทำงานก่อนที่จะเริ่มต้น A ในกรณีดังกล่าวให้เพิ่มส่วนที่ต้องการ B และ B ไปที่ส่วนหน่วยของ A ถ้าการพึ่งพาเป็นทางเลือกให้เพิ่ม Wants B และ After B แทน โปรดทราบว่าต้องการและต้องการไม่ได้หมายความว่าหลังจาก หมายความว่าถ้าไม่ได้ระบุไว้หลังจากที่ทั้งสองหน่วยจะเริ่มทำงานแบบขนาน การพึ่งพาอาศัยมักจะอยู่ในบริการและไม่ใช่เป้าหมาย ตัวอย่างเช่น network. target ถูกดึงโดยเซอร์วิสใดก็ตามที่กำหนดค่าอินเทอร์เฟซเครือข่ายของคุณดังนั้นจึงสั่งหน่วยที่กำหนดเองของคุณหลังจากที่มีค่าใช้จ่ายเพียงพอเนื่องจาก network. target เริ่มต้นทำงานต่อไป ชนิดของบริการมีหลายประเภทเริ่มต้นที่แตกต่างกันเพื่อพิจารณาเมื่อเขียนไฟล์บริการที่กำหนดเอง นี่คือการตั้งค่าด้วยพารามิเตอร์ Type ในส่วนบริการ: Typesimple (ค่าเริ่มต้น): systemd จะพิจารณาบริการที่จะเริ่มทำงานทันที กระบวนการนี้ต้องไม่แยกออก ห้ามใช้บริการประเภทนี้หากจำเป็นต้องสั่งซื้อบริการอื่น ๆ ในบริการนี้เว้นแต่จะมีการเปิดใช้งานซ็อกเก็ต Typeforking systemd จะพิจารณาว่าบริการเริ่มต้นขึ้นเมื่องอกระบวนการและผู้ปกครองได้ออก สำหรับ daemons แบบคลาสสิกใช้ประเภทนี้ถ้าคุณไม่ทราบว่าไม่จำเป็น คุณควรระบุ PIDFile ด้วยเพื่อให้ systemd สามารถติดตามกระบวนการหลักได้ Typeoneshot นี้เป็นประโยชน์สำหรับสคริปต์ที่ทำงานเดียวและจากนั้นออก คุณอาจต้องการตั้งค่า RemainAfterExityes ด้วยเพื่อให้ systemd ยังคงพิจารณาว่าบริการดังกล่าวทำงานอยู่หลังจากกระบวนการนี้ได้เกิดขึ้นแล้ว Typenotify เหมือนกับ Typesimple แต่ด้วยข้อเสนอว่าภูตจะส่งสัญญาณไปยังระบบเมื่อพร้อม การอ้างอิงสำหรับการแจ้งเตือนนี้มีให้โดย libsystemd-daemon. so Typedbus บริการจะถือเป็นความพร้อมเมื่อ BusName ที่ระบุปรากฏบนบัสระบบ DBuss Typeidle systemd จะทำให้การดำเนินงานของไบนารีบริการล่าช้าจนกว่าจะมีการส่งงานทั้งหมด นอกเหนือจากลักษณะการทำงานนั้นคล้ายกับ Typesimple ดู man page ของ systemd. service (5) เพื่อดูรายละเอียดเพิ่มเติมเกี่ยวกับค่า Type แก้ไขหน่วยที่จัดเตรียมไว้เพื่อหลีกเลี่ยงความขัดแย้งกับ pacman ไฟล์หน่วยที่จัดเตรียมโดยแพ็คเกจไม่ควรแก้ไขโดยตรง มีสองวิธีที่ปลอดภัยในการแก้ไขหน่วยโดยไม่ต้องแตะไฟล์ต้นฉบับ: สร้างไฟล์หน่วยใหม่ซึ่งจะแทนที่หน่วยต้นฉบับหรือสร้างตัวอย่างข้อมูลแบบหล่นลงซึ่งจะใช้กับส่วนต้นของหน่วยต้นฉบับ สำหรับทั้งสองวิธีคุณต้องโหลดหน่วยใหม่หลังจากใช้การเปลี่ยนแปลงของคุณ ซึ่งสามารถทำได้โดยการแก้ไขหน่วยด้วยการแก้ไข systemctl (ซึ่งจะโหลดหน่วยใหม่โดยอัตโนมัติ) หรือโดยการโหลดหน่วยทั้งหมดด้วย: คำแนะนำ: คุณสามารถใช้ systemd-delta เพื่อดูว่าไฟล์ยูนิตใดถูกแทนที่หรือขยายและสิ่งที่ได้มีการเปลี่ยนแปลง . ใช้หน่วย catcatl เพื่อดูเนื้อหาของไฟล์หน่วยและตัวอย่างข้อมูลที่เกี่ยวข้องทั้งหมดที่มีใน drop-in เน้นไวยากรณ์สำหรับไฟล์หน่วย systemd ภายใน Vim สามารถใช้งานได้โดยการติดตั้ง vim-systemd ไฟล์หน่วยทดแทนเมื่อต้องการแทนที่ยูนิท usrlibsystemdsystem unit file สร้างหน่วยแฟ้ม etcsystemdsystem และ reenable หน่วยเพื่อปรับปรุง symlinks: นี้จะเปิดหน่วย etcsystemdsystem ในตัวแก้ไขของคุณ (คัดลอกรุ่นที่ติดตั้งหากยังไม่มี) และจะโหลดใหม่เมื่อคุณเสร็จสิ้นการแก้ไข หมายเหตุ: Pacman ไม่อัปเดตไฟล์หน่วยทดแทนเมื่อมีการอัพเดตต้นฉบับดังนั้นวิธีนี้จะทำให้การบำรุงรักษาระบบทำได้ยากขึ้น ด้วยเหตุนี้จึงขอแนะนำแนวทางต่อไป ไฟล์แบบหล่นลงเพื่อสร้างไฟล์แบบสแตนด์อโลนสำหรับหน่วยไฟล์ usrlibsystemdsystem สร้างไดเร็กทอรี etcsystemdsystem unit. d และวางไฟล์. config เพื่อแทนที่หรือเพิ่มตัวเลือกใหม่ systemd จะแยกวิเคราะห์แฟ้ม. ไฟล์.conf เหล่านี้และนำไปใช้กับหน่วยเดิม วิธีที่ง่ายที่สุดในการดำเนินการนี้คือการเรียกใช้: จะเปิดไฟล์ etcsystemdsystem unit. toverride. conf ในโปรแกรมแก้ไขข้อความของคุณ (สร้างขึ้นในกรณีที่จำเป็น) และโหลดหน่วยใหม่โดยอัตโนมัติเมื่อแก้ไขเสร็จแล้ว ย้อนกลับไปยังเวอร์ชันของผู้ขายเมื่อต้องการย้อนกลับการเปลี่ยนแปลงใด ๆ ในหน่วยที่ทำโดยใช้การแก้ไข systemctl: ตัวอย่างเช่นหากคุณต้องการเพิ่มการพึ่งพาเพิ่มเติมในหน่วยคุณสามารถสร้างไฟล์ต่อไปนี้: เป็นอีกตัวอย่างหนึ่งเพื่อแทนที่ ExecStart คำสั่งสำหรับหน่วยที่ไม่ใช่แบบ oneshot สร้างไฟล์ต่อไปนี้: โปรดทราบว่า ExecStart ต้องถูกล้างก่อนที่จะถูกมอบหมายอีกครั้ง 1. การระงับเดียวกันสำหรับทุกรายการที่สามารถระบุได้หลายครั้งเช่น OnCalendar สำหรับตัวจับเวลา อีกตัวอย่างหนึ่งในการรีสตาร์ทเซอร์วิสโดยอัตโนมัติ: เหตุผล: คำอธิบายไม่ชัดเจนคัดลอกเนื้อหาที่วาง (ระบุอย่างชัดเจนถึง Fedora) (อภิปรายในหัวข้อ Talk: SystemdMake target ชัดเจนมากขึ้น) systemd ใช้เป้าหมายที่ทำหน้าที่คล้ายกับ runlevel แต่ทำหน้าที่แตกต่างกันเล็กน้อย แต่ละเป้าหมายมีชื่อแทนหมายเลขและมีจุดมุ่งหมายเพื่อตอบสนองวัตถุประสงค์เฉพาะโดยมีความเป็นไปได้ที่จะมีคนหลายคนที่ใช้งานอยู่ในเวลาเดียวกัน เป้าหมายบางตัวถูกนำมาใช้โดยสืบทอดบริการทั้งหมดของเป้าหมายอื่นและเพิ่มบริการเพิ่มเติมลงในนั้น มีเป้าหมาย systemd ที่เลียนแบบระดับการทำงานของ SystemVinit ทั่วไปเพื่อให้คุณสามารถเปลี่ยนเป้าหมายได้โดยใช้คำสั่ง RUNLEVEL telinit ที่คุ้นเคย รับเป้าหมายปัจจุบันควรใช้ค่าต่อไปนี้แทน systemd แทนที่จะใช้ runlevel สร้างเป้าหมายที่กำหนดเองระดับการทำงานที่มีความหมายที่กำหนดไว้ภายใต้ sysvinit (เช่น 0, 1, 3, 5 และ 6) มีการแม็พ 1: 1 กับเป้าหมาย systemd ที่ระบุ แต่น่าเสียดายที่ไม่มีวิธีที่ดีในการทำเช่นเดียวกันสำหรับ runlevels ที่ผู้ใช้กำหนดเช่น 2 และ 4 ถ้าคุณใช้ประโยชน์จากข้อเสนอแนะว่าคุณสร้างเป้าหมาย systemd ใหม่ชื่อว่า etcsystemdsystem เป้าหมายของคุณที่ใช้เวลาหนึ่ง runlevels ที่มีอยู่ เป็นฐาน (คุณสามารถดูที่ usrlibsystemsystemgraphical. target เป็นตัวอย่าง) ทำให้ไดเรกทอรี etcsystemdsystem เป้าหมายของคุณ. และจากนั้น symlink บริการเพิ่มเติมจาก usrlibsystemdsystem ที่คุณต้องการเปิดใช้งาน ตารางเป้าหมายเปลี่ยนเป้าหมายปัจจุบันในเป้าหมาย systemd จะแสดงผ่านหน่วยเป้าหมาย คุณสามารถเปลี่ยนได้ดังนี้: จะเปลี่ยนเป้าหมายปัจจุบันเท่านั้นและไม่มีผลต่อการบูตครั้งถัดไป คำสั่งนี้เหมือนกับคำสั่งเช่น telinit 3 หรือ telinit 5 ใน Sysvinit เปลี่ยนเป้าหมายเริ่มต้นเพื่อบูตเข้าสู่เป้าหมายมาตรฐานคือ default. target ซึ่งเป็น aliased โดยค่าเริ่มต้นเพื่อ graphical. target (ซึ่งประมาณสอดคล้องกับ runlevel เก่า 5) เมื่อต้องการเปลี่ยนค่าเริ่มต้นเป้าหมายเมื่อบูตเวลาให้เพิ่มพารามิเตอร์เคอร์เนลต่อไปนี้ลงใน bootloader ของคุณ: systemd. unitmulti-user. target (ซึ่งสอดคล้องกับระดับการทำงานของระบบปฏิบัติการเก่า 3), systemd. unitrescue. target (ซึ่งประมาณสอดคล้องกับ runlevel เก่า 1) หรือคุณอาจปล่อยให้โปรแกรมโหลดบูตเพียงอย่างเดียวและเปลี่ยน default. target ซึ่งสามารถทำได้โดยใช้ systemctl เพื่อให้สามารถแทนที่ชุดค่าเริ่มต้น default. target ที่ตั้งไว้ก่อนหน้านี้ ใช้ตัวเลือก force: ผลของคำสั่งนี้จะถูกส่งออกโดย systemctl การเชื่อมต่อ symlink ไปยังเป้าหมายเริ่มต้นใหม่จะกระทำที่ etcsystemdsystemdefault. target ไฟล์ชั่วคราว systemd-tmpfiles สร้าง, ลบและทำความสะอาดไฟล์และไดเรกทอรีที่มีความระเหยและชั่วคราว มันอ่านแฟ้มการกำหนดค่าใน etctmpfiles. d และ usrlibtmpfiles. d เพื่อค้นหาว่าการกระทำที่จะดำเนินการ ไฟล์คอนฟิกูเรชันในไดเร็กทอรีเดิมมีความสำคัญเหนือกว่าไดเร็กทอรีที่อยู่ในไดเรกทอรีหลัง แฟ้มการกำหนดค่าจะมีให้พร้อมกับไฟล์เซอร์วิสและมีชื่ออยู่ในรูปแบบของไฟล์ usrlibtmpfiles. d.conf ตัวอย่างเช่นภูต Samba คาดว่าไดเร็กทอรี runamba จะมีอยู่และมีสิทธิ์ที่ถูกต้อง ดังนั้นแพคเกจ samba มาพร้อมกับคอนฟิกูเรชันนี้: ไฟล์คอนฟิกูเรชันอาจถูกใช้เพื่อเขียนค่าลงในไฟล์บางไฟล์เมื่อบูต ตัวอย่างเช่นถ้าคุณใช้ etcrc. local เพื่อปิดใช้งานการปลุกจากอุปกรณ์ USB ด้วย echo USBE gt procacpiwakeup tmpfiles (8) และ tmpfiles. d (5) สำหรับรายละเอียดเพิ่มเติม หมายเหตุ: วิธีนี้อาจใช้ไม่ได้ในการตั้งค่าตัวเลือกใน sys เนื่องจากบริการ systemd-tmpfiles-setup อาจทำงานก่อนโหลดโมดูลอุปกรณ์ที่เหมาะสม ในกรณีนี้คุณสามารถตรวจสอบว่าโมดูลมีพารามิเตอร์สำหรับตัวเลือกที่คุณต้องการตั้งค่าด้วยโมดูล modinfo และตั้งค่าตัวเลือกนี้ด้วยไฟล์ config ใน etcmodprobe. d มิฉะนั้นคุณจะต้องเขียนกฎ udev เพื่อตั้งค่าแอตทริบิวต์ที่เหมาะสมทันทีที่อุปกรณ์ปรากฏขึ้น ตัวจับเวลาเป็นไฟล์การกำหนดค่าหน่วยที่ชื่อลงท้ายด้วย. timer และเข้ารหัสข้อมูลเกี่ยวกับตัวจับเวลาที่ควบคุมและดูแลโดย systemd สำหรับการเปิดใช้งานตามเวลา ดู systemdTimers เนื่องจาก systemd ใช้แทน System V init จึงเป็นผู้ดูแล mounts ที่ระบุไว้ใน etcfstab ในความเป็นจริงมันเกินกว่าความสามารถ fstab ปกติการใช้ตัวเลือก mount พิเศษนำหน้าด้วย x-systemd ดู FstabAutomount กับ systemd สำหรับตัวอย่างของ automounting (ติดตั้งตามความต้องการ) โดยใช้ส่วนขยายเหล่านี้ โปรดดูที่ 2 สำหรับเอกสารฉบับสมบูรณ์ของส่วนขยายเหล่านี้ systemd มีระบบบันทึกข้อมูลของตนเองที่เรียกว่า journal ดังนั้นจึงไม่จำเป็นต้องใช้ภูต syslog อีกต่อไป เมื่อต้องการอ่านล็อกให้ใช้: ใน Arch Linux ไดเรกทอรี varlogjournal เป็นส่วนหนึ่งของแพ็กเกจ systemd และ journal (เมื่อ Storage ถูกตั้งค่าเป็น auto ใน etcsystemdjournald. conf) จะเขียนไปที่ varlogjournal ถ้าคุณหรือบางโปรแกรมลบไดเร็กทอรีนั้น systemd จะไม่สร้างขึ้นใหม่โดยอัตโนมัติและจะเขียนบันทึกไปยัง อย่างไรก็ตามโฟลเดอร์จะถูกสร้างขึ้นใหม่เมื่อคุณตั้งค่า Storagepersistent และเรียกใช้ systemctl restart systemd-journald (หรือรีบูต) วารสาร Systemd แบ่งประเภทข้อความตามลำดับความสำคัญและสิ่งอำนวยความสะดวก การจัดหมวดหมู่การเข้าสู่ระบบสอดคล้องกับโปรโตคอล Syslog แบบคลาสสิก (RFC 5424) ระดับความสำคัญรหัสความรุนแรงของระบบ syslog (ในระบบที่เรียกว่าลำดับความสำคัญ) ใช้เพื่อระบุความสำคัญของข้อความ RFC 5424 หัวข้อ 6.2.1 ดังนั้นสิ่งอำนวยความสะดวกที่มีประโยชน์ในการชม: 0,1,3,4,9,10,15 การกรองเอาท์พุท journalctl ช่วยให้คุณสามารถกรองผลลัพธ์ตามฟิลด์เฉพาะ โปรดทราบว่าหากมีข้อความมากมายที่จะแสดงหรือกรองช่วงเวลาใหญ่ ๆ จะต้องทำผลลัพธ์ของคำสั่งนี้อาจล่าช้าไปสักระยะหนึ่ง เคล็ดลับ: แม้ว่าวารสารจะจัดเก็บในรูปแบบไบนารีเนื้อหาของข้อความที่เก็บไว้จะไม่ได้รับการแก้ไข ซึ่งหมายความว่าสามารถดูได้ด้วยสตริง ตัวอย่างเช่นสำหรับการกู้คืนในสภาพแวดล้อมที่ไม่มี systemd ติดตั้ง ตัวอย่างคำสั่ง: แสดงข้อความทั้งหมดจากการบูตนี้: อย่างไรก็ตามบ่อยครั้งที่บุคคลหนึ่งสนใจข้อความที่ไม่ได้มาจากปัจจุบัน แต่จากการบูตก่อนหน้านี้ (เช่นถ้าเกิดเหตุการณ์ระบบที่ไม่สามารถกู้คืนได้) นี่คือความเป็นไปได้ทางพารามิเตอร์ชดเชยของธง - b: journalctl - b -0 แสดงข้อความจากการบูตปัจจุบัน journalctl - b -1 จากบูตก่อนหน้าที่ journalctl - b -2 จากก่อนหน้าที่สองและอื่น ๆ ดู man 1 journalctl สำหรับคำอธิบายแบบเต็มความหมายมีประสิทธิภาพมากขึ้น แสดงข้อความทั้งหมดจากวันที่ (และเวลาไม่จำเป็น): แสดงข้อความทั้งหมดตั้งแต่ 20 นาทีที่ผ่านมา: ติดตามข้อความใหม่: แสดงข้อความทั้งหมดโดยเฉพาะที่ปฏิบัติการได้: แสดงข้อความทั้งหมดตามกระบวนการเฉพาะ: แสดงข้อความทั้งหมดโดยหน่วยเฉพาะ: แสดงแหวนเคอร์เนล บัฟเฟอร์: แสดงเฉพาะข้อความแสดงข้อผิดพลาดสำคัญและการแจ้งเตือนลำดับความสำคัญยังสามารถใช้ตัวเลขได้เช่นกัน journalctl - p 3..1 หากใช้คำหลักหมายเลขเดียว journalctl - p 3 - ระดับความสำคัญสูงกว่าทั้งหมดจะรวมอยู่ด้วย แสดงสิทธิ์ auth. log โดยการกรองสิ่งอำนวยความสะดวก syslog: ดู man 1 journalctl. ชาย 7 คน. หรือ Lennarts โพสต์บล็อกสำหรับรายละเอียด เคล็ดลับ: โดยค่าเริ่มต้น journalctl จะตัดทอนเส้นที่ยาวกว่าความกว้างของหน้าจอ แต่ในบางกรณีอาจเป็นการดีที่จะใช้การตัดแทนการตัดทอนได้ ซึ่งสามารถควบคุมได้โดยตัวแปรสภาพแวดล้อม SYSTEMDLESS (ค่าเริ่มต้นเพจเจอร์) และค่าดีฟอลต์เป็น FRSXMK (ดูรายละเอียดจาก man 1 less และ man 1 journalctl) การละเว้นตัวเลือก S ผลลัพธ์จะถูกห่อแทนที่จะตัดทอน ตัวอย่างเช่นเริ่ม journalctl ดังนี้: ถ้าคุณต้องการตั้งค่าลักษณะการทำงานนี้เป็นค่าดีฟอลต์ให้ส่งออกตัวแปรจากขีด จำกัด ของ Journal size หากวารสารเป็นแบบถาวร (non-volatile) ขีด จำกัด ของขนาดจะถูกกำหนดเป็นค่าดีฟอลต์เท่ากับ 10 ขนาดของระบบไฟล์ต้นแบบ แต่ จำกัด ไว้ที่ 4 GiB ตัวอย่างเช่นกับ varlogjournal ที่อยู่ในพาร์ติชัน 20 GiB ข้อมูลเจอร์นัลอาจใช้เวลาถึง 2 GiB ในพาร์ติชั่น 50 GiB จะมีความจุสูงสุดที่ 4 GiB ขนาดสูงสุดของรายการบันทึกถาวรจะสามารถควบคุมได้โดยการจดบันทึก uncomment และเปลี่ยนข้อมูลต่อไปนี้นอกจากนี้คุณยังสามารถใช้กลไกการแทนที่ค่าตัวอย่างข้อมูลแบบหล่นลงแทนการแก้ไขไฟล์การกำหนดค่าทั่วโลก ในกรณีนี้อย่าลืมวางการแทนที่ภายใต้หัวข้อ Journal: ดู man journald. conf สำหรับข้อมูลเพิ่มเติม ล้างไฟล์เจอร์นัลด้วยตนเองไฟล์บันทึกประจำวันสามารถนำออกจาก varlogjournal ทั่วโลกได้เช่น RM หรือสามารถตัดตามเกณฑ์ต่างๆโดยใช้ journalctl ตัวอย่าง: ลบไฟล์เจอร์นัลที่เก็บจนกว่าเนื้อที่ดิสก์ที่ใช้อยู่จะต่ำกว่า 100M: ทำให้ไฟล์เจอร์นัลทั้งหมดไม่มีข้อมูลที่เก่ากว่า 2 สัปดาห์ ดู man journalctl สำหรับข้อมูลเพิ่มเติม Journald ร่วมกับ syslog ความเข้ากันได้กับการใช้งาน syslog แบบคลาสสิกที่ไม่ใช่ journald สามารถให้ได้โดยให้ systemd ส่งต่อข้อความทั้งหมดผ่านทาง socketystemdjournalsyslog socket เพื่อให้ daemon syslog ทำงานร่วมกับสมุดรายวันจะต้องผูกกับซ็อกเก็ตนี้แทน devlog (ประกาศอย่างเป็นทางการ) journald. conf เริ่มต้นสำหรับการส่งต่อไปยังซ็อกเก็ตคือ ForwardToSyslogno เพื่อหลีกเลี่ยงค่าใช้จ่ายของระบบเนื่องจาก rsyslog หรือ syslog-ng ดึงข้อความจากสมุดบันทึกด้วยตัวเอง ส่งต่อ journald ไปที่ devtty12 สร้างไดเรกทอรีแบบหล่นลงใน etcsystemdjournald. conf. d และสร้างไฟล์ fw-tty12.conf ไว้: ระบุวารสารที่แตกต่างกันเพื่อดูอาจต้องตรวจสอบบันทึกของระบบอื่นที่ตายในระบบ น้ำเช่นบูตจากระบบที่มีอยู่เพื่อกู้คืนระบบการผลิต ในกรณีเช่นนี้คุณสามารถใส่ดิสก์ลงในตัวอย่างเช่น mnt และระบุเส้นทางสมุดบันทึกผ่าน - D --directory เช่นเดียวกับ: เคล็ดลับและเทคนิคเปิดใช้งานหน่วยที่ติดตั้งโดยค่าเริ่มต้นเหตุผล: วิธีการทำงานกับหน่วยที่สร้างขึ้น (อภิปรายในการพูดคุย: Systemd) เรือ Arch Linux มี usrlibsystemdsystem-preset99-default. preset ที่มีการปิดใช้งาน สาเหตุนี้ทำให้ systemctl ตั้งค่าให้ปิดใช้งานหน่วยทั้งหมดตามค่าเริ่มต้นเช่นเมื่อมีการติดตั้งแพคเกจใหม่ผู้ใช้ต้องเปิดใช้งานยูนิทด้วยตนเอง หากไม่ต้องการใช้งานโปรดเพียงแค่สร้าง symlink จาก etcsystemdsystem-preset99-default. preset เพื่อใช้ devnull เพื่อแทนที่ไฟล์การกำหนดค่า ซึ่งจะทำให้ systemctl ตั้งค่าไว้เพื่อเปิดใช้งานทุกยูนิตที่ได้รับการติดตั้งโดยไม่ต้องระบุประเภทของหน่วยที่ระบุในไฟล์อื่นในไดเร็กทอรีการกำหนดค่าระบบที่กำหนดไว้ล่วงหน้าของ systemctl หน่วยผู้ใช้ไม่ได้รับผลกระทบ ดู manpage สำหรับ systemd. preset สำหรับข้อมูลเพิ่มเติม หมายเหตุ: การเปิดใช้งานหน่วยทั้งหมดโดยค่าเริ่มต้นอาจทำให้เกิดปัญหากับแพคเกจที่มีหน่วยที่มีการยกเว้นกันอย่างน้อยสองหน่วย การตั้งค่าล่วงหน้าของ systemctl ถูกออกแบบมาให้ใช้โดยการกระจายและสปินหรือผู้ดูแลระบบ ในกรณีที่มีการเปิดใช้งานหน่วยที่ขัดแย้งกันสองหน่วยคุณควรระบุอย่างชัดเจนว่ารายการใดจะถูกปิดใช้งานในไฟล์กำหนดค่าที่กำหนดไว้ล่วงหน้าตามที่ระบุใน manpage สำหรับ systemd. preset สภาพแวดล้อมแอพพลิเคชันแบบแซนด์บ็อกซ์ไฟล์หน่วยสามารถสร้างเป็น sandbox เพื่อแยกแอพพลิเคชันและกระบวนการของพวกเขาภายในสภาพแวดล้อมแบบเสมือนที่แข็งตัว systemd ใช้ประโยชน์จาก namespaces white-blacklisting ของความสามารถ และกลุ่มควบคุมไปสู่กระบวนการจัดเก็บผ่านการกำหนดค่าสภาพแวดล้อมการทำงานที่กว้างขวาง การเพิ่มประสิทธิภาพของไฟล์ unit unit ที่มีอยู่แล้วด้วย sandboxing แอพพลิเคชันมักต้องการการทดสอบและข้อผิดพลาดพร้อมกับการใช้ strace แบบใจกว้าง stderr และบันทึกข้อผิดพลาด journalctl และสิ่งอำนวยความสะดวกการส่งออก ก่อนอื่นคุณอาจต้องการค้นหาเอกสารต้นน้ำสำหรับการทดสอบที่ทำไว้แล้วเพื่อทดลองใช้งาน ตัวอย่างบางส่วนเกี่ยวกับการใช้งาน sandboxing กับ systemd สามารถใช้งานได้: CapabilityBoundingSet กำหนดความสามารถที่ได้อนุญาตไว้ในรายการอนุญาตพิเศษ แต่อาจใช้เพื่อสร้างความสามารถพิเศษเฉพาะสำหรับหน่วยได้ ความสามารถ CAPSYSADM เช่นซึ่งควรเป็นหนึ่งในเป้าหมายของ sandbox ที่ปลอดภัย CapabilityBoundingSet CAPSYSADM UnboundSandboxing แสดงตัวอย่างเต็มรูปแบบของคุณสมบัติ systemd สำหรับ sandboxing การแก้ปัญหาการตรวจสอบข้อผิดพลาดของระบบตัวอย่างเช่นเราจะตรวจสอบข้อผิดพลาดกับเซอร์วิส systemd-module-load: 1. ให้ค้นหาเซอร์วิส systemd ที่ไม่สามารถเริ่มต้นได้: 2. ตกลงเราพบปัญหาเกี่ยวกับเซอร์วิส systemd-module-load เราต้องการทราบข้อมูลเพิ่มเติม: ถ้ารหัสกระบวนการไม่อยู่ในรายการให้รีสตาร์ทเซอร์วิสที่ล้มเหลวโดยใช้ systemctl restart systemd-modules-load 3. ตอนนี้เรามี id กระบวนการ (PID) เพื่อตรวจสอบข้อผิดพลาดนี้ในเชิงลึก ป้อนคำสั่งต่อไปนี้ด้วยรหัสกระบวนการปัจจุบัน (ที่นี่: 15630): 4. เราเห็นว่าการกำหนดค่าโมดูลเคอร์เนลบางส่วนมีการตั้งค่าผิด ดังนั้นเราจึงได้ดูการตั้งค่าเหล่านี้ใน etcmodules-load. d 5. การค้นหาโมดูล blacklist usblp ผิดพลาดอาจเกี่ยวข้องกับการตั้งค่าผิดพลาดภายใน blacklist. conf ให้ยกเลิกการใช้งานโดยใส่คำนำท้ายก่อนแต่ละตัวเลือกที่เราพบผ่านทางขั้นตอนที่ 3: 6. ขณะนี้ลองเริ่มต้นใช้งาน systemd-modules-load ถ้ามันประสบความสำเร็จไม่ควรให้อะไร ถ้าคุณเห็นข้อผิดพลาดใด ๆ ให้กลับไปที่ขั้นตอนที่ 3 และใช้ PID ใหม่เพื่อแก้ไขข้อผิดพลาดด้านซ้าย หากทุกอย่างเรียบร้อยคุณสามารถตรวจสอบได้ว่าบริการเริ่มต้นด้วย: บ่อยครั้งที่คุณสามารถแก้ปัญหาเหล่านี้ได้เช่นที่แสดงไว้ด้านบน สำหรับการตรวจสอบเพิ่มเติมโปรดดูที่ปัญหาเกี่ยวกับการวินิจฉัยปัญหารองเท้าบู๊ต การวิเคราะห์ปัญหาเกี่ยวกับการบูต systemd มีหลายทางเลือกในการวินิจฉัยปัญหาเกี่ยวกับกระบวนการบูต ดูการดีบักการบูตและเอกสารการดีบัก systemd การวิเคราะห์ปัญหาเกี่ยวกับบริการเฉพาะเหตุผล: อาจไม่สามารถตรวจจับข้อผิดพลาดทั้งหมดเช่นไลบรารีที่ขาดหายไปได้ (อภิปรายในการสนทนาของผู้ใช้: AlucrydPlex) ถ้าบางบริการ systemd misbehaves และคุณต้องการได้รับข้อมูลเพิ่มเติมเกี่ยวกับสิ่งที่เกิดขึ้นตั้งค่าตัวแปรสภาพแวดล้อม SYSTEMDLOGLEVEL เพื่อแก้ปัญหา ตัวอย่างเช่นในการเรียกใช้เดสก์ท็อป systemd-networkd ในโหมดดีบั๊ก: หรือแก้ไขแฟ้มบริการชั่วคราวเพื่อรวบรวมเอาท์พุทที่เพียงพอ ตัวอย่างเช่นถ้าจำเป็นต้องใช้ข้อมูลดีบักในระยะยาวให้เพิ่มตัวแปรตามปกติ ShutdownEboot ใช้เวลานานมากหากกระบวนการปิดระบบใช้เวลานานมาก (หรือดูเหมือนจะหยุดชะงัก) บริการส่วนใหญ่ที่ไม่ได้ออกจากระบบคือการทำโทษ systemd รอสักครู่สำหรับแต่ละบริการที่จะออกก่อนที่จะพยายามที่จะฆ่ามัน หากต้องการดูว่าคุณได้รับผลกระทบหรือไม่โปรดดูที่บทความนี้ กระบวนการสั้น ๆ ดูเหมือนจะไม่บันทึกเอาท์พุทใด ๆ เลยถ้า journalctl - u foounit ไม่แสดงผลลัพธ์ใด ๆ สำหรับบริการสั้น ๆ ให้ดูที่ PID แทน ตัวอย่างเช่นถ้า systemd-modules-load. service ล้มเหลวและสถานะ systemctl systemd-modules-load แสดงว่าทำงานเป็น PID 123 แล้วคุณอาจเห็นผลลัพธ์ในสมุดรายวันสำหรับ PID นั่นคือ journalctl - b PID61123 เขตข้อมูลเมตาสำหรับสมุดรายวันเช่น SYSTEMDUNIT และ COMM จะถูกเก็บรวบรวมแบบอะซิงโครนัสและพึ่งพาไดเร็กทอรี proc สำหรับกระบวนการที่มีอยู่ การแก้ไขนี้ต้องแก้ไข kernel เพื่อให้ข้อมูลนี้ผ่านการเชื่อมต่อซ็อกเก็ตคล้ายกับ SCMCREDENTIALS เวลาบูตที่เพิ่มขึ้นเมื่อเวลาผ่านไปหลังจากใช้ systemd - วิเคราะห์จำนวนผู้ใช้สังเกตว่าเวลาบูตของพวกเขาได้เพิ่มขึ้นอย่างมากเมื่อเทียบกับที่เคยเป็น หลังจากใช้ NetworkManager ที่ถูกกล่าวหาว่าวิเคราะห์ systemd ถูกรายงานว่าใช้เวลาในการเริ่มต้นเป็นจำนวนที่ผิดปกติ ปัญหาสำหรับผู้ใช้บางรายเกิดขึ้นเนื่องจาก varlogjournal มีขนาดใหญ่เกินไป ซึ่งอาจมีผลกระทบอื่น ๆ ต่อประสิทธิภาพการทำงานเช่นสถานะ systemctl หรือ journalctl (เช่นการแก้ปัญหาคือการลบทุกไฟล์ภายในโฟลเดอร์ (อย่างน้อยก็ควรทำการสำรองข้อมูลไว้ชั่วคราว) อย่างน้อยก็ชั่วคราว) จากนั้นตั้งค่าขีด จำกัด ขนาดไฟล์เจอร์นัลตามที่อธิบายไว้ในขีด จำกัด ขนาดของ Journal systemd-tmpfiles-setup. service ไม่สามารถเริ่มต้นได้เมื่อบูตเริ่มต้นด้วย systemd 219 usrlibtmpfiles. dsystemd. conf ระบุแอ็ตทริบิวต์ ACL สำหรับไดเร็กทอรีภายใต้ varlogjournal ดังนั้นจึงต้องมีการสนับสนุน ACL เพื่อเปิดใช้งานระบบไฟล์ที่บันทึกอยู่ ดูรายการควบคุมการเข้าถึงการเปิดใช้งาน ACL สำหรับคำแนะนำเกี่ยวกับวิธีเปิดใช้งาน ACL ในระบบแฟ้มที่เก็บข้อมูล varlogjournal systemctl enable ล้มเหลวสำหรับ symlinks ใน etcsystemdsystem ถ้า etcsystemdsystem foo. service เป็น symlink และ systemctl เปิดใช้งาน foo. service มีการรันจะล้มเหลวกับข้อผิดพลาดนี้: นี่คือทางเลือกในการออกแบบของ systemd เป็นวิธีแก้ปัญหาการเปิดใช้งานโดยเส้นทางสัมบูรณ์ทำงาน: เซอร์วิสที่ใช้ไม่ได้เริ่มทำงานเมื่อเริ่มต้นเซอร์วิสด้วยตนเองตัวอย่างหนึ่งที่มีชื่อเสียง (ตัวอย่างหนึ่ง) คือ libvirtd. service ซึ่งต้องการให้ virtlogd. socket ทำงานอย่างถูกต้อง การพึ่งพาใน usrlibsystemdsystemlibvirtd. service มีการกำหนดให้เป็นเพียงการกำหนดซ็อกเก็ตที่จำเป็นต่อการเปิดใช้บริการเท่านั้น (เช่น autostart) ด้วยเช่นกัน แต่ไม่ได้เริ่มทำงานเมื่อบริการ DISABLED (ไม่ใช่ autostarting) เริ่มทำงานด้วยตนเองเช่น โดยการรัน systemctl start libvirtd ด้วยเหตุนี้วิธีที่ถูกต้องในการเริ่มต้นเซอร์วิสกับ subservices ที่ขึ้นกับตัวเองครั้งเดียว (แทนการเริ่มต้นแต่ละครั้งของระบบ) อาจเป็นเวอร์ชัน systemd ที่พิมพ์ออกมาเมื่อบูตไม่เหมือนกับเวอร์ชันของแพ็คเกจที่ติดตั้งไว้คุณต้องสร้างใหม่ initramfs และเวอร์ชันควรตรงกัน เคล็ดลับ: เบ็ด pacman สามารถใช้เพื่อสร้าง initramfs ใหม่ทุกครั้งที่มีการอัพเกรด systemd ดูหัวข้อฟอรัมนี้และ PacmanHooks. systemd เป็นผู้จัดการระบบและบริการสำหรับ Linux ที่เข้ากันได้กับสคริปต์ init SysV และ LSB systemd ให้ความสามารถแบบขนานก้าวร้าวใช้ซ็อกเก็ตและการเปิดใช้งาน D-Bus สำหรับการเริ่มต้นบริการเสนอการเริ่มต้นของ daemons ตามความต้องการโดยจะคอยติดตามกระบวนการต่างๆโดยใช้ Linux cgroups สนับสนุน snapshotting และการคืนค่าสถานะของระบบรักษาจุดติดและจุดอัตโนมัติและใช้งาน ซับซ้อนตรรกะการควบคุมบริการขึ้นอยู่กับการทำธุรกรรม มันสามารถทำงานเป็นแบบหล่นลงแทน sysvinit สำหรับข้อมูลเพิ่มเติมดูวิดีโอที่ youtubewatchvTyMLi8QF6sw สำหรับผู้ดูแลระบบผู้ดูแลระบบสามารถเข้าชมหน้านี้ได้ เพื่อทำความเข้าใจวิธีใช้สาย systemctl ที่แทนที่กระบวนการทำงานเก่าของพวกเขาใน SysVinit โปรดทราบว่าคำสั่ง service และ chkconfig จะทำงานต่อไปตามที่คาดไว้ในโลกของ systemd ทำไม systemd systemd documentation system มีเอกสารที่ครอบคลุมมาก อ้างถึง Boot Kernel Command Line เมื่อ boot systemd เปิดใช้งาน (โดยดีฟอลต์) หน่วย default. target ของหน่วยเป้าหมายที่มีงานเพื่อเปิดใช้บริการและหน่วยงานอื่น ๆ โดยการดึงข้อมูลเหล่านี้ผ่านทาง dependencies เมื่อต้องการแทนที่หน่วยเพื่อเปิดใช้งาน systemd จะวิเคราะห์อาร์กิวเมนต์บรรทัดคำสั่งเคอร์เนลของตัวเองโดยใช้ตัวเลือกบรรทัดคำสั่ง systemd. unit ซึ่งอาจใช้สำหรับบูตชั่วคราวในหน่วยบูตอื่น ระดับรันไทม์คลาสสิกจะถูกแทนที่โดย: systemd. unitrescue. target เป็นหน่วยเป้าหมายพิเศษสำหรับการตั้งค่าระบบฐานและเปลือกกู้ภัย (คล้ายกับ run level 1) systemd. unitemergency. target คล้ายคลึงกับ initbinsh แต่มีตัวเลือกในการบูตระบบแบบเต็มจากที่นั่น systemd. unitmulti-user. target สำหรับการตั้งค่า systemd. unitgraphical. target สำหรับผู้ใช้หลายระบบแบบกราฟิกสำหรับการตั้งค่าหน้าจอการเข้าสู่ระบบแบบกราฟิก สำหรับรายละเอียดเกี่ยวกับหน่วยการบูตระบบพิเศษนี้โปรดดู man systemd. special page it scripts เครื่องมือในการจัดการบริการด้วย systemd systemctl คือเครื่องมือหลักในการใช้งาน มันรวมฟังก์ชันการทำงานของทั้งสองบริการและ chkconfig เป็นเครื่องมือเดียวที่คุณสามารถใช้เช่นบริการ enableisable อย่างถาวรหรือเฉพาะสำหรับเซสชั่นปัจจุบัน แสดงรายการบริการที่กำลังทำงานอยู่ทั้งหมด: ดูรายละเอียดเพิ่มเติมได้ที่ man systemctl systemd-cgls แสดงกระบวนการทำงานในรูปแบบต้นไม้ สามารถแสดงเนื้อหาแบบเรียงรายของกลุ่มควบคุมใดก็ได้ ดูรายละเอียดเพิ่มเติมได้ที่ man systemd-cgls เปิดใช้งานบริการทันที: ปิดการใช้งานบริการทันที: เริ่มบริการใหม่: แสดงสถานะของบริการรวมถึงไม่ว่าจะทำงานหรือไม่: เปิดใช้งานบริการที่จะเริ่มต้นเมื่อบูตเครื่อง: ปิดการใช้บริการที่จะไม่เริ่มในช่วง bootup: ป้องกันไม่ให้บริการเริ่มทำงานแบบไดนามิกหรือแม้แต่ด้วยตนเองเว้นแต่ unmasked: ตรวจสอบว่ามีการเปิดใช้งานบริการแล้วหรือไม่: ดู man systemctl สำหรับรายละเอียดเพิ่มเติม ฉันจะเปลี่ยนเป้าหมาย (runlevel) systemd มีแนวคิดเกี่ยวกับเป้าหมายซึ่งเป็นความยืดหยุ่นมากขึ้นสำหรับการแทนที่ runlevels ใน sysvinit เรียกใช้ระดับ 3 โดยใช้ multi-user. target เรียกใช้ระดับ 5 เป็นเลียนแบบโดย graphical. target runlevel3.target คือลิงค์สัญลักษณ์ไปยัง multi-user. target และ runlevel5.target คือลิงค์สัญลักษณ์ไปยัง graphical. target คุณสามารถเปลี่ยนไปใช้ runlevel 3 ได้โดยการรันคุณสามารถเปลี่ยนไปใช้ runlevel 5 ได้โดยการเรียกใช้ฉันจะเปลี่ยนค่าเริ่มต้นของเป้าหมายเป็นค่าดีฟอลต์ได้อย่างไร คุณอาจต้องการ multi - user. target สำหรับเทียบเท่ากราฟิกไม่ใช่ (runlevel 3) จาก init sysv รายการเป้าหมายทั้งหมดสามารถเข้าถึงได้ผ่าน systemctl list-units --typetarget systemd ไม่ใช้ไฟล์ etcinittab ฉันจะรู้ได้อย่างไรว่าเป้าหมายปัจจุบันวิธีการปิดเครื่องความเป็นไปได้บางอย่างเพิ่มเติม ได้แก่ : หยุด - p init 0. shutdown - P now Note that halt used to work the same as poweroff in previous Fedora releases, but systemd distinguishes between the two, so halt without parameters now does exactly what it says - it merely stops the system without turning it off. Does service command work with systemd Yes. It has been modified to call systemctl automatically when dealing with systemd service files. So either of the following commands does the same thing Does chkconfig command work with systemd Yes, for turning onoff services, compatibility has been provided both ways. chkconfig has been modified to call systemctl when dealing with systemd service files. Also systemctl automatically calls chkconfig when dealing with a traditional sysv init file. So either of the following commands does the same thing chkconfig --list doesnt list systemd services, only Sys V services. The output of chkconfig takes note of this, along with supplying additional information. Does system-config-services work with systemd How do I change the number of gettys running by default The simplest way is to edit etcsystemdlogind. conf (man page ): This setting will take effect after reboot. Alternatively, getty. services which open the login prompt can be enabled and started individually. To add another getty: To remove a getty: systemd does not use etcinittab file. How do I set automatic login on a virtual console terminal First create a new service similar to getty. service: then edit ExecStart, Restart and Alias values, like this: and finally reload daemon and start the service: Note that if you exit tty8 session, you wont be able to use it until next reboot or manual start by systemctl, except if you leave Restart as always, but I highly recommend to avoid this according to security reasons. How do I customize a unit file add a custom unit file The best way to customize unit files is to add etcsystemdsystemfoobar. service. d.conf where foobar. service is the name of the service you want to customize. If a directory doesnt already exist, create one and drop a conf file with the settings you want to override. For example, Refer to man systemd. unit page for more details. Dont forget to reload systemd daemon using systemctl daemon-reload and systemctl restart foobar after editing a unit file where foobar is the name of the unit. Also note that you can systemd-delta to list the unit files which have been customized and also the precise differences Special care must be taken when overriding options which can be set muliple times ( ExecStart. ExecStartPre. ExecStartPost are a common example). Assigning some value to the option appends to the existing list, while assiging the empty value resets the list. For example, lets say we have a service file like this: When started, this service will print The same rules apply to snippets in. d directories. This means that snippets which override ExecStart and similar settings, often should start with the empty assignment ExecStart. followed by the new setting. How do I debug systemd issues systemd comes with extensive documentation including several man pages. Referencessystemd - An alternative boot manager systemd is a system and session manager for Linux, compatible with SysV and LSB init scripts. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux cgroups, supports snapshotting and restoring of the system state, maintains mount and automount points and implements an elaborate transactional dependency-based service control logic. See the systemd home page for further information. Warning Experimental code systemd is under active development in Ubuntu although the rough plan would be to default to systemd during development of 15.04. If you want to help its best to be running 15.04. (14.10 might be doable as well..) Installing systemd in Ubuntu may limit the amount of help and support available to you. If you have a commercial support agreement then installing systemd would almost certainly invalidate it. Even if you rely on forums etc, you will probably have to reproduce problems on a standard Ubuntu build before anyone can help you much. If you want to quickly try out systemd, it may be a good idea to create a sandpit system for the purpose (e. g. a virtual machine that you can easily re-install or delete afterwards). If you are installing systemd on a system containing data that you care about, please take a full backup first, and make a plan for restoring from backup in the event that the system ends up unbootable. Personal Package Archive location systemd and related packages are available on this PPA To use the PPA, first add it to your software sources list as follows. Installing systemd systemd can be installed from the PPA as follows. This results in systemd being installed alongside upstart. Boot loader configuration After installation, the machine will still boot under upstart by default. To boot under systemd, the following argument must be specified on the kernel command line: Note that the systemd binary resides now in libsystemd and binsystemd is just a symlink to it. To boot under systemd by default, edit etcdefaultgrub and change the following line: After modifying any grub related configuration files like etcdefaultgrub the following command is needed to bring the changes into effect. systemd prints the following warning on boot: It is advisable to do as suggested and replace etcmtab . It is not only mount that will behave incorrectly otherwise, but also df and probably most other commands that look at the list of mounted filesystems. This change can be made as follows. Using systemd To boot under systemd, select the boot menu entry that you created for the purpose. If you didnt bother to create one, just select the entry for your patched kernel, edit the kernel command line directly in grub and add initlibsystemdsystemd . If a normal boot under systemd is not successful then it is worth trying with the following parameters: systemd. unit specifies the target state that the system should boot to (similar to specifying a run level under sysvinit). emergency. service launches an emergency bash shell on the console without attempting to start any other services. Controlling systemd once booted The main command used to control systemd is systemctl . Some of its subcommands are as follows. systemctl list-units - List all units (where unit is the term for a jobservice) systemctl start NAME. - Start (activate) one or more units systemctl stop NAME. - Stop (deactivate) one or more units systemctl enable NAME. - Enable one or more unit files systemctl disable NAME. - Disable one or more unit files systemctl reboot - Shut down and reboot the system For the complete list, see systemctl(1). systemadm is the GUI equivalent to systemctl . if you like that sort of thing. Remote filesystem mounts If you have NFS mounts listed in etcfstab then systemd will attempt to mount them but will typically do so too early, before networking has been configured. To get the timing correct we need to tell systemd explicitly that the mount depends on networking and on rpc. statd . To do this, create a file under libsystemdsystem named ltmount-unit-namegt. mount with contents as follows. mount-unit-name is the full path to the mountpoint in an escaped format. For example, a mount unit for usrlocal must be named usr-local. mount . mountpoint is the local mountpoint server : share specify the remote filesystem in the same manner as for etcfstab See systemd. unit(5) and systemd. mount(5) for further details. A similar approach will probably be required for other remote filesystem types such as nfs4 and cifs Useful snippets To see which other units a service depends on: systemd quickstart for upstart users Implementation issues Packaging of units A unit properly belongs in the package of the daemon that it starts. systemd units are already included in some upstream packages and some Debian Experimental packages. They will probably appear in Ubuntu packages in due course, unless Ubuntu maintainers deliberately remove them. The systemd-extra-units package is intended only to make systemd usable in the short term by shipping some important units that dont yet exist in other Ubuntu packages. It should be scaled back as and when units start to appear in their proper places, and should eventually be dropped. Dependencies on things not yet available in Ubuntu Upstream systemd depends on recent upstream changes to several other packages that are not yet available in Ubuntu. These have been worked around by reverting the relevant changes in systemd or disabling the relevant feature. In brief these are: systemd 15 wants libnotify gt 0.7 and vala 0.11 Relevant changes have been reverted in order to build with libnotify 0.5.0 and vala 0.9. systemd wants sbinagetty but DebianUbuntu renames it to sbingetty sbinagetty will be added as a link in Debian wheezy (Debian bug 603786 ). systemd invokes agetty - s where the option - s was added by recent upstream commits in util-linux . Units getty. service and serial-getty. service have been patched to remove this option. systemd-fsck invokes fsck - l where the option - l was added by recent upstream commits in util-linux systemd-fsck has been patched to remove this option. Networking NetworkManager. service just starts NetworkManager and does not wait for it to bring up a network interface. This seems appropriate, but network. target should not become active until a network connection is up. An extra unit, wait-for-network. service . has been created to delay network. target . The appropriate way to wait for a network connection with NetworkManager appears to be nm-online . but this binary is not shipped in the Debian or Ubuntu packages for some reason. For systemd-extra-units 0.2 a simple shell loop has been used. This is effective, but hardly in the spirit of systemd. TODO: Ask whether nm-online could be shipped in the network-manager package, or re-implement something similar if not. NOTE: The network-manager package from Debian experimental does ship nm-online and will be uploaded to wheezy as soon as squeeze is released. Remote filesystem mounts systemd reads etcfstab and automatically creates a mount unit for each entry. The automatically generated dependencies for these units are insufficient in the case of remote filesystems. The correct dependencies can be specified explicitly in a mount unit configuration file (see above) but ideally this should be handled automatically. Proposal: When parsing an etcfstab entry, systemd should look for a unit template named after the filesystem type (e. g. nfs. mount for an NFS mount). If a template is found it should be used, with appropriate substitutions. Otherwise systemd should fall back to creating the mount unit with default settings as per the current behaviour. TODO: Write a patch for this and propose it upstream. The upstart job for portmap saves state using pmapdump and restores it using pmapset . The sysvinit script in Debian does the same thing. These actions appear redundant because portmap itself saves state to varrunportmapmapping after each change. My guess is that this is all based on instructions in the upstream source README, which may be out of date or just misleading. TODO: Confirm whether pmapdump pmapset really serve some purpose and include them in the systemd unit if so. etccron. danacron invokes anacron via the upstart job, which wont work while booted under systemd. A change to the anacron package would be needed to address this. etcdefault Existing sysvinit style scripts read configuration in the form of variable assignments from a file under etcdefault . A policy decision is needed on whether systemd units will do the same. Advantages: Separates configuration from code, simplifies package upgrade (i. e. same reasoning that applies to the existing sysvinit scripts). Disadvantages: Extra complexity. Some may argue that systemd units are simple enough to be treated entirely as configuration files. etcdefault files can be read using the EnvironmentFile parameter in a systemd service unit. However, this is not fully compatible with the shell. In particular the quoting rules differ. It is not possible to write an environment variable assignment containing whitespace or literal quotes in a way that both a legacy init script and systemd will understand. TODO: Decide whether systemd will use etcdefault files. Needs discussion with Debian maintainers. There would be little benefit in Ubuntu going its own way on this. TODO: Finish off patch for shell compatible quoting support and submit upstream. Other TODO Items Unit(s) for static network configuration without NetworkManager . Units for remaining native Upstart jobs in a default Ubuntu install that dont currently have systemd equivalents: apport cups log dmesg after boot failsafe X session irqbalance bring up virtual network devices Desktop integration for systemadm Plymouth integration Workarounds Failures on software-upgrades The post-installation script of packages uses sbinstart and sbinstop to start and stop (running) services in an upstart environment. Both binaries are symlinks to sbininitctl shipped with upstart package. Unfortunately, software-upgrades break when switching to systemd as an alternative init-system on Ubuntu systems, more precisely the software-management tool dpkg breaks. NOTE: Below workarounds were tested on Ubuntuprecise with a very early systemd v43 (so be careful). Bug 1008837 cups fails to installupgrade with systemd A little demo Workaround: Using an initctl replacement On IRC I discussed with Michael Biebl and others on the topic and Michael had concerns using bintrue as a symlink to sbinstart and sbinstop . In the end, the idea of an initctl replacement was born. Rename the original sbininitctl binary: Edit a new sbininitctl replacement file (Thanks mbiebl and grawity): Make the new script executable: Create and list a divert for the original initctl (this prevents e. g. its removal on upgrades): Remove the new divert in case you want to restore original behaviour: Software-upgrades touching startstop of daemons should now work fine within an upstart or systemd environment. systemd ( pitti 2015-01-22 09:56:01)

Comments