Linux System Management-Disk Management 1

Source: Internet
Author: User

1. Disk structure

Sector sector: 512byte per sector storage

Track: Divide 63 sectors per track

Head head: Logical Head (disk) number set to 255

Cylinder cylinder: The size of a cylinder =255x63x512byte=8m (Linux partition units)

Capacity of hard disk or partition = cylinder size x number of cylinders

2. Hard Drive Boot Process

Identify hard disk---> Plan partitions---> Format---> Mount---> Read and write Data

3. Common partition mode

1>MBR (Master Boot Record) partition

Partitioning method: First sector (521BIT) + 4 primary partitions (3 primary partitions + one extended partition) + several logical partitions

Cons: Up to 4 primary partitions, maximum support of 2.2TB

2>gpt (GUID Partition Table)

Advantage: Multiple partitions can be divided, maximum support 18EB (1EB=1024PB=1024X1024TB=1024X1024X1024GB)

Note: MBR partitions cannot coexist with GPT partitions

4. Disk Partitioning tool

FDISK------> Support MBR Partitioning

parted------> Support GPT partition, MBR partition

1>fdisk Tools

FDISK-L Display system partition information

  

FDISK/DEV/SDB partition the disk SDB and enter the following interface after operation

  

Enter M or help to display frequently used commands and helpful information

  

Create Primary partition 2G:

N (Create a new partition)--->p (create primary partition)--->1 (enter partition number)--->1 (the starting cylinder of the input partition, typically the end cylinder of the previous section)--->+2g (input partition size)--->w (save and exit)---> PARTPROBE/DEV/SDB (get new partition Table)--->ls/dev/sdb* (view to create partition)

When you create a partition, the ID number is the partition ID of the disk, each partition type is distinguished by a different ID number, and the ID number can be modified by the L to see the ID of the partition by T.

Creating an extended partition 10G:MBR partition can only create one extended partition

N (Create a new partition)--->e (create primary partition)--->2 (enter partition number)--->263 (the starting cylinder of the input partition, typically the end cylinder of the previous section)--->+10g (input partition size)--->w (save and exit)--- >PARTPROBE/DEV/SDB (get new partition Table)--->ls/dev/sdb* (view to create partition)

Create logical partition 2G: Logical partition created within an extended partition, the total partition size cannot exceed the extended partition size

N (Create a new partition)--->l (create primary partition)--->263 (the starting cylinder of the input partition, typically the end cylinder of the previous partition)--->+2g (input partition size)--->w (save and exit)--->partprobe/dev /SDB (get new partition Table)--->ls/dev/sdb* (view to create partition)

2>parted Partitioning Tool

4.2.1> View partition table: PARTED/DEV/SDA print

model:vmware, VMware Virtual S (SCSI)
disk/dev/sda:21.5gb
Sector size (logical/phy sical): 512b/512b
Partition table:msdos

number  start   end      size    type     File system     Flags
  1      1049kb  316mb   315mb   primary  ext4             boot
  2       316mb   19.4gb  19.0gb  primary  ext4
  3       19.4gb  21.5gb  2114mb  primary  linux-swap (v1)
4.2.2> Enter interactive mode: PARTED/DEV/SDA
GNU Parted 2.1
using/dev/sda
Welcome to GNU parted! Type ' help ' to view a list of commands.

4.2.3> Common operations
Mktable: Create partition table, that is, create disk partition format

Mkpart: Creating a disk partition

RM + partition number: Delete partition

Quit: Save and exit

4.2.4> creating a disk partitioning process

MKTABLE[MSDOS|GPT]--->mkpart[primary|extended|logical]--->[ext4|vfat]---> Start cylinder---> End cylinder

Create a GPT partition

Parted/dev/sdb

(parted) mktable GPT [build GPT partition Table]

Mkpart Primary EXT4 0 4G [Establish first 4G size primary partition]

Mkpart primary EXT4 4G 8G [Create a second 4G size primary partition]

Mkpart Primary EXT4 8G 100%[The remaining space as the last partition]

The partition table is as follows:

Number Start End Size File system Name Flags
1 17.4kB 4000MB 4000MB Primary
2 4000MB 8000MB 3999MB Primary
3 8000MB 21.5GB 13.5GB Primary

5. Get a new partition table

After you create the disk partition, you can obtain a new partition table by following the method

1>partx-a/dev/sdb
2>partprobe/dev/sdb
3>reboot

6. Format the disk

After the disk is created, the disk needs to be formatted and the disk is assigned to the file system after it is

Mkfs. File system [disk partition]:MKFS.EXT4/DEV/SDB1

7. Swap partition

  To improve read and write efficiency and speed, the Linux kernel caches files in memory, which is the cache memory. The Cache memory will not be released automatically even after your program has finished running. This will cause you to read and write files frequently in your Linux system, and you will find that there is less available physical memory. When the system's physical memory is not sufficient, it is necessary to release some of the space in physical memory for use by the currently running program. The freed space may come from programs that have not been manipulated for a long time, and the freed space is temporarily saved in the swap space until those programs are run and the saved data is restored to memory from the swap partition. In this way, the system always does swap swap when physical memory is not enough.

To use a partition as a swap partition, you must first format the partition as a swap partition

Mkswap/dev/sdb1

Enable/DEV/SDB1 to swap partition

Swapon/dev/sdb1

  Deactivate/dev/sdb1 as a swap partition

Swapoff/dev/sdb1

View Swap partitions

Free-m

Swapon-s

Create swap partitions with files

DD If=/dev/zero (source device) of=/tmp/swap.db (target device) bs=1m (block size) count=1024 (number of blocks) Create 1G size files

Mkswap/tmp/swap.db Formatting swap partitions

Swapon/tmp/swap.db Loading swap partitions

Swapon-s Viewing swap partitions

Filename Type Size used priority
/dev/sda3 Partition 2064380 6500-1
/DEV/SDB1 Partition 3906228 0-2
/tmp/swap.db file 1048572 0-3

  

  

  

  
  

    

    

Linux System Management-Disk Management 1

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.