티스토리 뷰

반응형

오늘은 Linux 환경에서 온라인 중 Disk를 추가하는 방법에 대해 알려드리겠습니다.

해당 방법은 VMWare 환경을 예로 하였으나 동일하오니 참고하시기 바랍니다.

 

Linux 리부팅하지 않고 온라인중 Disk 추가 하는 방법

 

1. vmware 에서 디스크 추가

VMWare 설정편집에서 추가를 선택한다

새 가상 디스크 생성을 선택

하드디스크를 선택하여 추가

디스크 크기를 설정한다

다음

2. 기존 Linux에서 Disk를 SCAN한다

    저 같은 경우는 host2에서 붙은게 확인 되었습니다.

echo "- - -" > /sys/class/scsi_host/host2/scan 로 scan한다
sample →      
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan    
(이렇게 host 넘버 바꿔가면서 스캔하면 /dev/sdb가 붙은걸 확인할 수 있다)

/home/skdfslk]# fdisk -l
 
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d48c7
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        7833    62401536   8e  Linux LVM
 
Disk /dev/mapper/vg_spare-lv_root: 52.5 GB, 52495908864 bytes
255 heads, 63 sectors/track, 6382 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
Disk /dev/mapper/vg_spare-lv_swap: 6274 MB, 6274678784 bytes
255 heads, 63 sectors/track, 762 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
Disk /dev/mapper/vg_spare-lv_home: 5125 MB, 5125439488 bytes
255 heads, 63 sectors/track, 623 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
 
 
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

새 파티션을 생성합니다. 

/home/sadfjkl]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xabef0eb6.
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)
 
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').
 
Command (m for help): n            -----------> 새로운 파티션을 나눈다
Command action
   e   extended
   p   primary partition (1-4)
p                                 ------------> 주 파티션으로 사용한다
Partition number (1-4): 1         ------------> 파티션번호를 1번으로 지정한다
First cylinder (1-6527, default 1):                ------> 엔터
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-6527, default 6527):         -----> 엔터
Using default value 6527
 
Command (m for help): p          ------------> 나워진 파티션을 화면에 출련한다
 
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xabef0eb6
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        6527    52428096   83  Linux
 
Command (m for help): w              ---------------> 현재 나눠진 파티션을 저장한다
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
spare /]# mkfs -t ext4 /dev/sdb1        ---------------> 새로운 파일 시스템을 포맷한다
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107024 blocks
655351 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 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
 
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@spare /]# mount /dev/sdb1 /data
mount: mount point /data does not exist
 
  
[root@spare /]# mkdir data
[root@spare /]# mount /dev/sdb1 /data            -------------> 마운트 한다
 
 
[root@spare /]# vi /dev/fstab
[root@spare /]# vi /etc/fstab       -------->  신규 디스크에 대해 자동마운트 설정한다
     
/dev/sdb1   /data       ext4    default     0 0

이제 마운트 된 것을 확인 할 수 있다

 

 

서버를 운영하다 보면 부팅할 수 없는 환경에서 Disk를 추가해야 하는 경우가 생깁니다. 이런 경우 사용해 보시기 바랍니다.  해당 환경은 CentOS 환경입니다.

 

반응형

'IT 일반 > Linux 일반' 카테고리의 다른 글

리눅스 xfs 파일시스템 증설하기  (0) 2023.07.03
댓글