작은숲:위키노트/데비안에서 새로운 하드디스크 설치하기

현재 사용하고 있는 시스템에 새로운 하드 디스크를 장만해서 추가할 경우, 아래 순서대로 시행하면 된다.

시스템에 하드 디스크 설치하기

우선 시스템의 전원을 끈 다음, IDE 하드 디스크의 경우 Master/Slave를 설정해서 설치하고, SCSI 하드 디스크의 경우에는 SCSI ID를 설정하고 하드 디스크를 설치한 후 터미네이터를 적절하게 옮겨준다. IDE 하드 디스크는 설치한 후 CMOS에서 하드 디스크를 인식하도록 설정해준다.

부팅하기

설치가 완료되면 부팅 한다. 부팅 할 때 메시지를 잘 살펴보면 추가한 하드 디스크를 인식하는지 알 수 있다. 만약 커널에서 새로 추가한 하드 디스크를 인식한다면 제대로 된 것이다. 그렇지 않다면, 무엇이 문제인지 천천히 살펴보도록 하자. 아래는 SCSI 하드를 추가하였을 때 부팅 메시지이다.

scsi0 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.1
        <Adaptec 29160 Ultra160 SCSI adapter>
        aic7892: Ultra160 Wide Channel A, SCSI Id=7, 32/255 SCBs
  Vendor: SEAGATE   Model: ST318436LW        Rev: 0010
  Type:   Direct-Access                      ANSI SCSI revision: 03
  Vendor: SEAGATE   Model: ST336706LW        Rev: 010A
  Type:   Direct-Access                      ANSI SCSI revision: 03
scsi0:0:0:0: Tagged Queuing enabled.  Depth 253
scsi0:0:1:0: Tagged Queuing enabled.  Depth 253
scsi: <fdomain> Detection failed (no card)
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi disk sdb at scsi0, channel 0, id 1, lun 0
(scsi0:A:0): 160.000MB/s transfers (80.000MHz DT, offset 31, 16bit)
SCSI device sda: 35885168 512-byte hdwr sectors (18373 MB)
Partition check:
 sda: sda1 sda2 < sda5 sda6 >
(scsi0:A:1): 160.000MB/s transfers (80.000MHz DT, offset 63, 16bit)
SCSI device sdb: 71687370 512-byte hdwr sectors (36704 MB)
 sdb: unknown partition table

위 메시지를 보면, 새로 추가한 하드 디스크를 커널에서 인식했으며, /dev/sdb로 링크되었음을 알 수 있다.

파티션 만들기

새로운 하드 디스크를 추가했으니, 이제 해야할 일은 파티션을 만들어주는 것이다. 하나의 하드 디스크를 몇 개의 파티션으로 나누어도 상관 없으며, 각 파티션은 서로 다른 디스크처럼 동작하게 된다. 파티션을 만들 때는 fdisk를 사용한다. 기존 하드 디스크의 파티션 정보를 알고 싶다면 fdisk -l 옵션으로 실행한다.

# fdisk -l /dev/sda
Disk /dev/sda: 255 heads, 63 sectors, 2233 cylinders
Units = cylinders of 16065 * 512 bytes
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1   *         1       638   5124703+  83  Linux
/dev/sda2           639      2233  12811837+   5  Extended
/dev/sda5           639       689    409626   82  Linux swap
/dev/sda6           690      2233  12402148+  83  Linux

새로운 하드에 파티션을 만들기 위해 다음 명령을 사용한다.

# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 4462.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
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):

하드 디스크를 리눅스 파티션으로 만들려면 아래와 같은 명령을 준다.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
pPartition number (1-4): 1
First cylinder (1-4462, default 1): 1
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-4462, default 4462): 4462
Using default value 4462
Command (m for help):

파티션을 만든 후 확인을 하고 파티션 테이블을 저장하고 빠져나온다.

Command (m for help): p
Disk /dev/sdb: 255 heads, 63 sectors, 4462 cylinders
Units = cylinders of 16065 * 512 bytes
   Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1      4462  35840983+  83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

위의 예는 하드 디스크를 하나의 파티션으로 만들었지만, 여러 파티션으로 나눌 수도 있다. 첫 primary 파티션의 경우 /dev/sdb1으로 장치명이 붙는다.

포맷하기

이렇게 파티션을 나누었으면, 실제로 디스크를 사용하기 위해 포맷을 해야 한다. 여기에서 포맷한다는 것은 하드 디스크 상에 파일 시스템을 만들어준다는 것이다. 파일 시스템을 만들어줘야 그 파티션을 사용할 수 있기 때문이다. 리눅스에서는 파일 시스템을 만들기 위해 mkfs 명령을 사용할 수 있다. 현재 리눅스에서 사용할 수 있는 파일 시스템에는 여러 가지가 있습니다만, 여기에서는 ext2를 사용한다.

# mkfs -t ext2 /dev/sdb1
mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4480448 inodes, 8960245 blocks
448012 blocks (5.00%) reserved for the super user
First data block=0
274 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

마운트하기

파일 시스템은 사용하기 전에 먼저 마운트시켜야 한다. 마운트를 한다는 것은 사용자나 커널에서 하나의 파일 시스템을 가리키기 위한 포인트라고 생각하면 된다. 마운트를 하기 위해서 mount 명령을 사용한다. 그리고, 마운트 하기 전에는 먼저 마운트 시킬 포인트, 즉 디렉토리를 만들어줘야 한다. 여기에서는 /home/pub라는 디렉토리를 만들고, 거기에 새로 추가한 /dev/sdb1을 마운트할 것이다.

# mkdir /home/pub
# mount -t ext2 /dev/sdb1 /home/pub
# cd /home/pub
# ls -alF
total 24
drwxr-xr-x    3 root     root         4096 Aug 13 16:09 ./
drwxrwsr-x   22 root     staff        4096 Aug 13 16:10 ../
drwx------    2 root     root        16384 Aug 13 16:09 lost+found/
# df -k
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/sda1              5044156    399088   4388836   9% /
/dev/sda6             12207508   8056140   3531264  70% /home
/dev/sdb1             35278540        20  33486472   1% /home/pub

/etc/fstab 수정하기

이제 앞으로 리부팅을 하더라도 새로 추가한 디스크가 제대로 인식되게 하기 위해 /etc/fstab 파일을 수정한다.

# /etc/fstab: static file system information.
## <file system> <mount point> <type>  <options>                   <dump>  <pass>
/dev/sda1       /             ext2    defaults,errors=remount-ro  0       1
/dev/sda5       none          swap    sw                      0   0
proc            /proc         proc    defaults                    0       0
/dev/fd0        /floppy       auto    defaults,user,noauto        0       0
/dev/cdrom      /cdrom        iso9660 defaults,ro,user,noauto     0       0
/dev/sda6       /home         ext2    defaults                    0       2
proc            /proc         proc    defaults                    0       2
devpts          /dev/pts      devpts  defaults                    0       2
/dev/sdb1       /home/pub     ext2    defaults                    0       1
이 작은숲 문서의 출처는 위키노트의 위키노트/데비안에서 새로운 하드디스크 설치하기 문서입니다.