현재 마운트된 파티션별 저장공간 확인해보기 위해서 리눅스 디스크 사용량을 확인하는 명령어를 실행해봅시다. 리눅스 파일시스템 사용량을 출력하는 명령어는
df -Th Filesystem Size Used Avail Use% Mounted on devtmpfs 909M 0 909M 0% /dev tmpfs 919M 0 919M 0% /dev/shm tmpfs 919M 17M 903M 2% /run tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/vda2 99G 13G 82G 14% / tmpfs 184M 0 184M 0% /run/user/1000 ※ 참고로 위의 컴퓨터는 /dev/vda2 파티션이 / 경로에 마운트 되어있습니다.
sudo fdisk -l WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: gpt Disk identifier: B6AEA637-ED34-45E4-81A7-B2BA6C4F9435 1 2048 6143 2M BIOS boot biosboot 2 6144 209715165 100G EFI System rootfs Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes line 4~14는 기존에 마운트 되어있는 디스크이고, 새로 추가한 디스크는 아직 마운트 되지 않아 fdisk 명령어는 mount되지 않은 디스크도 포함하여 모든 디스크를 출력합니다. 그럼, ※ 데이터가 들어있는 디스크를 mount를 하는 것이라면 아래의 파티션 구성 및 포맷 과정은 건너뛰고 바로 mount를 하면 됩니다.
디스크를 파티션 구성하고 싶다면(Windows에서 D드라이브 E드라이 등으로 파티션 구성하듯...) 파티션 설정을 하면 됩니다. ※ 만일, 파티션 설정 없이 하나의 디스크로 마운트하고 싶다면 이 단계는 패스하면 됩니다. sudo fdisk /dev/vdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xa5017a1c. Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partitions system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) m을 누르면 파티션 구성을 위한 다영한 명령어에 대한 간략한 설명을 소개해줍니다. sudo fdisk /dev/vdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xa5017a1c. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-419430399, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): +50G Partition 1 of type Linux and of size 50 GiB is set Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): Using default response p Partition number (2-4, default 2): First sector (104859648-419430399, default 104859648): Using default value 104859648 Last sector, +sectors or +size{K,M,G} (104859648-419430399, default 419430399): +50G Partition 2 of type Linux and of size 50 GiB is set Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): Using default response p Partition number (3,4, default 3): First sector (209717248-419430399, default 209717248): Using default value 209717248 Last sector, +sectors or +size{K,M,G} (209717248-419430399, default 419430399): +50G Partition 3 of type Linux and of size 50 GiB is set Command (m for help): n Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e): e Selected partition 4 First sector (314574848-419430399, default 314574848): Using default value 314574848 Last sector, +sectors or +size{K,M,G} (314574848-419430399, default 419430399): Using default value 419430399 Partition 4 of type Extended and of size 50 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. 3개의 50G 용량의 주파티션과 1개의 extended 파티션으로 설정하였습니다. 파티션 구성을 마쳤다면 다시 sudo fdisk -l WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: gpt Disk identifier: B6AEA637-ED34-45E4-81A7-B2BA6C4F9435 1 2048 6143 2M BIOS boot biosboot 2 6144 209715165 100G EFI System rootfs Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xa5017a1c Device Boot Start End Blocks Id System /dev/vdb1 2048 104859647 52428800 83 Linux /dev/vdb2 104859648 209717247 52428800 83 Linux /dev/vdb3 209717248 314574847 52428800 83 Linux /dev/vdb4 314574848 419430399 52427776 5 Extended 3개의 주 파티션과 1개의 확장 파티션이 정상적으로 설정되었음을 확인할 수 있습니다 make file system 파티션 설정을 완료했다면 이제 주 파티션을 포맷해봅시다. sudo mkfs.xfs -f /dev/vdb1 sudo mkfs.xfs -f /dev/vdb2 sudo mkfs.xfs -f /dev/vdb3 위와같이
포맷까지 완료했다면, 이제 파티션을 사용하기 위한 준비가 모두 끝났습니다. sudo mount /dev/vdb1 /data/box1 sudo mount /dev/vdb2 /data/box2 sudo mount /dev/vdb3 /data/box3 ※ 참고로, 마운트를 해제하는 명령어는 그리고 파일상태를 다시 확인해봅니다. df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 909M 0 909M 0% /dev tmpfs 919M 0 919M 0% /dev/shm tmpfs 919M 17M 903M 2% /run tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/vda2 99G 13G 82G 14% / tmpfs 184M 0 184M 0% /run/user/1000 /dev/vdb1 50G 33M 50G 1% /data/box1 /dev/vdb2 50G 33M 50G 1% /data/box2 /dev/vdb3 50G 33M 50G 1% /data/box3 vdb1~vdb3 파티션이 잘 추가되었네요! 추가한 디스크의 파티션 설정과, 설정된 파티션을 3개의 디렉토리 경로에 정상적으로 mount하였습니다. 그러나, mount명령어로 디렉토리와 연결한 디스크 정보는 서버가 종료되기 전까지만 유효하며, 서버가 재부팅될 경우 umount 됩니다. 서버 재부팅시에도
자동으로 mount하고 싶다면 리눅스 시스템 설정파일인 sudo vim /etc/fstab UUID=0216ddbb-21e5-4f13-8b1e-74f3024b17da / ext4 defaults 1 1 /var/spool/swap/swapfile4G none swap defaults 0 0 /dev/vdb1 /data/box1 xfs defaults 0 0 /dev/vdb2 /data/box2 xfs defaults 0 0 /dev/vdb3 /data/box3 xfs defaults 0 0 필드명은 차례대로 파일 시스템의 용도에 맞게 옵션을 설정하세요.
※ auto, exec, user, suid 앞에 no가 붙을 경우 반대 속성입니다.
파일점검옵션으로, 0은 점검을 하지 않으며, 1로 설정된 파일시스템을 모두 선행한 후 2로 설정된 파일시스템의 파일점검을 시작합니다.
|