Bad file number linux

Thinstation по русски Всё о лёгком подключении тонкого клиента

Искать

ТЕМА: initrd failed: bad file number

initrd failed: bad file number 20 Апр 2016 13:19 #3642

Всем доброго времени суток.
Возникла проблема при запуске тонкого клиента по сети.
Проблема звучит так: «::/boot/initrd failed: Bad file number» Что с этим делать, как решать, какие настройки поменять?

Теперь опишу что у меня есть.
ВVirtualBox создал две машины, СЕРВЕР — Windows Server 2012 R2 Datacenter, КЛИЕНТ — Other/unknown(64-bit)
Настройки сервера:
1. Стоит Ttftpd64, работает только как tftp сервер. Каталог загрузки «С:\tftpboot». В этом каталоге лежит PXE
2. Настройки DHCP:
Пул адресов 10.0.2.100 — 10.0.2.254;
Параметры области (006 DNS-серверы 10.0.2.2)
(012 имя узла dyn.dhcp.test)
(066 имя узла сервера загрузки 10.0.2.2)
(067 имя файла загрузки «boot/pxelinux/pxelinux.0»)
Политики Класс BOOTP по умолчанию — отключен

В реестре Windows в ветке HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WDSServer\Providers\WDSTFTP добавил параметр
RootFolder = «C:\TFTPBOOT»
Изменил содержимое параметра ReadFilter на \*

При запуске клиента происходит следующее (снимок экрана):

Сам файл initrd лежит в папке «c:\tftpboot\boot\» на всякий случай разместил его и в корне «c:\tftpboot\»

Так же прикреплю файл с логом из TFTPD64 (что бы не спамить лишним текстом в теме/вопросе)

Источник

How to Fix/Repair Badblocks in Linux

The badblocks in a storage device are the portions of the device that are not readable for some reason. These badblocks can be recovered if we are able to reach the exact location of that block.

The SMART technology built into many storage devices (such as many ATA-3, later ATA, IDE and SCSI-3 hard drives) monitors the reliability of hard drive and can predict drive failures. The SMART stands for Self-Monitoring, Analysis and Reporting Technology.

This tutorial describes the actions that can be taken when smartmontools detect and report some badblocks on hard disk running linux.

About Smartmontools

The smartmontools package provides two utilities: smartrd and smartctl.

smartd is the deamon that polls the ATA and SCSI devices every 30 minutes (this value can be changed) and logs the SMART errors and changes in SMART attributes using SYSLOG interface.

The smartctl performs SMART tasks and can be used to print SMART self-tests and error logs among other tasks such as support for polling TapeAlert messages from SCSI tape drives. The usage of this command will be clear as we proceed through this article. This article proceeds through some examples of disk failure for different types of filesystem.

smartctl command

The smartctl command reports a badblock at Logical Block Address LBA = 0x016561e9 which in decimal number system is 23421417.

The LBA counts sectors in units of 512 bytes starting at zero. The value of «Current_Pending_Sector» attribute in «smartctl -A» command confirms the bad sector.

Fix badblocks

Step 1:

Locate the partition on which the bad block resides. The fdisk command can be used to view the sectors of the hard disk partitions.

Here we can see that the LBA 23421417 lies in the third partition, i.e. /dev/hda3. The offset value of the sector is 23421417 — 5269320 = 18152097 sectors in the partition /dev/hda3.

Now we need to check the type of filesystem of the partition. This can be checked from /etc/fstab file.

Step 2:

Now we need to find the block size of the filesystem using tune2fs command

This reports the block size to be 4096 bytes.

Step 3:

Find the filesystem block that contains this problematic LBA. We use the following formula:

b = File System block number
B = File system block size in bytes
L = LBA of bad sector
S = Starting sector of partition as shown by fdisk -lu
and (int) denotes the integer part.

For our example, L=23421417, S=5269320, and B=4096.

b = (int)18152097*512/4096 = (int)2269012.125

Step 4:

Use debugfs to locate the inode stored in this block, and hence the file that is stored at that location.

Here, in this case, the block is not in use. So the rest of this step can be skipped and we can jump directly to next step. Otherwise, if the block is in use, as reported by the following output:

In this case, the problematic file is: /data/S1/R/H/714197568-714203359/H-R-714202192-16.gwf

