문서의 이전 판입니다!


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

리눅스에서는 그냥 꼽는다고 저절로 D: 이런식으로 추가되는 것은 아니다. 따로 설정을 해줘야 한다.

고정 하드디스크 추가 방법

일단 접속된 하드디스크들을 알아본다.

sudo fdisk -l
  • 일반 IDE하드는 /dev/hda /dev/hdb /dev/hdc ….
  • 스카시, SATA, USB일 경우 /dev/sda /dev/sdb /dev/sdc ….

/etc/fstab를 수정한다

sudo nano /etc/fstab

마지막 줄에 다음을 추가 ( sdb1 이 추가할 하드 디스크라고 가정) - /media/disk 디렉토리가 이미 만들어져 있어야 합니다. ext3 대신 fat32의 경우 vfat, ntfs의 경우 ntfs-3g

/dev/sdb1  /media/disk  ext3    defaults   0 0
/dev/sdb1   /data   vfat defaults,rw,umask=000,iocharset=cp949,utf8  0 0
  • umask=000 모든이에게 권한을 777로 주게 된다.
  • iocharset=cp949,utf8 한글 코드를 설정.

임시 연결 (USB HDD 마운트)

sudo fdisk -l                                      # 정보보기
sudo mkdir /media/external                         # 연결할 폴더만들기
sudo mount -t vfat /dev/sdb1 /media/external       # FAT 마운트
sudo mount -t ntfs-3g /dev/sdb1 /media/external    # NTFS 마운트
sudo mount -w /dev/sdb1 /mnt/data -o umask=000,iocharset=cp949,utf8
sudo umount /dev/sdb1                 # 제거
sudo umount /media/external           # 장치 제거.
umount -f /mnt/xxx                    # 강제

1)

ISO파일 마운트

sudo mkdir /mnt/iso  # 연결할 폴더 생성
sudo mount -o loop <image>.iso /mnt/iso       

sudo mount -o loop /home/admin/Downloads/image1.iso /mnt/iso

CIFS 마운트

LVM mount

LVM Mount 참조

기타

① cat /etc/fstab 마운트 정보 확인 ② fdisk /dev/hdb * p로 기존 파티션 확인 * d로 기존 파티션 삭제 * n으로 파티션 추가 (p→1→크기지정 default 1 입력) full로 잡을시, 디폴트가 full * w로 쓴다

③ 포맷

  ext4:    mkfs.ext4 /dev/sda2
  ext3: mke2fs -j /dev/hdb  
  ext2: mkfs -t ext2 /dev/hdb 

④ 마운트할 디렉토리 생성 (mkdir /new_dir) ⑤ 마운트 (mount -t ext3 /dev/hdb /new_dir)

 sudo mount -t ntfs-3g /dev/sdb1 /mnt/data

여기서 ext3 은 파일시스템이고 /dev/sdb1 은 마운트할 장치명, /data2 는 하드를 사용할 폴더명이다. 마운트 하려면 반드시 위와 같이 장치가 연결될 폴더가 필요하므로 미리 해당 폴더를 만들어 두어야 한다. 폴더를 만들어서 위와 같이 연결해 주면 그 폴더로 해당 하드디스크가 붙게 된다.

⑥ fstab 수정

 sudo nano /etc/fstab 

⑦ df -h로 마운트 확인 ⑧ 재부팅

fstab 설명

한줄에 하나의 장치를 넣는다. 여섯개의 칸이 있다.

/dev/sdb1       /data           ext4    defaults     0       2
  1. 연결할 디바이스 명을 입력한다.
  2. 연결될 폴더
  3. 파일시스템의 종류를 나타낸다
    • dos
    • ext2
    • ext3
    • ext4
    • nfs
    • swap
    • vfat
  4. 옵션
    • default : 기본
    • noquota : 쿼타 사용안함
    • nosuid : SUID접근 불가능
    • quota : 쿼터 사용
    • ro : 읽기 가능
    • rw : 읽기 쓰기 가능
    • suid: SUID접근 가능
    • uid=1000,gid=1000 : 소유자 및 그룹
    • umask=007 :퍼미션 마스크
  5. 파일시스템이 덤프될 필요가 있는지를 설정한다.
    • 0 : 덤프될 필요없음
    • 1 : 덤프 필요합
  6. fsck에 의해 수행되는 무결성 검사를 위한 파일시스템 우선순위를 결정한다.
    • 0 : 체크 안함. 이동식드라이브
    • 1 : 우선적으로 체크. 부트 드라이브.
    • 2 : 1번이 끝난 후 체크. 기타 다른 모든 장비들.

