NoSpaceLeftError: No space left on devices的解决方法&未逻辑分区的虚拟机磁盘扩容(根目录在sda3 vgdisplay为空)
今天在anaconda创建虚拟环境时出现故障,想着这个问题虽然不是很常用,但对于小白来说还是比较困难的,故写下解决办法以供参考
磁盘扩展
打开linux虚拟机终端,输入一下命令
df -h
把虚拟机关机,依次点击虚拟机、设置
按照箭头,调整自己合适的硬盘大小,确定扩展
磁盘扩展成功,打开虚拟机,在终端上进行真正的磁盘扩容
磁盘扩容
输入lsblk
命令
可得
分区情况说明:
sda是单独的一块磁盘总大小30G,sda1、sda2、sda3是三个分区,sda2下面有三个逻辑分区(df命令时无可看的挂载点);
sda1挂载在/boot上
sda3挂载在/上
无卷组名称(通过pvdisplay查看)
但刚在虚拟机上磁盘扩展,现sda有10G闲置空间
因为没有逻辑分区,故采取下面方法
sudo fdisk /dev/sda
进入shell中
输入w
保存退出
代码文本如下
(base) [yan@hadoop103 ~]$ sudo fdisk /dev/sda
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): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x0002be46
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris
/dev/sda3 4810752 41943039 18566144 83 Linux
Command (m for help): d
Partition number (1-3, default 3):
Partition 3 is deleted
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3):
First sector (4810752-62914559, default 4810752):
Using default value 4810752
Last sector, +sectors or +size{K,M,G} (4810752-62914559, default 62914559):
Using default value 62914559
Partition 3 of type Linux and of size 27.7 GiB is set
Command (m for help): p
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x0002be46
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 616447 307200 83 Linux
/dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris
/dev/sda3 4810752 62914559 29051904 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.
输入reboot
重启
使用cat /etc/fstab
获取文件格式
# xfs格式 centos7(非红帽)默认格式
sudo xfs_growfs /dev/sda3
# ext格式
sudo resize2fs /dev/sda3
结果
(base) [yan@hadoop103 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 300M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 27.7G 0 part /
sr0 11:0 1 1024M 0 rom
(base) [yan@hadoop103 ~]$ sudo xfs_growfs /dev/sda3
meta-data=/dev/sda3 isize=512 agcount=4, agsize=1160384 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4641536, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 4641536 to 7262976
(base) [yan@hadoop103 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 13M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda3 28G 18G 11G 64% /
/dev/sda1 297M 163M 134M 55% /boot
tmpfs 378M 8.0K 378M 1% /run/user/42
tmpfs 378M 0 378M 0% /run/user/1000
至此,完美撒花!