linux系统并分区?linux创建分区

各位老铁们好,相信很多人对linux系统并分区都不是特别的了解,因此呢,今天就来为大家分享下关于linux系统并分区以及linux创建分区的问题知识,还望可以帮助大家,解决大家的一些困惑,下面一起来看看吧!

linux删除分区命令

linux系统下删除分区命令是什么呢?下面是具体介绍:

linux系统下删除分区命令是:fdisk命令。

1、fdisk命令简介:

fdisk- Partition table manipulator for Linux,译成中文的意思是磁盘分区表操作工具,其实就是分区工具。fdsik能划分磁盘成为若干个区,同时也能为每个分区指定分区的文件系统,比如linux、fat32、 linux、linux swap、fat16以及其实类Unix类操作系统的文件系统等;当然我们用fdisk对磁盘操作分区时,并不是一个终点,我们还要对分区进行格式化所需要的文件系统;这样一个分区才能使用;这和DOS中的fdisk是类似的。

2、fdisk操作硬盘的命令格式:

[root@localhost beinan]# fdisk设备

通过 fdisk-l得知/dev/hda或者/dev/sda设备;如果想再添加或者删除

一些分区,可以用

[root@localhost beinan]# fdisk/dev/hda

[root@localhost beinan]# fdisk/dev/sda

3、fdisk的说明:

通过 fdisk设备,进入相应设备的操作时,会有如下的提示。

[root@localhost beinan]# fdisk/dev/sda

Command(m for help):在这里按m,就会输出帮助;

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition注:这是删除一个分区的动作;

l list known partition types注:l是列出分区类型,以供我们设置相应分区的类型;

m print this menu注:m是列出帮助信息;

n add a new partition注:添加一个分区;

o create a new empty DOS partition table

p print the partition table注:p列出分区表;

q quit without saving changes注:不保存退出;

s create a new empty Sun disklabel

t change a partitions system id注:t改变分区类型;

u change display/entry units

v verify the partition table

w write table to disk and exit注:把分区表写入硬盘并退出;

x extra functionality(experts only)注:扩展应用,专家功能;12345678910111213141516171819

举例:

列出当前操作硬盘的分区情况,用p:

Command(m for help): p

Disk/dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units= cylinders of 16128* 512= 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32(LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

/dev/sda6 51 76 200781 83 Linux123456789

通过fdisk的d指令来删除一个分区:

Command(m for help): p注:列出分区情况;

Disk/dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units= cylinders of 16128* 512= 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32(LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

/dev/sda6 51 76 200781 83 Linux

Command(m for help): d注:执行删除分区指定;

Partition number(1-6): 6注:我想删除 sda6,就在这里输入 6;

Command(m for help): p注:再查看一下硬盘分区情况,看是否删除了?

Disk/dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units= cylinders of 16128* 512= 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32(LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

Command(m for help):1234567891011121314151617181920

注意:删除分区时要小心,请看好分区的序号,如果您删除了扩展分区,扩展分区之下的逻辑分区都会删除;所以操作时一定要小心;如果知道自己操作错了,用q不保存退出;在分区操作错了时,千万不要输入w保存退出。

安装linux必须创建的两个分区

安装Linux时,通常必须创建的两个分区是根分区(/)和交换分区(swap)。

在安装Linux操作系统时,分区的创建是至关重要的步骤。分区是对硬盘空间进行逻辑划分的一种方式,它允许操作系统更有效地管理数据。虽然现代Linux系统可以非常灵活地进行分区设置,并且有些安装场景可能不一定严格要求创建两个分区,但通常来说,根分区和交换分区是最基本也是最常见的两个必须创建的分区。

1.根分区(/):

根分区是Linux系统中最重要的分区,它包含了操作系统的主要文件和目录结构。系统的核心文件、大多数应用程序、用户的主目录以及系统配置文件等都存储在根分区中。根分区是Linux系统启动时首先挂载的分区,如果根分区出现问题,系统将无法正常运行。因此,在安装Linux时,为根分区分配足够的空间是非常重要的。

2.交换分区(swap):

交换分区在Linux系统中扮演了类似Windows系统中虚拟内存的角色。当系统的物理内存(RAM)不足时,系统会使用交换分区作为临时的内存扩展。交换分区中存储的数据是在系统运行时被换出到磁盘上的,这样可以释放物理内存供其他进程使用。虽然交换分区的使用会降低系统的性能(因为磁盘访问速度远低于内存),但在某些情况下,它是防止系统崩溃的关键。交换分区的大小通常建议为物理内存大小的1到2倍,但这也取决于具体的使用场景。

在实际安装过程中,根据用户的需求和硬盘空间的大小,还可以创建其他分区,如/home分区用于存储用户数据,/boot分区用于存储启动文件等。但这些分区都不是必须创建的,而根分区和交换分区则是安装Linux时最基本的分区需求。

linux磁盘分区方法

产品型号:Thinkpad E15

系统版本:centos8

案例:在sdb盘上建一个分区,大小为1G

在虚拟机上添加一块硬盘

例:对sdb这块盘划分一个100M的分区出来

[root@xuegod63~]# fdisk/dev/sdb

...

Command(m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition删除分区

g create a new empty GPT partition table

G create an IRIX(SGI) partition table

l list known partition types显示分区类型

m print this menu打印帮助菜单

n add a new partition添加新的分区

o create a new empty DOS partition table

p print the partition table显示分区表

q quit without saving changes不保存,退出

s create a new empty Sun disklabel

t change a partitions system id改变分区类型

u change display/entry units

v verify the partition table

w write table to disk and exit写分区表信息到硬盘,保存操作并退出

x extra functionality(experts only)

Command(m for help): p-----打印分区表

Command(m for help): n----新建一个分区

Partition type:

p primary(2 primary, 0 extended, 2 free) p:主分区

e extended e:扩展分区

Select(default p):--#直接默认

Using default response p

Partition number(1,4, default 1):---#直接默认

First sector(1230848-41943039, default 1230848):---#直接默认

Using default value 1230848

Last sector,+sectors or+size{K,M,G}(1230848-41943039, default 41943039):+1G

#输入分区大小

Partition 3 of type Linux and of size 1 GiB is set

Command(m for help): w#保存退出

格式化并创建文件系统

[root@xuegod63~]# mkfs.xfs/dev/sdb1

注:-f参数可以对已经存在文件系统的分区,强制格式化

[root@xuegod63~]# mkdir/sdb1#创建挂载点

[root@xuegod63~]# mount/dev/sdb1/sdb1/#挂载

[root@xuegod63~]# df-h#查看

阅读剩余
THE END