磁盘可不可以不分区直接mount?

来源:互联网 发布:起点数据库 编辑:程序博客网 时间:2024/05/01 18:18

1.问题

Linux中直接挂载硬盘和挂载分区有什么区别?
比如 /dev/sdb 的硬盘,直接mkfs.ext4 /dev/sdb 后mount 使用,
和 先fdisk 分区 ,在 mkfs 在mount 使用,
两者相比有何区别?


2.回答1

你确定,不用分区?而不是一块硬盘只分成一个区?

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

能用吗?


3.回答2

操作如下:


[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 查看,里面是没有分区的。。


4.回答3

看你的操作是这样的,但我从没这么用过,更不清楚原因,坐等高手。

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

5.回答4

我们常用硬盘, 有一块区域叫 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.

6.回答5

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

7.回答6

如果不分区直接使用的话,MBR区域都是都是0,且新的写入也不会占用这一扇区,当然这样使用的,通过fdisk -l 查看是没有硬盘标示符的。因为最后没有55AA


转自http://blog.csdn.net/wanglei9876/article/details/46968279