做app必须有网站吗,wordpress 主页html,网站首页鲁大师,城市建设档案馆网站Ubuntu 磁盘修复
在 ubuntu 文件系统变成只读模式#xff0c;该处理呢#xff1f; 文件系统内部的错误#xff0c;如索引错误、元数据损坏等#xff0c;也可能导致系统进入只读状态。磁盘坏道或硬件故障也可能引发文件系统只读的问题。/etc/fstab配置错误#xff0c;可能…Ubuntu 磁盘修复
在 ubuntu 文件系统变成只读模式该处理呢 文件系统内部的错误如索引错误、元数据损坏等也可能导致系统进入只读状态。磁盘坏道或硬件故障也可能引发文件系统只读的问题。/etc/fstab配置错误可能导致文件系统被错误地挂载为只读模式。接下来跟着文章逐步排查、修复问题。
作者炭烤毛蛋 点击博主了解更多。 提示:数据无价操作需谨慎。 文章目录 Ubuntu 磁盘修复1. 硬盘错误日志2. 硬盘错误分析3. 硬盘数据恢复3.1 借助 fsck 命令修复文件系统3.2 借助 smartctl 检查硬盘健康状态 结语 1. 硬盘错误日志
Ubuntu 系统在正常使用过程突然出现文件系统变为只读没过多久系统重启。 重启后系统无法正常开机而是停留在启动的命令终端。
启动日志
Ubuntu 22.04.2 LTS Linux tty1
Cloud-init[1327] v.23.1.2-OubuntuO~22.04.1 running moudles:config at Mon Aug 5 11:16:56 PM CST 2019 0000. Up 199.40 seconds.
Cloud-init[1334] v.23.1.2-OubuntuO~22.04.1 running moudles:final at Mon Aug 5 11:16:56 PM CST 2019 0000. Up 199.92 seconds.
Cloud-init[1334] v.23.1.2-OubuntuO~22.04.1 finished at Mon Aug 5 11:16:57 PM CST 2019 0000. Datasource DataSourceNone. Up 200.06 seconds.
Cloud-init[1334] Mon Aug 5 11:16:57 PM CST 2019 - cc_final_message.py[WWARNING]: Used failback datasource
blk_update_request: I/O error, dev sda, sector 24460536 op 0x0:(READ) flag 0x80700 phys_seg 2 prio class 0
blk_update_request: I/O error, dev sda, sector 24460576 op 0x0:(READ) flag 0x80700 phys_seg 1 prio class 0
blk_update_request: I/O error, dev sda, sector 24460624 op 0x0:(READ) flag 0x80700 phys_seg 1 prio class 0
blk_update_request: I/O error, dev sda, sector 24460576 op 0x0:(READ) flag 0x0 phys_seg 1 prio class 0
blk_update_request: I/O error, dev sda, sector 24460576 op 0x0:(READ) flag 0x0 phys_seg 1 prio class 0
blk_update_request: I/O error, dev sda, sector 1835808720 op 0x0:(READ) flag 0x80700 phys_seg 4 prio class 0
blk_update_request: I/O error, dev sda, sector 1835808720 op 0x0:(READ) flag 0x0 phys_seg 1 prio class 0
blk_update_request: I/O error, dev sda, sector 24466768 op 0x0:(READ) flag 0x80700 phys_seg 2 prio class 0
blk_update_request: I/O error, dev sda, sector 24466808 op 0x0:(READ) flag 0x80700 phys_seg 1 prio class 0
blk_update_request: I/O error, dev sda, sector 24466768 op 0x0:(READ) flag 0x0 phys_seg 1 prio class 0从启动日志分析磁盘可能出现坏道或者坏块影响正常使用。
尝试修复启动异常 尝试重新挂载文件系统发现仍然为只读模式。
mount -o remount,rw /尝试显示文件系统的元数据如果看到检测异常信息很大概率是磁盘问题。
tune2fs -l /dev/sda | grep checked2. 硬盘错误分析
磁盘损坏可能导致文件系统不稳定或丢失数据影响系统性能甚至导致系统无法启动。如果磁盘出现严重的物理故障可能需要更换硬盘或备份数据后进行恢复。 bios 查看磁盘状态 重新进入 BIOS 查看硬盘发现硬盘已经掉线使用机械硬盘从现象确认磁盘存在坏道问题。 重新挂载磁盘 raid0 阵列硬盘出现硬盘损坏情况系统默认记录当前状态。想要重新挂载该磁盘需要先清除磁盘标识再尝试挂载硬盘。 磁盘挂载成功然后仍然无法进入系统。好消息确认磁盘已损坏坏消息磁盘有大量数据。 抱着能找回尽量找回的原则可以尝试从 U 盘系统修复磁盘。 U盘引导进入系统 借助带有 Ubuntu 安装 U盘然后进入到 Ubuntu 尝试安装的临时系统然后尝试修复损坏磁盘。 制作启动U盘和U盘启动此处省略 1万字需要的小伙伴自行百度。进入U盘系统按照如下方法修复磁盘。
3. 硬盘数据恢复
在 Ubuntu 系统中修复磁盘通常是为了修复文件系统的损坏或修复磁盘上的错误。修复 Ubuntu 系统中的磁盘问题通常包括使用 fsck 修复文件系统错误、使用 smartctl 检查硬盘健康状态或者通过图形界面工具进行管理。
3.1 借助 fsck 命令修复文件系统
fsck文件系统检查器是 Linux 系统中用于检查和修复文件系统错误的工具。使用此命令可以扫描文件系统并自动修复文件系统中的错误。
检查磁盘
fsck /dev/sda/dev/sda 可以替换为需要修复的磁盘设备分区第一个磁盘分区则使用 /dev/sda1。
尝试自动修复磁盘 使用 fsck 尝试自动修复磁盘该命可以自动修复错误。
fsck -y /dev/sda提示磁盘正在被使用比如挂载了某个分区你需要先卸载该分区再执行恢复磁盘数据。
强制修复
fsck -f /dev/sda好在磁盘损坏较轻经过简单修复可以读到原来数据。接下来备份磁盘内容就不必多讲。
fsck 命令详细注释
Usage:fsck [options] -- [fs-options] [filesystem ...]Check and repair a Linux filesystem.Options:-A check all filesystems-C [fd] display progress bar; file descriptor is for GUIs-l lock the device to guarantee exclusive access-M do not check mounted filesystems-N do not execute, just show what would be done-P check filesystems in parallel, including root-R skip root filesystem; useful only with -A-r [fd] report statistics for each device checked;file descriptor is for GUIs-s serialize the checking operations-T do not show the title on startup-t type specify filesystem types to be checked;type is allowed to be a comma-separated list-V explain what is being done-?, --help display this help--version display versionSee the specific fsck.* commands for available fs-options.
For more details see fsck(8).3.2 借助 smartctl 检查硬盘健康状态
如果怀疑磁盘存在物理问题可以使用 smartctl 工具来检查硬盘的健康状况特别是对于固态硬盘 (SSD) 和机械硬盘 (HDD) 都非常有用。
安装 stmartmontools
sudo apt update
sudo apt install smartmontools检查硬盘状态
smartctl -a /dev/sda将输出硬盘的健康状态报告包括错误日志和一些详细的健康信息。看到“Reallocated Sector Count”或“Pending Sector”可能硬盘正在出现物理故障。
smartctl 命令详细注释
smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.167.4-microsoft-standard-WSL2] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.orgUsage: smartctl [options] device SHOW INFORMATION OPTIONS -h, --help, --usageDisplay this help and exit-V, --version, --copyright, --licensePrint license, copyright, and version information and exit-i, --infoShow identity information for device--identify[[w][nvb]]Show words and bits from IDENTIFY DEVICE data (ATA)-g NAME, --getNAMEGet device setting: all, aam, apm, dsn, lookahead, security,wcache, rcache, wcreorder, wcache-sct-a, --allShow all SMART information for device-x, --xallShow all information for device--scanScan for devices--scan-openScan for devices and try to open each device SMARTCTL RUN-TIME BEHAVIOR OPTIONS -j, --json[cgiosuvy]Print output in JSON or YAML format-q TYPE, --quietmodeTYPE (ATA)Set smartctl quiet mode to one of: errorsonly, silent, noserial-d TYPE, --deviceTYPESpecify device type to one of:ata, scsi[TYPE], nvme[,NSID], sat[,auto][,N][TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbprolific, usbsunplus, sntjmicron[,NSID], sntrealtek, intelliprop,N[TYPE], jmb39x[-q],N[,sLBA][,force][TYPE], jms56x,N[,sLBA][,force][TYPE], marvell, areca,N/E, 3ware,N, hpt,L/M/N, megaraid,N, aacraid,H,L,ID, cciss,N, auto, test-T TYPE, --toleranceTYPE (ATA)Tolerance: normal, conservative, permissive, verypermissive-b TYPE, --badsumTYPE (ATA)Set action on bad checksum to one of: warn, exit, ignore-r TYPE, --reportTYPEReport transactions (see man page)-n MODE[,STATUS], --nocheckMODE[,STATUS] (ATA, SCSI)No check if: never, sleep, standby, idle (see man page) DEVICE FEATURE ENABLE/DISABLE COMMANDS -s VALUE, --smartVALUEEnable/disable SMART on device (on/off)-o VALUE, --offlineautoVALUE (ATA)Enable/disable automatic offline testing on device (on/off)-S VALUE, --saveautoVALUE (ATA)Enable/disable Attribute autosave on device (on/off)-s NAME[,VALUE], --setNAME[,VALUE]Enable/disable/change device setting: aam,[N|off], apm,[N|off],dsn,[on|off], lookahead,[on|off], security-freeze,standby,[N|off|now], wcache,[on|off], rcache,[on|off],wcreorder,[on|off[,p]], wcache-sct,[ata|on|off[,p]] READ AND DISPLAY DATA OPTIONS -H, --healthShow device SMART health status-c, --capabilities (ATA, NVMe)Show device SMART capabilities-A, --attributesShow device SMART vendor-specific Attributes and values-f FORMAT, --formatFORMAT (ATA)Set output format for attributes: old, brief, hex[,id|val]-l TYPE, --logTYPEShow device log. TYPE: error, selftest, selective, directory[,g|s],xerror[,N][,error], xselftest[,N][,selftest], background,sasphy[,reset], sataphy[,reset], scttemp[sts,hist],scttempint,N[,p], scterc[,N,M], devstat[,N], defects[,N], ssd,gplog,N[,RANGE], smartlog,N[,RANGE], nvmelog,N,SIZE-v N,OPTION , --vendorattributeN,OPTION (ATA)Set display OPTION for vendor Attribute N (see man page)-F TYPE, --firmwarebugTYPE (ATA)Use firmware bug workaround:none, nologdir, samsung, samsung2, samsung3, xerrorlba, swapid-P TYPE, --presetsTYPE (ATA)Drive-specific presets: use, ignore, show, showall-B []FILE, --drivedb[]FILE (ATA)Read and replace [add] drive database from FILE[default is /etc/smart_drivedb.hand then /var/lib/smartmontools/drivedb/drivedb.h] DEVICE SELF-TEST OPTIONS -t TEST, --testTESTRun test. TEST: offline, short, long, conveyance, force, vendor,N,select,M-N, pending,N, afterselect,[on|off]-C, --captiveDo test in captive mode (along with -t)-X, --abortAbort any non-captive test on device SMARTCTL EXAMPLES smartctl --all /dev/sda (Prints all SMART information)smartctl --smarton --offlineautoon --saveautoon /dev/sda(Enables SMART on first disk)smartctl --testlong /dev/sda (Executes extended disk self-test)smartctl --attributes --logselftest --quietmodeerrorsonly /dev/sda(Prints Self-Test Attribute errors)smartctl --all --device3ware,2 /dev/sdasmartctl --all --device3ware,2 /dev/twe0smartctl --all --device3ware,2 /dev/twa0smartctl --all --device3ware,2 /dev/twl0(Prints all SMART info for 3rd ATA disk on 3ware RAID controller)smartctl --all --devicehpt,1/1/3 /dev/sda(Prints all SMART info for the SATA disk attached to the 3rd PMPortof the 1st channel on the 1st HighPoint RAID controller)smartctl --all --deviceareca,3/1 /dev/sg2(Prints all SMART info for 3rd ATA disk of the 1st enclosureon Areca RAID controller)结语
不枉博主详细讲解欢迎订阅博主–炭烤毛蛋 。