NTFS vs NTFS-3G

mount 명령을 내리면 파일시스템 종류를 자동으로 파악하거나 -o 옵션으로 지정할 수 있다. 그 다음에 mount.ext3/mount.ntfs 같은 파일시스템별 마운트 명령을 호출하게 된다. 리눅스 커널에 있는 NTFS 드라이버는 읽기 전용이고, 쓰기 지원은 아직까지도 구현되지 않았다. 그래서 대부분 배포판은 ntfs 커널 드라이버 대신 ntfs-3g를 사용함. 우분투라면 기본 상태에서 mount -o ntfs나 ntfs-3g를 직접 실행하나 결과는 같다. mount.ntfs가 mount.ntfs-3g로 향한 링크임. 궁금하면 직접 실행시켜 보라.

ntfs-3g의 성능은 완전 좌절임. USB 외장 하드를 ntfs-3g로 썼을 때는 둘 다 CPU 먹는 괴물이라서 대용량 파일 복사를 걸어 놓으면 말 그대로 아무 작업도 하지 못했다.

사용자 영역 드라이버라 일반 커널 드라이버를 가진 File System보다는 느린 편임. 당연히 사용자 영역 드라이버를 위해서 CPU를 점유하기 때문에 후덜덜하게 CPU를 사용하게 된다. 사용자 영역 드라이버의 경우 Operation을 하게 되면 메모리에 일단 잔뜩 쟁여 놓게 되는데 용량이 작은 경우 별 문제가 안되지만 클 경우 결국 I/O 처리 속도에 제한을 받게 된다. 당연히 Reverse Engineering으로 만들어진 드라이버 이기 때문에 MS의 드라이버보다 비 휴욜적이어서 속도가 느릴 수 밖에 없어서 결국 느리게 처리될 수 밖에 없다.

eSATA로 바꾸고 나니까 CPU 점유율이 아주 조금 개선되었지만 그래도 다른 작업에 방해가 된다. 결국 ext4로 파일시스템을 바꿨다.

새하드 포맷

Now to make a new partition. Press n <enter> (for new), then p <enter> (for primary), then 1 <enter> and then simply press enter for the next two questions. This will make a new partition that uses the entire disk. If you want more complex partitioning then read the fdisk manual (man fdisk) or use parted or some other app. Here's what we did with n, the values will differ from yours: Code:

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

Now to write the new partion and exit, press w and enter. You should be ready to make a filesystem now.

Making a filesystem : "Formatting" You need to put a system in-place, on the disk, such that it can handle files. This is called (unsurprisingly) a filesystem. The one we are going to use is called "ext3". On Gnu/Linux we are spoiled for choice and there are loads of filesystems you can use, go do some research if you want to. So, let's make the filesystem: Code:

sudo mkfs.ext3 /dev/sda1
* Note the 1 at the end, because we are making the filesystem in that partition (thanks Mike)

Now it will go off and do strange stuff, simply wait for it to finish.

Using the new file system Well, at this point you should be able to right-click on the icon (on your Desktop) and choose "mount" (I assume that's the verb it will present to you). After that you should be able to open a window and use the drive*

  • all this assumes it's an external USB drive.

If you cannot then you will need to mount it yourself, try: Code:

sudo mkdir /media/sda1
sudo mount /dev/sda1 /media/sda1

Note: We are actually mounting the first partition on the drive, hence the 1 at the end: sda1 And the mounted directory can be anywhere you like, but its common location is /media.

If those two steps worked then you are 90% done.

You may need to make a single folder in the new drive and give it your user permissions: Code:

cd /media/sda1
sudo mkdir afolder
chown you:you afolder

같이보기

1)
lrwxrwxrwx 1 root root 10 2011-12-12 23:23 66A0422EA0420551 → ../../sdb1 lrwxrwxrwx 1 root root 10 2012-01-25 00:48 7c59d0c8-046d-4947-9b83-d23a44c754dd → ../../sde1 lrwxrwxrwx 1 root root 10 2011-12-12 23:23 7d35a2df-fe23-4618-98f9-495ba6409ad8 → ../../sda5

역링크