1, first, we talk about the hard drive.
We all know that hard disk is used to store files, of course, with the file system (file system management of the corresponding hardware resources).
A hard disk consists of multiple disks, each with two sides, a head on each side, and multiple tracks on the disk.
The hard disk is divided into several sectors, the current normal one sector is 512byte. The first sector stores the master boot record and the partition table information.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/DD/wKioL1fjobqAtcvgAABduCoIwXE278.png-wh_500x0-wm_3 -wmp_4-s_2919637898.png "title=" disk. png "alt=" wkiol1fjobqatcvgaabducoiwxe278.png-wh_50 "/>
HDD Storage capacity = number of Heads x track (cylinder) x number of sectors x per sector × bytes per slice
(1) The hard disk has several platters, two faces per platter, one head per face
(2) The disc is divided into a plurality of sector sectors i.e. sector
(3) Concentric circles with different radii of the same disc as track
(4) cylindrical surface with same radius of different discs
(5) formula: Storage capacity = number of Heads x track (cylinder) x number of sectors per sector X number of bytes per sector
(6) Information record can be expressed as: xx track (cylinder), XX Head, XX sector
2. HDD partition and Mount under Linux
2.1 Everything is in the form of a document
In Linux, all the devices are in the form of files, including hard drives.
The device file path in the/dev path. For example, there is a hard disk SDA in the machine. Coexist in partition Sda1,sda2,sda5.
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/87/DD/wKioL1fjouvRd4PxAACvY0xzrQY399.png-wh_500x0-wm_3 -wmp_4-s_2913838612.png "title=" added Sdb.png "alt=" Wkiol1fjouvrd4pxaacvy0xzrqy399.png-wh_50 "/>
The other/path is the root path of the Linux system.
Below the machine, the SDA1 partition is mounted under the root path, and the partition is 85G in size.
[Email protected]:/dev$ df-h
Filesystem Size used Avail use% mounted on
Udev 982M 4.0K 982M 1%/dev
Tmpfs 199M 1.7M 197M 1%/run
/DEV/SDA1 85G 23G 58G 29%/
None 4.0K 0 4.0K 0%/sys/fs/cgroup
None 5.0M 0 5.0M 0%/run/lock
None 992M 144K 992M 1%/RUN/SHM
None 100M 36K 100M 1%/run/user
2.2 Adding and partitioning a hard drive
We have an example of this machine
The machine is a virtual machine built on Windows using VMware, Ubuntu system.
First we add the hard drive, and then we need to reboot.
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/87/DD/wKioL1fjpOji14XUAADUQvUyo6U962.png-wh_500x0-wm_3 -wmp_4-s_3440062530.png "title=" Add hard disk. png "alt=" wkiol1fjpoji14xuaaduqvuyo6u962.png-wh_50 "/>
After adding, we can see the newly added hard disk device in/dev:/dev/sdb
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/87/E1/wKiom1fjpS6A9Xb1AACvY0xzrQY936.png-wh_500x0-wm_3 -wmp_4-s_3503685345.png "title=" added Sdb.png "alt=" Wkiom1fjps6a9xb1aacvy0xzrqy936.png-wh_50 "/>
2.3 Hard Disk partitions
After finding the newly added hard disk file (/DEV/SDB), we need to partition it
[Email protected]:/dev$ sudo fdisk SDB
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF Disklabel
Building a new DOS disklabel with disk identifier 0x1fc07a59.
Changes'll remain in memory only, until the decide to write them.
After that, of course, the previous content won ' t is recoverable.
Warning:invalid flag 0x0000 of partition Table 4 would be a 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 sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x1fc07a59
Device Boot Start End Blocks Id System
Command (M for help): N
Partition Type:
P Primary (0 primary, 0 extended, 4 free)
E Extended
Select (default p): P
Partition number (1-4, default 1): 1
First sector (2048-10485759, default 2048):
Using Default Value 2048
Last sector, +sectors or +size{k,m,g} (2048-10485759, default 10485759): +2g
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
The above procedure we added a 2Gbyte partition sdb1
Above we notice that the partition number can only be 1~4, because:
We talked before. The first sector stores the master boot record and the partition information,
The master boot record needs 446byte, each partition information needs 16byte, and a sector is only 512byte,
therefore (512-446)/16----4 maximum of 4 partitions.
Of course, we can choose to use 3 primary partition to add an extended partition method, the extended partition can create an infinite number of logical partitions.
For example, after partitioning we can find the partition file/dev/sdb1
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/87/DE/wKioL1fjpu3A7VHHAAAgAoNOWIQ214.png-wh_500x0-wm_3 -wmp_4-s_508972014.png "title=" Partition Sdb1.png "width=" "height=" 294 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width : 250px;height:294px; "alt=" Wkiol1fjpu3a7vhhaaagaonowiq214.png-wh_50 "/>
2.4 Formatting partitions
We formatted/DEV/SDB1 as EXT4 (Ext4 is one of the file system formats)
[Email protected]:/dev$ mkfs.ext4/dev/sdb1
MKE2FS 1.42.9 (4-feb-2014)
Mkfs.ext4:Permission denied while trying to determine filesystem size
[Email protected]:/dev$ sudo mkfs.ext4/dev/sdb1
MKE2FS 1.42.9 (4-feb-2014)
Filesystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the Super user
First Data block=0
Maximum filesystem blocks=536870912
Block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group Tables:done
Writing Inode Tables:done
Creating Journal (16384 blocks): Done
Writing superblocks and filesystem accounting Information:done
2.5 Mount Partition
Mounting is roughly understood to hook up a storage device with a path.
Mount partitions can be mounted temporarily using mount, or you can modify the fstab directly to mount them.
2.5.1 Mount Temporary Mount
Mount temporarily mounts a device that is no longer mounted after rebooting the system. Files created and written during Mount are not lost.
[Email protected]:~$ mkdir Mynewdisk
[Email protected]:~$ ls
Bin Desktop Documents Downloads examples.desktop Music myLearn mynewdisk Pictures public Templates Videos work S
[Email protected]:~$ sudo mount/dev/sdb1 ~/mynewdisk
When mounted
[Email protected]:/dev$ df-h
Filesystem Size used Avail use% mounted on
Udev 982M 4.0K 982M 1%/dev
Tmpfs 199M 1.7M 197M 1%/run
/DEV/SDA1 85G 23G 58G 29%/
None 4.0K 0 4.0K 0%/sys/fs/cgroup
None 5.0M 0 5.0M 0%/run/lock
None 992M 144K 992M 1%/RUN/SHM
None 100M 36K 100M 1%/run/user
/DEV/SDB1 2.0G 3.1M 1.8G 1%/home/jetxu/mynewdisk
This allows us to use the newly added hard drive resources. The operation on the/home/jetxu/mynewdisk path is based on the newly added hard drive.
2.5.2 Permanent Mount
Add the following to the/etc/fstab file.
/dev/sdb1/home/jetxu/mynewdisk EXT4 Defaults 0 0
[Email protected]:/dev$ cat/etc/fstab
#/etc/fstab:static File System information.
#
# use ' Blkid ' to print the universally unique identifier for a
# device; This is used with uuid= as a more robust-to name devices
# that works even if disks is added and removed. See Fstab (5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
#/was on/dev/sda1 during installation
UUID=1664B5BB-45E6-43F5-BFE7-3AE34CCAA6AC/EXT4 Errors=remount-ro 0 1
# Swap was on/dev/sda5 during installation
Uuid=e714a2eb-4856-4081-893f-29bd947a3dc2 None swap SW 0 0
/dev/fd0/media/floppy0 Auto Rw,user,noauto,exec,utf8 0 0
/dev/sdb1/home/jetxu/mynewdisk EXT4 Defaults 0 0
After reboot (boot process system automatically mounts)
[Email protected]:/dev$ df-h
Filesystem Size used Avail use% mounted on
Udev 982M 4.0K 982M 1%/dev
Tmpfs 199M 1.7M 197M 1%/run
/DEV/SDA1 85G 23G 58G 29%/
None 4.0K 0 4.0K 0%/sys/fs/cgroup
None 5.0M 0 5.0M 0%/run/lock
None 992M 144K 992M 1%/RUN/SHM
None 100M 32K 100M 1%/run/user
/DEV/SDB1 2.0G 3.1M 1.8G 1%/home/jetxu/mynewdisk
Linux HDD Mount