Linux中直接掛載硬碟和掛載分區有什麼區別?
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