What is the difference between directly attaching a hard disk and attaching a partition in Linux ?, Linux mounting

Source: Internet
Author: User

What is the difference between directly attaching a hard disk and attaching a partition in Linux ?, Linux mounting
Zookeeper

1. Problem

What is the difference between directly mounting a hard disk and attaching a partition in Linux?
For example, the hard disk of/dev/sdb can be mounted directly after mkfs. ext4/dev/sdb,
And fdisk partitioning, used in mkfs in mount,
What is the difference between the two?


2. Answer 1

Are you sure you don't need to partition? Instead of dividing a hard disk into one partition?

Direct use of/dev/sdb hard disks, direct mkfs. ext4

Can it be used?


3. Answer 2

The procedure is as follows:


[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!
What should I do? (Y, n) y
File System tag =
Operating System: Linux
Block size = 4096 (log = 2)
Part size = 4096 (log = 2)
Stride = 0 blocks, Stripe width = 0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block = 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,983 04, 163840,229 376, 294912,819 200, 884736,160 5632, 2654208,
4096000

Writing to inode table: complete
Creating journal (32768 blocks): Done
Writing superblocks and filesystem accounting information: complete

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 stronugly recommended
Switch off the mode (command 'C') and change display units
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


We can see that/dev/sdc has no partitions. After mkfs is directly mounted to/mnt, it can be used and viewed using fdisk/dev/sdc. No partitions exist ..


4. Answer 3

You can see that your operation is like this, but I have never used it like this, but I don't know the reason, wait for a master.

This saves the trouble of connecting partition tables. I don't know if there will be any adverse consequences.

5. Answer 4

We often use hard disks. One area is MBR (traditional). It is generally in the hard disk with 0 columns, 0 faces, and 1 sector, and is about 512 bytes. in fact, the first 446 bytes are real MBR, or Master Boot records. the next 64 bytes are the Partition Table (MBR Partition Table), and the last two bytes are 55AA (this is the MBR end mark ).

Because there are only 64-byte partition tables, the MBR structure only supports four primary partitions (16 bytes per record ), it also limits the maximum size of each partition (2 T ). therefore, for a hard disk larger than 2 TB, you need to use the GPT partition table. I have not studied the GPT partition table. If any one has relevant information, I will also learn about it.

For general use, the hard disk should be partitioned first (at least one partition). If the whole hard disk is used directly (no partition, I am not sure whether the MBR will be killed together, that is to say, the hard disk is used from the 1st sector. the landlord can add the first 512 bytes of your hard disk to a file, and then hexdump-C ufile to check whether the last two bytes are 55AA or AA55.

6. Answer 5

Your hard disk is processed as a cyclic device, that is, there is a file system but there is no partition, like a DVD or CD. Use PARTED to see partition table type: LOOP

7. Answer 6

If it is used directly without partitions, the MBR region is all 0, and new writes do not occupy this sector. Of course, this is the case, no hard disk identifier is displayed through fdisk-l. Because there is no 55AA

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.