使用fdisk给新增加硬盘分区

1.使用fdisk创建6个分区[1P+1E(5L)]   //dev/sdb1 /dev/sdb5 /dev/sdb6 /dev/sdb7 /dev/sdb8 /deb/sdb9

 1 [[email protected] ~]# fdisk -l
 2
 3 Disk /dev/sda: 8589 MB, 8589934592 bytes
 4 255 heads, 63 sectors/track, 1044 cylinders
 5 Units = cylinders of 16065 * 512 = 8225280 bytes
 6 Sector size (logical/physical): 512 bytes / 512 bytes
 7 I/O size (minimum/optimal): 512 bytes / 512 bytes
 8 Disk identifier: 0x000aec72
 9
10    Device Boot      Start         End      Blocks   Id  System
11 /dev/sda1   *           1          26      204800   83  Linux
12 Partition 1 does not end on cylinder boundary.
13 /dev/sda2              26          91      524288   82  Linux swap / Solaris
14 Partition 2 does not end on cylinder boundary.
15 /dev/sda3              91        1045     7658496   83  Linux
16
17 Disk /dev/sdb: 1073 MB, 1073741824 bytes
18 255 heads, 63 sectors/track, 130 cylinders
19 Units = cylinders of 16065 * 512 = 8225280 bytes
20 Sector size (logical/physical): 512 bytes / 512 bytes
21 I/O size (minimum/optimal): 512 bytes / 512 bytes
22 Disk identifier: 0x00000000

2.fdisk -cu /dev/sdb开始分区

1 [[email protected] ~]# fdisk -cu /dev/sdb   //-c:表示丢弃DOS兼容模式,切换到mode模式; -u:表示从柱面分区改为扇区分区
2 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
3 Building a new DOS disklabel with disk identifier 0x94c5ab35.
4 Changes will remain in memory only, until you decide to write them.
5 After that, of course, the previous content won‘t be recoverable.
6
7 Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
8
9 Command (m for help):

3.输入m查看帮助

 1 Command (m for help): m
 2 Command action
 3    a   toggle a bootable flag
 4    b   edit bsd disklabel
 5    c   toggle the dos compatibility flag
 6    d   delete a partition    //删除创建的分区
 7    l   list known partition types   //列出分区类型
 8    m   print this menu   //查看帮助
 9    n   add a new partition     //创建新分区
10    o   create a new empty DOS partition table
11    p   print the partition table   //打印分区表
12    q   quit without saving changes
13    s   create a new empty Sun disklabel
14    t   change a partition‘s system id
15    u   change display/entry units
16    v   verify the partition table
17    w   write table to disk and exit   //写入分区表保存
18    x   extra functionality (experts only)
19
20 Command (m for help): 

4.分出一个10M的主分区

 1 Command (m for help): n
 2 Command action
 3    e   extended    //代表扩展分区
 4    p   primary partition (1-4)   //代表主分区
 5 p     //选择p 主分区
 6 Partition number (1-4): 1
 7 First sector (2048-2097151, default 2048):     //默认2048开始
 8 Using default value 2048
 9 Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +10M
10
11 Command (m for help): p
12
13 Disk /dev/sdb: 1073 MB, 1073741824 bytes
14 255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
15 Units = sectors of 1 * 512 = 512 bytes
16 Sector size (logical/physical): 512 bytes / 512 bytes
17 I/O size (minimum/optimal): 512 bytes / 512 bytes
18 Disk identifier: 0x94c5ab35
19
20    Device Boot      Start         End      Blocks   Id  System
21 /dev/sdb1            2048       22527       10240   83  Linux

5.将剩余的空间全部分配给扩展分区

 1 Command (m for help): n
 2 Command action
 3    e   extended
 4    p   primary partition (1-4)
 5 e
 6 Partition number (1-4): 2    //分区编号选择为2
 7 First sector (22528-2097151, default 22528):   //默认缺省大小
 8 Using default value 22528
 9 Last sector, +sectors or +size{K,M,G} (22528-2097151, default 2097151):     //默认缺省大小
