In addition to account management, file permissions, archive management content, disk partitioning and formatting operations, file system mounts and other uses are also a Linux system administrator is an indispensable skill.
When partitioning a disk in Linux does not meet the requirements, you need to plan and adjust the hard disk partition, and sometimes the newly added disk will require us to partition and mount.
1. Detect and confirm the new disk
The system will recognize the new disk if it is hooked up to a disk restart. We use "fdisk-l" To view the disk device .
[Email protected] ~]# fdisk-l
disk/dev/sda:85.9 GB, 85899345920 bytes The original disk name size and other information
255 heads, Sectors/track, 10443 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x0002454c
whether the device name is a boot partition the size (in bytes) partition type of the end location partition at the start of the partition in the secondary disk
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 2614 20480000 Linux
/dev/sda3 2614 3634 8192000 -up Linux
/DEV/SDA4 3634 10444 54701056 5 Extended
/dev/sda5 3634 4144 4096000 , Linux Swap/solaris
/dev/sda6 4144 10444 50603008 -up Linux
Disk /dev/sdb: 53.7 GB, 53687091200 bytes not partitioned and mounted are new disks
255 heads, Sectors/track, 6527 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000
ID: Above ID: A special description of the EXT3 partition for Linux is required. 8e:LVM Logical Volume : The swap partition
Identify the new hard drive device and we can start creating a new partition.
2. Planning for disk partitioning
the Create, delete, and change partition operations are also performed with the Fdisk command.
Access to the Interactive partition management interface
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7D/85/wKioL1bqOiOw-UFwAABLprH9_2I018.png "style=" float: none; "title=" Fdisk.png "alt=" Wkiol1bqoiow-ufwaablprh9_2i018.png "/>
Get help:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7D/88/wKiom1bqOZWxV6caAABN01uCtHE315.png "style=" float: none; "title=" M.png "alt=" Wkiom1bqozwxv6caaabn01ucthe315.png "/>
list disk partition conditions
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7D/88/wKiom1bqOZbCuHXYAAA0v1WIGEI237.png "style=" float: none; "title=" P.png "alt=" Wkiom1bqozbcuhxyaaa0v1wigei237.png "/>
New Partition
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7D/85/wKioL1bqOuSxXkNiAAAPvjZlm08453.png "title=" N.png " alt= "Wkiol1bqousxxkniaaapvjzlm08453.png"/>
Partition includes primary partition and extended partition input e create extended partition input p Create primary partition
The ordinal number of primary and extended partitions can only be 1-4.
Creating Partitions
(1) Creation of 1 primary partitions
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/88/wKiom1bqPOzThAN9AABgYdVujyk332.png "title=" Z.png " alt= "Wkiom1bqpozthan9aabgydvujyk332.png"/>
(2) Create an extended partition and logical partition
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7D/85/wKioL1bqPvPCR6ufAABvaBz2HIw511.png "title=" kz.png "alt=" Wkiol1bqpvpcr6ufaabvabz2hiw511.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7D/85/wKioL1bqQrewP1kXAAB-mUqkaXQ388.png "title=" L.png " alt= "Wkiol1bqqrewp1kxaab-muqkaxq388.png"/>
(3) d delete partition T change partition type
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/7D/88/wKiom1bqQVmjLlWGAAB_ehTXnGw924.png "title=" ss.png "alt=" Wkiom1bqqvmjllwgaab_ehtxngw924.png "/>
the default partition file system type is EXT3, which generally does not need to be changed if the newly created partition is to be used as a swap partition or other partition type. You need to change the partition type. Change the ID number of the partition with the T instruction. The common EXT3, swap file system IDs are 83, 82, respectively. The ID number of the FAT32 for Windows is typically B. System boot partition and extended partition cannot change partition type
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7D/88/wKiom1bqRNPjaQwNAAC7zNKup8Q207.png "title=" T.png " alt= "Wkiom1bqrnpjaqwnaac7znkup8q207.png"/>
(4) W save exit Q Exit Do not save
The Fdisk partitioning tool is to be rolled out after the partition of the disk is complete.
W: Save the action, exit
Q: Do not save any operations you have done to exit. 650) this.width=650; "Src=" http://s4.51cto.com/wyfs02/M02/7D/86/wKioL1bqR9b Wskevaacyghts5mw428.png "title=" Wqa.png "alt=" Wkiol1bqr9bwskevaacyghts5mw428.png "/> Note: After you change the partition of your hard disk (especially the hard disk you are using), it is a good idea to restart the system once or use the Partprobe command to re-detect the partition table. In Linux, if you do not do this, the formatted partition may cause corruption to the data on the hard disk, which can cause the system to crash when it is critical.
For example, perform partprobe to re-detect the partition change of the/DEV/SDB disk.
Partprobe/dev/sdb
3. Managing the File system
after partitioning with Fdisk in Linux, the partition is formatted to mount to the specified directory and store the data.
creating a file system
1. Partitioning with the MKFS command
mkfs-t file system partition device
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7D/AB/wKiom1bsxTTxhXPqAAChVnvPHeY532.png "title=" 3.png " alt= "Wkiom1bsxttxhxpqaachvnvphey532.png"/>
2.mount mount using a formatted partition
Mount disk device mount point
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/A8/wKioL1bsyXOgfy9aAABFvOt_9Uo259.png "title=" M.png " alt= "Wkiol1bsyxogfy9aaabfvot_9uo259.png"/>
3. umount unmount File System
Umount/usr/shamoluotuo unmount the corresponding disk partition by mounting the directory
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7D/A8/wKioL1bsy0PCdSc5AABMCtrfLfY497.png "title=" U.png " alt= "Wkiol1bsy0pcdsc5aabmctrflfy497.png"/>
4. Set file system auto Mount
Mount mounts are automatically uninstalled after the system restarts, which is dangerous to use in a production environment. So we have to use auto mount. Prevent the occurrence of the kind of situation. The/etc/fatab file in the system is visible as a configuration file for the Mount name order, which stores the statically mounted data of the file system. Linux reads this file every time it is powered on. So we write the attached command to this file. It can be mounted automatically.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/A8/wKioL1bs0HXTYdHUAACsFUXMvWY918.png "title=" Fstab.png "alt=" Wkiol1bs0hxtydhuaacsfuxmvwy918.png "/>
Automatically mount the/DEV/SDB1/usr/shamoluotuo this file: configured as follows
write the following configuration to/etc/fstab
' 650 ' this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7D/AC/wKiom1bs0feiIXf3AAAITjqM6Hk805.png "title=" Aa.png "alt=" Wkiom1bs0feiixf3aaaitjqm6hk805.png "/>
Reboot the system with df-th to verify that the configuration is in effect.
5. MKSWAP Create swap partition (Swap)
the swap partition of Linux, similar to the virtual memory of Windows, solves the problem of insufficient physical memory before using Mkswap to create the swap partition. To use Fdisk, first set the ID number of the disk partition to:.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7D/AC/wKiom1bs3OziorKhAABUmpXOVv0510.png "title=" Mkswap.png "alt=" Wkiom1bs3oziorkhaabumpxovv0510.png "/>
After you finish mksawp, the swap partition has been created. Let's look at how much virtual memory the system originally had. And then turn on the swap that we just made.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7D/AC/wKiom1bs3hSgwIfWAABNW8gydlY927.png "title=" Swapon.png "alt=" Wkiom1bs3hsgwifwaabnw8gydly927.png "/>
This basic part of our disk and file system management has been largely completed.
This article is from "Desert Camel" blog, please make sure to keep this source http://maomaochong.blog.51cto.com/9260445/1752851
Disk and File System Management (1)