1. 程式人生 > >空白硬碟(不分割槽)掛載方式

空白硬碟(不分割槽)掛載方式

1、檢視所有硬碟狀況

fdisk -l

Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors
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: 0x586e0d2f

Device     Boot Start      End  Sectors Size Id Type
/dev/vda1  *     2048
83886046 83883999 40G 83 Linux Disk /dev/vdc: 1 TiB, 1099511627776 bytes, 2147483648 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

2、格式化新加硬碟

mkfs.ext4 /dev/vdc

# 使用ext4格式化空白硬碟 filesystem ext4
mke2fs 1.42
.13 (17-May-2015) /dev/vdc contains a ext4 file system last mounted on Thu Dec 14 07:16:20 2017 Proceed anyway? (y,n) y Creating filesystem with 268435456 4k blocks and 67108864 inodes Filesystem UUID: 9c12e85e-6f1f-4bfe-afa6-13fa0b37657c 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 (32768 blocks): done Writing superblocks and filesystem accounting information: done

3、修改/etc/fstab

vi /etc/fstab

uuid 是硬碟的唯一標識,而/dev/vda(b,c,d,e)是根據磁碟連線順序來接入的,序號可能發生改變,uuid通過 blkid 檢視
新增一行:

UUID=9c12e85e-6f1f-4bfe-afa6-13fa0b37657c /var/lib/elasticsearch ext4 defaults 0 0

4、使/etc/fstab生效

mount -a