新規にHDD2台を買ったのでgdiskでmount

Pocket

mountする

環境はcentos7.1
買ってきたのはHDD4TB WD40EZRZ 税込10349円を2台

cuzqaqiusamwz9m

以前使っていたディスク2台と新規で購入した1台をサーバにつけてどれもmountしていない状態
OSはsdaに入っている状態

[root@localhost ~]# df -h
ファイルシス            サイズ  使用  残り 使用% マウント位置
/dev/mapper/centos-root    50G   17G   34G   34% /
devtmpfs                  2.8G     0  2.8G    0% /dev
tmpfs                     2.8G     0  2.8G    0% /dev/shm
tmpfs                     2.8G  8.5M  2.8G    1% /run
tmpfs                     2.8G     0  2.8G    0% /sys/fs/cgroup
/dev/sda1                 494M  172M  323M   35% /boot
/dev/mapper/centos-home   875G   33M  875G    1% /home
tmpfs                     568M     0  568M    0% /run/user/0
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0 931.5G  0 disk 
├─sda1            8:1    0   500M  0 part /boot
└─sda2            8:2    0   931G  0 part 
  ├─centos-root 253:0    0    50G  0 lvm  /
  ├─centos-swap 253:1    0   5.8G  0 lvm  [SWAP]
  └─centos-home 253:2    0 875.2G  0 lvm  /home
sdb               8:16   0   3.7T  0 disk 
sdc               8:32   0 931.5G  0 disk 
└─sdc1            8:33   0 931.5G  0 part 
sdd               8:48   0 931.5G  0 disk 
└─sdd1            8:49   0 931.5G  0 part 
[root@localhost ~]# 

sdbが新規購入分っぽいのでこれをgdisk

[root@localhost ~]# 
[root@localhost ~]# gdisk -l /dev/sd
sda   sda1  sda2  sdb   sdc   sdc1  sdd   sdd1  
[root@localhost ~]# gdisk -l /dev/sdb 
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.
Disk /dev/sdb: 7814037168 sectors, 3.6 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): C4F1A9D5-6621-417F-9DE2-40F021C2F20F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 7814037134
Partitions will be aligned on 2048-sector boundaries
Total free space is 7814037101 sectors (3.6 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-7814037134, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-7814037134, default = 7814037134) or {+-}size{KMGTP}: 
Current type is '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/sdb: 7814037168 sectors, 3.6 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 5F602FDF-FF38-4A77-93D6-9E76A3F9D502
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 7814037134
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      7814037134   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/sdb.
The operation has completed successfully.
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# gdisk -l /dev/sdb 
GPT fdisk (gdisk) version 0.8.6

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sdb: 7814037168 sectors, 3.6 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 5F602FDF-FF38-4A77-93D6-9E76A3F9D502
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 7814037134
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      7814037134   3.6 TiB     8300  Linux filesystem
[root@localhost ~]# 

mountする

[root@localhost ~]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda               8:0    0 931.5G  0 disk 
├─sda1            8:1    0   500M  0 part /boot
└─sda2            8:2    0   931G  0 part 
  ├─centos-root 253:0    0    50G  0 lvm  /
  ├─centos-swap 253:1    0   5.8G  0 lvm  [SWAP]
  └─centos-home 253:2    0 875.2G  0 lvm  /home
sdb               8:16   0   3.7T  0 disk 
└─sdb1            8:17   0   3.7T  0 part 
sdc               8:32   0 931.5G  0 disk 
└─sdc1            8:33   0 931.5G  0 part 
sdd               8:48   0 931.5G  0 disk 
└─sdd1            8:49   0 931.5G  0 part 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# mkfs.xfs /dev/sdb1 
meta-data=/dev/sdb1              isize=256    agcount=4, agsize=244188597 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=976754385, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=476930, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# mkdir /hdd1
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sun Oct 16 11:06:16 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=33a5f5a1-c348-40fd-b9db-03cce5573433 /boot                   xfs     defaults        0 0
/dev/mapper/centos-home /home                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# vi /etc/fstab
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sun Oct 16 11:06:16 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=33a5f5a1-c348-40fd-b9db-03cce5573433 /boot                   xfs     defaults        0 0
/dev/mapper/centos-home /home                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/sdb1	/hdd1	xfs	defaults	0 0
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# mount -a
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# df -h
ファイルシス            サイズ  使用  残り 使用% マウント位置
/dev/mapper/centos-root    50G   17G   34G   34% /
devtmpfs                  2.8G     0  2.8G    0% /dev
tmpfs                     2.8G     0  2.8G    0% /dev/shm
tmpfs                     2.8G  8.5M  2.8G    1% /run
tmpfs                     2.8G     0  2.8G    0% /sys/fs/cgroup
/dev/sda1                 494M  172M  323M   35% /boot
/dev/mapper/centos-home   875G   33M  875G    1% /home
tmpfs                     568M     0  568M    0% /run/user/0
/dev/sdb1                 3.7T   33M  3.7T    1% /hdd1
[root@localhost ~]# cd /hdd1/
[root@localhost hdd1]# ls
[root@localhost hdd1]# 
[root@localhost hdd1]# 
[root@localhost hdd1]# 

以前はUUIDとか調べてやってたけど

/dev/sdb1   /hdd1   xfs defaults    0 0

これでいけるからもうずっとこれ

だったが。。。。

HDDの抜き差しとかがあると順番が入れ替わったりして結構面倒なことんなったりするのでUUIDにすることにした
あとfstabの書き方も変えることでディスクがなくても起動してくれるようにできるっぽいので修正版はこちら

UUIDを調べる

[root@localhost ~]# ls -l /dev/disk/by-uuid  
合計 0
lrwxrwxrwx 1 root root 10 10月 19 02:50 0e1c5871-b233-431c-8579-9009c5dc980c -> ../../sda1
lrwxrwxrwx 1 root root 10 10月 19 02:51 24cdc0f4-45c0-4532-964c-acf1aa9687b4 -> ../../dm-1
lrwxrwxrwx 1 root root 10 10月 19 02:51 33a5f5a1-c348-40fd-b9db-03cce5573433 -> ../../sde1
lrwxrwxrwx 1 root root 10 10月 19 02:51 453c8c19-7ae6-4c66-97c7-694150b6e3cd -> ../../dm-2
lrwxrwxrwx 1 root root 10 10月 19 02:50 80acfa3a-ffe8-489d-a2cd-29e7088e3590 -> ../../sdb1
lrwxrwxrwx 1 root root 10 10月 19 02:51 bbd80598-c871-4a54-8a86-9402ff61a0fd -> ../../dm-0
lrwxrwxrwx 1 root root 10 10月 19 02:50 d8748f43-4435-4484-8aeb-f13bae65eec2 -> ../../sdc1
lrwxrwxrwx 1 root root 10 10月 19 02:50 f36ac49a-bb57-4c37-994c-1e1663ff5a8f -> ../../sdd1

そしてfstabはこうなる

[root@localhost ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Sun Oct 16 11:06:16 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=33a5f5a1-c348-40fd-b9db-03cce5573433 /boot                   xfs     defaults        0 0
/dev/mapper/centos-home /home                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
UUID=0e1c5871-b233-431c-8579-9009c5dc980c	/hdd1	xfs	nofail	0 0
UUID=80acfa3a-ffe8-489d-a2cd-29e7088e3590	/hdd2	xfs	nofail	0 0
UUID=d8748f43-4435-4484-8aeb-f13bae65eec2	/hdd3	xfs	nofail	0 0
UUID=f36ac49a-bb57-4c37-994c-1e1663ff5a8f	/hdd4	xfs	nofail	0 0

相変わらずhdd1とかhdd2とかでマウントしてるけどこれはこれで便利だ
nofailにすることでマウントに失敗しても無視して起動してくれる

コメントを残す

メールアドレスが公開されることはありません。