rosieblue
article thumbnail
728x90

๋Ÿฐ๋ ˆ๋ฒจ์ด๋ž€ ๊ทธ์ € ์–ด๋–ค ๋ชจ๋“œ๋กœ ์ปดํ“จํ„ฐ๋ฅผ ์‹œ์ž‘ํ• ๊นŒ?์— ๊ด€ํ•œ ๋‚ด์šฉ์ด๋ผ๊ณ  ๋ณด๋ฉด๋œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด init ํ”„๋กœ์„ธ์Šค๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ์—๋Š” /etc/inittab๋ผ๋Š” ์Šคํฌ๋ฆฝํŠธ ํŒŒ์ผ์„ ์ฝ์€ ํ›„ ์„ค์ •๋œ ๋Ÿฐ๋ ˆ๋ฒจ์— ๋Œ€ํ•œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.

 

  • ๋ฌด์Šจ ๋Ÿฐ๋ ˆ๋ฒจ๋“ค์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณด์ž

/lib/systemd/system ๋””๋ ‰ํ† ๋ฆฌ๋กœ ์ด๋™ํ•œ ํ›„ "runlevel?.target"ํ˜•์‹์œผ๋กœ ๋˜์–ด ์žˆ๋Š” ํŒŒ์ผ๋“ค์˜ ์ •๋ณด๋ฅผ ์ถœ๋ ฅํ•ด๋ณด์ž.

 

์œ„ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ runlevel0๋ถ€ํ„ฐ runlevel6๊นŒ์ง€ ์ถœ๋ ฅ๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

runlevel?.target ํŒŒ์ผ๋“ค์€ ๋ชจ๋‘ ๋งํฌํŒŒ์ผ๋กœ ๋‹ค๋ฅธ ํƒ€๊นƒํŒŒ์ผ์— ์—ฐ๊ฒฐ๋˜์–ด์žˆ๋‹ค.

์ฐธ๊ณ ๋กœ ๋‚˜๋Š” init์ด ์•„๋‹ˆ๋ผ systemd๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ™˜๊ฒฝ์ž„์—๋„ runlevel์ด๋ผ๋Š” ์šฉ์–ด๊ฐ€ ๊ณ„์†ํ•ด์„œ ์“ฐ์ด๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค.

 

๋Ÿฐ๋ ˆ๋ฒจ๊ณผ target์„ ํ‘œ๋กœ ์ •๋ฆฌํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

๋Ÿฐ๋ ˆ๋ฒจ target ์˜๋ฏธ
1 rescue.target ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜์˜ ๋‹จ์ผ ์‚ฌ์šฉ์ž ๋ชจ๋“œ(single user mode)
3 multi-user.target ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜์˜ ๋‹ค์ค‘ ์‚ฌ์šฉ์ž ๋ชจ๋“œ
0 poweroff.target ์‹œ์Šคํ…œ ์ค‘๋‹จ(Halt)
6 reboot.target ์‹œ์Šคํ…œ ๋ฆฌ๋ถ€ํŒ…
2 multi-user.target ์‚ฌ์šฉ๋˜์ง€ ์•Š์Œ(์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ • ๊ฐ€๋Šฅ)
4 multi-user.target ์‚ฌ์šฉ๋˜์ง€ ์•Š์Œ(์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ • ๊ฐ€๋Šฅ)
5 graphical.target  X ์œˆ๋„ ๊ธฐ๋ฐ˜์˜ ๋‹ค์ค‘ ์‚ฌ์šฉ์ž ๋ชจ๋“œ(๋กœ๊ทธ์ธ๋„ X ์œˆ๋„์—์„œ ์ด๋ค„์ง)
  • ๋‚ด ์ปดํ“จํ„ฐ์˜ ํ˜„์žฌ ๋Ÿฐ๋ ˆ๋ฒจ(ํƒ€๊ฒŸ) ํ™•์ธ
$ systemctl get-default
multi-user.target

์œ„ ์˜ˆ์—์„œ๋Š” multi-user.target์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ๋‚˜์˜จ๋‹ค

systemd์—์„œ๋Š” ๋Ÿฐ๋ ˆ๋ฒจ์—๋‹ค๊ฐ€ 'target'์ด๋ผ๋Š” ์šฉ์–ด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค

 

X์œˆ๋„์šฐ๋ฅผ ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋‚ด ์นผ๋ฆฌ ๋ฆฌ๋ˆ…์Šค์—์„œ ํ™•์ธํ•ด๋ณด๋‹ˆ graphical.target์ด ์ถœ๋ ฅ๋˜์—ˆ๋‹ค.

 

