server

ubuntu 하드디스크 마운트

· John Doe

1026 Views

현재 시스템에 연결된 디스크 목록을 확인

contact@me:~$ sudo fdisk -l

추가로 연결한 하드가 있다면 아래처럼 뜸 (파티션을 나누지 않은 상태)

Disk /dev/sdd: 9.1 TiB, 10000831348736 bytes, 19532873728 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

외장하드를 연결했다면 아래처럼 뜸 

The backup GPT table is corrupt, but the primary appears OK, so that will be used.
Disk /dev/sdd: 3.7 TiB, 4000787029504 bytes, 7814037167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 9DB1508D-F261-47ED-BEB0-5AF9974A311C
 
Device      Start        End    Sectors  Size Type
/dev/sdd1      34     262177     262144  128M Microsoft reserved
/dev/sdd2  264192 7814035455 7813771264  3.7T Microsoft basic data
 
Partition 1 does not start on physical sector boundary.

4TB와 같이 용량이 크면 GPT 방식으로 파티션을 나누게 되는데 그러한 경우 아래 명령어 입력

contact@me:~$ sudo parted -l

파티션 나누는 자세한 방법은 생략

마운트 전에 해당영역을 포맷

contact@me:~$ sudo mkfs.ext4 /dev/sda1
mke2fs 1.44.1 (24-Mar-2018)
/dev/sda1 contains a ntfs file system
Proceed anyway? (y,N) y
Creating filesystem with 1220804352 4k blocks and 152600576 inodes
Filesystem UUID: 9DB1508D-F261-47ED-BEB0-5AF9974A311C
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

contact@me:~$

포맷하면 UUID가 바뀜

* ntfs 포맷

contact@me:~$ sudo mkntfs -f /dev/sdc1

다음 명령으로 연결된 하드디스크의 UUID 검색

contact@me:~$ ls -l /dev/disk/by-uuid
합계 0
lrwxrwxrwx 1 root root 10 11월  4 15:38 9DB1508D-F261-47ED-BEB0-5AF9974A311C -> ../../sda1
lrwxrwxrwx 1 root root 10 11월  4 15:38 9DB1508D-F261-47ED-BEB0-5AF9974A311C -> ../../sda2

마운트 시도했지만 아래와같이 나온다면

contact@me:~$ sudo mount -t ntfs-3g /dev/sdd2 /mpoint/x1
Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command.

연결후 이미 자동으로 마운트되어있던 상태였기에 기존 마운트 해제

contact@me:~$ sudo eject /dev/sdd2

다시 시도하면 정상적으로 된다.

contact@me:~$ sudo mount -t ntfs-3g /dev/sdd2 /mpoint/x1

/dev/sdd2 : 아까 sudo fdisk -l 명령어 쳤을 때 나온, Device Boot

/mpoint/x1 : 하나 생성한 디렉터리 경로

* fdisk로 확인했을때 아래처럼 나왔다면

/dev/sda4  1161216 976771071 975609856 465.2G Linux filesystem

ext4 포맷방식은 아래 명령으로 마운트

contact@me:~$ sudo mount -t ext4 /dev/sda4 /경로/hdd

또는 fstab에 설정 후 재부팅없이 마운트

fstab 백업 후 수정

contact@me:~$ sudo cp /etc/fstab /etc/fstab.bak
contact@me:~$ sudo vi /etc/fstab

UUID번호 / 마운트 위치 / 파일 시스템 종류 / 옵션 / 덤프 / 패스

- file system : 위에서 확인한 UUID
- mount point : 자동으로 하드디스크를 마운트할 위치
- type : 파일 시스템의 종류. 보통은 ext4 / fat 포맷이면 vfat / ntfs 포맷이면 ntfs
- options : 특이 사항이 없다면 defaults
- dump : 특이 사항이 없다면 0
- pass : 특이 사항이 없다면 0 

contact@me:~$ sudo nano /etc/fstab
UUID=9DB1508D-F261-47ED-BEB0-5AF9974A311C /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=01X5-3AB1  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0

UUID=9DB1508D-F261-47ED-BEB0-5AF9974A311C /folder/A ext4 defaults 0 0
UUID=9DB1508D-F261-47ED-BEB0-5AF9974A311C /folder/B ntfs defaults 0 0

contact@me:~$ sudo mount -a

*ntfs 포맷이라면 다음 명령으로 설치

contact@me:~$ sudo apt-get install ntfs-3g

디스크 파일 시스템 명령 df -h를 사용하여 마운트에 성공했는지 확인

권한설정이 필요하면 다음명령 사용

contact@me:~$ sudo chmod 777 /folder/A

우분투(Ubuntu) 하드디스크 자동으로 마운트 하는 방법 :: BlankSpace (tistory.com)

* unmount 와 eject 의 차이점

nautilus - What is the difference between "Unmount", "Eject", "Safely Remove Drive" and the eject icon? - Ask Ubuntu

* 추가 하드디스크 마운트 방법

[Ubuntu] 추가 하드디스크 마운트 방법 (tistory.com)

* 기타 자료

Mr. P Blog: [ Ubuntu ] 우분투 외장하드 마운트 (perdupper.blogspot.com)

https://bluexmas.tistory.com/727

https://m.blog.naver.com/PostView.nhn?blogId=hymne&logNo=220977353373&proxyReferer=https:%2F%2Fwww.google.com%2F

https://topis.me/109

https://blog.dalso.org/uncategorized/813

[참고 및 출처 사이트] 더보기 이론, 그림 - https://itguava.tistory.com/100 실습, 그림 - https://m.blog.naver.com/haejoon90/220749495797 1. 리눅스 파티션 기본 정보 [파티셔닝] 하나의 물리 저장장치를 시스템 내부에서 여러 디스크 공간으로 나누는 작업 Primary Partition(주 영역 파티션) 물리적 파티션 최대 4개까지의 공간으로 나눌 수 있다.(Extended Partit

Ubuntu mount