Device의 major, minor number란 무엇인가?
Linux에서 device는 하나의 파일이며 그 파일들을 통해서 device를 관리한다.
또한 device 파일들은 Major와 Minor Number를 갖는데 그렇다면 Device의 Major와 Minor Number란 무엇인가?
/dev 디렉토리에서 ls -alrt 명령어를 수행 해보면 device들의 Major와 Minor Number 정보들을 얻을 수 있다.
Major number는 어느 driver(module)을 통해서 장치가 관리되는지 구분하기 위해서 사용하는 number이다.
즉, device가 같은 major number를 갖고 있다면 그 device는 같은 driver(module)로 관리되어진다.
예를 들어, 위 그림에서 vda, vda1, vdb, vdb1가 같은 252이라는 device major number를 갖고 있는데 그렇다면
위 4개의 장치는 같은 driver(module)을 통해 관리 되어지는 장치라는걸 확인 할 수 있다.
Minor number는 driver(module)내에서 서로 다른 device임을 구분하기 위해서 사용되는 number이다.
예를 들어, 위 그림에서 vda, vda1, vdb, vdb1가 같은 252 device major number를 갖지만 서로 다른 장치이기 때문에 다른 minor number를 갖고있다. 이것은 driver(module)내에서 위 장치들이 서로 다른 장치임을 구분하기위해서 사용된다.
Linux는 device를 사용할때, major number를 통해 어느 driver(module)을 사용할지 결정하고 minor number를 통해
어느 장치에게 명령을 내릴지 결정합니다.
출처: <https://www.tldp.org/HOWTO/Partition-Mass-Storage-Definitions-Naming-HOWTO/x183.html>
<http://javeedkaleem.blogspot.com/2010/02/raw-devices-on-linux.html>