导航:首页 > 程序命令 > linux建立主分区和逻辑分区的命令

linux建立主分区和逻辑分区的命令

发布时间:2022-04-27 12:17:31

① 虚拟机里的linux 硬盘分区问题,在线等

1.
fdisk /dev/sdb
说明: 硬盘分区的表示:在Linux 是通过hd*x 或 sd*x 表示的,其中 * 表示的是a、b、c ... ... x表示的数字 1、2、3 ... ... hd大多是IDE硬盘;sd大多是SCSI或移动存储;
n :增加分区的命令
p :主分区
1 :因为你还没有第一个
直接回车 :1开始
+10240M :10G
n :增加分区的命令
e :扩展分区 由扩展分区内包含逻辑分区
2
直接回车:因为一共40g 后面的30G就全给扩展分区了
n :增加分区的命令
l :会提示由几开始,看你linux系统的设定了 你设分区可以有4个 那就从5开始
如:Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
5 :
直接回车:
+10240M:
6 :
直接回车:
直接回车:剩下的20G
wq :保存退出
mkfs.ext3 /dev/sdb2 : 格式化扩展分区
reboot :重启
mkfs.ext3 /dev/sdb1
mkfs.ext3 /dev/sdb5
mkfs.ext3 /dev/sdb6
mkdir -p /mnt/sdb1
mkdir -p /mnt/sdb2
mkdir -p /mnt/sdb5
mkdir -p /mnt/sdb6
mount /dev/sdb1 /mnt/sdb1
mount /dev/sdb2 /mnt/sdb2
mount /dev/sdb5 /mnt/sdb5
mount /dev/sdb6 /mnt/sdb6
df :查看
umount /dev/sdb6 :卸载
我只是把前面人说的一步一步写出来,你这是考试题?

② 怎样给linux操作系统分区

1、磁盘分区格式说明

linux分区不同于windows,linux下硬盘设备名为(IDE硬盘为hdx(x为从a—d)因为IDE硬盘最多四个,SCSI,SATA,USB硬盘为sdx(x为a—z)),硬盘主分区最多为4个,不用说大家也知道…..所以主分区从sdb1开始到sdb4,逻辑
分区从sdb5开始,(逻辑分区永远从sdb5开始…)设备名可以使用fdisk–l查看。

2、分区详解

使用ssh远程连接工具登录到系统,使用fdisk-l命令查看磁盘状态。

划分的空间与我们计划划分相同,最后输入w回车,进行保存退出。

再次使用fdisk-l命令就可以查看到磁盘hdb已经分区成功。

磁盘划分成功,下面就要对分区进行格式化了

使用命令mkfs-text3/dev/hdb1

mkfs-text3/dev/hdb5

mkfs-text3/dev/hdb6

mkfs-text3/dev/hdb7

分别对磁盘进行格式化处理,格式化为ext3文件类型。

③ 阐述linux中主分区和逻辑分区的产生

sudo fdisk /dev/sda

命令(输入 m 获取帮助): n
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p):
选p就是新建主分区
选l就是新建逻辑分区

④ linux怎么在磁盘里的主分区创建逻辑分区

主分区里就不能建啥逻辑分区了,是占用一个主分区记录的位置建扩展分区,在扩展分区里建若干个逻辑分区。
以前mbr盘只能建立四个主分区或扩展分区,多个扩展分区windows不认,linux也不认,但是可以用。
后来改变了,有gpt盘,这个是没限制了,都是主分区,windows给留了127个位置……

⑤ linux如何创建逻辑分区(LVM逻辑卷管理)

不同发行版的安装程序采用的分区工具不尽相同,不知道你安装的哪个发行版?
而且看你的问题好像与LVM不是一回事。如果只是需要建立一个普通的逻辑分区,在新建分区时默认是主分区,你可以在主分区这个选项旁边下拉菜单,改变为逻辑分区就OK了,只要建立了逻辑分区,扩展分区就自动产生了。
LVM则需要用一个或将几个分区(PV)建立卷组(VG),然后在VG上建立逻辑卷(LV)。如果安装程序的分区软件不支持LVM,这个操作过程是无法完成的。

⑥ Linux当中怎么用parted分区请写明步骤

