免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 17068 | 回复: 15

[学习分享] Linux中直接挂载硬盘和挂载分区有什么区别? [复制链接]

论坛徽章:
0
发表于 2014-03-02 01:01 |显示全部楼层
如题,Linux中直接挂载硬盘和挂载分区有什么区别?
比如 /dev/sdb 的硬盘,直接mkfs.ext4 /dev/sdb 后mount 使用,
和 先fdisk 分区 ,在 mkfs 在mount 使用,
两者相比有何区别?非常感谢。

论坛徽章:
26
CU十二周年纪念徽章
日期:2013-10-24 15:41:34技术图书徽章
日期:2014-07-11 16:27:52辰龙
日期:2014-09-04 13:40:43白羊座
日期:2014-09-09 12:51:55双子座
日期:2014-09-26 11:00:042014年中国系统架构师大会
日期:2014-10-14 15:59:00子鼠
日期:2014-10-23 16:48:23巨蟹座
日期:2014-10-27 08:21:10申猴
日期:2014-12-08 10:16:282015年辞旧岁徽章
日期:2015-03-03 16:54:15NBA常规赛纪念章
日期:2015-05-04 22:32:03IT运维版块每日发帖之星
日期:2016-01-29 06:20:00
发表于 2014-03-02 08:37 |显示全部楼层
你确定,不用分区?而不是一块硬盘只分成一个区?

直接用过/dev/sdb 的硬盘,直接mkfs.ext4

能用吗?

论坛徽章:
0
发表于 2014-03-02 11:44 |显示全部楼层
回复 2# cryboy2001

操作如下:


[root@rhel6_storage ~]# fdisk -l

Disk /dev/sda: 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: 0x0008b221

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496   8e  Linux LVM

Disk /dev/mapper/vg_rhel6x64-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 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: 0x00000000


Disk /dev/mapper/vg_rhel6x64-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 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: 0x00000000


Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x00000000


Disk /dev/sdc: 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: 0x00000000

[root@rhel6_storage ~]# mkfs.ext4 /dev/sdc
mke2fs 1.41.12 (17-May-2010)
/dev/sdc is entire device, not just one partition!
无论如何也要继续? (y,n) y
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

正在写入inode表: 完成                           
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@rhel6_storage ~]# mount /dev/sdc /mnt
[root@rhel6_storage ~]# cd /mnt
[root@rhel6_storage mnt]# ls
lost+found
[root@rhel6_storage mnt]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xaed63d20.
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)

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): p

Disk /dev/sdc: 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: 0xaed63d20

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): d
No partition is defined yet!

Command (m for help): q


可以看到 /dev/sdc 没有分区,直接mkfs 后 ,mount到了 /mnt  ,并且可以使用,同时用fdisk /dev/sdc 查看,里面是没有分区的。。

   

论坛徽章:
0
发表于 2014-03-02 11:46 |显示全部楼层
[root@rhel6_storage mnt]# df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/vg_rhel6x64-lv_root   18G  1.2G   16G   8% /
tmpfs                            495M     0  495M   0% /dev/shm
/dev/sda1                        485M   33M  427M   8% /boot
/dev/sdc                          20G  172M   19G   1% /mnt

论坛徽章:
26
CU十二周年纪念徽章
日期:2013-10-24 15:41:34技术图书徽章
日期:2014-07-11 16:27:52辰龙
日期:2014-09-04 13:40:43白羊座
日期:2014-09-09 12:51:55双子座
日期:2014-09-26 11:00:042014年中国系统架构师大会
日期:2014-10-14 15:59:00子鼠
日期:2014-10-23 16:48:23巨蟹座
日期:2014-10-27 08:21:10申猴
日期:2014-12-08 10:16:282015年辞旧岁徽章
日期:2015-03-03 16:54:15NBA常规赛纪念章
日期:2015-05-04 22:32:03IT运维版块每日发帖之星
日期:2016-01-29 06:20:00
发表于 2014-03-02 12:49 |显示全部楼层
看你的操作是这样的,但我从没这么用过,更不清楚原因,坐等高手。

这样是不是连分区表也省了啊,不知道会不会有什么不良后果

论坛徽章:
0
发表于 2014-03-02 14:40 |显示全部楼层
cu似乎没什么人气?还是我待的板块不对哦。

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
发表于 2014-03-03 07:41 |显示全部楼层
我们常用硬盘, 有一块区域叫 MBR(传统), 它一般是在硬盘0柱0面1扇区, 差不多512字节. 其实前446字节是真正的MBR, 或者叫 主引导记录. 后面的 64字节就是分区表(MBR分区表), 最后两个字节是55AA(这是MBR结束标志).

由于只有64字节的分区表, 所以, 在MBR结构的分区表中, 只能有4个主分区(每条记录16字节), 也限制了每个分区的最大大小(2T).所以, 超过2T的硬盘, 要使用 GPT的分区表, 关于GPT的分区表, 我没有研究过, 如果有哪位有相关的信息, 我也学习一下.

对于一般的使用, 硬盘应该是先分区(至少一个分区), 如果直接使用整个硬盘(没有分区, 我不是太确定是不是会把MBR也一起干掉, 也就是硬盘从第1扇区就开始用了. 楼主可以 把你的硬盘的前512字节dd到一个文件里, 然后 hexdump -C ufile, 可以查到最后两个字节是不是 55AA或者  AA55.

论坛徽章:
2
辰龙
日期:2015-01-11 00:34:002015年亚洲杯之巴勒斯坦
日期:2015-01-28 10:35:37
发表于 2014-03-03 08:35 |显示全部楼层
本帖最后由 securitypluscn 于 2014-03-03 10:41 编辑

你的硬盘被当作循环设备处理了,也就是有文件系统但没有分区,像DVD,CD 一样。 用PARTED可以看到PARTITION TABLE TYPE: LOOP

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
发表于 2014-03-03 09:41 |显示全部楼层
没测试过,还是至少分一个区再挂载吧。

论坛徽章:
0
发表于 2014-03-03 23:01 |显示全部楼层
q1208c 发表于 2014-03-03 07:41
我们常用硬盘, 有一块区域叫 MBR(传统), 它一般是在硬盘0柱0面1扇区, 差不多512字节. 其实前446字节是真正的 ...


谢谢,如果不分区直接使用的话,MBR区域都是都是0,且新的写入也不会占用这一扇区,当然这样使用的,通过fdisk -l 查看是没有硬盘标示符的。因为最后没有55AA
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP