Disk partitioning and attaching, and disk partitioning and mounting
[Root @ localhost xiaofeng] # fdisk-l
Disk/dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sector of 1*512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimum): 512 bytes/512 bytes
Disk/dev/sda: 16.1 GB, 16106127360 bytes, 31457280 sectors
Units = sector of 1*512 = 512 bytes
Sector size (logical/physical): 512 bytes/512 bytes
I/O size (minimum/optimum): 512 bytes/512 bytes
Disk tag type: dos
Disk ID: 0x00076ca1
Device Boot Start End Blocks Id
System
/Dev/sda1*2048 411647 204800 83
Linux
/Dev/sda2 411648 30408703 14998528 83
Linux
/Dev/sda3 30408704 31457279 524288 82
Linux swap/Solaris
Run the fdisk-l command to check whether the hard disk is identified.
Use the fdisk command to partition:
[Root @ localhost xiaofeng] # fdisk/dev/sdb
Welcome to fdisk (util-linux 2.23.2 ).
The change will stay in the memory until you decide to write the change to the disk.
Think twice before using the write command.
Device does not contain a recognized partition table
Use the disk identifier 0x177ee503 to create a new DOS disk tag.
Command (enter m for help): m
Command operation
A toggle a bootable flag Set bootable flag
B edit bsd disklabel
C toggle the dos compatibility flag edit bsd disk tag
D delete a partition
G create a new empty GPT partition table delete a partition
G create an IRIX (SGI) partition table
L list known partition types displays known file system types.
82 is the Linux swap partition and 83 is the Linux partition.
M print this menu displays the Help menu
N add a new partition create a partition
O create a new empty DOS partition table creation Blank
Dos partition table
P print the partition table displays the partition list
Q quit without saving changes does not save and exits
S create a new empty Sun disklabel
T change a partition's system id to change the system of a partition
System ID
U change display/entry units
V verify the partition table to verify the partition table
W write table to disk and exit save and exit
X extra functionality (experts only) additional features (dedicated only
Home)
Command (enter m for help ):
Re-read partition table information:
[Root @ localhost xiaofeng] # partprobe
When the partition table is occupied and needs to be restarted, you can use this command without restarting!
Format partitions
[Root @ localhost xiaofeng] # mkfs-t ext4/dev/sdb1
Create and mount a mount point
[Root @ localhost xiaofeng] # mkdir/disk1
[Root @ localhost xiaofeng] # mount/dev/sdb1/disk1/
[Root @ localhost xiaofeng] # mount
Run the mount or df command to check whether the partition is successfully mounted.
Automatic partition mounting and fstab file repair
1./etc/fstab file
◆ Field 1: partition device file name or UUID)
◆ Field 2: mount point
◆ Field 3: File System name
◆ Field 4: Mount Parameters
◆ Field 5: Specifies whether the partition is backed up by dump. 0 indicates no backup, and 1 indicates daily backup.
Copies, 2 indicates irregular backup
◆ Field 6: Specifies whether the partition is detected by fsck. 0 indicates no detection.
The priority of table detection. Of course, the priority of 1 is higher than that of 2.
View the device file name (the first field can be viewed)
[Root @ localhost xiaofeng] # dumpe2fs-h/dev/sdb1
Automatic partition mounting
[Root @ localhost xiaofeng] # vi/etc/fstab
/Dev/sdb1/disk1 ext4 defaults 1 2
The format must be noted, otherwise the system may have problems or even crashes.
[Root @ localhost xiaofeng] # mount-
# Automatically mount all written Configurations Based on the configuration file/etc/fstab
To test whether an error is reported, so that the system will not crash due to the automatic mounting configuration at the next startup.
/Etc/fstab file repair
[Root @ localhost xiaofeng] # mount-o remount, rw/
Remount the file and grant the write permission to it. Then you can modify the file content.