linux对一个新硬盘sdb进分区,要求划分有两个主分区,一个扩展分区,两个逻辑分区,分区大小自行决定
时间: 2024-05-04 19:17:51 浏览: 208
linux系统硬盘分区
5星 · 资源好评率100%
好的,下面是对新硬盘sdb进行分区的步骤:
1. 使用fdisk命令对硬盘进行分区,命令如下:
```
sudo fdisk /dev/sdb
```
2. 输入`n`创建新分区,选择`p`创建主分区,输入分区号(1或2),然后输入起始扇区和结束扇区,这里以默认值为例。
```
Command (m for help): 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): 1
First sector (2048-10485759, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759):
Created a new partition 1 of type 'Linux' and of size 5 GiB.
```
3. 接着创建第二个主分区,同样按照上述步骤操作。
```
Command (m for help): 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): 2
First sector (10485760-10485759, default 10485760):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (10485760-10485759, default 10485759):
Created a new partition 2 of type 'Linux' and of size 5 GiB.
```
4. 创建扩展分区,同样按照上述步骤操作。
```
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): e
Partition number (2-4, default 3):
First sector (10485760-10485759, default 10485760):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (10485760-10485759, default 10485759):
Created a new partition 3 of type 'Extended' and of size 9 GiB.
```
5. 接下来创建两个逻辑分区,同样按照上述步骤操作。
```
Command (m for help): n
Partition type
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (10485761-10485759, default 10485761):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (10485761-10485759, default 10485759):
Created a new partition 5 of type 'Linux' and of size 4 GiB.
Command (m for help): n
Partition type
p primary (2 primary, 1 extended, 0 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (12582912-10485759, default 12582912):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (12582912-10485759, default 10485759):
Created a new partition 6 of type 'Linux' and of size 1 GiB.
```
6. 最后使用`w`命令保存分区表。
```
Command (m for help): w
The partition table has been altered.
Syncing disks.
```
7. 分区完成后,可以使用`lsblk`命令查看分区信息。
```
$ lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 5G 0 part
├─sdb2 8:18 0 5G 0 part
├─sdb3 8:19 0 9G 0 part
├─sdb5 8:21 0 4G 0 part
└─sdb6 8:22 0 1G 0 part
```
阅读全文