img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化的资料的朋友,可以戳这里获取

如下添加完成:
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

重新分区和挂载

新增的磁盘也可参考如下步骤,不过只要从新增n步骤开始即可。 不需要有删除的动作。

目标是使用 fdisk /dev/sda 删除/dev/sda2,新建 11G的sda2 和 10G的sda3。

步骤如下:

注意,分区是危险操作,请注意备份。

查看磁盘情况,使用命令

sudo fdisk -l

输出如下:

[zzq@ceph2 ~]$ sudo fdisk -l
[sudo] password for zzq: 

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00092a44

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        2611    20458496   8e  Linux LVM

Disk /dev/mapper/vg_localhost-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_localhost-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

卸下分区

cd /home/
sudo umount /dev/sda2
# 如果 umount 出现 device is busy,使用命令fuser -m /dev/sda2查看读写磁盘的pid,找出来kill之

我们这里将sda的21.5GB重新分区,使用命令

sudo fdisk /dev/sda

此时要输入命令,m 帮助菜单 \ p 该整磁盘详细信息 \ d 删除分区 \ n 添加分区

我们的命令步骤如下:
d #删除动作\选择删除的区号2\n #新建分区\p 选择类型为primary partition\选择分区为2\直接回车从默认的磁盘扇区开始即可\输入 +11G 回车 #懒得计算扇区,可以照提示使用”+容量”的方式
这样就完成了新建11G的sda2分区。
n #新建分区\p 选择类型为primary partition\选择分区为3\直接回车从默认的磁盘扇区开始即可\直接回车 #使用所有剩余的容量作为sda3的容量
这样就完成了新建10G的sda3分区。

使用p命令再次查看分区表

确认无误后使用 w命令写入磁盘即可(危险操作,需谨慎确认无误),如果有误的话 使用q命令不保存退出。

输出如下:

[zzq@ceph2 home]$ sudo fdisk /dev/sda
[sudo] password for zzq: 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): d  #删除动作
Partition number (1-4): 2

Command (m for help): n #新建分区
Command action
   e   extended
   p   primary partition (1-4)
p #选择类型为primary partition
Partition number (1-4): 2  #选择分区为2
First cylinder (64-2610, default 64): 
Using default value 64
Last cylinder, +cylinders or +size{K,M,G} (64-2610, default 2610): +11G

Command (m for help): n #新建分区
Command action
   e   extended
   p   primary partition (1-4)
p  #选择类型为primary partition
Partition number (1-4): 3  #选择分区为3
First cylinder (1501-2610, default 1501): 
Using default value 1501
Last cylinder, +cylinders or +size{K,M,G} (1501-2610, default 2610): 
Using default value 2610

Command (m for help): p  #查看现在的分区情况

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00092a44

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1500    11535726   83  Linux
/dev/sda3            1501        2610     8916075   83  Linux

Command (m for help): w  
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
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)
Syncing disks.
[zzq@ceph2 home]$ 

看到上面的warning报错别紧张,回到shell后看看是否重新分区成功
使用命令

sudo fdisk -l

输出如下:

[zzq@ceph2 home]$ sudo fdisk -l
[sudo] password for zzq: 

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00092a44

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1500    11535726   83  Linux
/dev/sda3            1501        2610     8916075   83  Linux

Disk /dev/mapper/vg_localhost-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_localhost-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

这个时候分区是不能被系统识别的,需要强制重读
否则在格式化和使用时会报错
Could not stat /dev/sda2 — No such file or directory
The device apparently does not exist; did you specify it correctly?

通知内核强制重读磁盘分区表:
CentOS 5,6,7:partprobe,partx, kpartx
partprobe [device]
partx -a [device]
kpartx -af [device]

我们这里是centos 6,使用命令,注意 device的参数使用的是顶层,比如我们划分了/dev/sda的sda2和sda3使用的参数应该是/dev/sda,否则报错last arg is not the whole disk

sudo partx -a /dev/sda

如果报错

[zzq@ceph2 home]$ sudo partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3

img
img

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