ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 리눅스(Ubuntu) 하드 디스크 추가하고 mount하기
    프로그래밍/Linux 2018. 8. 7. 20:14
    728x90
    반응형



    수집되고 있는 데이터들이 많아져서 1TB 디스크 두 개를 추가하였습니다. 

    fdisk -l 로 추가된 디스크를 확인합니다. 





    # fdisk -l


    ...


    ...

    Disk /dev/sdd: 2048.4 GB, 2048408248320 bytes

    255 heads, 63 sectors/track, 249038 cylinders, total 4000797360 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 identifier: 0x00000000


    Disk /dev/sdd doesn't contain a valid partition table


    Disk /dev/sde: 2048.4 GB, 2048408248320 bytes

    255 heads, 63 sectors/track, 249038 cylinders, total 4000797360 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 identifier: 0x00000000


    Disk /dev/sde doesn't contain a valid partition table



    새로운 디스크 2개의 경로를 확인합니다. 

    /dev/sdd 와 /dev/sde 로 잡혀있습니다. 


    fdisk /dev/sdd 을 입력해서 파티션 설정을 합니다. 

    m을 입력하면 명령어 리스트를 볼 수 있습니다. 





    # fdisk /dev/sdd

    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

    Building a new DOS disklabel with disk identifier 0x5bb28c04.

    Changes will remain in memory only, until you decide to write them.

    After that, of course, the previous content won't be recoverable.


    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


    Command (m for help):


    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

       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):



    fdisk /dev/sdd 를 입력하고 n으로 새로운 파티션을 추가합니다.

    primary type만 선택하고 나머지는 enter를 입력합니다.


    # fdisk /dev/sdd

    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

    Building a new DOS disklabel with disk identifier 0x183fc52b.

    Changes will remain in memory only, until you decide to write them.

    After that, of course, the previous content won't be recoverable.


    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


    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):  enter

    Using default value 1

    First sector (2048-4000797359, default 2048): enter

    Using default value 2048

    Last sector, +sectors or +size{K,M,G} (2048-4000797359, default 4000797359): enter

    Using default value 4000797359


    Command (m for help): w

    The partition table has been altered!


    Calling ioctl() to re-read partition table.

    Syncing disks.





    fdisk -l 명령어를 사용하여 단일 파티션이 구성된 것을 확인했습니다. 




    # fdisk -l /dev/sdd


    Disk /dev/sdd: 2048.4 GB, 2048408248320 bytes

    30 heads, 63 sectors/track, 2116824 cylinders, total 4000797360 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 identifier: 0x183fc52b


       Device Boot      Start         End      Blocks   Id  System

    /dev/sdd1            2048  4000797359  2000397656   83  Linux




    이제 새로운 디스크를 포맷해야 합니다. 

    blkid 명령어를 사용하면 해당 디스크의 파일시스템 타입을 알 수 있습니다. 

    ext4로 나타나서 mkfs.ext4를 사용하여 ext4타입으로 포맷을 합니다. 



    # mkfs.ext4 /dev/sdd

    mke2fs 1.42.9 (4-Feb-2014)

    /dev/sdd is entire device, not just one partition!

    Proceed anyway? (y,n) y

    Discarding device blocks: done

    Filesystem label=

    OS type: Linux

    Block size=4096 (log=2)

    Fragment size=4096 (log=2)

    Stride=0 blocks, Stripe width=0 blocks

    125026304 inodes, 500099670 blocks

    25004983 blocks (5.00%) reserved for the super user

    First data block=0

    Maximum filesystem blocks=4294967296

    15262 block groups

    32768 blocks per group, 32768 fragments per group

    8192 inodes per group

    Superblock backups stored on blocks:

            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

            4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

            102400000, 214990848


    Allocating group tables: done

    Writing inode tables: done

    Creating journal (32768 blocks): done

    Writing superblocks and filesystem accounting information: done



    포맷이 완료되면 이제 mount를 할 준비가 다 되었습니다. 

    이제 새로운 디스크를 mount할 새로운 폴더를 생성합니다. 


    root 디렉토리로 이동하여 data 디렉토리를 생성합니다. 

    그리고 mount 명령어를 사용하여 mount를 완료합니다. 


    df -h를 사용하여 mount 정보를 확인합니다. 

    새로운 하드 디스크가 제대로 마운트 된 것이 확인 되었습니다. 






    # cd/

    #mkdir data


    # mount -t ext4 /dev/sdd /data

    # df -h

    Filesystem      Size  Used Avail Use% Mounted on

    ...

    /dev/sdd        1.9T   68M  1.8T   1% /data

    root@rt-MS-7885:/#



    참고: http://yonoo88.tistory.com/651

    http://blog.naver.com/PostView.nhn?blogId=jsky10503&logNo=220730292263&redirect=Dlog&widgetTypeCall=true

    728x90
    반응형
Designed by Tistory.