In case of ext3 filesystem, this block can be the part of journal itself. The inode will be very small and debugfs will not be able to report any filename.

In this case, we can remove the journal with tune2fs command:

Now, we repeat the step 4, and if the problem is not reported anymore, we can rebuild the journal:

Step 5:

This step will destroy the data on that block by writing zeroes on it. The bad block will be recovered but the data of the file will be lost. If you are sure, you can proceed with the following step:

Now we can again check the «smartctl -A» output to verify that everything is back to normal.

Here you can see that the value of «Current_Pending_Sector» is zero.

Smart Error on Ext2/ext3

This email from smartd shows the first sign of trouble. As talked about in the previous example, we run «smartctl -a /dev/hda» to confirm the problem:

The LBA reported is 0x021d9f44 (base 16) = 35495748 (base 10)

Here, 3 sectors are unreadable. Using the following bash script, we can check the sectors around that area.

35495734
1+0 records in
1+0 records out
35495735
dd: reading `/dev/hda’: Input/output error
0+0 records in
0+0 records out

35495751
dd: reading `/dev/hda’: Input/output error
0+0 records in
0+0 records out
35495752
1+0 records in
1+0 records out

This shows that 17 sectors 35495735-35495751 are unreadable.

The filesystem blocks that contain this area are:

L=35495735 to 35495751
S=5269320
B=4096
so b=3778301 to 3778303

To identify files at these locations, we run debugfs:

We can use md5sum to confirm our file:

So, we force the disk to reallocate the bad blocks:

Now we can check if the bad block are creating no trouble with the value of «Current_Pending_Sector» attribute (smartctl -A command):

Unassigned sectors

In the above examples, we have not considered the case when the bad blocks are not assigned to any file. This will be clear when we run debugfs command to find the file corresponding to a particular block. If this is the case, then we can first create a file that is large enough to fill the remaining filesystem (again, dd command is the rescue).

This command will run until there is no space left on the filesystem. And now we can proceed through rest of the steps.

BadBlock on ReiserFS

In this example, the filesystem used is ReiserFS. So, some of the commands used will be different from the above case.

The SMART error log indicates the bad block address to be 58656333. The partition table indicates that the block is in a partition with ReiserFS filesystem, starting at block address 54781650.

Get the block size of filesystem

Get the block number

More information about the block

The problem has occurred looks like a hardware problem.

Here, we see that reading the block fails. But we now know from this output that it is unused block.

At this point, we can try to write the bad block and see if the drive remaps the bad block. If it cannot remap the block, use badblock option (-B) with reiserfs utils to handle this block correctly.

bread: Cannot read the block (484335): (Input/output error).

At least we have the correct bad block.

Find the affected file

Run badblock -n to provoke reallocation

If everything happens as expected, debugreiserfs -1 484335 /dev/hda3 reports no errors. Otherwise:

Use dd command to write zeroes on the particular area

Badblock Repair LVM

This example considers the badblock to be on an LVM volume:

An error is reported and the bad block is found to be at LBA 37383668 with the following command:

sfdisk can help to find the physical partition of the bad block:

The bad block is in /dev/hdb3 partition, which is an LVM based partition. The offset of this block is: (37383668 — 1188810) = 36194858

The physical partition used by LVM is divided into PE (Physical Extent). The ‘pvdisplay’ command gives the size of PE of the LVM partition:

# part=/dev/hdb3 ; pvdisplay -c $part | awk -F: ‘
4096

To get its size in LBA block size (512 bytes or 0.5 KB), we multiply this number by 2 : 4096 * 2 = 8192 blocks for each PE.

Now we search the PE in which the bad block is residing: physical partition’s bad block number / sizeof(PE)

36194858 / 8192 = 4418.3176

Now we need to find the logical partition corresponding to PE number 4418.

Hence, the PE 4418 is in /dev/WDC80Go/ext1 logical partition.
Size of logical block of filesystem on /dev/WDC80Go/ext1 is

The logical partition starts on PE 3072:

