ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 디스크 파티션 나누기(non-interactive command parted)
    2011. 8. 29. comments
    반응형

    리눅스에서 하드디스크에서 파티션을 나누는 방법에는 fdisk와 parted 유틸리티를 사용하는 방법이 있다.

    추가된 하드디스크를 파티션을 나눠주고 포맷해주는 스크립트를 만들어야 할 일이 있었는데 fdisk는 user interactive한 설정만 가능해서 스크립트에서 사용하기 유용하지 않았다.사실 parted라는 유틸리티를 잘 몰랐었는데, user interactive하지 않은 명령어가 없나, 확인하는 과정에서 찾게된 유틸리티이다.

    명령어의 help를 확인하게 되면, script 옵션을 지원한다.

    [root@localhost download]# parted --help
    Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]
    Apply COMMANDs with PARAMETERS to DEVICE.  If no COMMAND(s) are given, run in
    interactive mode.
    
    OPTIONs:
      -h, --help                    displays this help message
      -i, --interactive             where necessary, prompts for user intervention
      -l, --list                    lists partition tables of all detected devices
      -s, --script                  never prompts for user intervention
      -v, --version                 displays the version
    
    

    user interactive대화형 명령어인데,  아래의 예제처럼 사용자가 명령을 내릴 때 추가입력이 필요할 경우 설명이 나타나고 사용자는 거기에 대한 명령어를 다시 내리는 형태의 대화형 명령어를 user interactive라고 한다.

    ※ 아래의 명령어는 xvda 디스크에 새로운 파티션을 추가하려는 과정의 일부이다.

    [root@localhost download]# fdisk /dev/xvda
    The number of cylinders for this disk is set to 2610.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
       (e.g., DOS FDISK, OS/2 FDISK)
    
    Command (m for help): ?
    ?: unknown command
    Command action
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       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 partition's system id
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    



    non interactive 과정은, 여러 인자를 통하여 한번에 명령을 내려서 추가 입력하는 과정이 없다.
    ※ 아래의 명령어는 새로 추가될 디스크에 파티션을 하나 만들고 그 디스크의 공간을 하드디스크 100% 사용하는 명령어다.

    [root@localhost download]# parted -s /dev/xvdb mklabel msdos
    [root@localhost download]# parted -s /dev/xvdb mkpart primary 0 100%
    


    이번 글은 파티션을 나누는 방법보다는, "스크립트를 통해 파티션을 나눌 때 parted를 사용하세요"의 글에 가깝다.

      

    반응형

    댓글

Designed by Tistory.