Skip to content

Split View: Ubuntu adding mvme ssd 추가

|

Ubuntu adding mvme ssd 추가

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

Adding an NVMe SSD on Ubuntu

Background

Steps

Installing the SSD

Power off the machine, install the NVMe SSD into the correct slot, and reboot.

Verifying Disk Detection

Confirm that the newly installed 465 GiB NVMe SSD has been properly detected.

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

...

Checking Currently Used Disks

You can see that the NVMe SSD (/dev/nvme0n1) installed above has not yet been mounted.

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

Creating a Disk Partition

Follow the steps below to create a partition on the disk identified above.

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.

The message Created a new partition 1 of type 'linux' and of size 465.8 GiB. will appear, and you must type w to actually write the partition.

Checking Disk Status

If you check with fdisk -l, you can see that the disk is now listed as a device, unlike before.

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

Formatting the Partition

Use the following command to check how other file systems are formatted.

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% /

We want to match the format of /dev/mmcblk2p2, which uses the most storage. Therefore, we will format the new disk with ext4 as well.

Proceed with formatting.

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

Running sudo blkid will show the disk formatted as 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"

Mounting the Disk

Create a folder to use the disk.

root@latte01:~# mkdir -p /data1

Add the auto-mount information for the new disk to /etc/fstab.

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

After adding:

# /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

Applying the Mount

sudo mount -a

Verifying the Result

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

You can confirm that 458 GiB of storage is now available at the mount point data1.

Reference

Quiz

Q1: What is the main topic covered in "Adding an NVMe SSD on Ubuntu"? Adding an NVMe SSD on Ubuntu

Q2: What are the key steps for Installing the SSD? Power off the machine, install the NVMe SSD into the correct slot, and reboot.

Q3: Explain the core concept of Verifying Disk Detection. Confirm that the newly installed 465 GiB NVMe SSD has been properly detected.

Q4: What are the key aspects of Checking Currently Used Disks? You can see that the NVMe SSD (/dev/nvme0n1) installed above has not yet been mounted.

Q5: How does Creating a Disk Partition work? Follow the steps below to create a partition on the disk identified above. The message Created a new partition 1 of type 'linux' and of size 465.8 GiB. will appear, and you must type w to actually write the partition.