10 Using default value 2097151
11
12 Command (m for help): p   //打印
13
14 Disk /dev/sdb: 1073 MB, 1073741824 bytes
15 255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
16 Units = sectors of 1 * 512 = 512 bytes
17 Sector size (logical/physical): 512 bytes / 512 bytes
18 I/O size (minimum/optimal): 512 bytes / 512 bytes
19 Disk identifier: 0x94c5ab35
20
21    Device Boot      Start         End      Blocks   Id  System
22 /dev/sdb1            2048       22527       10240   83  Linux
23 /dev/sdb2           22528     2097151     1037312    5  Extended
24
25 Command (m for help): n

6.接着将扩展分区分成5个逻辑分区,首先创建第1个大小为10M的逻辑分区

 1 Command (m for help): n
 2 Command action
 3    l   logical (5 or over)
 4    p   primary partition (1-4)
 5 l   //选择创建逻辑分区
 6 First sector (24576-2097151, default 24576):    //默认开始直接回车
 7 Using default value 24576
 8 Last sector, +sectors or +size{K,M,G} (24576-2097151, default 2097151): +10M   //输入分区大小10M
 9
10 Command (m for help): p   //打印分区
11
12 Disk /dev/sdb: 1073 MB, 1073741824 bytes
13 255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
14 Units = sectors of 1 * 512 = 512 bytes
15 Sector size (logical/physical): 512 bytes / 512 bytes
16 I/O size (minimum/optimal): 512 bytes / 512 bytes
17 Disk identifier: 0x94c5ab35
18
19    Device Boot      Start         End      Blocks   Id  System
20 /dev/sdb1            2048       22527       10240   83  Linux
21 /dev/sdb2           22528     2097151     1037312    5  Extended
22 /dev/sdb5           24576       45055       10240   83  Linux   //分区表从5开始,代表逻辑分区

7.接着创建扩展分区中第2个大小为10M的逻辑分区

 1 Command (m for help): n
 2 Command action
 3    l   logical (5 or over)
 4    p   primary partition (1-4)
 5 l
 6 First sector (47104-2097151, default 47104):
 7 Using default value 47104
 8 Last sector, +sectors or +size{K,M,G} (47104-2097151, default 2097151): +10M
 9
10 Command (m for help): p
11
12 Disk /dev/sdb: 1073 MB, 1073741824 bytes
13 255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
14 Units = sectors of 1 * 512 = 512 bytes
15 Sector size (logical/physical): 512 bytes / 512 bytes
16 I/O size (minimum/optimal): 512 bytes / 512 bytes
17 Disk identifier: 0x94c5ab35
18
19    Device Boot      Start         End      Blocks   Id  System
20 /dev/sdb1            2048       22527       10240   83  Linux
21 /dev/sdb2           22528     2097151     1037312    5  Extended
22 /dev/sdb5           24576       45055       10240   83  Linux
23 /dev/sdb6           47104       67583       10240   83  Linux

8.接着创建扩展分区中第3个大小为10M的逻辑分区

 1 Command (m for help): n
 2 Command action
 3    l   logical (5 or over)
 4    p   primary partition (1-4)
 5 l
 6 First sector (69632-2097151, default 69632):
 7 Using default value 69632
 8 Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte)
 9             2^N: K  (KibiByte), M  (MebiByte), G  (GibiByte)
10 Last sector, +sectors or +size{K,M,G} (69632-2097151, default 2097151): =
11 Last sector, +sectors or +size{K,M,G} (69632-2097151, default 2097151): +10M
12
13 Command (m for help): p
14
15 Disk /dev/sdb: 1073 MB, 1073741824 bytes
16 255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
17 Units = sectors of 1 * 512 = 512 bytes
18 Sector size (logical/physical): 512 bytes / 512 bytes
19 I/O size (minimum/optimal): 512 bytes / 512 bytes
20 Disk identifier: 0x94c5ab35
21
22    Device Boot      Start         End      Blocks   Id  System
23 /dev/sdb1            2048       22527       10240   83  Linux
24 /dev/sdb2           22528     2097151     1037312    5  Extended
25 /dev/sdb5           24576       45055       10240   83  Linux
26 /dev/sdb6           47104       67583       10240   83  Linux
27 /dev/sdb7           69632       90111       10240   83  Linux

9.接着创建扩展分区中第4个大小为10M的逻辑分区

 1 Command (m for help): n
 2 Command action
 3    l   logical (5 or over)
 4    p   primary partition (1-4)
 5 l
 6 First sector (92160-2097151, default 92160):
 7 Using default value 92160
 8 Last sector, +sectors or +size{K,M,G} (92160-2097151, default 2097151): +10M
 9
