美文网首页
linux新增、挂载、扩容磁盘

linux新增、挂载、扩容磁盘

作者: wsf535 | 来源:发表于2018-06-13 12:29 被阅读39次

1、增加硬盘

2可以看到磁盘并没有马上认出来

3、由于不知道新增硬盘挂载的位置,可以先查看现有硬盘挂载的适配器。

4、发现正在磁盘挂载到host0,可以尝试使用下边命令,重新扫描host0信息

echo "- - -" > /sys/class/scsi_host/host0/scan

5、再次有fdisk -l可以看到新的磁盘已经扫出来了

image.png

以下开始创建分区

格式化分区

挂载分区

扩容:(需要关机)

卸载分区

umount /dev/sdb1

删除并重新建分区


[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Command (m for help): p

Disk /dev/sdb: 16.1 GB, 16106127360 bytes, 31457280 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

Disk label type: dos

Disk identifier: 0xead24600

 Device Boot Start End Blocks Id System

/dev/sdb1 2048 20971519 10484736 83 Linux

Command (m for help): d

Selected partition 1

Partition 1 is deleted

Command (m for help): n

Partition type:

 p primary (0 primary, 0 extended, 4 free)

 e extended

Select (default p): p

Partition number (1-4, default 1): 1

First sector (2048-31457279, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279):

Using default value 31457279

Partition 1 of type Linux and of size 15 GiB is set

Command (m for help): p

Disk /dev/sdb: 16.1 GB, 16106127360 bytes, 31457280 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

Disk label type: dos

Disk identifier: 0xead24600

 Device Boot Start End Blocks Id System

/dev/sdb1 2048 31457279 15727616 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

检查并变更文件系统大小

[root@localhost ~]# e2fsck -f /dev/sdb1

e2fsck 1.42.9 (28-Dec-2013)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/sdb1: 13/655360 files (0.0% non-contiguous), 79698/2621184 blocks

[root@localhost ~]# resize2fs /dev/sdb1

resize2fs 1.42.9 (28-Dec-2013)

Resizing the filesystem on /dev/sdb1 to 3931904 (4k) blocks.

The filesystem on /dev/sdb1 is now 3931904 blocks long.

重新挂载

mount /dev/sdb1 /mydata

查看数据是否存在(可保留原数据)

[root@localhost ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/centos-root 17G 1.1G 16G 7% /

devtmpfs 476M 0 476M 0% /dev

tmpfs 488M 0 488M 0% /dev/shm

tmpfs 488M 7.7M 480M 2% /run

tmpfs 488M 0 488M 0% /sys/fs/cgroup

/dev/sda1 1014M 130M 885M 13% /boot

tmpfs 98M 0 98M 0% /run/user/0

/dev/sdb1 15G 26M 14G 1% /mydata

[root@localhost ~]# cd /mydata/

[root@localhost mydata]# ll

total 24

drwx------. 2 root root 16384 Jun 11 04:19 lost+found

drwxr-xr-x. 2 root root 4096 Jun 11 04:26 test

-rw-r--r--. 1 root root 4 Jun 11 04:26 test.txt

相关文章

网友评论

      本文标题:linux新增、挂载、扩容磁盘

      本文链接:https://www.haomeiwen.com/subject/qjrjeftx.html