(# PE’s start of partition * sizeof(PE)) + parttion offset[pe_start] = (3072 * 8192) + 384 = 25166208

There are 512 blocks of physical partition, so the bad block number is:

(36194858 — 25166208) / (sizeof(fs block) / 512) = 11028650 / (4096 / 512) = 1378581.25

You can verify if this is the actual bad block with dd command:

If the command issues some error, then the calculation for the bad block is correct. Otherwise, recheck the calculations to find the correct block. Once you have found the correct block, resolve the issue with dd command as explained in all above examples:

Conclusion

All the examples given in this article concentrate on finding the correct bad block and the partition. Once you have found the bad block, all you need to do is to run dd command to write zeroes on the block. The different examples provide the methods of finding the bad block location in different filesystems and in different scenarios.

7 Comments. add one

Thanks for the page
I’m having problems trying to find the partition offset with fdisk on my gpt partitioned disks.

For disks that have been partitioned with gpt, I have to use gdisk right?
trying to use fdisk as above, gave me confusion

gdisk reports like this on my gpt partitioned disk
$ gdisk -l /dev/sda
GPT fdisk (gdisk) version 0.8.1

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 7814037168 sectors, 3.6 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 58CF1ED7-6886-401C-B98A-08F60893C58A
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 7814037134
Partitions will be aligned on 8-sector boundaries
Total free space is 1739 sectors (869.5 KiB)

Number Start (sector) End (sector) Size Code Name
1 2048 102402047 48.8 GiB 8300
2 102402048 204802047 48.8 GiB 8300
3 204802048 307202047 48.8 GiB 8300
4 307202048 409602047 48.8 GiB 8300
5 409602048 512002047 48.8 GiB 8300
6 512002048 4608002047 1.9 TiB 8300
7 4608002048 7199637503 1.2 TiB 8300
8 7199637504 7814035455 293.0 GiB 8200
9 34 1987 977.0 KiB EF02

I have similar problem. Do you have any update how to calculate the right position on GPT?

This article was immensely helpful. Thank you.

The script below finds bad sectors, puts them into a text file, then test if text file size is different than zero, so e2fsck will mark bad sectors (these sectors will not be used by operating system)

#!/bin/sh
minsize=0
target=»/tmp/bad-blocks.txt»
for disc in `fdisk -l | grep ‘^/’ | awk ‘< print $1 >‘`; do
badblocks -v $disc > «$target»
tam=$(du -k «$target» | cut -f 1)
if [ $tam -eq $minsize ]; then
echo «no badblocks on $disc»
else
echo «badblock(s) found(s) on $disc»
e2fsck -l «$target» «$disc»
fi
done

It looks like dd command must have bs parameter equal to physical block size, not logical one. Otherwise writing fails with I/O error and HDD does not reallocate anything.

Thank you for that detailed information! It is very valuable for me.
However, I cannot use tune2fs, because my damage filesystem is ntfs-type (instead of ext2/3/4).
Can you recommend me a simmilar tool for that case?
Would steps be simmilar for a ntfs filesystem?

Thank you in advance. 🙂

This happened to me on the block holding /etc/hosts no less, rendering my system unusable!

Booting from USB and following your instructions I managed to clean it, then wrote a new basic hosts file and got things running again.

Phew! I had not had such a tough time since the early years of Linux!

Источник

greggyNapalm / gist:2413028

  • sargonit
# @see /usr/include/asm-generic/errno-base.h
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Not a typewriter */
#define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Math argument out of domain of func */
#define ERANGE 34 /* Math result not representable */
#endif
# @see /usr/include/asm-generic/errno.h
#ifndef _ASM_GENERIC_ERRNO_H
#define _ASM_GENERIC_ERRNO_H
#include
#define EDEADLK 35 /* Resource deadlock would occur */
#define ENAMETOOLONG 36 /* File name too long */
#define ENOLCK 37 /* No record locks available */
#define ENOSYS 38 /* Function not implemented */
#define ENOTEMPTY 39 /* Directory not empty */
#define ELOOP 40 /* Too many symbolic links encountered */
#define EWOULDBLOCK EAGAIN /* Operation would block */
#define ENOMSG 42 /* No message of desired type */
#define EIDRM 43 /* Identifier removed */
#define ECHRNG 44 /* Channel number out of range */
#define EL2NSYNC 45 /* Level 2 not synchronized */
#define EL3HLT 46 /* Level 3 halted */
#define EL3RST 47 /* Level 3 reset */
#define ELNRNG 48 /* Link number out of range */
#define EUNATCH 49 /* Protocol driver not attached */
#define ENOCSI 50 /* No CSI structure available */
#define EL2HLT 51 /* Level 2 halted */
#define EBADE 52 /* Invalid exchange */
#define EBADR 53 /* Invalid request descriptor */
#define EXFULL 54 /* Exchange full */
#define ENOANO 55 /* No anode */
#define EBADRQC 56 /* Invalid request code */
#define EBADSLT 57 /* Invalid slot */
#define EDEADLOCK EDEADLK
#define EBFONT 59 /* Bad font file format */
#define ENOSTR 60 /* Device not a stream */
#define ENODATA 61 /* No data available */
#define ETIME 62 /* Timer expired */
#define ENOSR 63 /* Out of streams resources */
#define ENONET 64 /* Machine is not on the network */
#define ENOPKG 65 /* Package not installed */
#define EREMOTE 66 /* Object is remote */
#define ENOLINK 67 /* Link has been severed */
#define EADV 68 /* Advertise error */
#define ESRMNT 69 /* Srmount error */
#define ECOMM 70 /* Communication error on send */
#define EPROTO 71 /* Protocol error */
#define EMULTIHOP 72 /* Multihop attempted */
#define EDOTDOT 73 /* RFS specific error */
#define EBADMSG 74 /* Not a data message */
#define EOVERFLOW 75 /* Value too large for defined data type */
#define ENOTUNIQ 76 /* Name not unique on network */
#define EBADFD 77 /* File descriptor in bad state */
#define EREMCHG 78 /* Remote address changed */
#define ELIBACC 79 /* Can not access a needed shared library */
#define ELIBBAD 80 /* Accessing a corrupted shared library */
#define ELIBSCN 81 /* .lib section in a.out corrupted */
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
#define EILSEQ 84 /* Illegal byte sequence */
#define ERESTART 85 /* Interrupted system call should be restarted */
#define ESTRPIPE 86 /* Streams pipe error */
#define EUSERS 87 /* Too many users */
#define ENOTSOCK 88 /* Socket operation on non-socket */
#define EDESTADDRREQ 89 /* Destination address required */
#define EMSGSIZE 90 /* Message too long */
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
#define ENOPROTOOPT 92 /* Protocol not available */
#define EPROTONOSUPPORT 93 /* Protocol not supported */
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
#define EPFNOSUPPORT 96 /* Protocol family not supported */
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
#define EADDRINUSE 98 /* Address already in use */
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
#define ENETDOWN 100 /* Network is down */
#define ENETUNREACH 101 /* Network is unreachable */
#define ENETRESET 102 /* Network dropped connection because of reset */
#define ECONNABORTED 103 /* Software caused connection abort */
#define ECONNRESET 104 /* Connection reset by peer */
#define ENOBUFS 105 /* No buffer space available */
#define EISCONN 106 /* Transport endpoint is already connected */
#define ENOTCONN 107 /* Transport endpoint is not connected */
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
#define ETIMEDOUT 110 /* Connection timed out */
#define ECONNREFUSED 111 /* Connection refused */
#define EHOSTDOWN 112 /* Host is down */
#define EHOSTUNREACH 113 /* No route to host */
#define EALREADY 114 /* Operation already in progress */
#define EINPROGRESS 115 /* Operation now in progress */
#define ESTALE 116 /* Stale NFS file handle */
#define EUCLEAN 117 /* Structure needs cleaning */
#define ENOTNAM 118 /* Not a XENIX named type file */
#define ENAVAIL 119 /* No XENIX semaphores available */
#define EISNAM 120 /* Is a named type file */
#define EREMOTEIO 121 /* Remote I/O error */
#define EDQUOT 122 /* Quota exceeded */
#define ENOMEDIUM 123 /* No medium found */
#define EMEDIUMTYPE 124 /* Wrong medium type */
#define ECANCELED 125 /* Operation Canceled */
#define ENOKEY 126 /* Required key not available */
#define EKEYEXPIRED 127 /* Key has expired */
#define EKEYREVOKED 128 /* Key has been revoked */
#define EKEYREJECTED 129 /* Key was rejected by service */
/* for robust mutexes */
#define EOWNERDEAD 130 /* Owner died */
#define ENOTRECOVERABLE 131 /* State not recoverable */
#define ERFKILL 132 /* Operation not possible due to RF-kill */
#endif

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

Читайте также:  Не работает hear windows 10
Оцените статью