In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the Linux hard disk problems". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the Linux hard disk problems"?
# 1-error: no space left on the device
You will see this message on the screen when your UNIX-like system disk is full. In this case, I run the fallocate command and my system prompts that the disk space is running out:
$fallocate-l 1G test4.imgfallocate: test4.img: fallocate failed: No space left on device
The first step is to run the df command to view information about the total disk space and free space of a partitioned file system:
$df
Or try a more readable output format:
$df-h
Partial output:
Filesystem Size Used Avail Use% Mounted on/dev/sda6 117G 54G 57G 49% / udev 993M 4.0K 993M 1% / devtmpfs 201M 264K 200m 1% / runnone 5.0M 05.0M 0% / run/locknone 1002M 01002M 0% / run/shm/dev/sda1 1.8G 115M 1.6G 7% / boot/dev/ Sda7 4.7G 145m 4.4G 4% / tmp/dev/sda9 9.4G 628M 8.3G 7% / var/dev/sda8 94G 579M 89G 1% / ftpusers/dev/sda10 4.0G 4.0G 0100% / ftpusers/tmp
Using the output of the df command, you can clearly see that the total 4.0Gb space under the / dev/sda10 partition is full.
Fix the problem that the disk is full
1. Use the gzip,bzip2 or tar command to compress uncompressed logs and other files:
Gzip / ftpusers/tmp/*.logbzip2 / ftpusers/tmp/large.file.name
two。 Use the rm command to delete unwanted files on a UNIX-like system:
Rm-rf / ftpusers/tmp/*.bmp
3. Use the rsync command to move files to another system or external hard drive:
Rsync-- remove-source-files-azv / ftpusers/tmp/*.mov / mnt/usbdisk/rsync-- remove-source-files-azv / ftpusers/tmp/*.mov server2:/path/to/dest/dir/
4. Find the directory or file that takes up the most disk space in a UNIX-like system:
Du-a / ftpusers/tmp | sort-n-r | head-n 10du-cks * | sort-rn | head
5. Empties the specified file. This works for log files:
Truncate-s 0 / ftpusers/ftp.upload.log### bash/sh, etc. # # > / ftpusers/ftp.upload.log## perl # # perl-e'truncate "filename", LENGTH'
6. Find and delete large files that appear but have been deleted in Linux and UNIX:
# # based on Linux/Unix/OSX/BSD and other systems # # lsof-nP | grep'(deleted)'# # based on Linux # # find / proc/*/fd-ls | grep'(deleted)'
Empty it:
# # based on all systems such as Linux/Unix/OSX/BSD # # > "/ path/to/the/deleted/file.name" # # only based on Linux # # > "/ proc/PID-HERE/fd/FD-HERE"
# 2-is the file system read-only?
When you try to create or save a file, you may end up with errors such as the following:
$cat > file-bash: file: Read-only file system
Run the mount command to see if the mounted file system is read-only:
$mount$ mount | grep'/ ftpusers'
To fix this problem on Linux-based systems, simply mount the read-only file system:
# mount-o remount,rw / ftpusers/tmp
(LCTT translation note: if the hard drive fallback to read-only mode due to hardware failure, it is recommended that you do not force it to change back to read-write mode, but replace the hard drive as soon as possible.)
In addition, I remounted the root directory of the FreeBSD 9.x server in rw mode:
# mount-o rw / dev/ad0s1a /
# 3-Am I running out of inodes?
Sometimes the df command shows that the disk has free space but the system claims that the file system is full. At this point, you need to check the index nodes that identify the file and its attributes in the file system with the following command:
$df-I $df-I / ftpusers/
Partial output:
Filesystem Inodes IUsed IFree IUse% Mounted on/dev/sda8 6250496 11568 6238928 1% / ftpusers
As shown above, there are a total of 62jm 50496 KB Inode under / ftpusers, but only 11568KB is used. You can create an additional file of 62Jing 38928KB in the / ftpusers location. If your Inode is 100% used, try the following options:
Find the unwanted file and delete it, or move it to another server. Find the large file you don't want and delete it, or move it to another server.
(LCTT translation note: if a partition stores too many small files, it will run out of inode and the storage sector will be free. In this case, either clear the small files or package them into a large file without independent access, or repartition the data and set the-t news attribute of the partition to increase the inode allocation.)
# 4-is my hard drive down?
The input / output errors in the log file (such as / var/log/messages) indicate that there is something wrong with the hard drive and may have failed. You can use the smartctl command to check the errors on the hard drive, which is a command to control and monitor the status of the hard disk in a UNIX-like system. The syntax is as follows:
Smartctl-a / dev/DEVICE# check / dev/sda smartctl-a / dev/sda under the Linux server
You can also use "Disk Utility" to get the same information.
Figure 01: Gnome disk tool (Applications > System Tools > Disk Utility)
Note: do not treat S.M.A.R.T. The expectation of the tool is too high, it will not work in some situations, and we need to make regular backups.
# 5-is my hard drive and server too hot?
High temperatures can cause inefficient servers, so you need to keep servers and disks at a steady and appropriate temperature. High temperatures can even lead to server downtime or damage to file systems and disks. With the hddtemp or smartctl function, through the support of S.M.A.R.T. Features the way data is read on the hard drive to find out the temperature of your hard disk on Linux or UNIX-based systems. Only modern hard drives have temperature sensors. The hddtemp function also supports reading S.M.A.R.T from the SCSI drive. information. Hddtemp can be used as a simple command-line tool or daemon to get information from all servers:
Hddtemp / dev/DISKhddtemp / dev/sg0
Some of the outputs are as follows:
Figure 02: hddtemp is running
You can also use the smartctl command as shown below:
Smartctl-d ata-A / dev/sda | grep-I temperature
How do I get the temperature of CPU
You can use Linux hardware monitoring tools, such as the lm_sensor function based on Linux system, to obtain CPU temperature:
Sensors
Part of the output of the Debian server:
Figure 03: the sensors command provides CPU core temperature and other information for a Linux computer
# 6-dealing with corrupted file systems
The file system on the server may be damaged by a hardware restart or some other error such as a bad sector. You can use the fsck command to repair corrupted file systems:
Umount / ftpusersfsck-y / dev/sda8
Take a look at how to deal with Linux file system failures for more information.
# 7-processing soft arrays in Linux
Enter the following command to view the recent status of the Linux soft array:
# # get the details of the disk array on / dev/md0 # # mdadm-- detail / dev/md0## View status # # cat / proc/mdstatwatch cat / proc/mdstat
Partial output:
Figure 04: view Linux soft Array status Command
You need to replace the faulty hardware drive. Don't delete it wrong. In this case, I replaced / dev/sdb (the second hardware drive in RAID 6). There is no need to rely on offline storage of files to repair disk arrays on Linux, as this only works if your server supports hot-swappable hard drives:
# # remove disks from a md0 array # # mdadm-- manage / dev/md0-- fail / dev/sdb1mdadm-- manage / dev/md0-- remove / dev/sdb1# do the same for the rest of / dev/sdbX # if it is not a hot-swappable hard drive, perform shutdown operation # # shutdown-h now## copy partition table from / dev/sda to new / dev/sdb # # sfdisk- D / dev/sda | sfdisk / dev/sdbfdisk-lumped # add # # mdadm-- manage / dev/md0-- add / dev/sdb1# do the same for the rest of / dev/sdbX # now md0 will synchronize again View # # watch cat / proc/mdstat on the display screen
Take a look at tips for speeding up the synchronization of Linux disk arrays for more information.
# 8-processing hard Array
You can use the samrtctl command or vendor-specific commands to view the disk array and the status of the disks you manage:
# # SCSI disk smartctl-d scsi-- all / dev/sgX## Adaptec disk array / usr/StorMan/arcconf getconfig 1 disk # 3ware disk array tw_cli / c0 show
Replace your faulty disk against vendor-specific documentation.
Thank you for your reading, the above is the content of "what are the Linux hard disk problems". After the study of this article, I believe you have a deeper understanding of what Linux hard disk problems there are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.