์•„๊นŒ ์œ„์—์„œ ์–ด๋–ค ๋Ÿฐ๋ ˆ๋ฒจ ํƒ€๊นƒ๋“ค์ด ์žˆ๋Š”์ง€ ์‚ดํŽด๋ณด๊ธฐ ์œ„ํ•ด /lib/systemd/system ๋””๋ ‰ํ† ๋ฆฌ์— ๋“ค๋ ธ์—ˆ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ์—ฌ๊ธฐ์—๋Š” default.target์ด๋ผ๊ณ  ๋ถ€ํŒ…๋  ๋•Œ ๊ธฐ๋ณธ์ ์œผ๋กœ ์„ธํŒ…๋˜๋Š” ๋Ÿฐ๋ ˆ๋ฒจ์ด ์ง€์ •๋˜์–ด์žˆ๋‹ค.

dafulat.target ๋งํฌ๊ฐ€ graphical.target์„ ๊ฐ€๋ฆฌํ‚ค๊ณ  ์žˆ๋‹ค.

์ด์ฒ˜๋Ÿผ systemctl get-default ๋Œ€์‹  ์ด๋ ‡๊ฒŒ default.target์ด ๋ฌด์—‡์ธ์ง€ ํ™•์ธํ•ด๋„๋œ๋‹ค.

 

  • ํ™œ์„ฑํ™”๋œ ํƒ€๊ฒŸ ์ •๋ณด ์ถœ๋ ฅ. (๋ชจ๋“  ํƒ€๊ฒŸ ์ถœ๋ ฅํ•˜๋ ค๋ฉด --all ์ถ”๊ฐ€)
$ systemctl list-units --type target
 
UNIT                  LOAD   ACTIVE SUB    DESCRIPTION
basic.target          loaded active active Basic System
cryptsetup.target     loaded active active Encrypted Volumes
getty.target          loaded active active Login Prompts
local-fs-pre.target   loaded active active Local File Systems (Pre)
local-fs.target       loaded active active Local File Systems
multi-user.target     loaded active active Multi-User System
network-online.target loaded active active Network is Online
network.target        loaded active active Network
paths.target          loaded active active Paths
remote-fs.target      loaded active active Remote File Systems
slices.target         loaded active active Slices
sockets.target        loaded active active Sockets
sound.target          loaded active active Sound Card
swap.target           loaded active active Swap
sysinit.target        loaded active active System Initialization
timers.target         loaded active active Timers
 
LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type

 

  • ๋””ํดํŠธ ํƒ€๊ฒŸ ๋ณ€๊ฒฝ

ํ•œํŽธ ์œ„์—์„œ ๋ณธ /lib/systemd/system/default.target์€ ๋งํฌํŒŒ์ผ์ด์—ˆ๋‹ค. ์ด ํŒŒ์ผ์œผ ๋‹ค๋ฅธ ํƒ€๊นƒ์— ์—ฐ๊ฒฐํ•˜๋ฉด default.target์ด ๋ฐ”๋€Œ๊ฒŒ ๋œ๋‹ค. ์ฆ‰ ๋ถ€ํŒ…ํ•  ๋•Œ ์‹คํ–‰๋˜๋Š” ๋Ÿฐ๋ ˆ๋ฒจ์ด ๋ณ€๊ฒฝ๋˜๋Š” ๊ฒƒ์ด๋‹ค. ๋ช…๋ น์–ด๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

$ ln -sf /lib/systemd/system/multi-user.target /lib/systemd/system/default.target

 

์•„๋‹ˆ๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ๊ทธ๋ƒฅ ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ฐ”๊ฟ”๋„ ๋œ๋‹ค.

$ sudo systemctl set-default ํƒ€๊ฒŸ์ด๋ฆ„

 

  • init ๋ช…๋ น์–ด
$ init ๋Ÿฐ๋ ˆ๋ฒจ

์˜ˆ๋ฅผ ๋“ค์–ด init 0 ์ด๋Ÿฐ ์‹์œผ๋กœ ํ•˜๋ฉด ์ปดํ“จํ„ฐ๊ฐ€ ์ฆ‰์‹œ ์ข…๋ฃŒ๋œ๋‹ค.

์ฃผ๋กœ init 0 (์‹œ์Šคํ…œ ์ข…๋ฃŒ), init 6(์žฌ๋ถ€ํŒ…)์ด ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค.


 

profile

rosieblue

@Rosieblue

ํฌ์ŠคํŒ…์ด ์ข‹์•˜๋‹ค๋ฉด "์ข‹์•„์š”โค๏ธ" ๋˜๋Š” "๊ตฌ๋…๐Ÿ‘๐Ÿป" ํ•ด์ฃผ์„ธ์š”!