首页 > 系统 > Linux > 正文

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

2019-11-02 16:43:38
字体:
来源:转载
供稿:网友

一.查看新添加磁盘

[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):将使用默认值 10487808Last 扇区, +扇区 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 atthe next reboot or after you run partprobe(8) or kpartx(8)正在同步磁盘。

三.磁盘格式化

[root@localhost /]# partprobe /dev/sdb2                          (刷新分区表)[root@localhost /]# mke2fs /dev/sdb2mke2fs 1.42.9 (28-Dec-2013)文件系统标签=OS type: Linux块大小=4096 (log=2)分块大小=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks327680 inodes, 1310720 blocks65536 blocks (5.00%) reserved for the super user第一个数据块=0Maximum filesystem blocks=134217728040 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock 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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表