debian 10 (buster) hdd(ssd)増設


Debian BusterにHddを増設する

HDDを増設する
こちらの記事のdebian10でもできることを確かめただけ
多分ubuntu18とかでも一緒(知らんけど)

感謝します
HDD増設手順メモ-@bwtakacy

デバイス

  • OS Debian GNU/Linux 10(buster)
  • メモリ 16GB
  • プロセッサ Intel©Core i7-9700K CPU @ 3.60GHz × 8
  • グラフィック RTX 2070/PCle/SSE2
  • GNOME 3.30.2

(他にもHDD,ssdごとにwindows10 pro, ArchLinuxが乗っております)

追加デバイス

  • TOSHIBA DT01ACA200 [2TB/3.5インチ内蔵ハードディスク] [7200rpm] / SATA 6Gb/s/ バルク品
  • (正直容量があって6Gb/sくらいあったら何でも良かった)

増設

確認

一旦何も考えずにhddをつなげて電源を入れてみる
とりあえずdriveとして認識されているかの確認

# fdisk -l

-なんかいろいろ

Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: TOSHIBA DT01ACA2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

よくわからないけど生きてるみたい

フォーマット

fdsiskを使う

パーティションの削除

debian# 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.

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

Command (m for help): d
No partition is defined yet!

そりゃそうだ。初期化状態では何もない

新パーティションの作成

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-3907029167, default 2048): 2048
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-3907029167, default 3907029167): 3907029167    

Created a new partition 1 of type 'Linux' and of size 1.8 TiB.

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

できた!!
一つのパーティションで、Linux(debian)のみで認識できれば良いため、pを選択
20483907029167は両方共初期値の選択

するとfdiskの表示が変わります  

debian# fdisk -l

Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: TOSHIBA DT01ACA2
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: dos
Disk identifier: 0xc7bfb39d

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdb1        2048 3907029167 3907027120  1.8T 83 Linux

ファイルシステムの作成

debian# mkfs -t ext4 /dev/sdb1 
mke2fs 1.44.5 (15-Dec-2018)
Creating filesystem with 488378390 4k blocks and 122101760 inodes
Filesystem UUID: huga-hoge-hage-huga
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848

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

出来たらしい

手動でマウントしてみる

mkfs -t ext4 /dev/sdb1
mke2fs 1.44.5 (15-Dec-2018)
/dev/sdb1 contains a ext4 file system

マウント出来た!!

起動時の自動マウント

# UUIDの確認  
root@debian:~# blkid /dev/sdb1
/dev/sdb1: UUID="huga-hoge-hage-huga" TYPE="ext4" PARTUUID="hogege-01"

# 現在値の確認  
root@debian:~# cat /etc/fstab 

# /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/sdb2 during installation
UUID=hage-hage-hage-hage /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
# UUID=fuga-fuga  /boot/efi       vfat    umask=0077      0       1
# swap was on /dev/sdb3 during installation
UUID=hoge-hoge-hoge-hoge none            swap    sw              0       0

# 追記
root@debian:~# echo "UUID=huga-hoge-hage-huga /database ext4 defaults" >> /etc/fstab

# 確認 

root@debian:~# cat /etc/fstab 

# /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/sdb2 during installation
UUID=hage-hage-hage-hage /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p1 during installation
# UUID=fuga-fuga  /boot/efi       vfat    umask=0077      0       1
# swap was on /dev/sdb3 during installation
UUID=hoge-hoge-hoge-hoge none    
UUID=0aa26fe6-a085-4b1b-bf73-6509fceafed4 /database ext4 defaults

再起動して確認

root@debian:~# ls /

/database

完了!!

最後にもう一度勝手に参考にさせていただいた

HDD増設手順メモ-@bwtakacy 

ありがとうございました!!