自学内容网 自学内容网

docker- No space left on device

mac苹果电脑docker: No space left on device

首先检查一下有没有用不到的镜像,docker images 可以进行rmi,但一般都还有用。

第一步,查看docker挂载的空间

[root@localhost ~]# df -h
文件系统                    容量  已用  可用 已用% 挂载点
devtmpfs                    716M     0  716M    0% /dev
tmpfs                       730M     0  730M    0% /dev/shm
tmpfs                       730M  8.7M  721M    2% /run
tmpfs                       730M     0  730M    0% /sys/fs/cgroup
/dev/mapper/cl_fedora-root  5.6G  5.3G  320M   95% /
/dev/nvme0n1p2             1014M  155M  860M   16% /boot
/dev/nvme0n1p1              599M  9.0M  590M    2% /boot/efi
tmpfs                       146M     0  146M    0% /run/user/0
overlay                     5.6G  5.3G  320M   95% /var/lib/docker/overlay2/9a7010dfbe78c01d98031d78a28ff79cb3aa2898c6c394cba038772ad91f15d0/merged

可以看到我的挂载空间是5.6G,很小,其实就是/dev/mapper/cl_fedora-root,然后为了保存我们原来的镜像,现在要进行扩容

第二步,关机,进行硬盘扩容处理。

这个点击虚拟机,选择设置,点击硬盘,修改大小即可。

第三步,systemctl stop docker

第四步,分区查看

[root@localhost /]# lsblk
NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme0n1            259:0    0   64G  0 disk 
├─nvme0n1p3        259:3    0  6.4G  0 part 
│ ├─cl_fedora-swap 253:1    0  820M  0 lvm  [SWAP]
│ └─cl_fedora-root 253:0    0  5.6G  0 lvm  /
├─nvme0n1p1        259:1    0  600M  0 part /boot/efi
└─nvme0n1p2        259:2    0    1G  0 part /boot
sr0                 11:0    1  7.6G  0 rom  

可以看到新加的磁盘是60G,也就是nvme0n1

第五步之fdisk /dev/nvme0n1。把nvme0n1挂载到/dev/mapper/cl_fedora-root

[root@localhost /]# fdisk /dev/nvme0n1
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。


命令(输入 m 获取帮助):n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
分区号 (2-4,默认 2):4
起始 扇区 (16777216-134217727,默认为 16777216):
将使用默认值 16777216
Last 扇区, +扇区 or +size{K,M,G} (16777216-134217727,默认为 134217727):
将使用默认值 134217727
分区 4 已设置为 Linux 类型,大小设为 56 GiB

命令(输入 m 获取帮助):p

磁盘 /dev/nvme0n1:68.7 GB, 68719476736 字节,134217728 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x00000000

        设备 Boot      Start         End      Blocks   Id  System
/dev/nvme0n1p1               1    16777215     8388607+  ee  GPT
/dev/nvme0n1p4        16777216   134217727    58720256   83  Linux

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。

第六步之parted /dev/nvme0n1。把nvme0n1挂到/dev/mapper/cl_fedora-root,注意需要计算挂载大小

[root@localhost /]# parted /dev/nvme0n1
GNU Parted 3.1
使用 /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) /dev/nvme0n1                                                     
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free
        space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information
        of GNU Parted
(parted) p                                                                
Model: NVMe Device (nvme)
Disk /dev/nvme0n1: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  标志
 1      1049kB  630MB   629MB   fat32        EFI System Partition  启动
 2      630MB   1704MB  1074MB  xfs
 3      1704MB  8589MB  6885MB                                     lvm
(parted) mkpart
分区名称?  []? 4
文件系统类型?  [ext2]? ext2                                             
起始点? 18850
结束点? 58880                                                            
(parted) p                                                                
Model: NVMe Device (nvme)
Disk /dev/nvme0n1: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                  标志
 1      1049kB  630MB   629MB   fat32        EFI System Partition  启动
 2      630MB   1704MB  1074MB  xfs
 3      1704MB  8589MB  6885MB                                     lvm
 4      18.9GB  58.9GB  40.0GB               4

(parted) quit                                                             
信息: You may need to update /etc/fstab.

[root@localhost /]# lsblk                                                 
NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme0n1            259:0    0   64G  0 disk 
├─nvme0n1p3        259:3    0  6.4G  0 part 
│ ├─cl_fedora-swap 253:1    0  820M  0 lvm  [SWAP]
│ └─cl_fedora-root 253:0    0  5.6G  0 lvm  /
├─nvme0n1p1        259:1    0  600M  0 part /boot/efi
├─nvme0n1p4        259:4    0 37.3G  0 part 
└─nvme0n1p2        259:2    0    1G  0 part /boot
sr0                 11:0    1  7.6G  0 rom  

第七步,partprobe /dev/nvme0n1

第八步,pvcreate /dev/nvme0n1p4

[root@localhost /]# lsblk
NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
nvme0n1            259:0    0   64G  0 disk 
├─nvme0n1p3        259:3    0  6.4G  0 part 
│ ├─cl_fedora-swap 253:1    0  820M  0 lvm  [SWAP]
│ └─cl_fedora-root 253:0    0  5.6G  0 lvm  /
├─nvme0n1p1        259:1    0  600M  0 part /boot/efi
├─nvme0n1p4        259:4    0 37.3G  0 part 
└─nvme0n1p2        259:2    0    1G  0 part /boot
sr0                 11:0    1  7.6G  0 rom  
[root@localhost /]# pvcreate /dev/nvme0n1p4
  Physical volume "/dev/nvme0n1p4" successfully created.

