ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 우분투에 HDD 추가하기
    개발 2016. 6. 8. 12:40

    1.현재 파티션 정보를 확인한다.

    sayit@ubuntu:~$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            478M     0  478M   0% /dev
    tmpfs            98M  4.9M   93M   5% /run
    /dev/sda1        19G  1.2G   17G   7% /
    tmpfs           489M     0  489M   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           489M     0  489M   0% /sys/fs/cgroup
    tmpfs            98M     0   98M   0% /run/user/1000

    2.HDD가 정상적으로 추가되었는지 확인한다.

    sayit@ubuntu:~$ sudo fdisk -l
    [sudo] password for sayit:

    Disk /dev/fd0: 1.4 MiB, 1474560 bytes, 2880 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: 0x90909090

    Device     Boot      Start        End    Sectors  Size Id Type
    /dev/fd0p1 ?    2425393296 4850786591 2425393296  1.1T 90 unknown
    /dev/fd0p2 ?    2425393296 4850786591 2425393296  1.1T 90 unknown
    /dev/fd0p3 ?    2425393296 4850786591 2425393296  1.1T 90 unknown
    /dev/fd0p4 ?    2425393296 4850786591 2425393296  1.1T 90 unknown

    Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x66d2cf83

    Device     Boot    Start      End  Sectors  Size Id Type
    /dev/sda1  *        2048 39845887 39843840   19G 83 Linux
    /dev/sda2       39847934 41940991  2093058 1022M  5 Extended
    /dev/sda5       39847936 41940991  2093056 1022M 82 Linux swap / Solaris

    Disk /dev/sdb: 70 GiB, 75161927680 bytes, 146800640 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

    마지막을 확인해보면 /dev/sdb 70기가 장치가 있는 것을 확인할 수 있다.

    3.새로추가된 HDD를 파티션 작업을 한다.

    sayit@ubuntu:~$ sudo fdisk /dev/sdb

    Welcome to fdisk (util-linux 2.25.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.
    Created a new DOS disklabel with disk identifier 0xfe8998b1.

    Command (m for help): m

    Help:

      DOS (MBR)
       a   toggle a bootable flag
       b   edit nested BSD disklabel
       c   toggle the dos compatibility flag

      Generic
       d   delete a partition
       l   list known partition types
       n   add a new partition
       p   print the partition table
       t   change a partition type
       v   verify the partition table

      Misc
       m   print this menu
       u   change display/entry units
       x   extra functionality (experts only)

      Save & Exit
       w   write table to disk and exit
       q   quit without saving changes

      Create a new label
       g   create a new empty GPT partition table
       G   create a new empty SGI (IRIX) partition table
       o   create a new empty DOS partition table
       s   create a new empty Sun partition table


    Command (m for help): n
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p):

    Using default response p.
    Partition number (1-4, default 1):
    First sector (2048-146800639, default 2048):
    Last sector, +sectors or +size{K,M,G,T,P} (2048-146800639, default 146800639):

    Created a new partition 1 of type 'Linux' and of size 70 GiB.

    Command (m for help): p
    Disk /dev/sdb: 70 GiB, 75161927680 bytes, 146800640 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: 0xfe8998b1

    Device     Boot Start       End   Sectors Size Id Type
    /dev/sdb1        2048 146800639 146798592  70G 83 Linux


    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.

    4.파티션 정보 재확인

    sayit@ubuntu:/sbin$ sudo fdisk -l

    Disk /dev/fd0: 1.4 MiB, 1474560 bytes, 2880 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: 0x90909090

    Device     Boot      Start        End    Sectors  Size Id Type
    /dev/fd0p1 ?    2425393296 4850786591 2425393296  1.1T 90 unknown
    /dev/fd0p2 ?    2425393296 4850786591 2425393296  1.1T 90 unknown
    /dev/fd0p3 ?    2425393296 4850786591 2425393296  1.1T 90 unknown
    /dev/fd0p4 ?    2425393296 4850786591 2425393296  1.1T 90 unknown

    Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x66d2cf83

    Device     Boot    Start      End  Sectors  Size Id Type
    /dev/sda1  *        2048 39845887 39843840   19G 83 Linux
    /dev/sda2       39847934 41940991  2093058 1022M  5 Extended
    /dev/sda5       39847936 41940991  2093056 1022M 82 Linux swap / Solaris

    Disk /dev/sdb: 70 GiB, 75161927680 bytes, 146800640 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: 0xfe8998b1

    Device     Boot Start       End   Sectors Size Id Type
    /dev/sdb1        2048 146800639 146798592  70G 83 Linux

    5.포맷

    sayit@ubuntu:/sbin$ sudo mkfs.ext4 /dev/sdb1
    mke2fs 1.42.12 (29-Aug-2014)
    Creating filesystem with 18349824 4k blocks and 4587520 inodes
    Filesystem UUID: ec60583a-d84e-40f6-bcb1-16a8c1cc3224
    Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

    Allocating group tables: done                           
    Writing inode tables: done                           
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done 

    포맷타입은 원하는 것으로 변경할 수 있다.
    포맷타입은 /sbin/에서 확인가능.

    6.HDD를 마운트 하기위한 UUID 확인

    sayit@ubuntu:/sbin$ ls -alF /dev/disk/by-uuid/
    total 0
    drwxr-xr-x 2 root root 100 Apr 21 00:09 ./
    drwxr-xr-x 5 root root 100 Apr 20 23:59 ../
    lrwxrwxrwx 1 root root  10 Apr 20 23:59 d0652bd6-9c7f-49d2-8cf8-103dee620427 -> ../../sda1
    lrwxrwxrwx 1 root root  10 Apr 20 23:59 e5ec694c-4d6a-44e2-8f78-ec027b45e64d -> ../../sda5
    lrwxrwxrwx 1 root root  10 Apr 21 00:09 ec60583a-d84e-40f6-bcb1-16a8c1cc3224 -> ../../sdb1

    7.마운트
    HDD 파티션 나누고 포맷도 했지만, 지금은 사용할 수 없다. 마운트를 해야한다.

    마운트할 디렉토리를 만든다.

    sayit@ubuntu:/sbin$ cd /
    sayit@ubuntu:/$ sudo mkdir zetacore
    sayit@ubuntu:/$ sudo mkdir /zetacore/cube

    매번 부팅시마다 자동으로 마운트가 되도록 다음과 같이 설정한다.

    sudo vi /etc/fstab

    ...
    UUID=ec60583a-d84e-40f6-bcb1-16a8c1cc3224 /zetacore/cube               ext4    errors=remount-ro 0       1


    부팅하지 않아도 바로 적용할 수 있다.

    sayit@ubuntu:/zetacore/cube$ sudo mount -a

    8.확인

    sayit@ubuntu:/zetacore/cube$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            478M     0  478M   0% /dev
    tmpfs            98M  4.9M   93M   5% /run
    /dev/sda1        19G  1.2G   17G   7% /
    tmpfs           489M     0  489M   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           489M     0  489M   0% /sys/fs/cgroup
    tmpfs            98M     0   98M   0% /run/user/1000
    /dev/sdb1        69G   52M   66G   1% /zetacore/cube

    반응형

    '개발' 카테고리의 다른 글

    리눅스(Centos6.x) 서버에 node.js 설치하기  (0) 2017.09.12
    우분투 호스트명 변경  (0) 2016.06.08
    MySQL 미러링 (REPLICATION)  (0) 2016.06.08
    아파치(2.2) 톰캣 연동  (0) 2016.03.12
    AIX 에서 시간 설정하기  (0) 2015.12.10

    댓글

Designed by Tistory.