본문 바로가기

IT인생_스크랩/Linux

리눅스 하드디스크 추가하기

[   출처 : http://blog.naver.com/slamrukawa/10029858865   ]



리눅스 하드디스크 추가 (파티션&마운트)

 

* 파티션생성
* 파일시스템생성
* 마운트포인트생성

1. 서버에 하드 추가 후 OS 부팅시 하드가 올라오는지 확인한다.

2. vi /etc/fstab을 열어 ext2, ext3인지 판단..

3. fdisk로 파티션을 잡는다.
예)
3-1. fdisk /dev/hdb (IDE 하드인 경우), fdisk /dev/sdb (SCSI 하드인 경우)

3-2. p로 기존 파티션이 잡혀있는지 확인한다.


3-3. d로 기존 파티션이 잡혀있으면 삭제후 p로 확인한다.
3-4. n으로 파티션 추가- > p(primary로) -> 1 -> 크기지정 default 1 입력(Full로 잡을시, 디폴트가 Full) -> 엔터
3-5. w로 쓴다.
※ 전 eide 하드에서 sda 하드 하나 추가해서 나온 그림입니다.

[root@localhost /]# fdisk /dev/sda
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 1044.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
Command (m for help): p              
 
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
 
Command (m for help): d
No partition is defined yet!
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):                           <------enter
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):                     <- enter
Using default value 1044
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
Syncing disks.


4. format
ext3 : mke2fs -j /dev/hdb
ext2 : mkfs -t ext2 /dev/hdb

 

[root@localhost dev]# mke2fs -j /dev/sda
mke2fs 1.35 (28-Feb-2004)
/dev/sda is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2097152 blocks
104857 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
 
Writing inode tables: done                           
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.



5. 마운트할 디렉토리 생성
/에서 mkdir /home2 등등

6. mount
ext3 : mount -t ext3 /dev/hdb /home2
ext2 : mount -t ext2 /dev/hdb /home2

 

저의 경우 scsi이기때문에

[root@localhost /]# mount -t ext3 /dev/sda /home2



7. fstab 수정 (vi /etc/fstab)
예)
LABEL=/home /home ext3 defaults 1 2 (를 카피하여 페이스트 하여 아래와 같이 편집)
-> /dev/hdb /home2 ext3 defaults 1 2 (앞 두부분만 수정)

/dev/sda                /home2                  ext3    defaults        1 2

 


8. df -h로 마운트 확인

Filesystem            Size  Used Avail Use% Mounted on
/dev/hda2             4.9G  156M  4.5G   4% /
/dev/hda1              99M   12M   82M  13% /boot
none                  252M     0  252M   0% /dev/shm
/dev/hda7              15G   71M   15G   1% /home
/dev/hdb              7.9G   51M  7.5G   1% /hdd2
/dev/hda3             4.9G 1020M  3.6G  22% /usr
/dev/hda5             3.9G   70M  3.6G   2% /var
/dev/sda              7.9G   51M  7.5G   1% /home2



9. 재부팅후 이상없이 올라온후 마운트 되었는지 확인