Linux中进行磁盘分区一般是用fdisk这个命令,但是fdisk命令无法支持大于2TB以上的分区,而parted命令就是用于2TB以上大小的磁盘分区的工具。parted命令的用法:
1. 列出磁盘分区的信息(这个可以看到接下来新建分区的起始点):
形式:parted 磁盘设备名称 print
例如:parted /dev/hdc print
2. 新建一个分区:
形式:parted 磁盘设备名称 mkpart logical 文件系统类型 新建分区起始位置 新建分区结束位置
例子:parted /dev/hdc mkpart logical ext3 20.3G 80.3G
说明:/dev/hdc是磁盘设备名称,mkpart是新建分区,logical表示是一个逻辑分区,ext3是文件系统类型,20.3G是分区起始位置,这个是查看分区信息的时候,显示的最末尾的那个分区End这一栏的,80.3G是结束位置,也就是说这个新建的分区有60G大小。
3. 删除一个分区:
形式:parted 磁盘设备名称 rm 设备Number
例子:parted /dev/hdc rm 7
说明:设备Number的那个数字是用parted列出的分区信息里面,有一列是Number号码,需要删除那个分区就对应那个数字。

⑦ Linux怎么创建逻辑分区

用linux系统提供的终端创建分区的时候 使用L那个参数,表示是logical逻辑分区。此外,还可以用第三方的分区软件创建分区。

⑧ 在LINUX系统中,分区与格式化硬盘的命令是什么

Linux下常用的分区工具:
fdisk/sfdisk:命令行工具,各种版本和环境都能使用,包含在软件包util-linux中
diskdruid:图形化分区工具,只能在安装REDHAT系统时使用。

第一步:fdisk
[root@novice ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System

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

Command (m for help): #在输入上面的命令后会出现左边的提示,输入m就会得到一个帮助菜单,如下:
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
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)
#help虽然是英文的,可都很简单,在这里不再解释。

#现在,我们正式开始分区的操作:
Command (m for help): n #新建分区
Command action
e extended
p primary partition (1-4)
#e/p分别对应扩展分区 /主分区;我们先分四个主分区,每个50M;然后再来增加主分区或扩展分区,看会出现怎样的状况,嘿嘿。
p #分区类型为主分区
Partition number (1-4, default 1): 1 #分区号,在这里我们依次选择1、2、3、4
First sector (2048-496127, default 2048): #指定分区的起始扇区,一般默认,按enter键即可。
Last sector, +sectors or +size{K,M,G} (2048-496127, default 496127): +50M #指定分区的终止扇区,根据前面的提示我们可以做出相应的选择+sectors 或 +size{K,M,G}
Command (m for help): p #用p打印出已建好的分区列表

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux

#剩下的三个分区的建立操作同上
#分好四个主分区后的情况如下
Command (m for help): p

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 309298 25+ 83 Linux
#已经建好四个主分区啦,现在我们来看看如果再建主分区或是扩展分区的话会出现怎样的情况:
Command (m for help): n
You must delete some partition and add an extended partition first
#看到了吧,不能再建分区啦!要再建分区的话必须删除some分区,再新建一个扩展分区才行。
#现在,我们删掉一个主分区,来新建扩展分区
Command (m for help): d #删除分区
Partition number (1-4): 4 #选择要删除分区的分区号,我们选第四个

Command (m for help): p #打印,如下,四个分区变成了三个!

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux

#新建一个扩展分区
#如果在没有建满三个主分的区的情况下建立扩展分区,相关选项会有些不同。
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First sector (309248-496127, default 309248): #enter,默认
Using default value 309248
Last sector, +sectors or +size{K,M,G} (309248-496127, default 496127): #enter,默认,使用剩余空间
Using default value 496127

Command (m for help): p

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended

#接下来,我们在新建的扩展分区里再新建两个逻辑分区,因为已经有了三个主分区,这里不会再显示是建立逻辑分区还是主分区的提示!
Command (m for help): n
First sector (311296-496127, default 311296): #enter
Using default value 311296
Last sector, +sectors or +size{K,M,G} (311296-496127, default 496127): +50M

Command (m for help): n
First sector (415744-496127, default 415744): #enter
Using default value 415744
Last sector, +sectors or +size{K,M,G} (415744-496127, default 496127): #enter
Using default value 496127

Command (m for help): p