10 Command (m for help): p
11
12 Disk /dev/sdb: 1073 MB, 1073741824 bytes
13 255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
14 Units = sectors of 1 * 512 = 512 bytes
15 Sector size (logical/physical): 512 bytes / 512 bytes
16 I/O size (minimum/optimal): 512 bytes / 512 bytes
17 Disk identifier: 0x94c5ab35
18
19    Device Boot      Start         End      Blocks   Id  System
20 /dev/sdb1            2048       22527       10240   83  Linux
21 /dev/sdb2           22528     2097151     1037312    5  Extended
22 /dev/sdb5           24576       45055       10240   83  Linux
23 /dev/sdb6           47104       67583       10240   83  Linux
24 /dev/sdb7           69632       90111       10240   83  Linux
25 /dev/sdb8           92160      112639       10240   83  Linux

10.接着创建扩展分区中第5个逻辑分区,将剩余空间都分配

 1 Command (m for help): n
 2 Command action
 3    l   logical (5 or over)
 4    p   primary partition (1-4)
 5 l
 6 First sector (114688-2097151, default 114688):
 7 Using default value 114688
 8 Last sector, +sectors or +size{K,M,G} (114688-2097151, default 2097151):
 9 Using default value 2097151
10
11 Command (m for help): p
12
13 Disk /dev/sdb: 1073 MB, 1073741824 bytes
14 255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
15 Units = sectors of 1 * 512 = 512 bytes
16 Sector size (logical/physical): 512 bytes / 512 bytes
17 I/O size (minimum/optimal): 512 bytes / 512 bytes
18 Disk identifier: 0x94c5ab35
19
20    Device Boot      Start         End      Blocks   Id  System
21 /dev/sdb1            2048       22527       10240   83  Linux
22 /dev/sdb2           22528     2097151     1037312    5  Extended
23 /dev/sdb5           24576       45055       10240   83  Linux
24 /dev/sdb6           47104       67583       10240   83  Linux
25 /dev/sdb7           69632       90111       10240   83  Linux
26 /dev/sdb8           92160      112639       10240   83  Linux
27 /dev/sdb9          114688     2097151      991232   83  Linux

11.将/dev/sdb9改为LVM分区(即动态调整)

 1 Command (m for help): t
 2 Partition number (1-9): 9   //要修改的分区标识
 3 Hex code (type L to list codes): 8e    //代表LVM,可用l查询对应的Id
 4 Changed system type of partition 9 to 8e (Linux LVM)
 5
 6 Command (m for help): p
 7
 8 Disk /dev/sdb: 1073 MB, 1073741824 bytes
 9 255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
10 Units = sectors of 1 * 512 = 512 bytes
11 Sector size (logical/physical): 512 bytes / 512 bytes
12 I/O size (minimum/optimal): 512 bytes / 512 bytes
13 Disk identifier: 0x94c5ab35
14
15    Device Boot      Start         End      Blocks   Id  System
16 /dev/sdb1            2048       22527       10240   83  Linux
17 /dev/sdb2           22528     2097151     1037312    5  Extended
18 /dev/sdb5           24576       45055       10240   83  Linux
19 /dev/sdb6           47104       67583       10240   83  Linux
20 /dev/sdb7           69632       90111       10240   83  Linux
21 /dev/sdb8           92160      112639       10240   83  Linux
22 /dev/sdb9          114688     2097151      991232   8e  Linux LVM

12.分区结尾工作

1 Command (m for help): w    //写入分区表
2 The partition table has been altered!
3
4 Calling ioctl() to re-read partition table.
5 Syncing disks.
6 [[email protected] ~]# partprobe /dev/sdb    //将分区表的修改结果告诉内核,这样可用忽略重启系统

至此分区工作结束!!

时间: 2024-10-28 20:34:59

使用fdisk给新增加硬盘分区的相关文章

LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while)

LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while) 2015-09-04 11:28:01 分类: Linux LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while) 给某个硬盘增加分区之后 [[email protected]-213-66 ~]# df -h Filesystem Size Used Avail Use% Mounted

mysql数据文件迁移到新的硬盘分区的方法

