Linux HDD Mount 하드 추가

테스트 환경 OS

  • Ubuntu18.04 Bionic Beaver
  • Debian10 Buster

파티션 잡기

두가지 툴을 보통 사용

  • fdisk 2TB이하
  • parted 2TB이상 대용량

이었는데… fdisk에서 gpt가 지원이 되는 듯 한데..
원래 됐다 / 지금도 안된다 / 버전업되서 추가됐다
3가지중 뭘까

fdisk로 파티션 잡기

$ fdisk -v
 fdisk from util-linux 2.33.1

$ sudo fdisk -l
여기서 새로 설치한 디스크를 잘~ 확인

$ fdisk /dev/sdb
Welcome to fdisk (util-linux 2.33.1).
 Changes will remain in memory only, until you decide to write them.
 Be careful before using the write command.
 Command (m for help): m
 Help:
 GPT
    M   enter protective/hybrid MBR
 Generic
    d   delete a partition
    F   list free unpartitioned space
    l   list known partition types
    n   add a new partition
    p   print the partition table
    t   change a partition type
    v   verify the partition table
    i   print information about a partition
 Misc
    m   print this menu
    x   extra functionality (experts only)
 Script
    I   load disk layout from sfdisk script file
    O   dump disk layout to sfdisk script file
 Save & Exit
    w   write table to disk and exit
    q   quit without saving changes
 Create a new label
    g   create a new empty GPT partition table
    G   create a new empty SGI (IRIX) partition table
    o   create a new empty DOS partition table
    s   create a new empty Sun partition table

(??) m  -- 위에 나온거 다시볼 수 있다

(??) d  -- 파티션 다 지우기

(??) g  -- GTP로..

(??) n  -- 파티션 생성

(??) i  -- 파티션 정보보기

(??) p -- 파티션 테이블 정보보기

parted로 파티션 잡기

https://blog.hqcodeshop.fi/archives/273-GNU-Parted-Solving-the-dreaded-The-resulting-partition-is-not-properly-aligned-for-best-performance.html
$ sudo parted /dev/sdb
~~~
parted는 기본으로 안 깔려있으니 설치
$ sudo apt install parted

(parted) mktable gpt
(parted) mkpart
ext4
0%
100%

포맷

http://mhugt.tistory.com/47
http://noota.tistory.com/entry/%EC%9E%90%EB%8F%99-%EB%A7%88%EC%9A%B4%ED%8A%B8-%EB%B6%80%ED%8C%85-%EC%8B%9C-%EC%9B%90%ED%95%98%EB%8A%94-%ED%95%98%EB%93%9C%EB%94%94%EC%8A%A4%ED%81%AC-%EC%9E%90%EB%8F%99%EC%9C%BC%EB%A1%9C-%EB%A7%88%EC%9A%B4%ED%8A%B8-%EB%90%98%EB%8F%84%EB%A1%9D-%EC%B2%98%EB%A6%AC%ED%95%98%EA%B8%B0

$ sudo mkfs.ext4 /dev/sdb1
$ mkdir tmpdir
$ sudo mount /dev/sdb1 /tmpdir

자동 마운트

uuid 확인

$ sudo blkid
$ ll /etc/disk/by-uuid
$ nano /etc/fstab

맨뒷줄에 추가
UUID=xxxxxxxxxxxxxxxxxxxxxxuuidxxxxx /tmpdir ext4 defaults 0 0

tmpdir을 원하는 경로로 변경

마운트 테스트

$ sudo mount -fav

LVM추가

  • https://hiseon.me/linux/lvm-configuration/
  • https://jangpd007.tistory.com/235
  • https://wiki.debian.org/LVM#Create_a_PV

Ubuntu GPT disk 등록하기

파티션 만들기
2T이상은 gpt로 만들어야된다. fdisk로 안된다는 얘기… 설치할 때 한번에 하는게 편하지만 하드를 중간에 추가할 경우에는 이 작업이 필요하다.

$ sudo fdisk -l
$ sudo parted /dev/sdb
(parted) mklabel gpt
(parted) unit TB
(parted) print
1번방법-
(parted) mkpart
name 알아서
filesystem 다시포멧할거니까그냥엔터 아니면 ext4
start 0
end 위에서 print할 때 봤던거 하드끝까지 3.0TB
2번방법-
(parted) mkpart primary 0 0
3번방법-
(parted) mkpart primary 0.00TB 3.00TB
위에1,2,3번방법 아무거나 맘에드는대로 해주면되고
(parted) quit

파일시스템만들기 – 포멧
mkfs –type ext4 /dev/sdXY

마운트하기
$ sudo mkdir /data
$ sudo mount /dev/sdb1 /data
이렇게 하면 부팅할 때 마다 다시 등록해줘야한다.

영구적으로 마운트하기위해서 fstab 등록하기

$ sudo blkid
uuid확인
붙여넣기를 해야되니 ssh로 접속하는게 좋다
/etc/fstab에 위의 정보들을 보고 따라 잘 등록

UUID=39489af1-0f3z-7777c-djen-69a03jf93afd0 /data ext4 errors=remount-ro 0 1
UUID는 blkid했을 때 나온 주소
/data는 파일 마운트 경로
파일시스템타입ext4

$ sudo mount -a
전체 마운트 재등록하라는 뜻. 설정이 제대로 됏다면 오류없이 완료.

끝. 재부팅해본다.
제대로 등록되지 않았다면 컴퓨터가 안 켜질거다. 그렇다면 재설치