Published on

Ubuntu adding mvme ssd 추가

Authors
  • Name
    Twitter

Background

Steps

SSD 장착

작업을 위해 machine 전원을 내리고 mvme ssd를 홈에 맞게 장착 후 재부팅.

디스크 장착 확인

방금전에 장착한 465 GiB 의 nvme ssd가 정상적으로 인식 된 것을 확인.

root@latte01:~# sudo fdisk -l

...

Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SHGP31-500GM
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

...

현재 사용중인 Disk 확인

위에서 장착한 mvme ssd(/dev/nvme0n1)가 아직 마운트 되지 않은 것을 확인할 수 있습니다.

root@latte01:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           777M  2.0M  775M   1% /run
/dev/mmcblk2p2   57G   39G   16G  72% /
tmpfs           3.8G     0  3.8G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/mmcblk2p1  511M  5.3M  506M   2% /boot/efi
tmpfs           777M   88K  777M   1% /run/user/1000

디스크 마운트 진행

위에서 확인한 disk에 파티션을 생성해주기 위해 아래 과정을 진행합니다.

root@latte01:~# sudo fdisk /dev/nvme0n1

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x66336a6e.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-976773167, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-976773167, default 976773167):

Created a new partition 1 of type 'linux' and of size 465.8 GiB.

Command (m for help): p
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SHGP31-500GM
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x66336a6e

Device         Boot Start       End   Sectors   Size Id Type
/dev/nvme0n1p1       2048 976773167 976771120 465.8G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Created a new partition 1 of type 'linux' and of size 465.8 GiB. 문구가 나오고, w 까지 입력해야 partition이 제대로 생성됩니다.

디스크 상태 확인한

fdisk -l 로 확인해보면 이전과 달리 Device로 잡힌 것을 확인할 수 있습니다.

root@latte01:~# sudo fdisk -l

Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SHGP31-500GM
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x66336a6e

Device         Boot Start       End   Sectors   Size Id Type
/dev/nvme0n1p1       2048 976773167 976771120 465.8G 83 Linux

파티션 포맷

아래 명령어를 통해 다른 File system은 어떤 식으로 포맷되었는지 확인합니다.

root@latte01:~# sudo blkid
/dev/mmcblk2p2: UUID="aa495c97-2344-4d43-a689-b619820a0210" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="f60e2f86-337d-4890-bfbd-fc6555e075f0"
/dev/loop1: TYPE="squashfs"
/dev/nvme0n1p1: PARTUUID="66336a6e-01"
/dev/mmcblk2p1: UUID="986C-B2FC" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="995635dd-2919-4051-9388-abfd4e42d81e"

root@latte01:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           777M  2.1M  775M   1% /run
/dev/mmcblk2p2   57G   39G   16G  72% /

가장 큰 용량을 차지하는 /dev/mmcblk2p2 랑 포맷을 맞춰주려고 합니다. 따라서 새로운 disk도 ext4 방식으로 포맷하면 될 것 같습니다.

포맷 진행.

root@latte01:~# sudo mkfs.ext4 /dev/nvme0n1
mke2fs 1.46.5 (30-Dec-2021)
Found a dos partition table in /dev/nvme0n1
Proceed anyway? (y,N)  y
Discarding device blocks: done
Creating filesystem with 122096646 4k blocks and 30531584 inodes
Filesystem UUID: 482ee0df-9d2d-4959-9026-de7206de5aaf
Superblock backups stored on blocks:
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
	102400000

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

sudo blkid를 입력하면 ext4로 포맷된 디스크를 확인할 수 있습니다.

root@latte01:~# sudo blkid

#AS IS
# /dev/nvme0n1p1: PARTUUID="66336a6e-01"

#TO BE
/dev/nvme0n1: UUID="482ee0df-9d2d-4959-9026-de7206de5aaf" BLOCK_SIZE="4096" TYPE="ext4"

디스크 마운트

디스크를 사용하기위한 폴더를 생성해줍니다.

root@latte01:~# mkdir -p /data1

새로 추가한 disk를 자동마운트 하기위한 정보를 /etc/fstab에 추가합니다.

# data1
UUID=482ee0df-9d2d-4959-9026-de7206de5aaf   /data1  ext4    defaults    0   0

추가 후

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/mmcblk1p2 during installation
UUID=aa495c97-2344-4d43-a689-b619820a0210 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/mmcblk1p1 during installation
UUID=986C-B2FC  /boot/efi       vfat    umask=0077      0       1
# data1
UUID=482ee0df-9d2d-4959-9026-de7206de5aaf   /data1  ext4    defaults    0   0
/swapfile                                 none            swap    sw              0       0

마운트 적용

sudo mount -a

결과 확인

root@latte01:~# sudo mount -a
root@latte01:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           777M  2.0M  775M   1% /run
/dev/mmcblk2p2   57G   39G   16G  72% /
tmpfs           3.8G     0  3.8G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/mmcblk2p1  511M  5.3M  506M   2% /boot/efi
tmpfs           777M   88K  777M   1% /run/user/1000
/dev/nvme0n1    458G   28K  435G   1% /data1

data1이라는 곳에 458GiB의 용량이 잡힌 것을 확인 할 수 있습니다.

Reference