linux 创建分区 linux中创建分区的命令

大家好,linux 创建分区相信很多的网友都不是很明白,包括linux中创建分区的命令也是一样,不过没有关系,接下来就来为大家分享关于linux 创建分区和linux中创建分区的命令的一些知识点,大家可以关注收藏,免得下次来找不到哦,下面我们开始吧!

linux下怎么创建分区

Linux下可以用fdisk命令新建分区,方法如下:

1、首先查看硬盘信息,用fdisk-l命令,如果有硬盘有剩余空间就可以对其进行分区。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

[root@bogon桌面]# fdisk-l

Disk/dev/sda: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0x000471ad

Device Boot Start End Blocks Id System

/dev/sda1* 1 26 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 26 3851 30720000 83 Linux

/dev/sda3 3851 4106 2048000 82 Linux swap/ Solaris

/dev/sda4 4106 10444 50912256 5 Extended

/dev/sda5 4106 10444 50911232 83 Linux

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0x00000000

#从上面看出/dev/sda空间已经用完了,/dev/sdb没有使用。

2、下面对/dev/sdb进行分区

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

[root@bogon桌面]# fdisk/dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xfaa2aa49.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode(command'c') and change display units to

sectors(command'u').

Command(m for help): m//输入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

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 partition's system id

u change display/entry units

v verify the partition table

w write table to disk and exit

x extra functionality(experts only)

#fdisk选中/dev/sdb输入m所有基本选项都出现,输入n新建分区

Command(m for help): n

Command action

e extended

p primary partition(1-4)

3、有扩展分区和主分区,逻辑分区在扩展分区中建立。注意到括号中的1-4,最多只能建四个主分区(包括扩展分区)。先建一个主分区:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

Command(m for help): n

Command action

e extended

p primary partition(1-4)

p#建主分区

Partition number(1-4): 1#分区号为1

First cylinder(1-2610, default 1):#直接回车默认从第一个柱面开始划分

Using default value 1

Last

cylinder,+cylinders or+size{K,M,G}(1-2610, default 2610):+2G

#加空间大小,这里有很多种选择:+后面单位可以接M,G,K(记得要大写)表示划分你所加的空间,也可以是柱面数。不管怎样都不能超过该磁盘剩余的空间否则无效。

Command(m for help): p#分好后查看分区信息,刚所做的所有一目了然。

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System

/dev/sdb1 1 262 2104483+ 83 Linux

4、同上所述建立扩展分区:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

Command(m for help): n

Command action

e extended

p primary partition(1-4)

e#建立扩展分区

Partition number(1-4): 4

First cylinder(263-2610, default 263):

Using default value 263

Last cylinder,+cylinders or+size{K,M,G}(263-2610, default 2610):+4G

Command(m for help): p

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System

/dev/sdb1 1 262 2104483+ 83 Linux

/dev/sdb4 263 785 4200997+ 5 Extended

5、扩展分区建好就可以在扩展分区建立逻辑分区了

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

Command(m for help): n

Command action

l logical(5 or over)

p primary partition(1-4)

l#建逻辑分区

First cylinder(263-785, default 263):

Using default value 263

Last cylinder,+cylinders or+size{K,M,G}(263-785, default 785):+2G

Command(m for help): p

Disk/dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units= cylinders of 16065* 512= 8225280 bytes

Sector size(logical/physical): 512 bytes/ 512 bytes

I/O size(minimum/optimal): 512 bytes/ 512 bytes

Disk identifier: 0xfaa2aa49

Device Boot Start End Blocks Id System

/dev/sdb1 1 262 2104483+ 83 Linux

/dev/sdb4 263 785 4200997+ 5 Extended

/dev/sdb5 263 524 2104483+ 83 Linux

6、上面显示已经建好一个主分区,一个逻辑分区,但是这些现在还没有生效,需要保存退出。

1

2

3

4

5

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

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

linux创建分区 swap、/、/boot 分区分别是什么意思

1、boot分区

在Linux中,boot是存储内核及在引导过程中使用文件的分区,是启动Linux时使用的一些核心文件;在boot中包括了系统kernel的配置文件、启动管理程序GRUB的目录、启动时的模块供应的主要来源Initrd文件和vmlinuz文件。

/boot分区就是操作系统的内核及在引导过程中使用的文件,一般是几年前的版本要求划分的一个区,大小为100MB左右,但现在的新版本都不需要对这个分区进行单独划分,也就是说你完全可以不分/boot。

安装Linux只要求两个基本分区,即根分区及交换分区,如果你的磁盘空间足够大,可以多划分空间给根分区,你也可以把常用的目录新建到桌面,如下载的软件包,放到桌面不影响你进入Linux系统的速度,当然这要求你有足够大的根分区。

2、swap分区

swap就是Linux下的虚拟内存分区,它的作用是在物理内存使用完之后,将磁盘空间虚拟成内存来使用。

它和Windows系统的交换文件作用类似,但是它是一段连续的磁盘空间,并且对用户不可见。

需要注意的是,虽然这个swap分区能够作为虚拟的内存,但它的速度比物理内存可是慢多了,因此如果需要更快的速度的话,并不能寄厚望于SWAP,最好的办法仍然是极大物理内存。SWAP分区只是临时的解决办法。

交换分区的合理值一般在内存的2倍左右?一种流行的说法是,安装Linux系统时,交换分区swap的大小应该是内存的两倍。也就是说,如果内存是2G,那么就应该分出4G的硬盘空间作为交换空间。其实这是严重的浪费。真实的情况是:可以根据你系统内存的大小,以及所使用的程序,自行决定交换分区的大小,甚至可以完全不用交换分区。

3、根分区

所谓根分区,说白了就是系统分区,是root分区,所有的东西都放在这里面。

Linux是一个树形文件系统,根分区就是它的root节点,任何的目录文件都会挂在根节点以下。Linux只有一个根。你可以给你的硬盘进行分区,但是,分区设备一定挂载到Linux根目录下的指定位置,如/usr、/var、/home等。如果要对分区进行操作的话,只能到分区所挂载的目录中进行操作。所以,不管对硬盘分多少个区,都要将这些分区挂载到根目录底下才可以使用。

Linux中如何创建新分区啊

Linux中创建新分区步骤如下。

1、查看当前系统磁盘容量,以及已经分好的分区。

2、然后从还有生于空间的分区上创建新的分区,使用m选项可以先查看创建分区选项。

3、然后使用n选项创建分区,这里因为是同一步磁盘已经存在主分区,所以现在只能创建扩展分区,这里选择e,如果是新磁盘可以直接创建主分区。

4、创建完成后,还需要把扩展分区转换为逻辑分区才可以进行使用,创建完成后需要重启计算机。

5、重启完成后,就可以对分区进行格式化操作了。

6、格式化完成后需要把格式化后的分区进行挂载才可以进行使用,挂载前需要选建立挂载目录。

这就可以从其中一个分区上拿一点空间出来创建一个新的分区。

阅读剩余
THE END