vdb卷分区及扩容

  • Post author:
  • Post category:其他


记一些基础的东西:


1、volume attach instance后,进入instance进行分区格式化,第二块盘名字为vdb:

[root@test ~]# fdisk -l


Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000b2270

Device Boot      Start         End      Blocks   Id  System

/dev/vda1   *        2048   104856254    52427103+  83  Linux

Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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


开始分区:

[root@test ~]# fdisk /dev/vdb

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.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x7ecd0300.

Command (m for help): p

Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x7ecd0300

Device Boot      Start         End      Blocks   Id  System

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-209715199, default 2048):

Using default value 2048

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

Using default value 209715199

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

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.


分区结束后,查看:

[root@test ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000b2270

Device Boot      Start         End      Blocks   Id  System

/dev/vda1   *        2048   104856254    52427103+  83  Linux

Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x7ecd0300

Device Boot      Start         End      Blocks   Id  System

/dev/vdb1            2048   209715199   104856576   83  Linux


如果不格式化,直接去挂载,报错:

[root@test ~]# mount /dev/vdb1 /mnt

mount: /dev/vdb1 is write-protected, mounting read-only

mount: unknown filesystem type ‘(null)’


格式化:

[root@test ~]# mkfs.ext4 /dev/vdb1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

6553600 inodes, 26214144 blocks

1310707 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2174746624

800 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


挂载:

[root@test ~]# mount /dev/vdb1 /mnt

修改/etc/fstab:添加/dev/vdb1 /mnt ext4 defaults 0 0重启后自动挂载,永久生效


2、extend volume vdb后,重新attach:

[root@test ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000b2270

Device Boot      Start         End      Blocks   Id  System

/dev/vda1   *        2048   104856254    52427103+  83  Linux

Disk /dev/vdb: 128.8 GB, 128849018880 bytes, 251658240 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: 0x7ecd0300

Device Boot      Start         End      Blocks   Id  System

/dev/vdb1            2048   209715199   104856576   83  Linux


对vdb1进行扩容:

[root@test ~]# fdisk /dev/vdb

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/vdb: 128.8 GB, 128849018880 bytes, 251658240 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: 0x7ecd0300

Device Boot      Start         End      Blocks   Id  System

/dev/vdb1            2048   209715199   104856576   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-251658239, default 2048):

Using default value 2048

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

Using default value 251658239

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

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.


检查分区完整性:

[root@test ~]# e2fsck -f /dev/vdb1

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/vdb1: 11/6553600 files (0.0% non-contiguous), 459544/26214144 blocks


分区扩容:

[root@test ~]# resize2fs /dev/vdb1

resize2fs 1.42.9 (28-Dec-2013)

Resizing the filesystem on /dev/vdb1 to 31457024 (4k) blocks.

The filesystem on /dev/vdb1 is now 31457024 blocks long.


挂载:

[root@test ~]# mount /dev/vdb1 /mnt

[root@test ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/vda1        50G  1.7G   49G   4% /

devtmpfs        1.9G     0  1.9G   0% /dev

tmpfs           1.9G     0  1.9G   0% /dev/shm

tmpfs           1.9G   17M  1.9G   1% /run

tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup

overlay          50G  1.7G   49G   4% /var/lib/docker/overlay/b00e0a4755ea2b6470c44ae489e832a08b836e933579f5b4e843626bb7386bda/merged

shm              64M     0   64M   0% /var/lib/docker/containers/8ab930a7c7cf1699b1e5b58ee7779fac54600ea3657411a7994fa6889042406a/shm

tmpfs           380M     0  380M   0% /run/user/0

/dev/vdb1       118G   60M  112G   1% /mnt



版权声明:本文为yasyal515原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。