1
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Diskの初期化方法

Last updated at Posted at 2017-07-19

読み込み

reboot

Diskの確認

fdisk -l

パーティションを分割 (sdb → sdb0, sdb1, ...)

# fdisk /dev/sdb
Command (m for help): n
Command action
e extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-13054, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054):
Using default value 13054
Command (m for help): p
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x88ac1a04
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1
1       13054   104856223+  83  Linux
Command (m for help): w
The partition table has been altered!

もし、こんなエラーが出たら?

Calling ioctl() to re-read partition table.
Syncing disks.

rebootかこのコマンド

partprobe

できていることを確認

# fdisk -l
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       13054   104856223+  83  Linux

ext4で初期化

mkfs -t ext4 /dev/sdb1

マウント

cp -p /etc/fstab{,.org}
vi /etc/fstab

このラインを追加

/dev/sdb1               /var/lib/mysql          ext4    defaults,noatime        1 2
mkdir -p /var/lib/mysql

読み込み

mount -a

確認

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        27G  1.2G   25G   5% /
tmpfs           244M     0  244M   0% /dev/shm
/dev/sda1       488M   26M  437M   6% /boot
/dev/sdb1        99G   60M   94G   1% /var/lib/mysql
1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?