laohoo@laohoo-virtual-machine:~$ sudo fdisk /dev/sdb [sudo] password for laohoo:
Welcome to fdisk (util-linux 2.37.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x43d3de27.
Command (m forhelp): p Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 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: dos Disk identifier: 0x43d3de27
Command (m forhelp): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): First sector (2048-167772159, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-167772159, default 167772159): +256m
Created a new partition 1 of type'Linux' and of size 256 MiB.
Command (m forhelp): p Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 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: dos Disk identifier: 0x43d3de27
Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 526335 524288 256M 83 Linux
Command (m forhelp): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): p Partition number (2-4, default 2): First sector (526336-167772159, default 526336): Last sector, +/-sectors or +/-size{K,M,G,T,P} (526336-167772159, default 167772159): +4g
Created a new partition 2 of type'Linux' and of size 4 GiB.
Command (m forhelp): p Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 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: dos Disk identifier: 0x43d3de27
Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 526335 524288 256M 83 Linux /dev/sdb2 526336 8914943 8388608 4G 83 Linux
Command (m forhelp): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): p Partition number (3,4, default 3): First sector (8914944-167772159, default 8914944): Last sector, +/-sectors or +/-size{K,M,G,T,P} (8914944-167772159, default 167772159):
Created a new partition 3 of type'Linux' and of size 75.7 GiB.
Command (m forhelp): p Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 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: dos Disk identifier: 0x43d3de27
Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 526335 524288 256M 83 Linux /dev/sdb2 526336 8914943 8388608 4G 83 Linux /dev/sdb3 8914944 167772159 158857216 75.7G 83 Linux
Command (m forhelp): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
laohoo@laohoo-virtual-machine:~$ sudo mkfs -v -t ext4 /dev/sdb1 [sudo] password for laohoo: mke2fs 1.46.5 (30-Dec-2021) fs_types for mke2fs.conf resolution: 'ext4', 'small' Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 65536 inodes, 65536 blocks 3276 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=67108864 2 block groups 32768 blocks per group, 32768 fragments per group 32768 inodes per group Filesystem UUID: b7750a3f-1ad6-4c4a-b288-c70348502c3c Superblock backups stored on blocks: 32768
Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
laohoo@laohoo-virtual-machine:~$ sudo mkfs -v -T small -t ext4 /dev/sdb3 mke2fs 1.46.5 (30-Dec-2021) fs_types for mke2fs.conf resolution: 'ext4', 'small' Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 19857408 inodes, 19857152 blocks 992857 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2168455168 606 block groups 32768 blocks per group, 32768 fragments per group 32768 inodes per group Filesystem UUID: ffb2ba6a-a067-4a61-94fc-8e20787a412d Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424
Allocating group tables: done Writing inode tables: done Creating journal (131072 blocks): done Writing superblocks and filesystem accounting information: done
将 swap 分区(/dev/sdb2)设置为交换分区
1
sudo mkswap /dev/sdb2
操作过程如下:
1 2 3 4
laohoo@laohoo-virtual-machine:~$ sudo mkswap /dev/sdb2 Setting up swapspace version 1, size = 4 GiB (4294963200 bytes) no label, UUID=1c107759-3120-4944-ac3f-2d686cb658d2