별의 공부 블로그 🧑🏻‍💻
728x90
728x170

/etc/fstab

/etc/fstab

  • 파일 시스템에 대한 다양한 정보를 담고 있는 파일
  • 부팅 시에 마운트 할 파티션 정보가 기록 되어 있는 파일이기도 하다.
  • 파티션 정보를 변경하였거나 디스크를 추가한 경우 이 파일에 등록해야만 부팅 시에 자동으로 마운트할 수 있다.
  • 다음의 명령어가 수행될 때, 이 파일의 정보를 참조한다.
    • mount
    • umount
    • fsck
  •  6개의 필드로 구성되어 있다.
# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Feb 11 01:16:53 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root                    /                       xfs     defaults        0 0
UUID=de2b8b5c-d1c5-4813-906a-d1802d3a4298 /boot                    xfs     defaults        0 0
/dev/mapper/centos-swap                    swap                    swap    defaults        0 0

 

fstab의 필드 구성

  • man fstab 명령어를 사용하여 필드 구성을 확인할 수 있다.
더보기

       The first field (fs_spec).
              This field describes the block special device or remote filesystem to be mounted.

              For ordinary mounts it will hold (a link to) a block special device  node  (as  created  by
              mknod(8))  for  the device to be mounted, like `/dev/cdrom' or `/dev/sdb7'.  For NFS mounts
              one will have <host>:<dir>, e.g., `knuth.aeb.nl:/'.  For procfs, use `proc'.

              Instead of giving the device explicitly, one may indicate the  filesystem  that  is  to  be
              mounted  by  its  UUID or LABEL (cf.  e2label(8) or xfs_admin(8)), writing LABEL=<label> or
              UUID=<uuid>, e.g., `LABEL=Boot' or `UUID=3e6be9de-8139-11d1-9106-a43f08d823a6'.

              It's also possible to use PARTUUID= and PARTLABEL=. These partitions identifiers  are  sup‐
              ported for GUID Partition Table (GPT) and MAC partition table only.

              See blkid(8) or lsblk(8) for more details about devices identifiers.

              Note  that  mount(8) uses UUIDs as strings. The string representation of the UUID should be
              based on lower case characters.

       The second field (fs_file).
              This field describes the mount point for the filesystem.  For swap partitions,  this  field
              should  be specified as `none'. If the name of the mount point contains spaces these can be
              escaped as `\040'.

       The third field (fs_vfstype).
              This field describes the type of the filesystem.  Linux supports lots of filesystem  types,
              such  as  adfs,  affs,  autofs, coda, coherent, cramfs, devpts, efs, ext2, ext3, hfs, hpfs,
              iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4,  reiserfs,  romfs,  smbfs,  sysv,
              tmpfs,  udf,  ufs,  umsdos,  vfat,  xenix,  xfs, and possibly others. For more details, see
              mount(8).

              For the filesystems currently supported by the running kernel, see /proc/filesystems.

              An entry swap denotes a file or partition to be used for swapping, cf. swapon(8).  An entry
              none is useful for bind or move mounts.

              mount(8)  and  umount(8) support filesystem subtypes.  The subtype is defined by '.subtype'
              suffix.  For example 'fuse.sshfs'. It's recommended to use subtype notation rather than add
              any prefix to the first fstab field (for example 'sshfs#example.com' is deprecated).

       The fourth field (fs_mntops).
              This field describes the mount options associated with the filesystem.

              It  is  formatted  as  a comma separated list of options.  It contains at least the type of
              mount plus any additional options appropriate to the filesystem type. For documentation  on
              the  available  mount  options,  see  mount(8).   For  documentation  on the available swap
              options, see swapon(8).

              Basic file system independent options are:

              defaults
                     use default options: rw, suid, dev, exec, auto, nouser, and async.

              noauto do not mount when "mount -a" is given (e.g., at boot time)

              user   allow a user to mount

              owner  allow device owner to mount

              comment
                     or x-<name> for use by fstab-maintaining programs

              nofail do not report errors for this device if it does not exist.

       The fifth field (fs_freq).
              This field is used for these filesystems by the dump(8) command to determine which filesys‐
              tems need to be dumped.  If the fifth field is not present, a value of zero is returned and
              dump will assume that the filesystem does not need to be dumped.

       The sixth field (fs_passno).
              This field is used by the fsck(8) program to determine the order in which filesystem checks
              are  done  at  reboot time.  The root filesystem should be specified with a fs_passno of 1,
              and other filesystems should have a fs_passno of 2.  Filesystems within  a  drive  will  be
              checked  sequentially, but filesystems on different drives will be checked at the same time
              to utilize parallelism available in the hardware.  If the sixth field  is  not  present  or
              zero, a value of zero is returned and fsck will assume that the filesystem does not need to
              be checked.

 