Disk /dev/sdb: 254 MB, 254017536 bytes
8 heads, 61 sectors/track, 1016 cylinders, total 496128 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 83 Linux
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 83 Linux
#上面的列表,就是我们今天分区的成果啦!接下来保存退出,重启计算机,就可以进行下一步的mkfs操作啦!如果忘记了相关的操作命令,记得按m!!!
Command (m for help): w #保存
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

另:在建好分区后,我们还可以更改相关分区的文件系统类型
#如,我们要把第二个主分区改成Linux下的交换分区,操作如下
Command (m for help): t #更改文件系统类型
Partition number (1-6): 2 #选择第二个分区
Hex code (type L to list codes): L #选择要更改的文件系统编码,可以按L来查看相关编码信息。
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
............
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): 82 #查找到linux swap的编码为82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): p
..............
Device Boot Start End Blocks Id System
/dev/sdb1 2048 104447 51200 83 Linux
/dev/sdb2 104448 206847 51200 82 Linux swap / Solaris
/dev/sdb3 206848 309247 51200 83 Linux
/dev/sdb4 309248 496127 93440 5 Extended
/dev/sdb5 311296 413695 51200 83 Linux
/dev/sdb6 415744 496127 40192 83 Linux
#最后别忘了保存!如果你须要的话!
#扩展分区不能直接使用,逻辑分区只能建立在扩展分区上!

第二步:mkfs(mkfs时分区的格式最好与fdisk设定的分区格式一致,不然.......)
mkfs支持ext2 ext3 vfa msdos jfs reiserfs等文件系统。
用法1:mkfs -t
例: mkfs -t ext3 /dev/sdb2

用法2:mkfs.
例:mkfs,vfat /dev/sdb3

mke2fs支持ext2/ext3文件系统
用法:mke2fs [-j]
例:mke2fs -j /dev/sdb5
# 更多更具体的用法请参照相关命令的man手册

下面,接着实验:
例一
[root@novice ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
12824 inodes, 51200 blocks
2560 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=52428800
7 block groups
8192 blocks per group, 8192 fragments per group
1832 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

第三部:挂载
挂载:mount
例:mount /dev/sdb1 /mnt /sdb1

卸载:umonut
例:umount /dev/sdb1

⑨ Linux中如何创建新分区啊

Linux下可以用fdisk命令新建分区,方法如下:
1、首先查看硬盘信息,用fdisk -l命令,如果有硬盘有剩余空间就可以对其进行分区。
2、下面对/dev/sdb 进行分区
3、有扩展分区和主分区,逻辑分区在扩展分区中建立。注意到括号中的1-4,最多只能建四个主分区(包括扩展分区)。先建一个主分区:
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、同上所述建立扩展分区:
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、扩展分区建好就可以在扩展分区建立逻辑分区了
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、上面显示已经建好一个主分区,一个逻辑分区,但是这些现在还没有生效,需要保存退出。
Command (m for help): w #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks. 《Linux就该这么学》这本书上有详细的介绍

⑩ LINUX如何分区

fdisk /dev/sdb
输入m查看帮助:
下面列出常用命令。
n new 新建分区,会让选主分区还是扩展分区,
p print 打印当前分区表
w write 将修改写入硬盘并退出,慎重操作
d delete 删除分区
t type 修改分区类型,例如创建swap分区
l list 列出分区类型代码

阅读全文

与linux建立主分区和逻辑分区的命令相关的资料

热点内容
解压机压什么不烂 浏览:370
大牛盒子插件文件夹 浏览:12
用友t3如何远程连接服务器 浏览:741
保时捷行车记录仪需要什么app 浏览:715
文件服务器中的DFS全名是什么 浏览:460
365小说app现在叫什么 浏览:54
海贝音乐app的独占usb输出是什么 浏览:400
宏观经济学高鸿业pdf 浏览:296
我的荣耀9x有方舟编译器吗 浏览:974
linux父子进程通信 浏览:889
程序员为什么总是用手机 浏览:309
安卓9程序怎么用 浏览:846
如何恢复编译 浏览:851
mybatispdf 浏览:880
plc使用的是单片机吗 浏览:814
如何让安卓平板音量上限 浏览:236
代理服务器请求超时如何设置 浏览:117
pdf批量盖章 浏览:780
珠江宽频网关服务器地址 浏览:711
程序员练打字网站 浏览:578