linux分区挂载扩容,linux新增、挂载、扩容磁盘

1、增加硬盘

8bf751cc0c1a

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

8bf751cc0c1a

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

8bf751cc0c1a

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

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

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

8bf751cc0c1a

image.png

以下开始创建分区

8bf751cc0c1a

格式化分区

8bf751cc0c1a

挂载分区

8bf751cc0c1a

扩容:(需要关机)

8bf751cc0c1a

卸载分区

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值