ubuntu 20 เพิ่มขนาด disk command บน Vmware workstation

จากหัวข้อ ในส่วนของ VM ให้ไปที่
Expand disk capacity ในส่วนตั้งค่า disk

 

จากนั้นเข้าไปที่ ubuntu  โดยจะขอ ปะไว้ก่อน เนื่องจากยังสรุปคำสั่งที่แน่นอนไม่ได้ หากได้ชัดแล้วจะมาสรุปอีกที

Resize partitions and file systems (ทดสอบบน Ubuntu 20.0.4 แล้ว)

  1. Run the following command to check the size of the existing disk:
    fdisk -l
    In the following example command output, the size of the /dev/vda disk is 100 GiB:

    [root@ecshost ~]# fdisk -l
    Disk /dev/vda: 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: 0x000bad2b
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048    83886046    41941999   83  Linux
  2. Run the following command to check the size of the partition and the type of the file system:
    df -Th
    In the following example command output, the size of the /dev/vda1 partition is 40 GiB, and the type of the file system is ext4:

    [root@ecshost ~]# df -Th
    Filesystem     Type      Size  Used Avail Use% Mounted on
    devtmpfs       devtmpfs  869M     0  869M   0% /dev
    tmpfs          tmpfs     879M     0  879M   0% /dev/shm
    tmpfs          tmpfs     879M  460K  878M   1% /run
    tmpfs          tmpfs     879M     0  879M   0% /sys/fs/cgroup
    /dev/vda1      ext4       40G  1.8G   36G   5% /
    tmpfs          tmpfs     176M     0  176M   0% /run/user/0
  3. Run the following command to resize partitions:
    growpart <DeviceName> <PartionNumber>
    In the following example command output, the first partition /dev/vda1 of the system disk is resized:

    [root@ecshost ~]# growpart /dev/vda 1
    CHANGED: partition=1 start=2048 old: size=83883999 end=83886047 new: size=209713119 end=209715167
    Note If the unexpected output in sfdisk –version [sfdisk, from util-linux 2.23.2] error is prompted when the growpart /dev/vda 1 command is run, try to change the character encoding to fix the problem. For more information, see FAQ.
  4. Resize the file system.
    Use the df -Th command to check the type of the file system. Then, select one of the following methods to resize the file system based on the type of the file system:

    • If the type of the file system is ext* such as ext3 and ext4, run the following command to resize the file system:
      resize2fs <PartitionName>
      In the following example, the file system of the /dev/vda1 partition is resized:

      [root@ecshost ~]# resize2fs /dev/vda1
      resize2fs 1.42.9 (28-Dec-2013)
      Filesystem at /dev/vda1 is mounted on /; on-line resizing required
      old_desc_blocks = 3, new_desc_blocks = 7
      The filesystem on /dev/vda1 is now 26214139 blocks long.
    • If the type of the file system is XFS, run the following command to resize the file system:
      xfs_growfs <mountpoint>

      In the following example, the file system of the /dev/vda1 partition is resized. The mount point of the /dev/vda1 partition is the / root directory.

      [root@ecshost ~]# xfs_growfs /
      meta-data=/dev/vda1              isize=512    agcount=13, agsize=1310656 blks
               =                       sectsz=512   attr=2, projid32bit=1
               =                       crc=1        finobt=1, sparse=1, rmapbt=0
               =                       reflink=1
      data     =                       bsize=4096   blocks=15728379, imaxpct=25
               =                       sunit=0      swidth=0 blks
      naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
      log      =internal log           bsize=4096   blocks=2560, version=2
               =                       sectsz=512   sunit=0 blks, lazy-count=1
      realtime =none                   extsz=4096   blocks=0, rtextents=0
      data blocks changed from 15728379 to 20971259
      Note The commands may vary depending on versions of the xfs_growfs tool. Run xfs_growfs –help to check the corresponding commands.
  5. Run the following command to check the size of the disk partition:
    df -h
    The following example shows that the size of the /dev/vda1 partition is 100 GiB. This indicates that the partition is resized.

    [root@ecshost ~]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        869M     0  869M   0% /dev
    tmpfs           879M     0  879M   0% /dev/shm
    tmpfs           879M  492K  878M   1% /run
    tmpfs           879M     0  879M   0% /sys/fs/cgroup
    /dev/vda1        99G  1.8G   93G   2% /
    tmpfs           176M     0  176M   0% /run/user/0

https://partners-intl.aliyun.com/help/doc-detail/111738.htm

 

 

ที่มา https://www.login.in.th/index.php?rp=/knowledgebase/294/Resize-partitions-and-file-systems-%E0%B8%97%E0%B8%94%E0%B8%AA%E0%B8%AD%E0%B8%9A%E0%B8%9A%E0%B8%99-Ubuntu-20.0.4-%E0%B9%81%E0%B8%A5%E0%B8%A7.html

ใส่ความเห็น

อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น ช่องที่ต้องการถูกทำเครื่องหมาย *