ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • LINUX DISK 추가를 통한 파티션 생성하는 방법(2편)
    System of Infra/Linux System 2022. 3. 23. 00:07
    반응형

    LINUX로고이미지

    LINUX DISK 추가를 통한 파티션 생성하는 방법(1편)

    [root@localhost dev]# ls -ltr | grep -i sd
    brw-rw----  1 root disk      8,  16  3월 20 16:44 sdb
    brw-rw----  1 root disk      8,   0  3월 20 16:44 sda
    brw-rw----  1 root disk      8,   1  3월 20 16:44 sda1
    brw-rw----  1 root disk      8,   2  3월 20 16:44 sda2
    ▶ LINUX DISK 추가를 통한 파티션 생성하는 방법(1편)을 통해서 1GB 디스크 한 개를 할당했다면 서버에서는 /dev/sdb의 디스크가 추가로 생성된 것을 확인할 수 있습니다.
    [root@localhost ~]# fdisk -l
    Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 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
    Disklabel type: dos
    Disk identifier: 0xbe61492f
    
    Device     Boot   Start       End   Sectors Size Id Type
    /dev/sda1          2048   8390655   8388608   4G 82 Linux swap / Solaris
    /dev/sda2  *    8390656 167772159 159381504  76G 83 Linux
    
    
    Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 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
    ▶ fdisk -ㅣ 명령어를 통해서 현재 /dev/sda 디스크에 파티션을 나눈 /dev/sda1,sda2를 제외하고 1G로  /dev/sdb가 생성된 것을 다시 한번 확인할 수 있습니다.
    [root@localhost dev]# fdisk /dev/sdb
    
    Welcome to fdisk (util-linux 2.32.1).
    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.
    Created a new DOS disklabel with disk identifier 0xd15f3f39.
    
    Command (m for help): n
    
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (2048-2097151, default 2048): 
    Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151): 
    
    Created a new partition 1 of type 'Linux' and of size 1023 MiB.
    
    Command (m for help): p
    Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 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
    Disklabel type: dos
    Disk identifier: 0xd15f3f39
    
    Device     Boot Start     End Sectors  Size Id Type
    /dev/sdb1        2048 2097151 2095104 1023M 83 Linux
    
    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.
    ▶ 추가된 /dev/sdb의 디스크에 n( new) -> p(primary) -> enter -> enter 후 p(print)를 통해서 내가 어떻게 생성을 했는지 미리보기를 할 수 있습니다. Type이 Linux로 보이는데 이 부분은 다음에 자세하게 설명을 하도록 하겠습니다.
    설정이 완료 됬으면 w(write) 저장하고 마무리를 합니다.

    * Partition number (1-4, default 1): 1
    - 해당 디스크에 최대 만들 수 있는 논리적 파티션 개수가 4개로 이후부터는 extend 확장으로 설정할 수 있음.

    * First sector (2048-2097151, default 2048): Enter
    - 2048의 섹터부터 용량을 할당할 수 있기 때문에 용량 수치를 계산하여 할당을 할 수 있음.

    * Last sector, +sectors or +size{K,M,G,T,P} (2048-2097151, default 2097151): Enter
    - 마지막 섹터의 용량을 보여주고 용량 할당시 KB, MB, GB 중 어느 것으로 할 것인지 확인
    [root@localhost dev]# fdisk -l
    Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 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
    Disklabel type: dos
    Disk identifier: 0xbe61492f
    
    Device     Boot   Start       End   Sectors Size Id Type
    /dev/sda1          2048   8390655   8388608   4G 82 Linux swap / Solaris
    /dev/sda2  *    8390656 167772159 159381504  76G 83 Linux
    
    
    Disk /dev/sdb: 1 GiB, 1073741824 bytes, 2097152 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
    Disklabel type: dos
    Disk identifier: 0xd15f3f39
    
    Device     Boot Start     End Sectors  Size Id Type
    /dev/sdb1        2048 2097151 2095104 1023M 83 Linux
    ▶ fdisk -l 명령어를 수행하게 되면 /dev/sdb의 디스크에 논리적으로 /dev/sdb1의 파티션이 1G로 생성된 것을 확인할 수 있습니다.
    [root@localhost dev]# mkfs.ext4 /dev/sdb1
    mke2fs 1.44.3 (10-July-2018)
    Creating filesystem with 261888 4k blocks and 65536 inodes
    Filesystem UUID: d517a0b4-cd22-4dc9-af84-c51b3ce38808
    Superblock backups stored on blocks: 
    	32768, 98304, 163840, 229376
    
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (4096 blocks): done
    Writing superblocks and filesystem accounting information: done
    ▶ 논리적으로 파티션을 하게되면 생성된 파티션의 형태를 포맷해줘야 하는데 이번에는  ext4의 Type으로 포맷을 해주도록 하겠습니다. ext4 외에 xfs 파일 시스템이 최근에 centos7 이후부터 Default로 많이 사용되기도 하기 때문에 다음 시간에 다뤄보도록 하겠습니다.
    [root@localhost /]# vi /etc/fstab
    #
    # /etc/fstab
    # Created by anaconda on Mon Feb 28 20:48:23 2022
    #
    # 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.
    #
    # After editing this file, run 'systemctl daemon-reload' to update systemd
    # units generated from this file.
    #
    UUID=6d75a782-7d9b-4e9e-a338-fa882a919ada /                       xfs     defaults        0 0
    UUID=ae9aeae5-2577-49e3-86d9-63db631bc9d8 swap                    swap    defaults        0 0
    /dev/sdb1	                          /mydata		  ext4    defaults	  0 0(추가)
    ▶ 부팅시 mount 되도록 /etc/fstab에 등록을 해주도록 합니다. 
    앞에 있는 0의 의미는 dumpchek를 하겠다는 의미로 일반적으로 확장된 디스크에 대해서 덤프 체크는 필요 없기 때문에 0으로 지정하고 뒤에 있는 0의 경우는 부팅 시 디스크에 대한 체크를 하겠다는 의미로 많은 디스크가 붙어 있는 시스템일 경우 체크를 모두 하기 때문에 부팅시간이 오래 걸리기 때문에 0으로 지정합니다.

     

    2022.03.21 - [System of Infra/LINUX] - LINUX DISK 추가를 통한 파티션 생성하는 방법(1편)

     

    LINUX DISK 추가를 통한 파티션 생성하는 방법(1편)

     LINUX  DISK 추가를 통한 파티션 생성하는 방법 [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 80G 0 disk ├─sda1 8:1 0 4G 0 part [SWAP] └─sda2 8:2 0 76G 0 par..

    pinetreeday.tistory.com

     

    PS. 포스팅의 내용은 제 기준으로 작성한 것이기 때문에 참고해서 보시면 감사하겠습니다.

    포스팅 과정의 오류 및 오타 그리고 궁금한 점에 대해서는 댓글 남겨주세요.

     

    반응형

    댓글

Designed by Tistory.