linux创建删除磁盘分区
来源:互联网 发布:jav网络机顶盒怎么样 编辑:程序博客网 时间:2024/06/01 20:55
可以使用fdisk -l查看系统认到的硬盘以及硬盘分区标识.
首先,使用命令n创建一个新的分区:
# fdisk /dev/hda
Command (m for help): n (create new partition)
Command action
e extended
p primary partition (1-4)
下一步,选择p创建一个主分区:
选择分区的起点,默认会选择下一个有效磁盘柱面:
First cylinder (1675-4863, default 1675):
Using default value 1675
下面输入新分区的大小,例如分区大小为1GB,您应该输入: +1024M
Last cylinder or +size or +sizeM or +sizeK (1675-4863, default 4863): +1024M
回车以后,会退回到命令行(Command)下,您可以查看新的分区信息。
Command (m for help): p
Disk /dev/hda: 40.0 GB, 40000000000 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 1543 12289725 83 Linux
/dev/hda3 1544 1674 1052257+ 82 Linux swap
/dev/hda4 1675 1799 1004062+ 83 Linux
最后一行是新创建的分区信息。分区的ID类型默认是Linux,您可以在此分区上创建文件系统。
最后,输入命令w,保存磁盘分区信息,然后退出。说明:在没有执行w命令之前,您新添加的分区信息并没有实际生效,如果没有执行w命令就退出,您新创建的分区信息不会生效。
Command (m for help): w
按w保存后还需要输入partprobe
这样就创建了一个分区,然后使用系统mount命令挂载此分区,系统就可以使用这个硬盘分区了.
还有一种parted分区
输入命令:parted
(parted) mkpart
Partition name? []? gpt2t ---指定分区名称
File system type? [ext2]ext3 ----指定分区类型
Start? 1 ---指定开始位置
End? 2190GB ---指定结束位置
(parted) P ----显示分区信息
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sde: 2190GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 2190GB 2190GB gpt2t
(parted) print ---打印分区信息
(parted) Q ---退出
Information: Don't forget to update /etc/fstab, if necessary. -----提示不要忘记更新/etc/fstab文件
删除分区:
[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): d
Partition number (1-4): 3
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM
Command (m for help):
首先,使用命令n创建一个新的分区:
# fdisk /dev/hda
Command (m for help): n (create new partition)
Command action
e extended
p primary partition (1-4)
下一步,选择p创建一个主分区:
p
选择分区的起点,默认会选择下一个有效磁盘柱面:
First cylinder (1675-4863, default 1675):
Using default value 1675
下面输入新分区的大小,例如分区大小为1GB,您应该输入: +1024M
Last cylinder or +size or +sizeM or +sizeK (1675-4863, default 4863): +1024M
回车以后,会退回到命令行(Command)下,您可以查看新的分区信息。
Command (m for help): p
Disk /dev/hda: 40.0 GB, 40000000000 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 1543 12289725 83 Linux
/dev/hda3 1544 1674 1052257+ 82 Linux swap
/dev/hda4 1675 1799 1004062+ 83 Linux
最后一行是新创建的分区信息。分区的ID类型默认是Linux,您可以在此分区上创建文件系统。
最后,输入命令w,保存磁盘分区信息,然后退出。说明:在没有执行w命令之前,您新添加的分区信息并没有实际生效,如果没有执行w命令就退出,您新创建的分区信息不会生效。
Command (m for help): w
按w保存后还需要输入partprobe
这样就创建了一个分区,然后使用系统mount命令挂载此分区,系统就可以使用这个硬盘分区了.
还有一种parted分区
输入命令:parted
(parted) mkpart
Partition name? []? gpt2t ---指定分区名称
File system type? [ext2]ext3 ----指定分区类型
Start? 1 ---指定开始位置
End? 2190GB ---指定结束位置
(parted) P ----显示分区信息
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sde: 2190GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 2190GB 2190GB gpt2t
(parted) print ---打印分区信息
(parted) Q ---退出
Information: Don't forget to update /etc/fstab, if necessary. -----提示不要忘记更新/etc/fstab文件
删除分区:
[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): d
Partition number (1-4): 3
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM
Command (m for help):
0 0
- linux创建删除磁盘分区
- Linux磁盘分区(二):删除
- Linux中如何给磁盘分区创建文件系统
- 在Linux下磁盘分区、创建文件系统、挂载
- linux 磁盘分区
- linux 磁盘分区
- linux磁盘分区
- Linux磁盘分区
- Linux磁盘分区
- Linux 磁盘分区
- linux磁盘分区
- linux磁盘分区
- Linux磁盘分区
- Linux磁盘分区
- Linux磁盘分区
- linux-磁盘分区
- Linux磁盘分区
- linux磁盘分区
- 快速搭建 Cocos2d-HTML5 开发调试环境 分享0
- Windows下nginx的安装与配置
- 地产类消费者行为习惯市场调查
- 詹姆斯谈绝杀:确保不给对手留时间
- spring对hibernate的session管理的配置
- linux创建删除磁盘分区
- 初来乍到,请多关照
- 问题:客户端从服务器分页获取列表,如何保证流量最少,且客户端和Server数据的一致性?
- Google App Engine的app.yaml详细说明
- 斯帅:没料到詹姆斯会耗光时间再投
- Cocos2d-x 中北景的无限游动的方法
- 【数据结构】堆排序
- Android-StageFright之数据流的封装和AwesomePlayer流程
- 偶遇一种复制内容到剪贴板的工具