LINUX实验磁盘分区,实验:使用fdisk创建简单磁盘分区

实验:使用fdisk创建简单磁盘分区

实验要求:

/dev/sdb8  100M

/dev/sdb9  100M

[root@linuxso.com ~]# fdisk -l /dev/sdb  #查看当前磁盘分区情况

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: 0xe7a49488

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1          65      522081   83  Linux

/dev/sdb2              66        2610    20442712+   5  Extended

/dev/sdb5              66          79      112423+  8e  Linux LVM

/dev/sdb6              80          93      112423+  fd  Linux raid autodetect

/dev/sdb7              94         107      112423+  fd  Linux raid autodetect

[root@linuxso.com ~]# fdisk /dev/sdb

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)

Command (m for help): n

Command action

l   logical (5 or over)

p   primary partition (1-4)

l  #这里选择l 表示要创建一个额外的逻辑分区First cylinder (108-2610, default 108):

Using default value 108

Last cylinder, +cylinders or +size{K,M,G} (108-2610, default 2610): +100M#这里指定新分区的大小是100M

Command (m for help): w     #指定大小后,选w回车保存分区操作后退出The partition table has been altered!

[root@linuxso.com ~]# partprobe #使用此命令更新分区表,如果出错,需要重启来成功更新分区表

[root@linuxso.com ~]# fdisk -l /dev/sdb  #再次查看硬盘分区情况就可以看到新分区/dev/sdb8,但是此时还不可以使用,因为还没有指定文件系统格式,和挂载

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: 0xe7a49488

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1          65      522081   83  Linux

/dev/sdb2              66        2610    20442712+   5  Extended

/dev/sdb5              66          79      112423+  8e  Linux LVM

/dev/sdb6              80          93      112423+  fd  Linux raid autodetect

/dev/sdb7              94         107      112423+  fd  Linux raid autodetect

/dev/sdb8             108         121      112423+  83  Linux

重复以上步骤,再新建另一个分区/dev/sdb9

[root@linuxso.com ~]# fdisk -l /dev/sdb

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: 0xe7a49488

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1          65      522081   83  Linux

/dev/sdb2              66        2610    20442712+   5  Extended

/dev/sdb5              66          79      112423+  8e  Linux LVM

/dev/sdb6              80          93      112423+  fd  Linux raid autodetect

/dev/sdb7              94         107      112423+  fd  Linux raid autodetect

/dev/sdb8             108         121      112423+  83  Linux

/dev/sdb9             122         135      112423+  83  Linux

此时,/dev/sdb8 /dev/sdb9还无法使用,因为还没有指定文件系统类型,和挂载

[root@linuxso.com ~]# mount /dev/sdb8 /mnt#因为还没有指定文件系统格式, 所以挂载会失败,无法识别file.html' target='_blank'>文件类型mount: you must specify the filesystem type

为了使该分区可以使用,下面对其进行格式化

[root@linuxso.com ~]# mkfs -t ext4 /dev/sdb8  #用ext4格式格式化分区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

28112 inodes, 112420 blocks

5621 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67371008

14 block groups

8192 blocks per group, 8192 fragments per group

2008 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@linuxso.com ~]# mount /dev/sdb8 /mnt #mount 到/mnt目录下以供使用

如要使该分区可以在系统启动时自动挂载,可以修改/etc/fstab文件来实现

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值