使用gparted工具分区。
apt install gparted
gparted
以下尝试是手动分区和挂载:
1.查看磁盘剩余空间
df -hl
2.查看磁盘空间状态,确认总空间大小和未分配空间大小
fdisk -l
3.进入磁盘分配选项
fdisk /dev/sda
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
输入命令:
n,新建一个新的分区
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
p,主分区,e,扩展分区
Select (default p): e
Partition number (2-4, default 2): 2
First sector (41940992-104857599, default 41940992):
Last sector, +sectors or +size{K,M,G,T,P} (41940992-104857599, default 104857599):
Created a new partition 2 of type 'Extended' and of size 30 GiB.
w,保存退出
4.再查看磁盘空间,分区完成
fdisk -l
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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: 0xbe6ff238
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 41940991 41938944 20G 83 Linux
/dev/sda2 41940992 104857599 62916608 30G 5 Extended
5.格式化
mkfs -t ext4 /dev/sda2
6.临时挂在到home目录,没有该目录新建一个
mount /dev/sda2 /mnt/home
7.修改分区id为LVM,LVM为Logical Volume Manager
fdisk /dev/sda
t,改变分区系统id
8e,修改为LVM类型
Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Extended' to 'Linux LVM'.
Command (m for help): w
The partition table has been altered.
Syncing disks.
8.扩展新分区
pvcreate /dev/sda2
apt install lvm2
//pvcreate指令用于将物理硬盘分区初始化为物理卷,以便被LVM使用。要创建物理卷必须首先对硬盘进行分区,并且将硬盘分区的类型设置为“8e”后,才能使用pvcreate指令将分区初始化为物理卷。
pvcreate /dev/sda2
Device /dev/sda2 excluded by a filter.