Lubuntu – 启动缓慢 – 可能是交换文件或分区

Lubuntu – 启动缓慢 – 可能是交换文件或分区

我注意到我的 Lubuntu 20.04 启动很慢。到目前为止,我已经阅读了一些帖子,我可以与大家分享我收集的所有信息:

# systemd-analyze blame
19.296s dev-sda5.device                                      
18.412s snapd.service                                        
17.480s networkd-dispatcher.service                          
16.627s accounts-daemon.service                              
15.142s udisks2.service                                      
12.115s dev-loop13.device                                    
11.692s NetworkManager-wait-online.service                   
11.054s dev-loop9.device                                     
11.010s bluetooth.service                                    
11.008s avahi-daemon.service                                 
10.916s dev-loop14.device                                    
10.872s dev-loop17.device                                    
10.831s dev-loop8.device                                     
10.798s dev-loop12.device                                    
10.755s dev-loop19.device                                    
10.734s NetworkManager.service                               
10.716s dundee.service                                       
10.665s dev-loop16.device                                    
10.638s dev-loop18.device                                    
10.604s dev-loop15.device                                    
10.604s dev-loop11.device                                    
 9.929s polkit.service                                       
 9.833s ofono.service                                                                                                                 
 9.176s switcheroo-control.service                                                                                                    
 9.158s thermald.service                                                                                                              
 9.155s systemd-logind.service                                                                                                        
 9.051s wpa_supplicant.service                                                                                                        
 8.573s dev-loop10.device                                                                                                             
 7.504s dev-loop6.device                                                                                                              
 7.450s dev-loop7.device                                                                                                              
 7.439s dev-loop2.device
...

关键链是:

# systemd-analyze critical-chain
graphical.target @50.502s
└─multi-user.target @50.502s
  └─kerneloops.service @50.294s +207ms
    └─network-online.target @50.270s
      └─NetworkManager-wait-online.service @38.577s +11.692s
        └─NetworkManager.service @27.837s +10.734s
          └─dbus.service @27.833s
            └─basic.target @27.480s
              └─sockets.target @27.478s
                └─snapd.socket @27.474s +3ms
                  └─sysinit.target @27.408s
                    └─snapd.apparmor.service @26.409s +998ms
                      └─apparmor.service @23.930s +2.464s
                        └─local-fs.target @23.929s
                          └─boot-efi.mount @23.880s +48ms
                            └─systemd-fsck@dev-disk-by\x2duuid-B86C\x2d1FC8.service @23.705s +155ms
                              └─dev-disk-by\x2duuid-B86C\x2d1FC8.device @23.704s

fstab:

    # sudo cat /etc/fstab
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sda5 during installation
    UUID=5376f975-326e-467b-b615-3c05494fc9c9 /               ext4    errors=remount-ro 0       1
    # /boot/efi was on /dev/sda1 during installation
    /swapfile                                 none            swap    sw              0       0
    UUID=B86C-1FC8 /boot/efi vfat umask=0077 0 1

blkid 显示:

sudo blkid
/dev/sda5: UUID="5376f975-326e-467b-b615-3c05494fc9c9" TYPE="ext4" PARTUUID="e2f7acbc-05"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/sda1: UUID="B86C-1FC8" TYPE="vfat" PARTUUID="e2f7acbc-01"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/loop15: TYPE="squashfs"
/dev/loop16: TYPE="squashfs"
/dev/loop17: TYPE="squashfs"
/dev/loop18: TYPE="squashfs"
/dev/loop19: TYPE="squashfs"

lsbkl 还输出以下内容:

#sudo lsbkl -f
# There is more info here, but I think it is not relevant at this point.
#...
sda                                                                       
├─sda1 vfat           B86C-1FC8                               511M     0% /boot/efi
├─sda2                                                                    
└─sda5 ext4           5376f975-326e-467b-b615-3c05494fc9c9  806,9G     7% /
sr0  

gnome-disks smart-data-1:

智能数据-1

gnome-disks smart-data-2:

智能数据-2

免费命令:

~$ free -h
total        used        free      shared  buff/cache   available
Mem:          5,7Gi       853Mi       409Mi       119Mi       4,4Gi       4,4Gi
Swap:         2,0Gi       1,0Mi       2,0Gi

你知道可能发生了什么吗?我猜 sda1 分区或交换文件可能是造成这种情况的原因。如果是这样,如何修复它?提前致谢!

答案1

您的硬盘有读/写错误和过多的加载/卸载错误。驱动器可能很旧,并且预先出现故障。

HDD 是很多比 SSD 慢,并且容易启动很多较慢。预计启动时间约为 30-90 秒。

电缆

重新安装硬盘背面和主板上的数据线和电源线。

分区表

您的磁盘可能应该是 GPT 格式...尽管 2014 年的计算机可能是 BIOS 而不是 UEFI...但这可能是不可能的。

交换

2G 的 /swapfile 有点小,我们将其增加到 4G...

笔记:错误使用rmdd命令可能会导致数据丢失。建议复制/粘贴。

在里面terminal...

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 6G RAM and 4G swap

sudo -H gedit /etc/fstab使用或编辑 /etc/fstab sudo pico /etc/fstab

确认 /etc/fstab 中的此 /swapfile 行...并确认没有其他“交换”行...在此行中使用空格...确认没有制表符...

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation

坏块

让我们检查一下您的磁盘是否有坏块...

注意:不要中止坏块扫描!

注意:不要对 SSD 造成坏块

注意:请先备份您的重要文件!

注意:这将花费很多小时

注意:您可能面临硬盘故障

在“尝试 Ubuntu”模式下启动 Ubuntu Live DVD/USB。

terminal...

sudo fdisk -l# 识别所有“Linux 文件系统”分区

sudo e2fsck -fcky /dev/sdXX# 只读测试

或者

sudo e2fsck -fccky /dev/sda5# 非破坏性读写测试(受到推崇的)

-k 很重要,因为它会保存之前的坏块表,并将任何新的坏块添加到该表中。如果没有 -k,您将丢失所有之前的坏块信息。

-fccky 参数...

   -f    Force checking even if the file system seems clean.

   -c    This option causes e2fsck to use badblocks(8) program to do
         a read-only scan of the device in order to find any bad blocks.
         If any bad blocks are found, they are added to the bad block
         inode to prevent them from being allocated to a file or direc‐
         tory.  If this option is specified twice, then the bad block scan
         will be done using a non-destructive read-write test.

   -k    When combined with the -c option, any existing bad blocks in the
         bad blocks list are preserved, and any new bad blocks found by
         running badblocks(8) will be added to the existing bad blocks
         list.

   -y    Assume an answer of `yes' to all questions; allows e2fsck to be
         used non-interactively. This option may not be specified at the
         same time as the -n or -p options.

相关内容