查看磁盘:fdisk -l

一块磁盘可以分14个分区

[root@wendyhost ~]# fdisk -l

Disk /dev/sda: 64.4 GB, 64424509440 bytes

255 heads, 63 sectors/track, 7832 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        1057     8385930   83 Linux

/dev/sda3            1058        1815     6088635   82 Linux swap / Solaris

/dev/sda4            1816        7832    48331552+   5 Extended

/dev/sda5            1816        2859     8385898+ 83 Linux

/dev/sda6            2860        3381     4192933+ 83 Linux

/dev/sda7            3382        3903     4192933+ 83 Linux

/dev/sda8            3904        7832    31559661   83 Linux

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

以上有2块磁盘,/dev/sdb没有分区


进行分区: fdisk /dev/sdb

[root@wendyhost ~]# 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.

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)

Command (m for help): p查看分区

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System

Command (m for help): n加分区add a new partition

Command (m for help): n

Command action

e   extended 扩展分区可以添加一个

p   primary partition (1-4)个

  • 主分区+扩展分区不能超过4个
  • 扩展分区是不能用的,只能在扩展分区下添加逻辑分区
  • 一块磁盘可以分14个分区

e

Partition number (1-4):

First cylinder (1-130, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):

Using default value 130

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System

/dev/sdb1               1         130     1044193+   5  Extended

Command (m for help): n

Command action

l   logical (5 or over)

p   primary partition (1-4)

l

First cylinder (1-130, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): +50M

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id System

/dev/sdb1               1         130     1044193+   5 Extended

/dev/sdb5               1           7       56164+ 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

[root@wendyhost ~]#

[root@wendyhost ~]# partprobe

Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.

[root@wendyhost ~]#


使用分区:mkfs.ext3 /dev/sdb5

[root@wendyhost ~]# mkfs.ext3 /dev/sdb5

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

14056 inodes, 56164 blocks

2808 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=57671680

7 block groups

8192 blocks per group, 8192 fragments per group

2008 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or

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


将分区mount到目录上,这样才能使用

[root@wendyhost ~]# mount

/dev/sda2 on / type ext3 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/sda8 on /u01 type ext3 (rw)

/dev/sda7 on /home type ext3 (rw)

/dev/sda6 on /var type ext3 (rw)

/dev/sda5 on /usr type ext3 (rw)

/dev/sda1 on /boot type ext3 (rw)

tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

.host:/ on /mnt/hgfs type vmhgfs (rw,ttl=1)

none on /proc/fs/vmblock/mountPoint type vmblock (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

以上是开机自动mount的


将sdb5分区mount到目录/mnt上:mount /dev/sdb5 /mnt

[root@wendyhost ~]# mount /dev/sdb5 /mnt

[root@wendyhost ~]# cd /mnt

[root@wendyhost mnt]# pwd

/mnt

[root@wendyhost mnt]# ls

lost+found

[root@wendyhost mnt]# touch test

[root@wendyhost mnt]# ls

lost+found test


创建了test文件,该文件是写在sdb5分区的磁盘上。

[root@wendyhost mnt]# mount

/dev/sda2 on / type ext3 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

/dev/sda8 on /u01 type ext3 (rw)

/dev/sda7 on /home type ext3 (rw)

/dev/sda6 on /var type ext3 (rw)

/dev/sda5 on /usr type ext3 (rw)

/dev/sda1 on /boot type ext3 (rw)

tmpfs on /dev/shm type tmpfs (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

.host:/ on /mnt/hgfs type vmhgfs (rw,ttl=1)

none on /proc/fs/vmblock/mountPoint type vmblock (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

/dev/sdb5 on /mnt type ext3 (rw)


如果umount /dev/sdb5,则在/mnt下看不到test文件。

[root@wendyhost /]# umount /dev/sdb5

最新文章

  1. C#实现Excel的导入导出
  2. JS-随机函数
  3. Neutron分析(5)—— neutron-l3-agent中的iptables
  4. 金额大小写转换和input失去焦点触发事件
  5. 数据库update的异常一例
  6. win7 64位安装 oracle 11G 和 使用 PLSQL Developer 连接服务器
  7. linux 进程监控和自动重启的简单实现
  8. 【Java学习笔记之三十一】详解Java8 lambda表达式
  9. Spark环境搭建(下)——Spark安装
  10. springMVC源码分析--异常处理机制HandlerExceptionResolver简单示例(一)
  11. ubuntu16.04上安装ros-kinetic
  12. document.getElementsByClassName返回的是一个数组
  13. 地图标绘系统V1.0测试版【申明:来源于网络】
  14. 微信小程序之自定义模态弹窗(带动画)实例
  15. 解决内存不能为read错误
  16. 去除partner页面消息 自动添加关注者的功能
  17. skipper lua 脚本支持
  18. Docker学习要点记录
  19. linespace函数
  20. [置顶] 【机器学习PAI实践十一】机器学习PAI为你自动写歌词,妈妈再也不用担心我的freestyle了(提供数据、代码

热门文章

  1. PHP 抽象类的使用
  2. unity5, UI Button "On Button Down"
  3. Xml+Xslt测试工具
  4. 如何启动mininet实例上的wireshark图形界面
  5. C# ZPL II 命令打印标签
  6. Mybatis设置超时时间
  7. java -jar命令
  8. bootstrap table 服务器端分页--ashx+ajax
  9. mongdb复制集搭建
  10. Unity3D避免代码被反编译