美文网首页
Linux扩容根目录的分区大小

Linux扩容根目录的分区大小

作者: Armlinux | 来源:发表于2023-04-20 15:17 被阅读0次

    1. 仅是参考,比较危险,出问题自负

    root@CentOS-7:~# fdisk -l  /dev/mmcblk0
    
    Disk /dev/mmcblk0: 31.3 GB, 31268536320 bytes, 61071360 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: 0x240d1f0f
    
            Device Boot      Start         End      Blocks   Id  System
    /dev/mmcblk0p1           32831    5119999          ...   83  Linux
    

    看到/dev/mmcblk0p1 起始扇区 32831

    cat > fdisk.cmd <<-EOF
    d
    
    n
    p
    1
    32831
    w
    EOF
    echo "fdisk.cmd done!"
    echo "disk partition..."
    fdisk /dev/mmcblk1 < fdisk.cmd
    mount -o remount,rw /
    resize2fs /dev/mmcblk0p1 
    df -h
    

    2. 安全一点的办法

    centos

    #yum update
    yum install cloud-utils-growpart -y 
    

    debian

    # apt-get  update
    apt-get install cloud-guest-utils xfsprogs -y 
    

    扩展mmcblk0设备的第1分区

    growpart /dev/mmcblk0 1 
    resize2fs /dev/mmcblk0p1
    

    相关文章

      网友评论

          本文标题:Linux扩容根目录的分区大小

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