当前位置: 首页 > 工具软件 > fdisk > 使用案例 >

ubuntu命令行fdisk扩展分区

韩宜春
2023-12-01

fdisk扩展分区

root@cmp:/home/cmp/Downloads# fdisk /dev/sda

Welcome to fdisk (util-linux 2.34).
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/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: VMware Virtual S
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: gpt
Disk identifier: 3EDB8DA1-4B24-4EB9-B3E6-60F47A913588

Device         Start       End   Sectors Size Type
/dev/sda1       2048      4095      2048   1M BIOS boot
/dev/sda2       4096 104855551 104851456  50G Linux filesystem
/dev/sda3  104855552 209715166 104859615  50G Linux filesystem

Command (m for help): d
Partition number (1-3, default 3): 

Partition 3 has been deleted.

Command (m for help): p
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: VMware Virtual S
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: gpt
Disk identifier: 3EDB8DA1-4B24-4EB9-B3E6-60F47A913588

Device     Start       End   Sectors Size Type
/dev/sda1   2048      4095      2048   1M BIOS boot
/dev/sda2   4096 104855551 104851456  50G Linux filesystem

Command (m for help): d
Partition number (1,2, default 2): 

Partition 2 has been deleted.

Command (m for help): p
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: VMware Virtual S
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: gpt
Disk identifier: 3EDB8DA1-4B24-4EB9-B3E6-60F47A913588

Device     Start   End Sectors Size Type
/dev/sda1   2048  4095    2048   1M BIOS boot

Command (m for help): n
Partition number (2-128, default 2): 
First sector (4096-209715166, default 4096): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (4096-209715166, default 209715166): 

Created a new partition 2 of type 'Linux filesystem' and of size 100 GiB.
Partition #2 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: Y

The signature will be removed by a write command.

Command (m for help): p           
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: VMware Virtual S
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: gpt
Disk identifier: 3EDB8DA1-4B24-4EB9-B3E6-60F47A913588

Device     Start       End   Sectors  Size Type
/dev/sda1   2048      4095      2048    1M BIOS boot
/dev/sda2   4096 209715166 209711071  100G Linux filesystem

Filesystem/RAID signature on partition 2 will be wiped.

Command (m for help): w
The partition table has been altered.
Syncing disks.

resize2fs更新分区

root@cmp:/home/cmp/Downloads# resize2fs /dev/sda2
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 13
The filesystem on /dev/sda2 is now 26213883 (4k) blocks long.

root@cmp:/home/cmp/Downloads# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           391M  1.7M  389M   1% /run
/dev/sda2        99G   46G   49G  49% /
tmpfs           2.0G   16K  2.0G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/loop1       62M   62M     0 100% /snap/core20/1405
/dev/loop2       62M   62M     0 100% /snap/core20/1376
/dev/loop0       56M   56M     0 100% /snap/core18/2344
/dev/loop3       68M   68M     0 100% /snap/lxd/21835
/dev/loop4       45M   45M     0 100% /snap/snapd/15534
/dev/loop5       44M   44M     0 100% /snap/snapd/15177
/dev/loop6       68M   68M     0 100% /snap/lxd/22753
tmpfs           391M     0  391M   0% /run/user/1000
 类似资料: