To add a disk expansion operation:
1. Add a physical disk to the server to restart the server, #fdisk-L View the identification disk (take/DEV/SDB as an example)
[~]# fdisk-l
disk/dev/sda:42.9 GB, 42949672960 bytes
255 heads, Sectors/track, 5221 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk IDENTIFIER:0X0006A7C5
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 204800 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 287 2097152 Swap/solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 287 5222 39640064-up Linux
disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 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
2. Adding partitions
[~]# Fdisk/dev/sdb
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 ') 1116.www.qixoo.qixoo.com and change display units to
Sectors (Command ' u ').
Command (M for help): M
Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS compatibility flag
D Delete a partition (delete partition)
L list known partition types
M Print this menu
n Add a new partition (new partition)
o Create a new empty DOS partition table
P Print the partition table (display partition information)
Q Quit without saving changes (do not save exit)
s create a new empty Sun Disklabel
t change a partition ' s system ID
U Change display/entry units
V Verify the partition table
W Write table to disk and exit (save exit)
X Extra functionality (experts only)
#用 "n" New partition Select "P" primary partition, where you can create a new three primary partition the rest of the extended partition can be built to select the "E" extended partition
Command (M for help): N
Command Action
E extended (extended partition)
P primary partition (1-4) (primary partition)
1
Invalid partition number for type ' 1 '
Command Action
E Extended
P primary partition (1-4)
P (P is the new primary partition)
Partition number (1-4): 1 (primary partition)
First cylinder (1-2610, default 1):
Using Default value 1
Last cylinder, +cylinders or +size{k,m,g} (1-2610, default 2610): +2g (allocates 2G space to the primary partition)
Command (M for help): P (print out the configured partition information)
disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk Identifier:0xbf76d5e8
Device Boot Start End Blocks Id System
/DEV/SDB1 1 262 2104483+ Linux (allocated partition)
It is generally necessary to build three primary partitions and then the extended partitions that are needed for the remaining space.
Create a new three primary partition and two extended partitions and save exit
Command (M for help): P
disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk Identifier:0xbf76d5e8
Device Boot Start End Blocks Id System
/DEV/SDB1 1 262 2104483+ Linux
/DEV/SDB2 263 524 2104515-up Linux
/DEV/SDB3 525 786 2104515-Up Linux
/DEV/SDB4 787 2610 14651280 5 Extended
/DEV/SDB5 787 918 1060258+-up Linux
/DEV/SDB6 919 1050 1060258+-up Linux
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
3. Make the partition effective
[~]# partprobe (forcing the kernel to re-locate the partition table)
4. View New partition
[~]# fdisk-l/dev/sdb
disk/dev/sdb:21.5 GB, 21474836480 bytes
255 heads, Sectors/track, 2610 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk Identifier:0xbf76d5e8
Device Boot Start End Blocks Id System
/DEV/SDB1 1 262 2104483+ Linux
/DEV/SDB2 263 524 2104515-up Linux
/DEV/SDB3 525 786 2104515-Up Linux
/DEV/SDB4 787 2610 14651280 5 Extended
/DEV/SDB5 787 918 1060258+-up Linux
/DEV/SDB6 919 1050 1060258+-up Linux
5. Format the partition
[~]# MKFS.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
131648 inodes, 526120 blocks
26306 blocks (5.00%) reserved for the Super user
First block of data =0
Maximum filesystem blocks=541065216
Block groups
32768 blocks per group, 32768 fragments per group
7744 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing Inode table: complete
Creating Journal (16384 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.
[~]# MKFS.EXT3/DEV/SDB2
[~]# MKFS.EXT3/DEV/SDB3
[~]# MKFS.EXT3/DEV/SDB5
[~]# MKFS.EXT3/DEV/SDB6 (the remaining partitions are formatted)
6. New mount directory and mount to system
[~]# mkdir-p/SDB/SDB1
[~]# mkdir-p/SDB/SDB2
[~]# mkdir-p/SDB/SDB3
[~]# mkdir-p/SDB/SDB5
[~]# mkdir-p/SDB/SDB6
[~]# Ls/sdb
SDB1 sdb2 sdb3 SDB5 SDB6
[~]# MOUNT/DEV/SDB1/SDB/SDB1
[~]# MOUNT/DEV/SDB2/SDB/SDB2
[~]# MOUNT/DEV/SDB3/SDB/SDB3
[~]# MOUNT/DEV/SDB5/SDB/SDB5
[~]# MOUNT/DEV/SDB6/SDB/SDB6
7. Modify the configuration file settings to automatically mount the boot
[~]# Vi/etc/fstab
#/etc/fstab
# Created by Anaconda on Fri Oct 14 22:27:19 2016
#
# 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=BD82CAD1-2B0A-4984-9846-06E690B1FDAD/EXT3 Defaults 1 1
Uuid=6d8f8e24-7849-4ad9-af35-7e8fb71eb7ec/boot ext3 Defaults 1 2
uuid=dc268ee4-ba91-471f-9acf-94d0a2658083 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
/DEV/SDB1/SDB/SDB1 ext3 defaults 0 0 (new add Mount option)
/DEV/SDB2/SDB/SDB2 ext3 defaults 0 0 (defaults are 00)
/DEV/SDB3/SDB/SDB3 ext3 defaults 0 0
/DEV/SDB5/SDB/SDB5 ext3 defaults 0 0
/DEV/SDB6/SDB/SDB6 ext3 defaults 0 0
8. Restart the server to take effect and view the partition results
[~]# reboot
[~]# Df-ht
Filesystem Type Size used Avail use% mounted on
/dev/sda3 ext3 38G 7.7G 28G 22%/
Tmpfs tmpfs 495M 0 495M 0%/dev/shm
/DEV/SDA1 ext3 194M 30M 155M 17%/boot
/DEV/SDB1 ext3 2.0G 68M 1.9G 4%/sdb/sdb1
/DEV/SDB2 ext3 2.0G 68M 1.9G 4%/sdb/sdb2
/DEV/SDB3 ext3 2.0G 68M 1.9G 4%/sdb/sdb3
/DEV/SDB5 ext3 1020M 34M 935M 4%/SDB/SDB5
/DEV/SDB6 ext3 1020M 34M 935M 4%/SDB/SDB6
Expansion succeeded.
Note: 1, this is the virtual machine on its own experimental operation, so a disk of space 20G in the real working environment of the expansion of the disk are hundreds of G or even several t;
2, Linux also has a better scalability for the server expansion of the method that is LVM, more flexible operation is also very simple.
Linux Add new disk expansion space