
질문 제목이 요약되어 있습니다. Debian 9 기반 VM으로 네트워크 어플라이언스를 배포하고 있지만 필요한 경우 사용자에게 추가 디스크 공간을 추가할 수 있는 기능을 제공하고 싶지만 명령줄에서 전체 시스템 액세스 권한을 갖는 것을 원하지 않습니다. fdisk 유형 활동만 수행하도록 제한된 계정을 만들려면 어떻게 해야 합니까? 또한 디스크를 탐색할 수 없도록 파일 시스템 액세스를 제한하고 싶습니다.
답변1
대신 가상 하드 드라이브와 파일 시스템의 크기를 조정하는 작업을 자동화해야 합니다.
예를 들어 cloud-init는 자동으로 설정될 수 있습니다.파티션을 키워라(및 파일 시스템) 가상 머신 인스턴스의 인스턴스이며 Amazon AWS 및 Google Cloud와 같은 주요 클라우드 제공업체의 VM 인스턴스에서 이미 그렇게 하도록 설정되어 있습니다. cloud-init를 직접 사용하여 이 작업을 자동화할 수 있습니다. 이 경우 최종 사용자는 하이퍼바이저에서 가상 디스크의 크기를 조정한 다음 인스턴스를 재부팅하면 cloud-init가 필요한 모든 단계를 자동으로 수행합니다.
문서의 예:
#cloud-config
#
# growpart entry is a dict, if it is not present at all
# in config, then the default is used ({'mode': 'auto', 'devices': ['/']})
#
# mode:
# values:
# * auto: use any option possible (any available)
# if none are available, do not warn, but debug.
# * growpart: use growpart to grow partitions
# if growpart is not available, this is an error.
# * off, false
#
# devices:
# a list of things to resize.
# items can be filesystem paths or devices (in /dev)
# examples:
# devices: [/, /dev/vdb1]
#
# ignore_growroot_disabled:
# a boolean, default is false.
# if the file /etc/growroot-disabled exists, then cloud-init will not grow
# the root partition. This is to allow a single file to disable both
# cloud-initramfs-growroot and cloud-init's growroot support.
#
# true indicates that /etc/growroot-disabled should be ignored
#
growpart:
mode: auto
devices: ['/']
ignore_growroot_disabled: false
답변2
sudoers 파일( /etc/sudoers
, 그러나 도구로 편집하는 것이 가장 좋음 visudo
)을 사용하여 사용자 그룹이 특정 명령으로 제한된 sudo(8) 사용을 허용할 수 있습니다. 사용자가 관련 없는 디스크에서 fdisk를 호출할 수 없도록 허용되는 인수를 추가할 수도 있습니다.
파일의 항목은 다음과 같습니다.
%yourgroup ALL=(ALL) NOPASSWD: /sbin/fdisk /dev/sdb
man sudoers
명령 구문 및 가능한 옵션에 대한 자세한 정보가 있습니다.