Linux Disk Management

Source: Internet
Author: User

Swap partition set to 2~2.5 times of physical memory

SD and HD Two kinds: SD means stat hard disk, HD represents IDE hard disk;

SCSI hard disk and USB drive is also SD

boot partition to store the operating system kernel

root partition,/boot partition,

/var partition, swap partition

Can avoid runaway log file size

root partition,/boot partition,/home partition, swap partition

For a computer that provides services to many users, you can help control the amount of space the user occupies

The primary partition starts from SDB1 to SDB4, and the logical partition starts with SDB5 (logical partition always starts from SDB5 ... )

In the/dev directory, you can find a new hard disk , usually labeled SD?
# ls/dev/sd*


So you can see all the hard drives, and the last one is the new hard drive.

# FDISK-L shows the current device partition, unpartitioned

Fdisk/dev/sdb/mnt

P Output The current/DEV/SDB partition information

n Create a new partition

D Delete a partition that already exists

W Write and exit

Q Discard This modification and exit the Fdisk interactive mode directly

Mount and Umount

Iso9660:cdrom (CD) standard file system

Mount does not have any options and displays the currently mounted file system by default

Mounting and unloading of floppy disks

Floppy: Soft floppy disk: floppy disk, soft magnetic disc #mkdir/mnt/floppy#mount/dev/fd0/mnt/floppy#umount/dev/fd0 or #mount/mnt/flo Ppycdrom mount and uninstall #mount-t ISO9660/DEV/CDROMUSB storage device mount and uninstall to USB flash drive: #mkdir/mnt/flash#mount-t vfat/dev/sdb/mnt/flash #umo Unt/dev/sdb to USB removable hard disk: #mkdir/mnt/disk#mount-t vfat/dev/sdc1/mnt/disk#umount/dev/sdc110 formatted partition: MKFS.EXT3/DEV/SDB  11du: Statistics files and directories take up disk space-H output results in a way that people are accustomed to (habit) # du-h "Sort-n" the statistical results of "du-h" in order from small to large # Du-h | Sort-n

2DF: Show file system disk space usage

# df–h

Automatic system Mount:
    1. 1. First Look at the disk information in the system and determine if partitioning is required.

2 . Partitioning disk Operations

3. Format the partition-good disk

4. mount the partition-formatted disk

5. Uninstall the test after it is correct

6 . Modify the fstab file

7. Restart the Linux system to check the Mount status

1. First Look at the disk information in the system and determine if partitioning is required.

[[Email protected]~]# fdisk-l

disk/dev/SDA: 8589 MB, 8589934592bytes here is the disk information for SDA

255heads, Sectors/track, 1044 Cylinders

units= Cylinders of 16065 * 8225280 bytes

Deviceboot Start End Blocks Id System

/dev/sda1* 1044 8281507+ Linux

Note here 1044, if the display is less than 1044, indicates that the disk still has partitions not divided

/dev/sda21 104391-Swap/solaris Linux

Partitiontable entries is not in disk order

disk/dev/sdb: 6442 MB, 6442450944 bytes

255heads, Sectors/track, 783 cylinders

units= Cylinders of 16065 * 8225280 bytes

Disk/dev/sdb doesn ' t contain a valid partitiontable this shows that disk DEV/SDB has not yet been formatted.

As shown above, the system has two disk SDA, SDB, and prompted that SDB does not contain a partitioned table, you need to partition the operation.

2 . Partitioning disk Operations

[[Email protected]~]# fdisk/dev/sdb

Command (M for help): P p:print the partintion table

disk/dev/sdb:6442 MB, 6442450944bytes display disk basic information

255heads, Sectors/track, 783 cylinders

units= Cylinders of 16065 * 8225280 bytes

Deviceboot Start End Blocks Id System

As you can see here, the disk has not been partitioned

Command (M for help): n        n:Add a new partition

Commandaction

Eextended Select Primary partition or extended partition, select Primary partition here

Pprimary partition (1-4)

P

PartitionNumber (1-4): 3 Select the number of partitions.

First Cylinder (1-783, DEFAULT1): Sets the partition size. 1000M is defined here. is the nearest cylinder number to 1000M.

Usingdefault value 1

Lastcylinder or +size or +sizem or +sizek (1-783, default 783): +1000m

Command (M for help): w Save the configuration information if the input w is no error, such as do not save input Q exit

Command (M for help): p View the disk information after the partition as follows

disk/dev/sdb:6442 MB, 6442450944 bytes

255heads, Sectors/track, 783 cylinders

units= Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1368 783 3341520 Linux

/dev/sdb2124 367 1959930 Linux

/dev/sdb31 123 987966 Linux

3. Format the partition-good disk

[[Email protected]~]# mkfs.ext3/dev/sdb1 to format the disk SDB1 as a ext3 file system.]

[[Email protected]~]# fdisk–l using FDISK to view disk partitioning

4. mount the partition formatted disk and check that the partition is formatted.

[[email protected]] #mkdir/MNT/SDB1 Create a new directory SDB, to facilitate the management system in the MNT directory creation directory.

[[email protected]] #mount/DEV/SDB1/MNT/SDB1 to mount the disk SDB to the system

[[Email PROTECTED]SDB1] #ls write a file test to see if the disk can be read and written (formatted)

A.txtb.txt lost+found write test using VI a.txt

5. Uninstall the test after it is correct

[[email protected]] #umount/DEV/SDB1

6 . Modify the fstab file as follows:

[[email protected]] #vi/etc/fstab

label=//ext3 defaults 1 1

TMPFS/DEV/SHMTMPFS Defaults 0 0

devpts/dev/ptsdevptsgid=5,mode=620 0 0

Sysfs/sys Sysfs Defaults 0 0

Proc/procproc Defaults 0 0

Label=swap-sda2swap SWAP Defaults 0 0

/DEV/SDB1/MNT/SDB1 ext3 defaults 0 0

/DEV/SDB2/MNT/SDB2 ext3 defaults 0 0

/DEV/SDB3/MNT/SDB3 ext3 defaults 0 0

ü /dev/sdb1 ( disk partition )/mnt/sdb1 ( mount directory ) ext3 ( file format ) defaults 0 0< /c6>

7. Restart the Linux system to check the Mount status

[Email protected]sdb1]# DF

File system 1k-block already used% mount point available

/DEV/SDA1 8022104 2893532 4714500 39%/

Tmpfs 127720 0 127720 0%/dev/shm

/DEV/SDB1 3288944 71328 3050540 3%/mnt/sdb1

/DEV/SDB2 1929100 35696 1795408 2%/mnt/sdb2

/DEV/SDB3 972404 17640 905368 2%/mnt/sdb3

Successfully mount the three partitions of the newly created disk to the system as shown above

Chkconfig: set up and check the system's service settings

NTSYSV:( graphical interface ) set up various services of the system

# ntsysv--level 2345 ( Cancel "*" with spacekey )

# NTSYSV--back

pgrep: query process PID information based on specific criteria

Common Command options:

-L: List the name of the process

-U: Lookup based on the user name the process belongs to

-T: Find based on the terminal where the process resides

Raid 0 Striped Volume Stripe "Patchwork"

Each hard drive must have the same amount of space to contribute

Raid 1 mirrored volumes Mirror Made up of two disks

Raid 5 at least three hard drives

Linux Disk Management

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.