Linux磁盘分区(一):加入
***********************************************声明************************************************
原创作品。出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明出处(http://blog.csdn.net/huangyanlong)。
表述有错误之处,请您留言或邮件(hyldba@163.com)指明。不胜感激。
*****************************************************************************************************
*****************************************************************************************************
Linux硬盘分区(一):加入
*****************************************************************************************************
*************************
过程简述
*************************
--加入磁盘
# fdisk -l --查看磁盘情况
# fdisk /dev/sdb --为/dev/sdb设备分区
n --加入分区
p/e --主分区/逻辑分区
w --保存退出
# mkdir /data --创建挂载文件夹
# mkfs.ext3 /dev/sdb --格式化磁盘为ext3文件系统
# fdisk -l --再次查看磁盘情况
# mount /dev/sdb /data --挂载磁盘到创建的挂载文件夹下
# vi /etc/fstab --改动启动自己主动挂载项
/dev/sdb /data ext3 defaults 0 0
*************************
说明
*************************
1、以上操作为精炼总结,若如能够看懂。以下内容无需浏览;
2、下面简单列举两例。细化操作过程。
*****************************************************************************************************
举例1:加入1块90G磁盘,将其分为1个分区
*****************************************************************************************************
*************************
查看磁盘情况
*************************
[root@hyldb /]# fdisk -l Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 514048+ 83 Linux
/dev/sda2 65 586 4192965 82 Linux swap / Solaris
/dev/sda3 587 15665 121122067+ 83 Linux Disk /dev/sdb: 96.6 GB, 96636764160 bytes
255 heads, 63 sectors/track, 11748 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table
*************************
磁盘分区
*************************
[root@hyldb /]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable. The number of cylinders for this disk is set to 11748.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 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) Command (m for help): n
--加入新分区
Command action
e extended
p primary partition (1-4)
p
--输入p加入主分区
Partition number (1-4): 1
--填写分区号
First cylinder (1-11748, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-11748, default 11748):
Using default value 11748 Command (m for help): p
--打印分区列表
Disk /dev/sdb: 96.6 GB, 96636764160 bytes
255 heads, 63 sectors/track, 11748 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sdb1 1 11748 94365778+ 83 Linux Command (m for help): w
--保存退出
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
*************************
创建挂载文件夹
*************************
[root@hyldb /]# mkdir /data
*************************
格式化磁盘
*************************
[root@hyldb /]# mkfs.ext3 /dev/sdb
--格式化sdb1,格式成ext3格式文件系统
mke2fs 1.39 (29-May-2006)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
11796480 inodes, 23592960 blocks
1179648 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
720 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000 Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@hyldb /]# fdisk -l Disk /dev/sda: 128.8 GB, 128849018880 bytes
255 heads, 63 sectors/track, 15665 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 514048+ 83 Linux
/dev/sda2 65 586 4192965 82 Linux swap / Solaris
/dev/sda3 587 15665 121122067+ 83 Linux Disk /dev/sdb: 96.6 GB, 96636764160 bytes
255 heads, 63 sectors/track, 11748 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table
*************************
挂载磁盘到指定路径下
*************************
[root@hyldb /]# mount /dev/sdb /data
[root@hyldb /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 112G 4.3G 102G 5% /
/dev/sda1 487M 17M 445M 4% /boot
tmpfs 1006M 0 1006M 0% /dev/shm
/dev/sdb 89G 184M 84G 1% /data
*************************
改动启动磁盘自己主动挂载
*************************
[root@xckydb ~]# vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/sdb /data ext3 defaults 0 0
~
~
"/etc/fstab" 8L, 608C written --格式说明
/dev/sdb1 /u01 ext3 defaults 0 0
要挂载的对象 挂载的文件夹 系统类型 文件系统訪问权限 开机后是否检測 出问题后是否转储
*****************************************************************************************************
举例2:
1、加入1块10G磁盘。
2、将其分为六个分区;
3、三个主分区分别为2G。
4、剩余空间分为扩展分区。详细分为两个逻辑分区分别为1G,剩余空间单独分为一个逻辑分区。
*****************************************************************************************************
*************************
查看磁盘情况
*************************
[root@hyl ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.7G 5.4G 3.9G 59% /
/dev/sda3 35G 17G 17G 50% /home
tmpfs 1006M 0 1006M 0% /dev/shm
[root@hyl ~]# fdisk -l Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sda1 * 1 1305 10482381 83 Linux
/dev/sda2 1306 1827 4192965 82 Linux swap / Solaris
/dev/sda3 1828 6527 37752750 83 Linux Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table
*************************
为/dev/sdb设备分区
*************************
[root@hyl ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable. The number of cylinders for this disk is set to 1305.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 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)
*************************
创建第一个主分区:大小2G
*************************
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305): +2048M
*************************
创建第二个主分区:大小2G
*************************
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305): +2048M Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (251-1305, default 251):
Using default value 251
Last cylinder or +size or +sizeM or +sizeK (251-1305, default 1305): +2048M
*************************
创建第三个主分区:大小2G
*************************
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (501-1305, default 501):
Using default value 501
Last cylinder or +size or +sizeM or +sizeK (501-1305, default 1305): +2048M
*************************
先打印分区列表看一下
*************************
Command (m for help): p Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sdb1 1 250 2008093+ 83 Linux
/dev/sdb2 251 500 2008125 83 Linux
/dev/sdb3 501 750 2008125 83 Linux
*************************
创建扩展分区
*************************
Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (751-1305, default 751):
Using default value 751
Last cylinder or +size or +sizeM or +sizeK (751-1305, default 1305):
Using default value 1305
*************************
创建第一个逻辑分区:大小1G
*************************
Command (m for help): n
First cylinder (751-1305, default 751):
Using default value 751
Last cylinder or +size or +sizeM or +sizeK (751-1305, default 1305): +1024M
*************************
创建第二个逻辑分区:大小1G
*************************
Command (m for help): n
First cylinder (876-1305, default 876):
Using default value 876
Last cylinder or +size or +sizeM or +sizeK (876-1305, default 1305): +1024M
*************************
剩余容量创建最后一个逻辑分区
*************************
Command (m for help): n
First cylinder (1001-1305, default 1001):
Using default value 1001
Last cylinder or +size or +sizeM or +sizeK (1001-1305, default 1305):
Using default value 1305
*************************
打印分区列表
*************************
Command (m for help): p Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sdb1 1 250 2008093+ 83 Linux
/dev/sdb2 251 500 2008125 83 Linux
/dev/sdb3 501 750 2008125 83 Linux
/dev/sdb4 751 1305 4458037+ 5 Extended
/dev/sdb5 751 875 1004031 83 Linux
/dev/sdb6 876 1000 1004031 83 Linux
/dev/sdb7 1001 1305 2449881 83 Linux
*************************
保存退出
*************************
Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
*************************
查看磁盘划分
*************************
[root@hyl ~]# fdisk -l Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sda1 * 1 1305 10482381 83 Linux
/dev/sda2 1306 1827 4192965 82 Linux swap / Solaris
/dev/sda3 1828 6527 37752750 83 Linux Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System
/dev/sdb1 1 250 2008093+ 83 Linux
/dev/sdb2 251 500 2008125 83 Linux
/dev/sdb3 501 750 2008125 83 Linux
/dev/sdb4 751 1305 4458037+ 5 Extended
/dev/sdb5 751 875 1004031 83 Linux
/dev/sdb6 876 1000 1004031 83 Linux
/dev/sdb7 1001 1305 2449881 83 Linux
--由此能够看出。sdb1、sdb2、sdb3为主分区。sdb5、sdb6、sdb7为逻辑分区
*************************
举例:将sdb1格式化为ext3文件系统
*************************
[root@hyl ~]# cd /
[root@hyl /]# mkdir data1
[root@hyl /]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
251392 inodes, 502023 blocks
25101 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=515899392
16 block groups
32768 blocks per group, 32768 fragments per group
15712 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912 Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
*************************
举例:为sdb1设置开机自己主动挂载
*************************
[root@hyl /]# vi /etc/fstab
--设置开机自己主动挂载
LABEL=/ / ext3 defaults 1 1
LABEL=/home /home ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/sdb1 /data1 ext3 defaults 0 0
~
~
~
"/etc/fstab" 8L, 608C written
[root@hyl /]# mount /dev/sdb1 /data1
[root@hyl /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.7G 5.4G 3.9G 59% /
/dev/sda3 35G 17G 17G 50% /home
tmpfs 1006M 0 1006M 0% /dev/shm
/dev/sdb1 1.9G 35M 1.8G 2% /data1
***********************************************声明************************************************
原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明出处(http://blog.csdn.net/huangyanlong)。
表述有错误之处,请您留言或邮件(hyldba@163.com)指明,不胜感激。
提醒:点击文件夹,更有助于您的查看。
*****************************************************************************************************
Linux磁盘分区(一):加入的更多相关文章
- linux磁盘分区模式
linux磁盘分区模式 模式一:MBR 1)主分区不超过四个 2)单个分区容量最大2TB 模式二:GPT 1)主分区个数"几乎"没有限制(原因:在GPT的分区表中最多可以支持128 ...
- <实训|第七天>横扫Linux磁盘分区、软件安装障碍附制作软件仓库
期待已久的linux运维.oracle"培训班"终于开班了,我从已经开始长期四个半月的linux运维.oracle培训,每天白天我会好好学习,晚上回来我会努力更新教程,包括今天学到 ...
- 调整Linux磁盘分区的大小的方法
昨天数据入库时,一直报错,说磁盘满了,,df -h 一看,发现/目录下只有50G空间,已使用49G:我的程序和dbss都安装在/目录下,ftp到的数据放在/data下的一个子目录下,分解完的 ...
- Linux磁盘分区与格式化
磁盘分区格式说明 linux分区不同于windows linux下分区标示: 例如:hda1 hd这两个字母表示分区所在的设备类型,hd标示IDE类型硬盘,sd表示SCSI类型硬盘 第三字母a标示硬盘 ...
- Linux fdisk命令参数及用法详解---Linux磁盘分区管理命令fdisk
fdisk 命令 linux磁盘分区管理 用途:观察硬盘之实体使用情形与分割硬盘用. 使用方法: 一.在 console 上输入 fdisk -l /dev/sda ,观察硬盘之实体使用情形. 二.在 ...
- Linux 磁盘分区修改与管理
--Linux 磁盘分区修改与管理 -----------------------------2014/03/05 1. 目的,将磁盘卷/dev/cciss/c0d0p8修改成新的用途. 原: /de ...
- Linux 磁盘分区方案简析
Linux 磁盘分区方案简析 by:授客 QQ:1033553122 磁盘分区 任何硬盘在使用前都要进行分区.硬盘的分区有两种类型:主分区和扩展分区.一个硬盘上最多只能有4个主分区,其中一个主分区 ...
- Linux磁盘分区与文件系统
一 Linux磁盘分区与文件系统 在Linux中常见的操作系统有:ext2 ext3 ext4 xfs btrfs reiserfs等文件系统的作用主要是明确磁盘或分区上的文件存储方法以及数据结构,L ...
- Linux磁盘分区UUID的获取及其UUID的作用
注:UUID-Universally Unique IDentifiers全局唯一标识符 一.Linux磁盘分区UUID的获取方法 1.[san@localhost ~]$ ls -l /dev/di ...
- linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例
转自:truemylife.linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例 基本概念: 磁盘.分区.物理卷[物理部分] 卷组[中间部分] 逻辑卷.文件系统[虚拟化后可控制部分] 磁 ...
随机推荐
- Having用法
HAVING 子句对 GROUP BY 子句设置条件的方式与 WHERE 和 SELECT 的交互方式类似.WHERE 搜索条件在进行分组操作之前应用:而 HAVING 搜索条件在进行分组操作之后应用 ...
- Null值操作
1)NULL值写入的操作 create table j010( id number(7), name varchar2(20), salary number(7,2) ...
- 洛谷 2921 记忆化搜索 tarjan 基环外向树
洛谷 2921 记忆化搜索 tarjan 传送门 (https://www.luogu.org/problem/show?pid=2921) 做这题的经历有点玄学,,起因是某个random题的同学突然 ...
- Html 播放 mp4格式视频提示 没有发现支持的视频格式和mime类型
转自原文 Html 播放 mp4格式视频提示 没有发现支持的视频格式和mime类型 播放mp4格式的时候提示 Html 播放 mp4格式视频提示 没有发现支持的视频格式和mime类型 原因是在IIS中 ...
- 測试jbpm6.2使用的基础类
方便了解jbpm6.2功能我们能够建立一个測试项目,在当中构建一个測试基础类,详细过程例如以下所看到的. 在集成了插件org.drools.updatesite-6.2.0.Final.zip的ecl ...
- C 语言运算符优先级(记忆口诀)
优先级 运算符 名称或含义 使用形式 结合方向 说明 1 [] 数组下标 数组名[常量表达式] 左到右 () 圆括号 (表达式)/函数名(形參表) . 成员选择(对象) 对象.成员名 -& ...
- TensorFlow高层次机器学习API (tf.contrib.learn)
TensorFlow高层次机器学习API (tf.contrib.learn) 1.tf.contrib.learn.datasets.base.load_csv_with_header 加载csv格 ...
- tf.placeholder类似函数中的形参
tf.placeholder(dtype, shape=None, name=None) 此函数可以理解为形参,用于定义过程,在执行的时候再赋具体的值 参数: dtype:数据类型.常用的是tf.fl ...
- [jzoj NOIP2018模拟11.02]
嗯T1忘记取模了,100到20 嗯T2忘记了那啥定理,暴力也写炸了,这题我认 嗯T3线段树合并分裂没有写炸,考场上就知道妥妥的70分.但是,分数出的时候听到有人说暴力也是70分,我???脸黑,枉我敲了 ...
- eclipse启动错误:An internal error occurred during: "reload maven project".
解决方案一: 简单粗暴!直接删除E:\eclipseWorkspace\.metadata目录!然后再单个导入eclipseWorkspace中的项目. 解决方案二: 打开这个配置文件:E:\ecli ...