How Linux uses the new hard drive that is added

Source: Internet
Author: User
Tags uuid

I. Disk partitioning

The device number of the first disk after the system has been installed is/DEV/SDA, which is typically/dev/sdb after you add a new disk

Enter the Fdisk interface * * *

# FDISK/DEV/SDB
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF Disklabel
Building a new DOS disklabel with disk identifier 0xa64fcc39.
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)

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 ').
P parameter Displays disk partition information * * * *
Command (M for help): P

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0xa64fcc39

Device Boot Start End Blocks Id System
n parameter create partition ******

Create primary partition
Command (M for help): N
Command Action
E Extended//extended partition
P primary partition (1-4)//Primary partition
P
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using Default value 1
Last cylinder, +cylinders or +size{k,m,g} (1-652, default 652): +1g

Command (M for help): P

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0xa64fcc39

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1060258+ Linux

Create an extended partition ******

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
E
Partition number (1-4): 4
First cylinder (133-652, default 133):
Using Default Value 133
Last cylinder, +cylinders or +size{k,m,g} (133-652, default 652):
Using Default value 652

Command (M for help): P

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0xa64fcc39

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1060258+ Linux
/DEV/SDB4 133 652 4176900 5 Extended
Creating Logical Partitions * * * *
Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (133-652, default 133):
Using Default Value 133
Last cylinder, +cylinders or +size{k,m,g} (133-652, default 652): +1g

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (265-652, default 265):
Using Default Value 265
Last cylinder, +cylinders or +size{k,m,g} (265-652, default 652):
Using Default value 652

Command (M for help): P

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0xa64fcc39

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1060258+ Linux
/DEV/SDB4 133 652 4176900 5 Extended
/DEV/SDB5 133 1060258+ Linux
/DEV/SDB6 265 652 3116578+-up Linux
Save partition settings and Exit fdisk*************
Command (M for help): W
The partition table has been altered!

Calling IOCTL () to re-read partition table.
Syncing disks.

Note: Beginners generally think that it is possible to use a new disk here, but this is not the case, but also to do, to create the file system, mount the file system before you can use *********

Two. Creating a file system

MKFS command to create a file system

mkfs-t [File system type] [disk device name]

-T: Specifies which file system to create

Linux system kernel can support dozens of types of file system, 1) ext2 file system should be said to be the original Linux file system, the early Linux are used ext2, but with the development of technology, most of the Linux distribution does not use this file system now , such as Redhat and Fedora are mostly recommended to use EXT3, Ext3 file system is developed by the ext2. For Linux Novice, we still recommend that you do not use Ext2 file system, ext2 support undelete (undelete), if you delete files by mistake, sometimes can be restored, but the operation is more troublesome; ext2 support large files; The official homepage of the ext2 file system is: 2) ext3 File system: It is developed by the ext2 file system; Ext3 is a journalizing "file system for Linux" (Ext3 is a log file system for Linux), EXT3 supports large files, but does not support undelete (undelete) operations Redhat and Fedora are very ext3; For more features of the Ext3 file system, visit the Linux file System (FileSystem) resource Index, 3) ReiserFS file system, and the ReiserFS file system is an excellent file system, Support large files, support anti-deletion (undelete), in my test ext2, ReiserFS undelete file function, I found ReiserFS file system performance is the best, almost recover more than 90% of the data, sometimes recover to 100%; Operation Undelete is easier ; ReiserFS supports large files; 4), Linux supported file systems; Linux currently supports almost all UNIX class file systems, in addition to the ext3, ReiserFS, and ext2 that we choose to install the Linux operating system, It also supports Apple MacOS's HFS and other Unix operating system file systems, such as XFS, JFS, Minix FS and UFS, which you can view in kernel source code, and if you want the system to support which file systems need to be compiled into modules or placed into the kernel Linux also supports Windows file system NTFST and fat, but does not support NTFS file system writes; Linux supports the FAT file system and also supports network file systems such as NFS.

# mkfs-t EXT3/DEV/SDB1
MKE2FS 1.41.12 (17-may-2010)
File System label =
Operating system: Linux
Block size =4096 (log=2)
Chunked size =4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
66384 inodes, 265064 blocks
13253 blocks (5.00%) reserved for the Super user
First block of data =0
Maximum filesystem blocks=272629760
9 Block groups
32768 blocks per group, 32768 fragments per group
7376 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Writing Inode table: complete
Creating Journal (8192 blocks): complete
Writing Superblocks and FileSystem accounting information: Complete

This filesystem'll be automatically checked every mounts or
Whichever comes first. Use Tune2fs-c or-i to override.
[Email protected] ~]# mkfs-t EXT3/DEV/SDB4
MKE2FS 1.41.12 (17-may-2010)
Mkfs.ext3:inode_size (+) * Inodes_count (0) too big for a
FileSystem with 0 blocks, specify higher inode_ratio (-i)
or lower inode count (-N).

Three. Mount and unmount the file system

Mount and Umount commands enable the mount and unload functions so that users can store data using the appropriate device *******

Set the directory/mnt/kk where you want to place the file system, and then mount the/DEV/SDB1 to the directory

# MKDIR/MNT/KK
# MOUNT/DEV/SDB1/MNT/KK,

View/mnt/kk, where there are no files
# LS/MNT/KK
Lost+found
# Mkdir/mnt/kk/test
# LS/MNT/KK
Lost+found Test

To view partition information using the DF command
# DF
Filesystem 1k-blocks used Available use% mounted on
/dev/sda3 18244476 2727168 14583884 16%/
Tmpfs 969900 969824 1%/DEV/SHM
/DEV/SDA1 194241 28677 155324 16%/boot
/dev/sr0 3116336 3116336 0 100%/media/rhel-6.6 server.i386
/DEV/SDB1 1043548 34112 956424 4%/mnt/kk

Uninstalling the file system

# UMOUNT/DEV/SDB1
# LS/MNT/KK
# DF
Filesystem 1k-blocks used Available use% mounted on
/dev/sda3 18244476 2726532 14584520 16%/
Tmpfs 969900 969824 1%/DEV/SHM
/DEV/SDA1 194241 28677 155324 16%/boot
/dev/sr0 3116336 3116336 0 100%/media/rhel-6.6 server.i386

A partition or device is mounted for later use, but when the computer restarts, it is necessary to re-mount this time by modifying the/etc/fstab file to automatically mount the file system

[Email protected] ~]# Cat/etc/fstab

#
#/etc/fstab
# Created by Anaconda on Sat 28 21:56:53 2015
#
# Accessible filesystems, by reference, is maintained under '/dev/disk '
# See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info
#
UUID=125DE97E-B784-4948-BC00-7DBFDC11C8A5/EXT4 Defaults 1 1
Uuid=e69780c7-d8f5-4d34-a7a7-8abe01c2299c/boot EXT4 Defaults 1 2
uuid=2b532692-271a-4f6b-845f-b07a271c603f swap swap defaults 0 0
TMPFS/DEV/SHM TMPFS Defaults 0 0
Devpts/dev/pts devpts gid=5,mode=620 0 0
Sysfs/sys Sysfs Defaults 0 0
PROC/PROC proc Defaults 0 0

On the bottom line of the/etc/fstab, add the/DEV/SDB1 boot to the auto-mount

/dev/sdb1/mnt/kk ext3 defaults 0 0

How to use new hard drives added by Linux

Related Article

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.