当前位置:   article > 正文

Linux 阿里云挂载新的硬盘 和 阿里云扩展根分区_阿里云 挂载 扩容根结点

阿里云 挂载 扩容根结点

1. 查看设备挂载的情况

  1. [root@192 ~]# lsblk
  2. NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  3. vda    253:0    0   40G  0 disk 
  4. └─vda1 253:1    0   40G  0 part /
  5. vdb    253:16   0  100G  0 disk 

2.分区

  1. [root@192 ~]# fdisk /dev/vd
  2. vda   vda1  vdb   
  3. [root@192 ~]# fdisk /dev/vdb 
  4. Welcome to fdisk (util-linux 2.23.2).
  5. Changes will remain in memory only, until you decide to write them.
  6. Be careful before using the write command.
  7. Device does not contain a recognized partition table
  8. Building a new DOS disklabel with disk identifier 0x538b9e95.
  9. Command (m for help): n
  10. Partition type:
  11.    p   primary (0 primary, 0 extended, 4 free)
  12.    e   extended
  13. Select (default p): p
  14. Partition number (1-4, default 1): 
  15. First sector (2048-209715199, default 2048): 
  16. Using default value 2048
  17. Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): 
  18. Using default value 209715199
  19. Partition 1 of type Linux and of size 100 GiB is set
  20. Command (m for help): w
  21. The partition table has been altered!

3. 格式化硬盘

 mkfs.ext4 /dev/vdb1

4. 创建挂载点,例如

mkdir /database

5. 挂载硬盘

 mount /dev/vdb1 /database

6. 查看结果

df -h

7. 设置系统自动挂载硬盘

  1. vi /etc/fstab
  2. /dev/vdb1 /database ext4 defaults 0 0

 

 

扩展根分区

https://help.aliyun.com/document_detail/111738.html?spm=a2c4g.11186623.6.801.4faf7f67tzAtVh阿里链接

1,买好磁盘后可以看到vda 还有100G 的空间

  1. [root@192 ~]# lsblk
  2. NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  3. vda    253:0    0  150G  0 disk 
  4. └─vda1 253:1    0   40G  0 part /
  5. vdb    253:16   0  100G  0 disk 
  6. └─vdb1 253:17   0  100G  0 part /database
  7. [root@192 ~]# growpart /dev/vda 1
  8. CHANGED: partition=1 start=2048 old: size=83873317 end=83875365 new: size=314566717,end=314568765


2,看到磁盘块满了,下面开始扩容

  1. [root@192 ~]# df -h
  2. Filesystem      Size  Used Avail Use% Mounted on
  3. /dev/vda1        40G   36G  1.5G  97% /
  4. devtmpfs        3.9G     0  3.9G   0% /dev
  5. tmpfs           3.9G     0  3.9G   0% /dev/shm
  6. tmpfs           3.9G 1000K  3.9G   1% /run
  7. tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
  8. /dev/vdb1        99G  360M   93G   1% /database
  9. overlay          40G   36G  1.5G  97%

3.命令调用growpart为需要扩容的云盘和对应的第几个分区扩容

  1. [root@192 ~]# growpart /dev/vda 1
  2. CHANGED: partition=1 start=2048 old: size=83873317 end=83875365 new: size=314566717,end=314568765

4.运行resize2fs <PartitionName>命令调用resize2fs扩容文件系统。

  1. [root@192 ~]# resize2fs /dev/vda1
  2. resize2fs 1.42.9 (28-Dec-2013)
  3. Filesystem at /dev/vda1 is mounted on /; on-line resizing required
  4. old_desc_blocks = 3, new_desc_blocks = 10
  5. The filesystem on /dev/vda1 is now 39320839 blocks long.

5.运行df -h命令查看云盘分区大小

  1. [root@192 ~]# df -h
  2. Filesystem      Size  Used Avail Use% Mounted on
  3. /dev/vda1       148G   37G  105G  27% /
  4. devtmpfs        3.9G     0  3.9G   0% /dev
  5. tmpfs           3.9G     0  3.9G   0% /dev/shm
  6. tmpfs           3.9G 1000K  3.9G   1% /run
  7. tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
  8. /dev/vdb1        99G  360M   93G   1% /database
  9. overlay         148G   37G  105G  27%


 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/188505
推荐阅读
相关标签
  

闽ICP备14008679号