zoukankan      html  css  js  c++  java
  • 扩容数据盘_Linux

    扩容数据盘_Linux_扩容云盘_云盘_用户指南_云服务器 ECS-阿里云 https://help.aliyun.com/document_detail/25452.html

    磁盘扩容付费后:

    在控制台上扩容数据盘的磁盘空间后,

    【扩容的 关键是理解扇区 】

    [root@d1 ~]# fdisk -l

    磁盘 /dev/sda:500.1 GB, 500107862016 字节,976773168 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 4096 字节
    I/O 大小(最小/最佳):4096 字节 / 4096 字节
    磁盘标签类型:dos
    磁盘标识符:0x00006125

    设备 Boot Start End Blocks Id System
    /dev/sda1 * 2048 2099199 1048576 83 Linux
    /dev/sda2 2099200 976773119 487336960 8e Linux LVM

    磁盘 /dev/mapper/cl-root:53.7 GB, 53687091200 字节,104857600 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 4096 字节
    I/O 大小(最小/最佳):4096 字节 / 4096 字节


    磁盘 /dev/mapper/cl-swap:8321 MB, 8321499136 字节,16252928 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 4096 字节
    I/O 大小(最小/最佳):4096 字节 / 4096 字节


    磁盘 /dev/mapper/cl-home:437.0 GB, 437017116672 字节,853549056 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 4096 字节
    I/O 大小(最小/最佳):4096 字节 / 4096 字节

    [root@test ~]# fdisk -l

    Disk /dev/vda: 42.9 GB, 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
    Disk label type: dos
    Disk identifier: 0x0009e68a

    Device Boot Start End Blocks Id System
    /dev/vda1 * 2048 83884031 41940992 83 Linux

    Disk /dev/vdb: 1192.9 GB, 1192927166464 bytes, 2329935872 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: 0x51281dfc

    Device Boot Start End Blocks Id System
    /dev/vdb1 2048 2329935871 1164966912 83 Linux
    [root@test ~]#

    Linux 格式化和挂载数据盘_步骤 4:格式化数据盘_个人版快速入门_云服务器 ECS-阿里云 https://help.aliyun.com/document_detail/25426.html

    扩容数据盘_Linux_扩容云盘_云盘_用户指南_云服务器 ECS-阿里云 https://help.aliyun.com/document_detail/25452.html

    【扩容与挂载】

    扩容需要先卸载,再删除旧的分区,再分区

    挂载是是直接分区

    1. 运行 umount 命令卸载主分区。
       
      umount /dev/vdb1
        说明
      使用 df -h 查看是否卸载成功,如果看不到 /dev/vdb1 的信息表示卸载成功。以下为示例输出结果。
       
      
      [root@iXXXXXX ~]# df -h
      Filesystem Size Used Avail Use% Mounted on
      /dev/vda1 40G 1.5G 36G 4% /
      devtmpfs 487M 0 487M 0% /dev
      tmpfs 497M 0 497M 0% /dev/shm
      tmpfs 497M 312K 496M 1% /run
      tmpfs 497M 0 497M 0% /sys/fs/cgroup
      tmpfs 100M 0 100M 0% /run/user/0
    2. 使用 fdisk 命令删除原来的分区并创建新分区:
        说明
      如果您使用 parted 工具操作分区,不能与 fdisk 交叉使用,否则会导致分区的起始扇区不一致。关于parted 工具的使用说明可以参考这里
      1. 运行命令 fdisk -l 罗列分区信息并记录扩容前数据盘的最终容量、起始扇区(First sector)位置。
      2. 运行命令 fdisk [数据盘设备名] 进入 fdisk 界面。本示例中,命令为 fdisk /dev/vdb
      3. 输入 d 并按回车键,删除原来的分区。
          说明
        删除分区不会造成数据盘内数据的丢失。
      4. 输入 n 并按回车键,开始创建新的分区。
      5. 输入 p 并按回车键,选择创建主分区。因为创建的是一个单分区数据盘,所以只需要创建主分区。
          说明
        如果要创建4个以上的分区,您应该创建至少一个扩展分区,即选择 e
      6. 输入分区编号并按回车键。因为这里仅创建一个分区,所以输入 1
      7. 输入第一个可用的扇区编号:为了保证数据的一致性,First sector需要与原来的分区保持一致。在本示例中,按回车键采用默认值。
          说明
        如果发现First sector显示的位置和之前记录的不一致,说明之前可能使用 parted 来分区,那么就停止当前的 fdisk 操作,使用 parted 重新操作。
      8. 输入最后一个扇区编号:因为这里仅创建一个分区,所以按回车键采用默认值。
      9. 输入 wq 并按回车键,开始分区。
         
        
        [root@iXXXXXX ~]# 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): 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):
        Using default response p
        Partition number (1-4, default 1):
        First sector (2048-62914559, default 2048):
        Using default value 2048
        Last sector, +sectors or +size{K,M,G} (2048-62914559, default 62914559):
        Using default value 62914559
        Partition 1 of type Linux and of size 30 GiB is set
        Command (m for help): wq
        The partition table has been altered!
        Calling ioctl() to re-read partition table.
        Syncing disks.
    1. 部分操作系统里,修改分区后可能会重新自动挂载文件系统。建议先执行 df -h 重新查看文件系统空间和使用情况。如果文件系统重新被挂载,执行 umount [文件系统名称] 再次卸载文件系统。
    2. 检查文件系统,并变更文件系统大小。
       
      
      e2fsck -f /dev/vdb1 # 检查文件系统
      resize2fs /dev/vdb1 # 变更文件系统大小
      
      
        说明
      • 使用 e2fsck 时,由于系统需要检查并订正文件系统元数据,所以速度较慢、耗时较长,请耐心等待。
      • 正确使用 e2fsck 和 resize2fs 指令,不会造成原有数据丢失。

      以下为示例输出结果。

       
      
      [root@iXXXXXX ~]# 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/1835008 files (0.0% non-contiguous), 159218/7339776 blocks
      [root@iXXXXXX ~]# resize2fs /dev/vdb1
      resize2fs 1.42.9 (28-Dec-2013)
      Resizing the filesystem on /dev/vdb1 to 7864064 (4k) blocks.
      The filesystem on /dev/vdb1 is now 7864064 blocks long.
    3. 将扩容完成的文件系统挂载到原来的挂载点(如本示例中的 /resizetest)。
       
      mount /dev/vdb1 /resizetest
    4. 查看文件系统空间和使用情况:运行命令 df -h。如果出现扩容后的文件系统信息,说明挂载成功,可以使用扩容后的文件系统了。
       

     扩展分区和文件系统_Linux系统盘_扩容云盘_云盘_块存储_云服务器 ECS-阿里云 https://help.aliyun.com/document_detail/111738.html

     (base) root@test:/showdoc_data# fdisk -l
    Disk /dev/vda: 128 GiB, 137438953472 bytes, 268435456 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: 0xb2ac676a

    Device     Boot Start      End  Sectors Size Id Type
    /dev/vda1  *     2048 83886046 83883999  40G 83 Linux
    (base) root@test:/showdoc_data# df -Th
    Filesystem     Type      Size  Used Avail Use% Mounted on
    udev           devtmpfs  3.9G     0  3.9G   0% /dev
    tmpfs          tmpfs     784M   15M  770M   2% /run
    /dev/vda1      ext4       40G   40G     0 100% /
    tmpfs          tmpfs     3.9G     0  3.9G   0% /dev/shm
    tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
    tmpfs          tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
    tmpfs          tmpfs     784M     0  784M   0% /run/user/0
    overlay        overlay    40G   40G     0 100% /var/lib/docker/overlay2/bde77d4e832ca10fd7b6338f62160bbeb67b9a7d027599935c2b67940a8c05df/merged


    (base) root@test:/showdoc_data# uname -a
    Linux test 4.15.0-91-generic #92-Ubuntu SMP Fri Feb 28 11:09:48 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux


    (base) root@test:/showdoc_data# growpart /dev/vda1
    growpart disk partition
       rewrite partition table so that partition takes up all the space it can
       options:
        -h | --help       print Usage and exit
             --fudge F    if part could be resized, but change would be
                          less than 'F' bytes, do not resize (default: 1048576)
        -N | --dry-run    only report what would be done, show new 'sfdisk -d'
        -v | --verbose    increase verbosity / debug
        -u | --update  R  update the the kernel partition table info after growing
                          this requires kernel support and 'partx --update'
                          R is one of:
                           - 'auto'  : [default] update partition if possible
                           - 'force' : try despite sanity checks (fail on failure)
                           - 'off'   : do not attempt
                           - 'on'    : fail if sanity checks indicate no support

       Example:
        - growpart /dev/sda 1
          Resize partition 1 on /dev/sda
    must supply partition-number


    (base) root@test:/showdoc_data# growpart /dev/vda 1
    CHANGED: partition=1 start=2048 old: size=83883999 end=83886047 new: size=268433375,end=268435423
    (base) root@test:/showdoc_data# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            3.9G     0  3.9G   0% /dev
    tmpfs           784M   15M  770M   2% /run
    /dev/vda1        40G   40G     0 100% /
    tmpfs           3.9G     0  3.9G   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
    tmpfs           784M     0  784M   0% /run/user/0
    overlay          40G   40G     0 100% /var/lib/docker/overlay2/bde77d4e832ca10fd7b6338f62160bbeb67b9a7d027599935c2b67940a8c05df/merged
    (base) root@test:/showdoc_data# df -Th
    Filesystem     Type      Size  Used Avail Use% Mounted on
    udev           devtmpfs  3.9G     0  3.9G   0% /dev
    tmpfs          tmpfs     784M   15M  770M   2% /run
    /dev/vda1      ext4       40G   40G     0 100% /
    tmpfs          tmpfs     3.9G     0  3.9G   0% /dev/shm
    tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
    tmpfs          tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
    tmpfs          tmpfs     784M     0  784M   0% /run/user/0
    overlay        overlay    40G   40G     0 100% /var/lib/docker/overlay2/bde77d4e832ca10fd7b6338f62160bbeb67b9a7d027599935c2b67940a8c05df/merged
    (base) root@test:/showdoc_data# resize2fs /dev/vda1
    resize2fs 1.44.1 (24-Mar-2018)
    Filesystem at /dev/vda1 is mounted on /; on-line resizing required
    old_desc_blocks = 3, new_desc_blocks = 8
    The filesystem on /dev/vda1 is now 33554171 (4k) blocks long.

    (base) root@test:/showdoc_data# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            3.9G     0  3.9G   0% /dev
    tmpfs           784M   15M  770M   2% /run
    /dev/vda1       126G   40G   82G  33% /
    tmpfs           3.9G     0  3.9G   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
    tmpfs           784M     0  784M   0% /run/user/0
    overlay         126G   40G   82G  33% /var/lib/docker/overlay2/bde77d4e832ca10fd7b6338f62160bbeb67b9a7d027599935c2b67940a8c05df/merged
    (base) root@test:/showdoc_data#

  • 相关阅读:
    nodejs入门API之http模块
    nodejs入门API之fs模块
    编程官方文档中的方法参数格式的含义
    vs Code编辑器智能提示功能
    nodejs入门之模块
    git的安装与使用
    TypeScript入门九:TypeScript的模块
    TypeScript入门八:TypeScript的命名空间
    TypeScript入门七:TypeScript的枚举
    TypeScript入门六:TypeScript的泛型
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9649573.html
Copyright © 2011-2022 走看看