스토리지(디스크) 추가 mount

곽동규·2024년 4월 7일

VMware나 cloud 운영 시 서버에 디스크를 추가했을 때 mount 작업

하기는 Ncloud 환경이다.
300GB 디스크를 추가했고 "xvdb" 를 mount 시키는 과정이다.
on-prem 이나 vm등도 다를것은 없다.



# fdisk -l  

Disk /dev/xvda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0002afae

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1            2048        4095        1024   83  Linux
/dev/xvda2            4096     4198399     2097152   82  Linux swap / Solaris
/dev/xvda3   *     4198400   104857599    50329600   83  Linux


Disk /dev/xvdb: 322.1 GB, 322122547200 bytes, 629145600 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/xvdb

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.


Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xd2c87c23.


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): 1
First sector (2048-629145599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599):
Using default value 629145599
Partition 1 of type Linux and of size 300 GiB is set


Command (m for help): help
h: unknown command
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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): w

<파일시스템 설정>

fdisk -l  확인   

 Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1            2048   629145599   314571776   83  Linux


# mkfs.ext4 /dev/xvdb1 (파일시스템 지정)

******* 기존에 다 ext4 사용해서 그냥 사용
* CentOS 5.x: mkfs.ext3 /dev/xvdb1
* CentOS 6.x: mkfs.ext4 /dev/xvdb1
* CentOS 7.x: mkfs.xfs /dev/xvdb1               

<스토리지 마운트>
/data dir은 mkdir -p /root/data로 만들어둔 상태

# mount /dev/xvdb1 /data/
# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda3       48G  1.9G   47G   4% /
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.8G     0  1.8G   0% /dev/shm
tmpfs           1.8G  8.4M  1.8G   1% /run
tmpfs           1.8G     0  1.8G   0% /sys/fs/cgroup
tmpfs           354M     0  354M   0% /run/user/0
/dev/xvdb1      296G   65M  281G   1% /data

<fstab 자동마운트에 추가>

추가한 xvdb1의 uuid 확인 후 fstab에 추가

# ll /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 11 Jan 22 16:06 29c3edf0-5d6b-4440-941f-67d5246bbf6c -> ../../xvdb1
lrwxrwxrwx 1 root root 11 Jan 22 15:50 592b6c47-fdb8-44ca-8bc7-d8ce52ce53b3 -> ../../xvda3
lrwxrwxrwx 1 root root 11 Jan 22 15:50 fb8d6192-b7c8-4ab7-bda0-2107ec77d696 -> ../../xvda2

# vi /etc/fstab
UUID=592b6c47-fdb8-44ca-8bc7-d8ce52ce53b3 /                       xfs     defaults        0 0
UUID=fb8d6192-b7c8-4ab7-bda0-2107ec77d696 swap                    swap    defaults        0 0
UUID=29c3edf0-5d6b-4440-941f-67d5246bbf6c /data                   ext4    defaults        1 1

0개의 댓글