- Authors
- Name
背景
手順
SSDの取り付け
マシンの電源を切り、NVMe 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
...
現在使用中のディスクの確認
上記で取り付けたNVMe 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
ディスクパーティションの作成
上記で確認したディスクにパーティションを作成するため、以下の手順を実行します。
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を入力するとパーティションが正しく作成されます。
ディスク状態の確認
fdisk -lで確認すると、以前とは異なりデバイスとして認識されていることが確認できます。
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
パーティションのフォーマット
以下のコマンドで他のファイルシステムがどのようにフォーマットされているか確認します。
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とフォーマットを合わせます。したがって、新しいディスクも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
新しく追加したディスクを自動マウントするための情報を/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の容量が割り当てられていることが確認できます。