标题: 一顿操作猛如虎,失败重来30秒
时间: 2019-05-18发布,2019-05-18修改
# e2fsck -n /dev/vdb
e2fsck 1.42.9 (28-Dec-2013)
Warning! /dev/vdb is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
/dev/vdb: clean, 11/6553600 files, 459382/26214400 blocks
查看磁盘可用空间,可以看到最后的数据盘已经满了
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 41151808 8534880 30503496 22% /
devtmpfs 1931336 0 1931336 0% /dev
tmpfs 1940844 0 1940844 0% /dev/shm
tmpfs 1940844 448 1940396 1% /run
tmpfs 1940844 0 1940844 0% /sys/fs/cgroup
tmpfs 388172 0 388172 0% /run/user/0
/dev/vdb 103081248 97838368 0 100% /home/wwwroot
显示数据盘的分区信息,可以看出,这个硬盘没分区
# fdisk -lu /dev/vdb
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
查询硬盘所用的文件系统。按照教程,应该是查分区的文件系统,但从上面可以看到,是没有分区的。虽然觉得不对劲,还是继续走下去吧。
# blkid /dev/vdb
/dev/vdb: UUID="047ad20b-3e2d-41d3-ba4d-72d22d5407d8" TYPE="ext3"
扩容前,要取消挂载,但实际不用
最后还取消挂载失败,有进程在使用这个磁盘,是谁呢?我明明已经停止了WEB服务,不应该还有在使用的。
# umount /dev/vdb
umount: /home/wwwroot: target is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
看下是哪个进程在使用吧,得到是pid=24402的进程在使用,通过进程ID查到是阿里云的云服务进程
# fuser -m /home/wwwroot
/home/wwwroot: 24402
干掉你
# kill 24402
继续取消挂载
# umount /dev/vdb
开始重新分区,开始了迈向了删库的门槛
1.删除分区(但是没有分区,再次觉得不对劲,但还是继续吧)
2.创建分区
3.选择分区类型为主分区
4.将磁盘分为为一个区(相当于Windows只有C盘个盘)
5.设置分区的起始位置
6.设置分区的结束位置
7.显示分区信息(看到还是只有100G,不对劲也继续吧,说不定就是这样的呢)
8.保存分区操作到磁盘
# fdisk /dev/vdb
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.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xe00c1f00.
Command (m for help): d
No partition is defined yet!
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): p
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xe00c1f00
Device Boot Start End Blocks Id System
/dev/vdb1 2048 209715199 104856576 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
再次看看磁盘的信息,但怎么还是100G
# lsblk /dev/vdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdb 253:16 0 100G 0 disk
└─vdb1 253:17 0 100G 0 part
# e2fsck -n /dev/vdb1
e2fsck 1.42.9 (28-Dec-2013)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/vdb1
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
# partprobe /dev/vdb
# resize2fs /dev/vdb1
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/vdb1
Couldn't find valid filesystem superblock.
失败了,恢复备份,重来
# resize2fs /dev/vdb
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vdb is mounted on /home/wwwroot; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 13
The filesystem on /dev/vdb is now 52428800 blocks long.
# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 8.2G 30G 22% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 340K 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vdb 197G 94G 95G 50% /home/wwwroot
tmpfs 380M 0 380M 0% /run/user/0
成功扩容
小米5s Plus
小米5s Plus
『回复列表(7|隐藏机器人聊天)』
Command (m for help): d
No partition is defined yet!
这里的失败再一次暗示了这一点:硬盘上没有分区,没有分区!
Command (m for help): p
然后你强行给磁盘分了区。当你按下w
并回车的时候,你就成功的覆盖了原EXT4文件系统的头部数据。然后就是,你新建分区的头部根本不是原来EXT4文件系统的头部(两者错位2048个扇区,也就是1MB。相当于你把原文件系统的开头1MB丢弃了),当然无法用e2fsck
修复。