当前位置: 移动技术网 > 网络运营>服务器>Linux > Linux磁盘分区实战案例(必看篇)

Linux磁盘分区实战案例(必看篇)

2019年04月26日  | 移动技术网网络运营  | 我要评论
一.查看新添加磁盘 [root@localhost /]# fdisk -l 磁盘 /dev/sda:53.7 gb, 53687091200 字节,10

一.查看新添加磁盘

[root@localhost /]# fdisk -l
 
磁盘 /dev/sda:53.7 gb, 53687091200 字节,104857600 个扇区
units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
i/o 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0009f1d1
 
  设备 boot   start     end   blocks  id system
/dev/sda1  *    2048   1026047   512000  83 linux
/dev/sda2     1026048   5253119   2113536  82 linux swap / solaris
/dev/sda3     5253120  104857599  49802240  83 linux
 
磁盘 /dev/sdb:21.5 gb, 21474836480 字节,41943040 个扇区
units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
i/o 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x12f9141b
 
  设备 boot   start     end   blocks  id system
/dev/sdb1      2048  10487807   5242880  83 linux

 二.磁盘分区

[root@localhost /]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
 
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
 
 
命令(输入 m 获取帮助):n                                                         (n为创建分区)
partition type:
  p  primary (1 primary, 0 extended, 3 free)                                            (p为主分区)
  e  extended                                                                   (e为扩展分区)
select (default p): p
分区号 (2-4,默认 2):2
起始 扇区 (10487808-41943039,默认为 10487808):
将使用默认值 10487808
last 扇区, +扇区 or +size{k,m,g} (10487808-41943039,默认为 41943039):+5g            (分区的大小)
分区 2 已设置为 linux 类型,大小设为 5 gib
 
命令(输入 m 获取帮助):w                                                         (w保存设置)
the partition table has been altered!
 
calling ioctl() to re-read partition table.
 
warning: re-reading the partition table failed with error 16: 设备或资源忙.
the kernel still uses the old table. the new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。

三.磁盘格式化

[root@localhost /]# partprobe /dev/sdb2                          (刷新分区表)
[root@localhost /]# mke2fs /dev/sdb2
mke2fs 1.42.9 (28-dec-2013)
文件系统标签=
os type: linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
stride=0 blocks, stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
第一个数据块=0
maximum filesystem blocks=1342177280
40 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
 
allocating group tables: 完成              
正在写入inode表: 完成              
writing superblocks and filesystem accounting information: 完成 

四.创建目录并挂载分区

[root@localhost /]# mkdir /soft
[root@localhost /]# mount /dev/sdb2 /soft

五.设置开机自挂载

[root@localhost /]# vim /etc/fstab 
/dev/sdb2     /soft     xfs     defaults    0   0

六.查看挂载

[root@localhost /]# df -ht
文件系统    类型   容量 已用 可用 已用% 挂载点
/dev/sda3   xfs    48g 3.7g  44g  8% /
devtmpfs    devtmpfs 906m   0 906m  0% /dev
tmpfs     tmpfs   914m  80k 914m  1% /dev/shm
tmpfs     tmpfs   914m 8.9m 905m  1% /run
tmpfs     tmpfs   914m   0 914m  0% /sys/fs/cgroup
/dev/sda1   xfs    497m 116m 382m  24% /boot
/dev/sdb1   ext2   5.0g  11m 4.7g  1% /dvd
/dev/sdb2   ext2   5.0g  10m 4.7g  1% /soft

以上就是小编为大家带来的linux磁盘分区实战案例(必看篇)全部内容了,希望大家多多支持移动技术网~

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网