还有一步:vgextend cl_fedora /dev/nvme0n1p4

[root@localhost docker]# pvcreate /dev/nvme0n1p4
  Physical volume "/dev/nvme0n1p4" successfully created.
[root@localhost docker]# lvscan
  ACTIVE            '/dev/cl_fedora/swap' [820.00 MiB] inherit
  ACTIVE            '/dev/cl_fedora/root' [<5.61 GiB] inherit
[root@localhost docker]# vgs
  VG        #PV #LV #SN Attr   VSize VFree
  cl_fedora   1   2   0 wz--n- 6.41g    0 
[root@localhost docker]# vgextend cl_fedora /dev/nvme0n1p4
  Volume group "cl_fedora" successfully extended
[root@localhost docker]# lvextend -l +100%FREE  /dev/mapper/cl_fedora-root
  Size of logical volume cl_fedora/root changed from <5.61 GiB (1436 extents) to <42.89 GiB (10979 extents).
  Logical volume cl_fedora/root successfully resized.
[root@localhost docker]# xfs_growfs /dev/mapper/cl_fedora-root
meta-data=/dev/mapper/cl_fedora-root isize=512    agcount=4, agsize=367616 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1 spinodes=1
data     =                       bsize=4096   blocks=1470464, 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 1470464 to 11242496
[root@localhost docker]# df -Th
文件系统                   类型      容量  已用  可用 已用% 挂载点
devtmpfs                   devtmpfs  716M     0  716M    0% /dev
tmpfs                      tmpfs     730M     0  730M    0% /dev/shm
tmpfs                      tmpfs     730M  8.7M  721M    2% /run
tmpfs                      tmpfs     730M     0  730M    0% /sys/fs/cgroup
/dev/mapper/cl_fedora-root xfs        43G  5.6G   38G   13% /
/dev/nvme0n1p2             xfs      1014M  155M  860M   16% /boot
/dev/nvme0n1p1             vfat      599M  9.0M  590M    2% /boot/efi
tmpfs                      tmpfs     146M     0  146M    0% /run/user/0

第九步

[root@localhost /]# lvextend -l +100%FREE  /dev/mapper/cl_fedora-root
  Size of logical volume cl_fedora/root changed from <5.61 GiB (1436 extents) to <42.89 GiB (10979 extents).
  Logical volume cl_fedora/root successfully resized.
[root@localhost /]# 
[root@localhost /]# df -Th
文件系统                   类型      容量  已用  可用 已用% 挂载点
devtmpfs                   devtmpfs  716M     0  716M    0% /dev
tmpfs                      tmpfs     730M     0  730M    0% /dev/shm
tmpfs                      tmpfs     730M  8.6M  721M    2% /run
tmpfs                      tmpfs     730M     0  730M    0% /sys/fs/cgroup
/dev/mapper/cl_fedora-root xfs       5.6G  5.3G  318M   95% /
/dev/nvme0n1p2             xfs      1014M  155M  860M   16% /boot
/dev/nvme0n1p1             vfat      599M  9.0M  590M    2% /boot/efi
tmpfs                      tmpfs     146M     0  146M    0% /run/user/0
[root@localhost /]# xfs_growfs /dev/mapper/cl_fedora-root
meta-data=/dev/mapper/cl_fedora-root isize=512    agcount=4, agsize=367616 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1 spinodes=1
data     =                       bsize=4096   blocks=1470464, 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 1470464 to 11242496
[root@localhost /]# 
[root@localhost /]# df -Th
文件系统                   类型      容量  已用  可用 已用% 挂载点
devtmpfs                   devtmpfs  716M     0  716M    0% /dev
tmpfs                      tmpfs     730M     0  730M    0% /dev/shm
tmpfs                      tmpfs     730M  8.6M  721M    2% /run
tmpfs                      tmpfs     730M     0  730M    0% /sys/fs/cgroup
/dev/mapper/cl_fedora-root xfs        43G  5.6G   38G   13% /
/dev/nvme0n1p2             xfs      1014M  155M  860M   16% /boot
/dev/nvme0n1p1             vfat      599M  9.0M  590M    2% /boot/efi
tmpfs                      tmpfs     146M     0  146M    0% /run/user/0
[root@localhost /]# systemctl start docker 
[root@localhost /]# df -Th
文件系统                   类型      容量  已用  可用 已用% 挂载点
devtmpfs                   devtmpfs  716M     0  716M    0% /dev
tmpfs                      tmpfs     730M     0  730M    0% /dev/shm
tmpfs                      tmpfs     730M  8.7M  721M    2% /run
tmpfs                      tmpfs     730M     0  730M    0% /sys/fs/cgroup
/dev/mapper/cl_fedora-root xfs        43G  5.6G   38G   13% /
/dev/nvme0n1p2             xfs      1014M  155M  860M   16% /boot
/dev/nvme0n1p1             vfat      599M  9.0M  590M    2% /boot/efi
tmpfs                      tmpfs     146M     0  146M    0% /run/user/0
overlay                    overlay    43G  5.6G   38G   13% /var/lib/docker/overlay2/9a7010dfbe78c01d98031d78a28ff79cb3aa2898c6c394cba038772ad91f15d0/merged
[root@localhost /]# 

原文地址:https://blog.csdn.net/weixin_45822638/article/details/142316394

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!