LinuxでHDDを初期化する
2TB以上の場合はgdiskを使ってGPT(GUID Partition Table) を設定するのがポイント ディスクを確認する
code:sh
lsblk -f
sudo fdisk -l
gdiskでパーティション作成
code:sh
sudo gdisk /dev/sdd
code:txt
Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-7814037133, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-7814037133, default = 7814037133) or {+-}size{KMGTP}:
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): p
Disk /dev/sdd: 7814037167 sectors, 3.6 TiB
Model: Expansion HDD
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): FD315571-08F4-4FD1-866C-570AB295459E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 7814037133
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 7814037133 3.6 TiB 8300 Linux filesystem
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.
作られたパーティションを確認
code:sh
lsblk -f
フォーマットする
code:sh
sudo mkfs -t ext4 /dev/sdd1
code:txt
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 976754385 4k blocks and 244195328 inodes
Filesystem UUID: xxxxxxx
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
マウント先の設定
UUIDを確認
code:sh
sudo blkid /dev/sdd1
マウントポイントを作成
code:sh
sudo mkdir -p /mnt/mydisk1
自動マウントの設定
code:sh
sudo vim /etc/fstab
# UUID=xxxx /mnt/mydisk1 auto nosuid,nodev,nofail,x-gvfs-show 0 0
マウントする
code:sh
mount /dev/sdd1
確認
code:sh
lsblk -f
code:sh
rsync -aP /mnt/mydisk1/ /mnt/mydisk2/
コピー元はスラッシュが大事