㈠ 如何在linux操作系统中新建磁盘分区
Linux下可以用fdisk命令新建分区,方法如下:
1、首先用fdisk -l命令查看硬盘信息,硬盘有剩余空间就可以对其进行分区。
2、假设/dev/sdb 没有使用,用 fdisk /dev/sdb [不会用请进入命令后根据提示键入m获得帮助]
3、有扩展分区和主分区,逻辑分区在扩展分区中建立。注意到括号中的1-4,最多只能建四个主分区(包括扩展分区)。/dev/sdb没有使用的话就先建一个主分区:
4、根据步骤3的说明建立扩展分区:
5、扩展分区建好就可以在扩展分区建立逻辑分区了
6、就会显示已经建好一个主分区,一个逻辑分区,需要保存退出使分区设置生效。
7、如果fdisk命令不熟悉使用 fdisk -h 查看帮助,或者在命令使用中根据提示操作
㈡ Linux下怎样用fdisk命令分区
body{
line-height:200%;
}
Linux下怎样用fdisk命令分区
1、添加新硬盘
因为在现有的硬盘当中,所有的空间以及被分配完了;这个时候就需要拿一块新的硬盘,然后在新硬盘进行分区。
虚拟机的好处是:只要你的真实机硬件空间足够,那你想添加多少块硬盘都可以;但是虚拟机必须先关闭,否则是不能添加新硬盘的
2、查看新硬盘
[root@localhost~]#
fdisk
-l
查询新添加的硬盘是否被识别。
3、使用fdisk命令分区
[root@localhost~]#
fdisk
/dev/sbd
fdisk交互指令说明
a:设置可引导标记
b:编辑bsd磁盘标签
c:设置DOS操作系统兼容标记
d:删除一个分区
l:显示已知的文件系统类型,82为Linux
swqp分区,83为Linux分区
m:显示帮助带单
n:新建分区
o:建立空白DOS分区表
p:显示分区列表
q:不保存退出
t:改变一个分区的系统ID
w:保存退出
4、重新读取分区表信息
[root@localhost~]#
partprobe
5、格式化分区
[root@localhost~]#
mkfs
-t
ext4
/dev/sdb1
6、建立挂载点并挂载
[root@localhost~]#
mkdir
/disk1
[root@localhost~]#
mount
/dev/sdb1/disk1/
㈢ Linux如何利用fdisk工具建立分区
fdisk磁盘分区工具
1.首先查看硬盘信息
fdisk -l 如果有硬盘有剩余空间就可以对其进行分区
[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没有使用。
下面我们对/dev/sdb 进行分区
[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
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)
有扩展分区和主分区,逻辑分区在扩展分区中建立。注意到括号中的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
同上所述建立扩展分区:
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
扩展分区建好我们就可以在扩展分区建立逻辑分区了
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
上面显示已经建好一个主分区,一个逻辑分区,但是这些现在还没有生效我们需要保存退出。
Command (m for help): w #保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[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: 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
再次查看就看到了/dev/sdb的分区信息,虽然现在我们看到进行分区了,但是内核kenel还没有识别为了不要重启将分区表写入kenel我们要用到partprobe工具:使kenel重新读取分区表。
[root@bogon 桌面]# partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (设备或资源忙). As a result, it may not reflect all of your changes until after reboot.
kenel识别分区表后,我们还不能使用它要对其进行格式化。mkfs.加文件系统格式,扩展分区是不能格式化的。
[root@bogon 桌面]# mkfs.ext4 /dev/sdb1 #格式化成ext4文件格式(要分区格式化,不能将整个硬盘格式化)
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131648 inodes, 20 blocks
26306 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@bogon 桌面]# mkfs.ext4 /dev/sdb5 #格式化逻辑分区
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131648 inodes, 20 blocks
26306 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=541065216
17 block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
格式化后就可以使用了
[root@bogon 桌面]# mkdir /bak
[root@bogon 桌面]# mount -o loop /dev/sdb1 /bak #挂载该分区到/bak
[root@bogon 桌面]# df -TH #查看当前硬盘挂载信息
文件系统 类型 容量 已用 可用 已用%% 挂载点
/dev/sda5 ext4 52G 3.9G 45G 8% /
tmpfs tmpfs 528M 279k 528M 1% /dev/shm
/dev/sda1 ext4 204M 28M 166M 15% /boot
/dev/sda2 ext4 31G 2.9G 27G 10% /usr
.host:/ vmhgfs 144G 41G 104G 29% /mnt/hgfs
/ios/RHEL6.3.iso
iso9660 3.2G 3.2G 0 100% /guazai
/dev/sdb1 ext4 2.2G 71M 2.0G 4% /bak
㈣ linux用fdisk怎么分区
分区是将一个硬盘驱动器分成若干个逻辑驱动器,分区是把硬盘连续的区块当做一个独立的磁硬使用。分区表是一个硬盘分区的索引,分区的信息都会写进分区表。
分区工具fdisk用法介绍:
p、打印分区表。
n、新建一个新分区。
d、删除一个分区。
q、退出不保存。
w、把分区写进分区表,保存并退出。
㈤ 如何在linux下使用fdisk创建一个10M的物理分区,并要求开机挂载在/my 目录下
1、fdisk
2、输入n
3、选primary处的1、2、3、4中的一个
4、first cylinder按回车缺省
5、last cylinder处输入:+10M
6、输入:w写入磁盘信息并退出
7、mkfs.ext3 /dev/xxx格式化新建的分区
8、每次通过命令挂载:mount /dev/xxx /my
或:编辑/etc/fstab加入:/dev/xxx /my ext3 defaults 1 2
保存后,重启后系统自动加载分区
㈥ 如何使用Linux进行磁盘分区(步骤)
用fdisk这个工具,可以查看硬盘分区情况
fdisk
-l
/dev/sda(如果是scsi接口的话)
,会发现创建了几个分区,分别用sda1,sda2,sda3,表示。如果,你上面显示的是柱面数,和下面结束的柱面数相同的话,说明你没有多余的空间了。fdisk
/dev/sda
按m键,会出现提示,n是添加一个分区,p是打印现在的分区情况,d是删除一个分区,q是退出,w是保存,你可以先删除分区,然后再重新创建分区,然后w保存退出,执行#partprobe,会使分区立即生效,不必重启。希望对你有帮助。
㈦ linux系统下fdisk命令怎么用
磁盘分区管理命令:fdisk
root@local:~#fdisk
/dev/sdb
(进入磁盘管理,可使用U盘测试)
Command
(m
for
help):
p
(查看所有分区)
Command
(m
for
help):
a
(设置可引导分区,就是*标记)
Command
(m
for
help):
n
(创建一个新分区,给新分区分配空间时,起始卷值默认即可,可避免空间浪费,然后给出空间大小,如+10000M就表明要分配1G的空间,然后自动计算结束卷值)
Command
(m
for
help):
t
(给新分区设置分区类型,可以通过L显示所有分区类型)
Command
(m
for
help):
w
(保存退出,但也需重启才能生效)
Command
(m
for
help):
q
(不保存退出)
新分区还需被格式化成相应的文件系统类型才能使用,常用的有mkfs.ext3(格式化为ext3格式,是Linux分区常用的)、mkfs.msdos(格式化为Fat16格式)和mkfs.vfat(格式化为Fat32格式);如mkfs.vfat
/dev/sdb1
㈧ linux 用fdisk 怎么分区 举例分一个扩展分区
首先输入fdisk
-l查看系统中的硬盘及分区信息
然后fdisk
/dev/sdb
(假设sdb是新添加的硬盘即还没分区)
输入m查看帮助,输入n新添加一个分区,输入e添加一个扩展分区,输入扩展分区号*,其他的按照默认的就行了,然后输入w保存并退出
接下来就是格式化了
假设新建的分区号为1,输入mkfs
-t
ext3
/dev/sdb1,回车就可以了
这样一个扩展分区就建立好了
㈨ linux 用fdisk 怎么分区
在虚拟硬盘中使用Fdisk命令。
㈩ linux_fdisk命令详解
磁盘分区管理命令:fdisk
root@local:~#fdisk /dev/sdb (进入磁盘管理,可使用U盘测试)
Command (m for help): p (查看所有分区)
Command (m for help): a (设置可引导分区,就是*标记)
Command (m for help): n (创建一个新分区,给新分区分配空间时,起始卷值默认即可,可避免空间浪费,然后给出空间大小,如+10000M就表明要分配1G的空间,然后自动计算结束卷值)
Command (m for help): t (给新分区设置分区类型,可以通过L显示所有分区类型)
Command (m for help): w (保存退出,但也需重启才能生效)
Command (m for help): q (不保存退出)
新分区还需被格式化成相应的文件系统类型才能使用,常用的有mkfs.ext3(格式化为ext3格式,是Linux分区常用的)、mkfs.msdos(格式化为Fat16格式)和mkfs.vfat(格式化为Fat32格式);如mkfs.vfat /dev/sdb1