필드 설명
첫 번째 - 장치명이 기록되는 영역이었으나, 최근 배포판 리눅스에서는 볼륨 레벨(Volume Level)이나 UUID가 대신 사용되고 있음.
- 네트워크로 연결된 호스트의 경우, 호스트명:디렉터리 형식으로 표기함.
- 예)
 /dev/sdb1
 LABEL=/
 UUID=de2b8b5c-d1c5-4813-906a-d1802d3a4298
 nfs.example.com:/data 
두 번째 - 마운트 될 디렉터리(Mount Point)
- 예) /, /home 
세 번째 - 파일 시스템의 유형
- 예) ext4, swap, nfs 
네 번째 - 마운트 될 때의 옵션
- 예) defaults, usrquota, grpquota, acl 
다섯 번째 - dump 명령을 통한 백업 시, 레벨 덤프 사용 주기를 결정하는 부분
 0 : dump를 사용하지 않음.
▶ 1 : 매일 수행
▶ 2 : 이틀에 한 번 수행
여섯 번째 - 부팅 시 파일 시스템을 점검하는 fsck 명령의 순서를 정함.
- 보통 루트 파일 시스템 1로 설정하여 가장 먼저 점검하고, 다른 파일 시스템은 2로 설정하여 두 번째로 점검함.
 0 : 부팅 시에 해당 파일 시스템은 검사하지 않음.

 

fstab 4번째 필드의 주요 옵션

  • mount 명령어의 메뉴얼 페이지인 man mount에서 확인할 수 있다.
옵션 설명
defaults rw, suid, dev, exec, auto, nouser, async가 적용됨.
auto 시스템 부팅 시 미디어가 존재하면 자동으로 마운트해 줌.
-a  옵션을 이용한 마운트 및 활성화 등을 가능하게 함.
noauto - 시스템 부팅 시 자동으로 마운트가 되지 않도록 하는 옵션
- 명시적으로만 마운트가 가능함.
-a 옵션을 이용한 마운트는 되지 않음.
user 로컬(Local) 시스템에서 일반 사용자가 마운트할 수 있는 권한 부여
owner 장치(Device) 소유자가 마운트할 수 있는 권한 부여
nofail 해당 장치 파일이 존재하지 않은 경우에도 에러 보고를 하지 않음.
uquota, usrquota 사용자의 용량을 제한하는 Disk Quota 를 사용할 때 해당 영역에 설정
gquota, grpquota Disk Quota 를 그룹별로 사용할 때 해당 영역에 설정
noquota 해당 파티션에서 사용자들의 Quota 를 설정하지 않음.
nosuid 해당 파티션에서 SUID 나 SGID 설정을 허용하지 않음.
nodev 해당 파티션에서 문자나 특별한 장치(디바이스)를 허용하지 않음.
noexec 해당 파티션에서 실행 파일이 실행되지 않도록 설정
suid 해당 파티션에서 SUID 나 SGID 의 사용을 허가
ro 해당 파티션을 읽기 전용(read-only)으로 설정
rw 해당 파티션을 읽고 쓰기(read-write) 모드로 설정
async 파일을 비동기적으로 관리하도록 설정
acl Access Control Lists 를 사용

 

728x90
그리드형(광고전용)
⚠️AdBlock이 감지되었습니다. 원할한 페이지 표시를 위해 AdBlock을 꺼주세요.⚠️
starrykss
starrykss
별의 공부 블로그 🧑🏻‍💻


📖 Contents 📖