该系统增加了一个硬盘.要创建新的分区/data文件夹,mysql对于数据文件夹/var/lib/mysql 1.  停止mysql维修 [[email protected]~]# service mysql stop Shuttingdown MySQL... SUCCESS! [[email protected]~]# 2.  将mysql原数据文件移动到新硬盘分区的mysql文件夹下 [[email protected] ~]# mv /var/lib/mysql//data/mysql/

centos6.5新增加硬盘+挂载

在内网主机新增一个2T硬盘,先关机断电再连接硬盘数据线和电源线! 查看当前磁盘设备信息: [[email protected] ~]# fdisk -l WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/sdb: 160.0 GB, 160041885696 bytes255 heads, 63 sect

硬盘分区fdisk\gdisk ,挂载mount \swapon

1 dd命令详解 dd:convert and copy a file dd if=/PATH/SOURCE of=/PATH/DEST bs=1[k|M] count=100 if=file,从文件读入内容. of=offile,写入文件. ibs=size 一次读size个byte obs=size 一次写size个byte bs=size 指定读写块大小 cbs=size 一次性转化size个大小 skip=blocks 从头忽略blocks个ibs大小的块 seek=blocks 从头忽

vmware中为linux增加硬盘和增加硬盘空间的方法

使用过程中,经常会遇到虚拟机磁盘空间不够或者按需增加硬盘的情况.在vmware中为Linux添加硬盘或增加硬盘空间的详细操作步骤如下: 一.Vmware中为linux增加硬盘的方法 1. 在vmware中为Linux虚拟机的编辑设置中(setting)增加一个硬盘. 2. 在vmware中看见第1个硬盘是/dev/sda , 第2个硬盘是 /dev/sdb 3. 创建硬盘信息fdisk /dev/sdba. 按n添加分区,选p(主分区);b. 选1,也就是sdb1;c. 然后就是空间划分,一路回

KVM虚拟机windows系统增加硬盘

原文:http://www.ilanni.com/?p=6211 前一篇文章介绍了有关linux系统添加硬盘的方法,这次我们来介绍有关windows系统添加的相关步骤. 其实linux和windows添加的硬盘的方法都是一样的,也是可以通过命令行和修改配置文件来添加. 下面主要介绍通过virsh edit命令编辑虚拟机配置文件,来添加硬盘的方法. 注意windows系统添加硬盘需要分硬盘接口,IDE接口和virtio接口. 首先创建一个新的硬盘,使用qemu-img create命令,如下: q

linux挂载硬盘分区

[转]https://www.jb51.net/article/138204.htm 基本步骤:分区--格式化--挂载--写入文件 1.使用fdisk    -l命令查看添加的硬盘名称,可以看到sdb为新增的硬盘: 2.进行分区,输入m查看提示 # fdisk /dev/sdb 分析:主要参数的解析 1. 输入 m 显示所有命令列示. 2. 输入 p 显示硬盘分割情形,打印分区表. 3. 输入 a 设定硬盘启动区. 4. 输入 n 创建新的硬盘分割区. 4.1. 输入 e 硬盘为[延伸]分割区(

给Linux系统新增加一块硬盘

今天公司测试Linux服务器硬盘不够用了,主要是mysql数据文件太大了,买了个500G的硬盘回来,这里记录下新加硬盘的方法PS 测试服务器的主板太差劲了,没有多余的电源接口,只能把光驱的电源拿出来,才能让硬盘使用.把硬盘装好后,我们用 fdisk -l 查看下: 图中可以看出 /dev/sdb 是500G,新加的硬盘.接下来我用命令 fdisk sdb 进行分区,输入 p 查看新硬盘分区,如图:可以用m命令来看fdisk命令的内部命令:n命令创建一个新分区:d命令删除一个存在的分区:p命令显示

mysql数据文件迁移到新硬盘分区的方法

系统增加一块硬盘,挂载新分区到/data目录下,mysql数据文件目录为/var/lib/mysql 1.  停止mysql服务 [[email protected]~]# service mysql stop Shuttingdown MySQL... SUCCESS! [[email protected]~]# 2.  将mysql原数据文件移动到新硬盘分区的mysql目录下 [[email protected] ~]# mv /var/lib/mysql//data/mysql/ 3.