简单的对CentOS硬盘分区小白教程,仅四个步骤



简单的对CentOS硬盘分区小白教程,仅四个步骤

作者: admin

全网最全的网络资源分享网站

手机扫码查看

标签:

特别声明:文章多为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

vvso

我在8个月前,完全是一个Linux小白,只是偶然机会,接触到了Linux,并对它产生了兴趣。
在3天前,我不晓得如何对硬盘进行分区,通过简单的学习,我懂了。
学习是一种技能,生命不息,学习不止。
我来介绍一下,简单的分区方法和技巧。
可能你一看就会懂,也有可能看不懂,反正每个人的学习能力都不一样吧。

第一步:查看你服务器中的硬盘,有几块硬盘。

ls /dev/sd?

sda代表第一块硬盘,sdb代表第二块硬盘,sdc代表。。。。。。

第二步,使用fdisk命令进行硬盘的选择分区,以sdb为例

 cd /
 fdisk /dev/sdb
 m                        //继续下一步
 
 p                        //查看硬盘分区信息
 
 d                        //先删除所有分区

 n                        //新建硬盘分区

 p                        //新建主分区

 Enter                    //默认回车

 w                        //保存并退出。

第三步,格式化硬盘

mkfs.ext4 /dev/sdb1

第四步,挂在分区

 
 mkdir  /media/sdb1
 mount /dev/sdb1 /media/sdb1
 echo "/dev/sdb1              /www                  ext4    defaults        0 0" >> /etc/fstab

四步OK!

[root@CSH9654644 /]# ls /dev/sdb1 →_→第一步,查看硬盘信息
/dev/sda /dev/sdb
[root@CSH9654644 /]# cd / →_→返回到根目录
[root@CSH9654644 /]# fdisk /dev/sdb →_→选择格式化硬盘

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): m →_→按m键继续
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
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): p →_→点击p查看硬盘的分区信息

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 2048 104857599 52427776 83 Linux

Command (m for help): d →_→点击d删除分区
Selected partition 1
Partition 1 is deleted

Command (m for help): 1 
1: unknown command
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
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 →_→按n新建分区
Partition type:
p primary (0 primary, 0 extended, 4 free) →_→按p新建主分区
e extended
Select (default p): p →_→一路回车
Partition number (1-4, default 1): 1 →_→一路回车
First sector (2048-104857599, default 2048): →_→一路回车
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): 
Using default value 104857599 →_→一路回车
Partition 1 of type Linux and of size 50 GiB is set →_→一路回车
Command (m for help): 
Command (m for help): w →_→按w保存并推出
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@CSH9654644 /]# mkfs.ext4 /dev/sdb1 →_→格式化硬盘
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done 
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13106944 blocks
655347 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2162163712
400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
4096000, 7962624, 11239424
Allocating group tables: done 
Writing inode tables: done 
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 
[root@CSH9654644 /]# mkdir /media/sdb1 →_→创建挂在目录
[root@CSH9654644 /]# mount /dev/sdb1 /media/sdb1 →_→临时挂在硬盘
[root@CSH9654644 /]# echo "/dev/sdb1 /www ext4 defaults 0 0" >> /etc/fstab →_→永久写入挂载
[root@CSH9654644 /]# df -h →_→查看硬盘分区
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 4.0G 14G 24% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 4.0K 1.9G 1% /dev/shm
tmpfs 1.9G 8.8M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 142M 873M 14% /boot
tmpfs 379M 0 379M 0% /run/user/0
/dev/sdb1 50G 53M 47G 1% /media/sdb1 →_→挂载成功!
[root@CSH9654644 /]#

分享到:
打赏
未经允许不得转载:

作者: admin, 转载或复制请以 超链接形式 并注明出处 小林博客
原文地址: 《简单的对CentOS硬盘分区小白教程,仅四个步骤》 发布于2019-6-24

评论

切换注册

登录

忘记密码?

您也可以使用第三方帐号快捷登录

切换登录

注册

简单的对CentOS硬盘分区小白教程,仅四个步骤

长按图片转发给朋友

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