This article was sponsored by Xiuyi linfeng and first launched in the dark world.
The company's FTP server does not have enough space. Alas, there is no way to add a new hard disk. Since hard disks have not been added to Linux servers before, simulation can only be performed on virtual machines.
Steps for adding a new hard disk:
1. server shutdown
2. Add a new hard disk
3. Start the server, partition the new hard disk, and use the fdisk command.
4. format the new partition and use commands related to mkfs. Ext *.
5. Mount the new partition and run the mount and DF commands.
Virtual System: VMWare workation 10 Linux: centos 6.4 64bit
First, the centos6.4 system is installed first, and then the new hard disk is added. For example:
We recommend that you select iSCSI for the disk format, for example:
After the hard disk is added, we start centos and run the fdisk command to view it, for example:
Fdisk-l
We can see that the current server has two hard disks. Hard Disk SDA and SDB. The hard disk SDA is divided into three partitions, and sda1 is the system startup partition. Hard Disk SDB does not currently have any partitions.
Now let's partition the hard disk SDB and use the fdisk command. For example:
Fdisk/dev/SDB
Several of the fdisk commands are frequently used,
M Displays all commands
N create a partition. after entering the option using this command, e Indicates creating a new extended partition, and P indicates creating a new primary partition.
P display Partition
Q: Do not save the modification and exit
W Save the modification and exit
[[Email protected] ~] # Fdisk/dev/SDB
Warning: DOS-compatible mode is deprecated. It's stronugly recommended
Switch off the mode (command 'C') and change display units
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
L List known partition types
M print this menu
N Add a new partition
O create a new empty DOS partition table
P print the Partition Table
Q quit without saving changes
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
X extra functionality (experts only)
Command (M for help): n
Command action
E extended
P primary partition (1-4)
P
Partition Number (1-4): 1
First cylinder (1-1305, default 1): 1
Last cylinder, + cylinders or + size {K, M, g} (1-1305, default 1305): + 5g
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
After the preceding partitions are completed, run the fdsik command again, for example:
We can see that the hard disk SDB has been divided into. Dev/sdb1 partitions. This operation is equivalent to creating a partition in the Windows system. At this time, the partition is not formatted.
Next we will perform the formatting operation, because the Linux system has different file systems. For example, ext2, ext3, and ext4. Each file system is different, while centos6.4 uses the ext4 File System by default. This is equivalent to the fat file format and NTFS file format in windows. Therefore, we need to format the new partition into the ext4 format. We can use the mkfs. ext4 command. If it is set to the ext3 format, we can use mkfs. ext3. For example:
Mkfs. ext4/dev/sdb1
After formatting, We can mount partitions. This part is equivalent to assigning a drive letter to the partition in windows. Partition mounting can be divided into two parts: Temporary mounting and permanent mounting. Temporary mounting: After the system is restarted, the mounting will disappear. Permanent mounting writes the partition to be mounted to the/etc/fstab file. The System reads the content of the file when it starts.
We will first perform temporary mounting and create a directory to mount the partition. For example:
Mkdir/data create a data directory under the root directory.
Mount-T ext4/dev/sdb1/data this command is used to mount the/data directory to the/dev/sdb1 partition, where-T is the specified file system type.
Mount-A enables the mounting to take effect.
Mount to view all mounts.
The above is a temporary mount. Next we will set a permanent mount. Before setting a permanent mount, we need to first detach the mounted file that has just been mounted and use the umount command, such:
Umount/data/
After uninstalling the file, edit the/etc/fstab file and add the following content:
/Dev/sdb1/Data ext4 defaults 0 0
Then run the Mount-a command to make the Mount take effect. For example: