티스토리 뷰

OS/CentOS

disk 추가

pu928 2019. 8. 28. 13:23
반응형

윈도우에서 사용하던 HDD 를 추가하여 CentOS에서 사용 할 수 있도록한다.

 

장치명: /dev/sda

Size: 1TB

 

 

1. 기존 disk 확인

[root@test ~]# fdisk -l

Disk /dev/nvme0n1: 512.1 GB, 512110190592 bytes, 1000215216 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: 0x000cdcd9

        Device Boot      Start         End      Blocks   Id  System
/dev/nvme0n1p1   *        2048     2099199     1048576   83  Linux
/dev/nvme0n1p2         2099200  1000214527   499057664   8e  Linux LVM

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors     <-- 대상 장치
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x948bc441

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000    7  HPFS/NTFS/exFAT
/dev/sda2         1026048  1953521663   976247808    7  HPFS/NTFS/exFAT

 

2. 기존 파티션 제거 및 새로 생성

[root@test ~]# fdisk /dev/sda

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
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.

Command (m for help): d    <-- 기존 파티션 제거
Partition number (1,2, default 2): 
Partition 2 is deleted

Command (m for help): d    <-- 기존 파티션 제거
Selected partition 1
Partition 1 is deleted

Command (m for help): n    <-- 파티션 새로 생성(기본: primary, 전체 size)
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
Partition number (1-4, default 1): 
First sector (2048-1953525167, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1953525167, default 1953525167): 
Using default value 1953525167
Partition 1 of type Linux and of size 931.5 GiB is set

Command (m for help): w    <-- 작업 저장
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

 

3. filesystem 생성(지정?)

[root@test ~]# mkfs -t xfs /dev/sda1    <-- ntfs 가 있다고 나오지만
mkfs.xfs: /dev/sda1 appears to contain an existing filesystem (ntfs).
mkfs.xfs: Use the -f option to force overwrite.
[root@test ~]# mkfs.xfs -f /dev/sda1    <-- '-f' 옵션으로 강제한다.
meta-data=/dev/sda1              isize=512    agcount=4, agsize=61047598 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=244190390, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=119233, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

 

4. disk 확인

[root@test /]# fdisk -l

Disk /dev/nvme0n1: 512.1 GB, 512110190592 bytes, 1000215216 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: 0x000cdcd9

        Device Boot      Start         End      Blocks   Id  System
/dev/nvme0n1p1   *        2048     2099199     1048576   83  Linux
/dev/nvme0n1p2         2099200  1000214527   499057664   8e  Linux LVM

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x948bc441

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048  1953525167   976761560   83  Linux

 

5. mount 및 확인

[root@test /]# mount /dev/sda1 /home2
[root@test /]# df -k
Filesystem                    1K-blocks    Used Available Use% Mounted on
/dev/mapper/centos_test-root  52403200 1205980  51197220   3% /
devtmpfs                       16307124       0  16307124   0% /dev
tmpfs                          16320964       0  16320964   0% /dev/shm
tmpfs                          16320964    9380  16311584   1% /run
tmpfs                          16320964       0  16320964   0% /sys/fs/cgroup
/dev/nvme0n1p1                  1038336  207912    830424  21% /boot
/dev/mapper/centos_test-home 429964164   33004 429931160   1% /home
tmpfs                           3264196       0   3264196   0% /run/user/1000
tmpfs                           3264196       0   3264196   0% /run/user/0
/dev/sda1                     976284628   33040 976251588   1% /home2

 

6. 서버 시작 시 자동 마운트를 위한 설정

- /etc/fstab 에 추가

/dev/sda1 /home2                   xfs     defaults        0 0

 

 

 

반응형

'OS > CentOS' 카테고리의 다른 글

CentOS 6 에서 yum 사용하기  (0) 2021.07.13
linux 자동 마운트  (0) 2019.08.12
[yum] 특정 버전으로 install 또는 update  (0) 2019.08.02
firewalld에 service 추가하기  (0) 2019.03.12
CentOS 4.8에서 yum 사용하기  (0) 2018.07.31
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함