Aici veti gasi detalii tehnice despre cum se pot realiza configurari software+ hardware.
Here you can find tehnical details about software/hardware configuration.

duminică, 26 decembrie 2021

fsck Error Messages

 

fsck Error Messages

Normally, fsck is run non-interactively to preen the file systems after an abrupt system halt in which the latest file system changes were not written to disk. Preening automatically fixes any basic file system inconsistencies and does not try to repair more serious errors. While preening a file system, fsck fixes the inconsistencies it expects from such an abrupt halt. For more serious conditions, the command reports the error and terminates.

When you run fsck interactively, fsck reports each inconsistency found and fixes innocuous errors. However, for more serious errors, the command reports the inconsistency and prompts you to choose a response. When you run fsck using the -y or -n options, your response is predefined as yes or no to the default response suggested by fsck for each error condition.

Some corrective actions will result in some loss of data. The amount and severity of data loss may be determined from the fsck diagnostic output.

fsck is a multipass file system check program. Each pass invokes a different phase of the fsck program with different sets of messages. After initialization, fsck performs successive passes over each file system, checking blocks and sizes, path names, connectivity, reference counts, and the map of free blocks (possibly rebuilding it). It also performs some cleanup.

The phases (passes) performed by the UFS version of fsck are:

  • Initialization

  • Phase 1 - Check blocks and sizes

  • Phase 2 - Check path names

  • Phase 3 - Check connectivity

  • Phase 4 - Check reference counts

  • Phase 5 - Check cylinder groups

The next sections describe the error conditions that may be detected in each phase, the messages and prompts that result, and possible responses you can make.

Messages that may appear in more than one phase are described in "General fsck Error Messages ". Otherwise, messages are organized alphabetically by the phases in which they occur.

Many of the messages include the abbreviations shown in the table below:

Table 43-1 Error Message Abbreviations

Abbreviation 

Meaning 

BLK

Block number 

DUP

Duplicate block number 

DIR

Directory name 

CG

Cylinder group 

MTIME

Time file was last modified 

UNREF

Unreferenced 

Many of the messages also include variable fields, such as inode numbers, which are represented in this book by an italicized term, such as inode-number. For example, this screen message:


INCORRECT BLOCK COUNT I=2529 

is shown as:


INCORRECT BLOCK COUNT I=inode-number

General fsck Error Messages

The error messages in this section may be displayed in any phase after initialization. Although they offer the option to continue, it is generally best to regard them as fatal. They reflect a serious system failure and should be handled immediately. When confronted with such a message, terminate the program by entering n(o). If you cannot determine what caused the problem, contact your local service provider or another qualified person.


CANNOT SEEK: BLK block-number (CONTINUE)
Cause

A request to move to a specified block number, block-number, in the file system failed. This message indicates a serious problem, probably a hardware failure.

If you want to continue the file system check, fsck will retry the move and display a list of sector numbers that could not be moved. If the block was part of the virtual memory buffer cache, fsck will terminate with a fatal I/O error message.

Action

If the disk is experiencing hardware problems, the problem will persist. Run fsck again to recheck the file system.

If the recheck fails, contact your local service provider or another qualified person.


CANNOT READ: BLK block-number (CONTINUE)
Cause

A request to read a specified block number, block-number, in the file system failed. The message indicates a serious problem, probably a hardware failure.

If you want to continue the file system check, fsck will retry the read and display a list of sector numbers that could not be read. If the block was part of the virtual memory buffer cache, fsck will terminate with a fatal I/O error message. If fsck tries to write back one of the blocks on which the read failed, it will display the following message:

WRITING ZERO'ED BLOCK sector-numbers TO DISK

Action

If the disk is experiencing hardware problems, the problem will persist. Run fsck again to recheck the file system. If the recheck fails, contact your local service provider or another qualified person.


CANNOT WRITE: BLK block-number (CONTINUE)
Cause

A request to write a specified block number, block-number, in the file system failed.

If you continue the file system check, fsck will retry the write and display a list of sector numbers that could not be written. If the block was part of the virtual memory buffer cache, fsck will terminate with a fatal I/O error message.

Action

The disk may be write-protected. Check the write-protect lock on the drive. If the disk has hardware problems, the problem will persist. Run fsck again to recheck the file system. If the write-protect is not the problem or the recheck fails, contact your local service provider or another qualified person.

Initialization Phase fsck Messages

In the initialization phase, command-line syntax is checked. Before the file system check can be performed, fsck sets up tables and opens files.

The messages in this section relate to error conditions resulting from command-line options, memory requests, the opening of files, the status of files, file system size checks, and the creation of the scratch file. All such initialization errors terminate fsck when it is preening the file system.


bad inode number inode-number to ginode
Cause

An internal error occurred because of a nonexistent inode inode-number. fsck exits.

Action

Contact your local service provider or another qualified person.


cannot alloc size-of-block map bytes for blockmap
cannot alloc size-of-free map bytes for freemap
cannot alloc size-of-state map bytes for statemap
cannot alloc size-of-lncntp bytes for lncntp
Cause

Request for memory for its internal tables failed. fsck terminates. This message indicates a serious system failure that should be handled immediately. This condition may occur if other processes are using a very large amount of system resources.

Action

Killing other processes may solve the problem. If not, contact your local service provider or another qualified person.


Can't open checklist file: filename
Cause

The file system checklist file filename (usually /etc/vfstab) cannot be opened for reading. fsck terminates.

Action

Check if the file exists and if its access modes permit read access.


Can't open filename
Cause

fsck cannot open file system filename. When running interactively, fsck ignores this file system and continues checking the next file system given.

Action

Check to see if read and write access to the raw device file for the file system is permitted.


Can't stat root
Cause

fsck request for statistics about the root directory failed. fsck terminates.

Action

This message indicates a serious system failure. Contact your local service provider or another qualified person.


Can't stat filename
Can't make sense out of name filename
Cause

fsck request for statistics about the file system filename failed. When running interactively, fsck ignores this file system and continues checking the next file system given.

Action

Check if the file system exists and check its access modes.


filename: (NO WRITE)
Cause

Either the -n option was specified or fsck could not open the file system filename for writing. When fsck is running in no-write mode, all diagnostic messages are displayed, but fsck does not attempt to fix anything.

Action

If -n was not specified, check the type of the file specified. It may be the name of a regular file.


IMPOSSIBLE MINFREE=percent IN SUPERBLOCK (SET TO DEFAULT)
Cause

The superblock minimum space percentage is greater than 99 percent or less than 0 percent.

Action

To set the minfree parameter to the default 10 percent, type y at the default prompt. To ignore the error condition, type n at the default prompt.


filename: BAD SUPER BLOCK: message
USE AN ALTERNATE SUPER-BLOCK TO SUPPLY NEEDED INFORMATION;
e.g., fsck[-f ufs] -o b=# [special ...]
where # is the alternate superblock.  See fsck_ufs(1M)
Cause

The superblock has been corrupted.

Action

One of the following messages may be displayed:


CPG OUT OF RANGE
FRAGS PER BLOCK OR FRAGSIZE WRONG
INODES PER GROUP OUT OF RANGE
INOPB NONSENSICAL RELATIVE TO BSIZE 
MAGIC NUMBER WRONG 
NCG OUT OF RANGE 
NCYL IS INCONSISTENT WITH NCG*CPG 
NUMBER OF DATA BLOCKS OUT OF RANGE
NUMBER OF DIRECTORIES OUT OF RANGE
ROTATIONAL POSITION TABLE SIZE OUT OF RANGE
SIZE OF CYLINDER GROUP SUMMARY AREA WRONG
SIZE TOO LARGE 
BAD VALUES IN SUPERBLOCK

Try to rerun fsck with an alternative superblock. Specifying block 32 is a good first choice. You can locate an alternative copy of the superblock by running the newfs -N command on the slice. Be sure to specify the -N option; otherwise, newfs overwrites the existing file system.


UNDEFINED OPTIMIZATION IN SUPERBLOCK (SET TO DEFAULT)
Cause

The superblock optimization parameter is neither OPT_TIME nor OPT_SPACE.

Action

To minimize the time to perform operations on the file system, type y at the SET TO DEFAULT prompt. To ignore this error condition, type n.

Phase 1: Check Blocks and Sizes Messages

This phase checks the inode list. It reports error conditions encountered while:

  • Checking inode types

  • Setting up the zero-link-count table

  • Examining inode block numbers for bad or duplicate blocks

  • Checking inode size

  • Checking inode format

All errors in this phase except INCORRECT BLOCK COUNT, PARTIALLY TRUNCATED INODE, PARTIALLY ALLOCATED INODE, and UNKNOWN FILE TYPE terminate fsck when it is preening a file system.

These messages (in alphabetical order) may occur in phase 1:


block-number BAD I=inode-number
Cause

Inode inode-number contains a block number block-number with a number lower than the number of the first data block in the file system or greater than the number of the last block in the file system. This error condition may generate the EXCESSIVE BAD BLKS error message in phase 1 if inode inode-number has too many block numbers outside the file system range. This error condition generates the BAD/DUP error message in phases 2 and 4.

Action

N/A


BAD MODE: MAKE IT A FILE?
Cause

The status of a given inode is set to all 1s, indicating file system damage. This message does not indicate physical disk damage, unless it is displayed repeatedly after fsck -y has been run.

Action

Type y to reinitialize the inode to a reasonable value.


BAD STATE state-number TO BLKERR
Cause

An internal error has scrambled the fsck state map so that it shows the impossible value state-number. fsck exits immediately.

Action

Contact your local service provider or another qualified person.


block-number DUP I=inode-number
Cause

Inode inode-number contains a block number block-number, which is already claimed by the same or another inode. This error condition may generate the EXCESSIVE DUP BLKS error message in phase 1 if inode inode-number has too many block numbers claimed by the same or another inode. This error condition invokes phase 1B and generates the BAD/DUP error messages in phases 2 and 4.

Action

N/A


DUP TABLE OVERFLOW (CONTINUE)
Cause

There is no more room in an internal table in fsck containing duplicate block numbers. If the -o p option is specified, the program terminates.

Action

To continue the program, type y at the CONTINUE prompt. When this error occurs, a complete check of the file system is not possible. If another duplicate block is found, this error condition repeats. Increase the amount of virtual memory available (by killing some processes, increasing swap space) and run fsck again to recheck the file system. To terminate the program, type n.


EXCESSIVE BAD BLOCKS I=inode-number (CONTINUE)
Cause

Too many (usually more than 10) blocks have a number lower than the number of the first data block in the file system or greater than the number of the last block in the file system associated with inode inode-number. If the -o p (preen) option is specified, the program terminates.

Action

To continue the program, type y at the CONTINUE prompt. When this error occurs, a complete check of the file system is not possible. You should run fsck again to recheck the file system. To terminate the program, type n.


EXCESSIVE DUP BLKS I=inode-number (CONTINUE)
Cause

Too many (usually more than 10) blocks are claimed by the same or another inode or by a free-list. If the -o p option is specified, the program terminates.

Action

To continue the program, type y at the CONTINUE prompt. When this error occurs, a complete check of the file system is not possible. You should run fsck again to recheck the file system. To terminate the program, type n.


INCORRECT BLOCK COUNT I=inode-number (number-of-BAD-DUP-or-missing-blocks should be
 number-of-blocks-in-filesystem) (CORRECT)
Cause

The block count for inode inode-number is number-of-BAD-DUP-or-missing-blocks, but should be number-of-blocks-in-filesystem. When preening, fsck corrects the count.

Action

To replace the block count of inode inode-number by number-of-blocks-in-filesystem, type y at the CORRECT prompt. To terminate the program, type n.


LINK COUNT TABLE OVERFLOW (CONTINUE)
Cause

There is no more room in an internal table for fsck containing allocated inodes with a link count of zero. If the -o p (preen) option is specified, the program exits and fsck has to be completed manually.

Action

To continue the program, type y at the CONTINUE prompt. If another allocated inode with a zero-link count is found, this error condition repeats. When this error occurs, a complete check of the file system is not possible. You should run fsck again to recheck the file system. Increase the virtual memory available by killing some processes or increasing swap space, then run fsck again. To terminate the program, type n.


PARTIALLY ALLOCATED INODE I=inode-number (CLEAR)
Cause

Inode inode-number is neither allocated nor unallocated. If the -o p (preen) option is specified, the inode is cleared.

Action

To deallocate the inode inode-number by zeroing out its contents, type y. This may generate the UNALLOCATED error condition in phase 2 for each directory entry pointing to this inode. To ignore the error condition, type n. A no response is appropriate only if you intend to take other measures to fix the problem.


PARTIALLY TRUNCATED INODE I=inode-number (SALVAGE)
Cause

fsck has found inode inode-number whose size is shorter than the number of blocks allocated to it. This condition occurs only if the system crashes while truncating a file. When preening the file system, fsck completes the truncation to the specified size.

Action

To complete the truncation to the size specified in the inode, type y at the SALVAGE prompt. To ignore this error condition, type n.


UNKNOWN FILE TYPE I=inode-number (CLEAR)
Cause

The mode word of the inode inode-number shows that the inode is not a pipe, special character inode, special block inode, regular inode, symbolic link, FIFO file, or directory inode. If the -o p option is specified, the inode is cleared.

Action

To deallocate the inode inode-number by zeroing its contents, which results in the UNALLOCATED error condition in phase 2 for each directory entry pointing to this inode, type y at the CLEAR prompt. To ignore this error condition, type n.

Phase 1B: Rescan for More DUPS Messages

When a duplicate block is found in the file system, this message is displayed:


block-number DUP I=inode-number
Cause

Inode inode-number contains a block number block-number that is already claimed by the same or another inode. This error condition generates the BAD/DUP error message in phase 2. Inodes that have overlapping blocks may be determined by examining this error condition and the DUP error condition in phase 1.

Action

When a duplicate block is found, the file system is rescanned to find the inode that previously claimed that block.

Phase 2: Check Path Names Messages

This phase removes directory entries pointing to bad inodes found in phases 1 and 1B. It reports error conditions resulting from:

  • Incorrect root inode mode and status

  • Directory inode pointers out of range

  • Directory entries pointing to bad inodes

  • Directory integrity checks

When the file system is being preened (-o p option), all errors in this phase terminate fsck, except those related to directories not being a multiple of the block size, duplicate and bad blocks, inodes out of range, and extraneous hard links.

These messages (in alphabetical order) may occur in phase 2:


BAD INODE state-number TO DESCEND
Cause

An fsck internal error has passed an invalid state state-number to the routine that descends the file system directory structure. fsck exits.

Action

If this error message is displayed, contact your local service provider or another qualified person.


BAD INODE NUMBER FOR '.' I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size MTIME=modification-time DIR=filename (FIX)
Cause

A directory inode-number has been found whose inode number for "." does not equal inode-number.

Action

To change the inode number for "." to be equal to inode-number, type y at the FIX prompt To leave the inode numbers for "." unchanged, type n.


BAD INODE NUMBER FOR '..' I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size MTIME=modification-time DIR=filename (FIX)
Cause

A directory inode-number has been found whose inode number for ".." does not equal the parent of inode-number.

Action

To change the inode number for ".." to be equal to the parent of inode-number, type y at the FIX prompt. (Note that "..'' in the root inode points to itself.)To leave the inode number for ".." unchanged, type n.


BAD RETURN STATE state-number FROM DESCEND
Cause

An fsck internal error has returned an impossible state state-number from the routine that descends the file system directory structure. fsck exits.

Action

If this message is displayed, contact your local service provider or another qualified person.


BAD STATE state-number FOR ROOT INODE
Cause

An internal error has assigned an impossible state state-number to the root inode. fsck exits.

Action

If this error message is displayed, contact your local service provider or another qualified person.


BAD STATE state-number FOR INODE=inode-number
Cause

An internal error has assigned an impossible state state-number to inode inode-number. fsck exits.

Action

If this error message is displayed, contact your local service provider or another qualified person.


DIRECTORY TOO SHORT I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size MTIME=modification-time DIR=filename (FIX)
Cause

A directory filename has been found whose size file-size is less than the minimum directory size. The owner UID, mode file-mode, size file-size, modify time modification-time, and directory name filename are displayed.

Action

To increase the size of the directory to the minimum directory size, type y at the FIX prompt. To ignore this directory, type n.


DIRECTORY filename: LENGTH file-size NOT MULTIPLE OF block-number (ADJUST)
Cause

A directory filename has been found with size file-size that is not a multiple of the directory block size block-number.

Action

To round up the length to the appropriate block size, type y. When preening the file system (-o p option), fsck only displays a warning and adjusts the directory. To ignore this condition, type n.


DIRECTORY CORRUPTED I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size MTIME=modification-time DIR=filename (SALVAGE)
Cause

A directory with an inconsistent internal state has been found.

Action

To throw away all entries up to the next directory boundary (usually a 512-byte boundary), type y at the SALVAGE prompt. This drastic action can throw away up to 42 entries. Take this action only after other recovery efforts have failed. To skip to the next directory boundary and resume reading, but not modify the directory, type n.


DUP/BAD I=inode-number OWNER=O MODE=M SIZE=file-size 
MTIME=modification-time TYPE=filename (REMOVE)
Cause

Phase 1 or phase 1B found duplicate blocks or bad blocks associated with directory or file entry filename, inode inode-number. The owner UID, mode file-mode, size file-size, modification time modification-time, and directory or file name filename are displayed. If the -p (preen) option is specified, the duplicate/bad blocks are removed.

Action

To remove the directory or file entry filename, type y at the REMOVE prompt. To ignore this error condition, type n.


DUPS/BAD IN ROOT INODE (REALLOCATE)
Cause

Phase 1 or phase 1B has found duplicate blocks or bad blocks in the root inode (usually inode number 2) of the file system.

Action

To clear the existing contents of the root inode and reallocate it, type y at the REALLOCATE prompt. The files and directories usually found in the root inode will be recovered in phase 3 and put into the lost+found directory. If the attempt to allocate the root fails, fsck will exit with: CANNOT ALLOCATE ROOT INODE. Type n to get the CONTINUE prompt. Type: y to respond to the CONTINUE prompt, and ignore the DUPS/BAD error condition in the root inode and continue running the file system check. If the root inode is not correct, this may generate many other error messages. Type n to terminate the program.


EXTRA '.' ENTRY I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size MTIME=modification-time DIR=filename (FIX)
Cause

A directory inode-number has been found that has more than one entry for ".".

Action

To remove the extra entry for "." type y at the FIX prompt. To leave the directory unchanged, type n.


EXTRA '..' ENTRY I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size MTIME=modification-time DIR=filename(FIX)
Cause

A directory inode-number has been found that has more than one entry for ".." (the parent directory).

Action

To remove the extra entry for `..' (the parent directory), type y at the FIX prompt. To leave the directory unchanged, type n.


hard-link-number IS AN EXTRANEOUS HARD LINK TO A DIRECTORY filename (REMOVE)
Cause

fsck has found an extraneous hard link hard-link-number to a directory filename. When preening (-o p option), fsck ignores the extraneous hard links.

Action

To delete the extraneous entry hard-link-number type y at the REMOVE prompt. To ignore the error condition, type n.


inode-number OUT OF RANGE I=inode-number NAME=filename (REMOVE)
Cause

A directory entry filename has an inode number inode-number that is greater than the end of the inode list. If the -p (preen) option is specified, the inode will be removed automatically.

Action

To delete the directory entry filename type y at the REMOVE prompt. To ignore the error condition, type n.


MISSING '.' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time DIR=filename (FIX)
Cause

A directory inode-number has been found whose first entry (the entry for ".") is unallocated.

Action

To build an entry for "." with inode number equal to inode-number, type y at the FIX prompt. To leave the directory unchanged, type n.


MISSING '.' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time DIR=filename CANNOT FIX, FIRST ENTRY IN 
DIRECTORY CONTAINS filename
Cause

A directory inode-number has been found whose first entry is filename. fsck cannot resolve this problem.

Action

If this error message is displayed, contact your local service provider or another qualified person.


MISSING '.' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time DIR=filename CANNOT FIX, INSUFFICIENT 
SPACE TO ADD '.'
Cause

A directory inode-number has been found whose first entry is not ".". fsck cannot resolve the problem.

Action

If this error message is displayed, contact your local service provider or another qualified person.


MISSING '..' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time DIR=filename (FIX)
Cause

A directory inode-number has been found whose second entry is unallocated.

Action

To build an entry for ".." with inode number equal to the parent of inode-number, type y at the FIX prompt. (Note that "..'' in the root inode points to itself.) To leave the directory unchanged, type n.


MISSING '..' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time DIR=filename CANNOT FIX, SECOND ENTRY IN 
DIRECTORY CONTAINS filename
Cause

A directory inode-number has been found whose second entry is filename. fsck cannot resolve this problem.

Action

If this error message is displayed, contact your local service provider or another qualified person.


MISSING '..' I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time DIR=filename CANNOT FIX, INSUFFICIENT SPACE 
TO ADD '..'
Cause

A directory inode-number has been found whose second entry is not ".." (the parent directory). fsck cannot resolve this problem.

Action

If this error message is displayed, contact your local service provider or another qualified person.


NAME TOO LONG filename
Cause

An excessively long path name has been found, which usually indicates loops in the file system name space. This error can occur if a privileged user has made circular links to directories.

Action

Remove the circular links.


ROOT INODE UNALLOCATED (ALLOCATE)
Cause

The root inode (usually inode number 2) has no allocate-mode bits.

Action

To allocate inode 2 as the root inode, type y at the ALLOCATE prompt. The files and directories usually found in the root inode will be recovered in phase 3 and put into the lost+found directory. If the attempt to allocate the root inode fails, fsck displays this message and exits: CANNOT ALLOCATE ROOT INODE. To terminate the program, type n.


ROOT INODE NOT DIRECTORY (REALLOCATE)
Cause

The root inode (usually inode number 2) of the file system is not a directory inode.

Action

To clear the existing contents of the root inode and reallocate it, type y at the REALLOCATE prompt. The files and directories usually found in the root inode will be recovered in phase 3 and put into the lost+found directory. If the attempt to allocate the root inode fails, fsck displays this message and exits :CANNOT ALLOCATE ROOT INODE. To have fsck prompt with FIX, type n.


UNALLOCATED I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time type=filename(REMOVE)
Cause

A directory or file entry filename points to an unallocated inode inode-number. The owner UID, mode file-mode, size file-size, modify time modification-time, and file name filename are displayed.

Action

To delete the directory entry filename, type y at the REMOVE prompt. To ignore the error condition, type n.


ZERO LENGTH DIRECTORY I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size MTIME=modification-time DIR=filename (REMOVE)
Cause

A directory entry filename has a size file-size that is zero. The owner UID, mode file-mode, size file-size, modify time modification-time, and directory name filename are displayed.

Action

To remove the directory entry filename, type y at the REMOVE prompt. This results in the BAD/DUP error message in phase 4. To ignore the error condition, type n.

Phase 3: Check Connectivity Messages

This phase checks the directories examined in phase 2 and reports error conditions resulting from:

  • Unreferenced directories

  • Missing or full lost+found directories

These messages (in alphabetical order) may occur in phase 3:


BAD INODE state-number TO DESCEND
Cause

An internal error has caused an impossible state state-number to be passed to the routine that descends the file system directory structure. fsck exits.

Action

If this occurs, contact your local service provider or another qualified person.


DIR I=inode-number1 CONNECTED. PARENT WAS I=inode-number2
Cause

This is an advisory message indicating a directory inode inode-number1 was successfully connected to the lost+found directory. The parent inode inode-number2 of the directory inode inode-number1 is replaced by the inode number of the lost+found directory.

Action

N/A


DIRECTORY filename LENGTH file-size NOT MULTIPLE OF block-number (ADJUST)
Cause

A directory filename has been found with size file-size that is not a multiple of the directory block size B. (This condition can recur in phase 3 if it is not adjusted in phase 2.)

Action

To round up the length to the appropriate block size, type y at the ADJUST prompt. When preening, fsck displays a warning and adjusts the directory. To ignore this error condition, type n.


lost+found IS NOT A DIRECTORY (REALLOCATE)
Cause

The entry for lost+found is not a directory.

Action

To allocate a directory inode and change the lost+found directory to reference it, type y at the REALLOCATE prompt. The previous inode reference by the lost+found directory is not cleared and it will either be reclaimed as an unreferenced inode or have its link count adjusted later in this phase. Inability to create a lost+found directory displays the message: SORRY. CANNOT CREATE lost+found DIRECTORY and aborts the attempt to link up the lost inode, which generates the UNREF error message in phase 4. To abort the attempt to link up the lost inode, which generates the UNREF error message in phase 4, type n.


NO lost+found DIRECTORY (CREATE)
Cause

There is no lost+found directory in the root directory of the file system. When preening, fsck tries to create a lost+found directory.

Action

To create a lost+found directory in the root of the file system, type y at the CREATE prompt. This may lead to the message NO SPACE LEFT IN / (EXPAND). If the lost+found directory cannot be created, fsck displays the message: SORRY. CANNOT CREATE lost+found DIRECTORY and aborts the attempt to link up the lost inode. This in turn generates the UNREF error message later in phase 4. To abort the attempt to link up the lost inode, type n.


NO SPACE LEFT IN /lost+found (EXPAND)
Cause

Another entry cannot be added to the lost+found directory in the root directory of the file system because no space is available. When preening, fsck expands the lost+found directory.

Action

To expand the lost+found directory to make room for the new entry, type y at the EXPAND prompt. If the attempted expansion fails, fsck displays: SORRY. NO SPACE IN lost+found DIRECTORY and aborts the request to link a file to the lost+found directory. This error generates the UNREF error message later in phase 4. Delete any unnecessary entries in the lost+found directory. This error terminates fsck when preening is in effect. To abort the attempt to link up the lost inode, type n.


UNREF DIR I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time (RECONNECT)
Cause

The directory inode inode-number was not connected to a directory entry when the file system was traversed. The owner UID, mode file-mode, size file-size, and modification time modification-time of directory inode inode-number are displayed. When preening, fsck reconnects the non-empty directory inode if the directory size is non-zero. Otherwise, fsck clears the directory inode.

Action

To reconnect the directory inode inode-number into the lost+found directory, type y at the RECONNECT prompt. If the directory is successfully reconnected, a CONNECTED message is displayed. Otherwise, one of the lost+found error messages is displayed. To ignore this error condition, type n. This error causes the UNREF error condition in phase 4.

Phase 4: Check Reference Counts Messages

This phase checks the link count information obtained in phases 2 and 3. It reports error conditions resulting from:

  • Unreferenced files

  • A missing or full lost+found directory

  • Incorrect link counts for files, directories, symbolic links, or special files

  • Unreferenced files, symbolic links, and directories

  • Bad or duplicate blocks in files and directories

  • Incorrect total free-inode counts

All errors in this phase (except running out of space in the lost+found directory) are correctable when the file system is being preened.

These messages (in alphabetical order) may occur in phase 4:


BAD/DUP type I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time (CLEAR)
Cause

Phase 1 or phase 1B found duplicate blocks or bad blocks associated with file or directory inode inode-number. The owner UID, mode file-mode, size file-size, and modification time modification-time of inode inode-number are displayed.

Action

To deallocate inode inode-number by zeroing its contents, type y at the CLEAR prompt. To ignore this error condition, type n.


(CLEAR)
Cause

The inode mentioned in the UNREF error message immediately preceding cannot be reconnected. This message does not display if the file system is being preened because lack of space to reconnect files terminates fsck.

Action

To deallocate the inode by zeroing out its contents, type y at the CLEAR prompt. To ignore the preceding error condition, type n.


LINK COUNT type I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size
MTIME=modification-time COUNT link-count SHOULD BE 
corrected-link-count (ADJUST)
Cause

The link count for directory or file inode inode-number is link-count but should be corrected-link-count. The owner UID, mode file-mode, size file-size, and modification time modification-time of inode inode-number are displayed. If the -o p option is specified, the link count is adjusted unless the number of references is increasing. This condition does not occur unless there is a hardware failure. When the number of references is increasing during preening, fsck displays this message and exits: LINK COUNT INCREASING

Action

To replace the link count of directory or file inode inode-number with corrected-link-count, type y at the ADJUST prompt. To ignore this error condition, type n.


lost+found IS NOT A DIRECTORY (REALLOCATE)
Cause

The entry for lost+found is not a directory.

Action

To allocate a directory inode and change the lost+found directory to reference it, type y at the REALLOCATE prompt. The previous inode reference by the lost+found directory is not cleared. It will either be reclaimed as an unreferenced inode or have its link count adjusted later in this phase. Inability to create a lost+found directory displays this message: SORRY. CANNOT CREATE lost+found DIRECTORY and aborts the attempt to link up the lost inode. This error generates the UNREF error message later in phase 4. To abort the attempt to link up the lost inode, type n.


NO lost+found DIRECTORY (CREATE)
Cause

There is no lost+found directory in the root directory of the file system. When preening, fsck tries to create a lost+found directory.

Action

To create a lost+found directory in the root of the file system, type y at the CREATE prompt. If the lost+found directory cannot be created, fsck displays the message: SORRY. CANNOT CREATE lost+found DIRECTORY and aborts the attempt to link up the lost inode. This error in turn generates the UNREF error message later in phase 4. To abort the attempt to link up the lost inode, type n.


NO SPACE LEFT IN / lost+found (EXPAND)
Cause

There is no space to add another entry to the lost+found directory in the root directory of the file system. When preening, fsck expands the lost+found directory.

Action

To expand the lost+found directory to make room for the new entry, type y at the EXPAND prompt. If the attempted expansion fails, fsck displays the message: SORRY. NO SPACE IN lost+found DIRECTORY and aborts the request to link a file to the lost+found directory. This error generates the UNREF error message later in phase 4. Delete any unnecessary entries in the lost+found directory. This error terminates fsck when preening (-o p option) is in effect. To abort the attempt to link up the lost inode, type n.


UNREF FILE I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time (RECONNECT)
Cause

File inode inode-number was not connected to a directory entry when the file system was traversed. The owner UID, mode file-mode, size file-size, and modification time modification-time of inode inode-number are displayed. When fsck is preening, the file is cleared if either its size or its link count is zero; otherwise, it is reconnected.

Action

To reconnect inode inode-number to the file system in the lost+found directory, type y. This error may generate the lost+found error message in phase 4 if there are problems connecting inode inode-number to the lost+found directory. To ignore this error condition, type n. This error always invokes the CLEAR error condition in phase 4.


UNREF type I=inode-number OWNER=UID MODE=file-mode SIZE=file-size 
MTIME=modification-time (CLEAR)
Cause

Inode inode-number (whose type is directory or file) was not connected to a directory entry when the file system was traversed. The owner UID, mode file-mode, size file-size, and modification time modification-time of inode inode-number are displayed. When fsck is preening, the file is cleared if either its size or its link count is zero; otherwise, it is reconnected.

Action

To deallocate inode inode-number by zeroing its contents, type y at the CLEAR prompt. To ignore this error condition, type n.


ZERO LENGTH DIRECTORY I=inode-number OWNER=UID MODE=file-mode 
SIZE=file-size MTIME=modification-time(CLEAR)
Cause

A directory entry filename has a size file-size that is zero. The owner UID, mode file-mode, size file-size, modification time modification-time, and directory name filename are displayed.

Action

To deallocate the directory inode inode-number by zeroing out its contents, type y. To ignore the error condition, type n.

Phase 5: Check Cylinder Groups Messages

This phase checks the free-block and used-inode maps. It reports error conditions resulting from:

  • Allocated inodes missing from used-inode maps

  • Free blocks missing from free-block maps

  • Free inodes in the used-inode maps

  • Incorrect total free-block count

  • Incorrect total used inode count

These messages (in alphabetical order) may occur in phase 5:


BLK(S) MISSING IN BIT MAPS (SALVAGE)
Error Message

BLK(S) MISSING IN BIT MAPS (SALVAGE)
Cause

A cylinder group block map is missing some free blocks. During preening, fsck reconstructs the maps.

Action

To reconstruct the free-block map, type y at the SALVAGE prompt. To ignore this error condition, type n.


CG character-for-command-option: BAD MAGIC NUMBER
Cause

The magic number of cylinder group character-for-command-option is wrong. This error usually indicates that the cylinder group maps have been destroyed. When running interactively, the cylinder group is marked as needing reconstruction. fsck terminates if the file system is being preened.

Action

If this occurs, contact your local service provider or another qualified person.


FREE BLK COUNT(S) WRONG IN SUPERBLK (SALVAGE)
Cause

The actual count of free blocks does not match the count of free blocks in the superblock of the file system. If the -o p option was specified, the free-block count in the superblock is fixed automatically.

Action

To reconstruct the superblock free-block information, type y at the SALVAGE prompt. To ignore this error condition, type n.


SUMMARY INFORMATION BAD (SALVAGE)
Cause

The summary information is incorrect. When preening, fsck recomputes the summary information.

Action

To reconstruct the summary information, type y at the SALVAGE prompt. To ignore this error condition, type n.

Cleanup Phase Messages

Once a file system has been checked, a few cleanup functions are performed. The cleanup phase displays the following status messages.


number-of files, number-of-files
used, number-of-files free (number-of frags, number-of blocks, 
percent fragmentation)

This message indicates that the file system checked contains number-of files using number-of fragment-sized blocks, and that there are number-of fragment-sized blocks free in the file system. The numbers in parentheses break the free count down into number-of free fragments, number-of free full-sized blocks, and the percent fragmentation.


***** FILE SYSTEM WAS MODIFIED *****

This message indicates that the file system was modified by fsck. If this file system is mounted or is the current root (/) file system, reboot. If the file system is mounted, you may need to unmount it and run fsck again; otherwise, the work done by fsck may be undone by the in-core copies of tables.


filename FILE SYSTEM STATE SET TO OKAY

This message indicates that file system filename was marked as stable. Use the fsck -m command to determine if the file system needs checking.


filename FILE SYSTEM STATE NOT SET TO OKAY

This message indicates that file system filename was not marked as stable. Use the fsck -m command to determine if the file system needs checking.

source

miercuri, 1 decembrie 2021

Qmail delivery to Vpopmail

 In latest version of vpopmail we need to add some parameters in startup script of spamassassin to deliver messages in vpopmail (/path_to_vpopmail/domain ).

Without these modification all messages from qmail will be delivered to /var/mail/vpopmail file.


When compile the vpopmail, we have following message:

duminică, 20 septembrie 2020

Encrypt string (password) using bcrypt

 

 You can use verry simple method with httpasswd:

htpasswd will return encrypted password

htpasswd -bnBC 10 "" password | tr -d ':\n'

joi, 10 septembrie 2020

Simple User Authentication with Apache and MySQL

 

Whether you're a college professor wishing to grant students access to test results, or a research firm seeking to provide paying subscribers access to custom reports, you'll need to devise some way for your users to identify themselves in order to gain access to the restricted content. By identifying themselves, the users authenticate their identities. They often accomplish this authentication by providing a username and password, for which the college professor could provide the entire class with a single authentication combination. In other cases, however, you should grant a unique username and password to each subscriber.

In this article I'll show you how to implement both of these authentication approaches using nothing more than the Apache Web Server's native capabilities. The first approach can be implemented in mere minutes using a text file and a few command-line calls. The second approach is a tad more involved, requiring a bit of additional server configuration and a MySQL database, although you'll gain some additional flexibility along the way.

Before we begin, keep in mind that while you can indeed use these approaches to restrict access to a certain part of your website, they do not protect the transmission of the username and password from the client's computer to the server! Because the credentials are transmitted in plaintext, a savvy attacker could capture the information as it's passed over the network, thereby allowing the attacker to masquerade as an authorized user. To ensure maximum security, you should configure your server to use an SSL certificate, a task that although fairly easy to accomplish is out of the scope of this article.

Storing Credentials in a Text File

Apache has long supported a fairly simple authentication solution involving storing a username and password within a text file, which resides within the directory you'd like to protect. This text file is named .htpasswd, and its contents generally look like this:

jason:npvd3u9E86LaU susie:z4ETQllnrvvDk

You'll create this file and add user accounts to it using a command-line utility appropriately named htpasswd. To password-protect a particular directory within your website, navigate to that directory via the command line and execute the following command:

%>htpasswd -c .htpasswd jason 

This command accomplishes two important tasks: It creates the file and then creates a new user named jason. When you execute the command you'll be prompted to provide and confirm a password for user jason.

When your .htpasswd file and user are created, you're free to add other users by executing the same command but this time omitting the -c option and providing a different username. For instance, to add another user named susie you would execute the following command and again provide and confirm Susie's password:

%>htpasswd .htpasswd susie 

Creating the .htpasswd file isn't enough to protect the directory. You'll also need to modify Apache's configuration to recognize the .htpasswd file. Thankfully these configuration changes can be managed locally, meaning you won't need to modify Apache's httpd.conf file in order to effect these changes -- something that wouldn't be possible in most hosting environments. Instead, you'll use a file named .htaccess, which can be used to configure Apache on a per-directory basis. Although the .htaccess file can be used to perform many tasks, for the purposes of authentication you'll place it in the same directory as your .htpasswd file, adding the following lines to it:

AuthName "Restricted Content"
AuthType Basic
AuthUserFile /var/www/wjgilmore.com/members/.htpasswd
Require valid-user

When saved, navigating to the directory will cause Apache to verify whether the user has already provided valid credentials. If so, the user is granted access to the directory.

 

Using Apache's native .htpasswd capabilities, you can password-protect a directory in mere minutes. However, maintaining user accounts can be difficult, particularly in situations where account subscriptions are regularly created, ending, or renewed. A more flexible solution is managing the account credentials within a MySQL table and configuring Apache to compare the provided credentials against this repository. You can then create a Web-based interface to manage these accounts, or even simply manage them using a utility such as phpMyAdmin.

Begin by creating the table used to manage the account credentials. At a minimum, this table should contain columns for storing the account username and password. I'll call this table accounts:

CREATE TABLE accounts ( username VARCHAR(100) NOT NULL, password CHAR(32) NOT NULL, PRIMARY KEY(username) );

Apache's default behavior is to use DES for password encryption. However, you can also use MySQL's native password() function. I've opted to use the latter and so have adjusted the password column width so it can manage 41 characters, which is the size of a string encrypted using the password() function.

When the table has been created, add a few test accounts. As I mentioned previously you could use a utility such as phpMyAdmin to perform this task, but in any case the SQL query will look something like this:

INSERT INTO accounts VALUES('jason', password('secret')); 

With a few rows added, the accounts table will look like this:

+----------+-------------------------------------------+
| username | password |
+----------+-------------------------------------------+
| jason | *14E65567ABDB5135D0CFD9A70B3032C179A49EE7 |
| susie | *7C67218EF7410F248763DC99AEDC705367393C4A |
+----------+-------------------------------------------+

Next you'll need to configure Apache so it can communicate with the accounts table. This is done by installing the mod_auth_mysql module. If you're running Ubuntu or Debian, you simply execute the following command:

%>sudo apt-get install libapache2-mod-auth-mysql 

When mod_auth_mysql is installed, enable the module by executing the following command:

%>sudo a2enmod auth_mysql

Restart Apache, and make sure the module has been loaded by executing the following command:

%>apache2 -M

In the list of modules you should see auth_mysql_module. When configured, you can update your .htaccess file to refer to the accounts table by adding the following directives:

AuthBasicAuthoritative Off
AuthMYSQL on
AuthMySQL_Authoritative on
AuthMySQL_Host localhost
AuthMySQL_User root
AuthMySQL_Password jason
AuthMySQL_DB developer
AuthMySQL_Password_Table accounts
AuthMySQL_Username_Field username
AuthMySQL_Password_Field password
AuthMySQL_Encryption_Types MySQL
Auth_MySQL_Scrambled_Passwords on

Save the file and attempt to access the restricted directory. This time Apache will talk to MySQL to determine whether you're allowed to enter!

 source

sâmbătă, 5 septembrie 2020

ffmpeg error: UDP timeout, retrying with TCP

In many cases I need to open a rtsp stream:

ffmpeg  -i rtsp://user:pass@X.X.X.X:554

but I have following error:

[rtsp @ 0x80670e000] UDP timeout, retrying with TCP
[rtsp @ 0x80670e000] method PAUSE failed: 551 Option not supported
[rtsp @ 0x80670e000] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://stream:c0L3g!u2021@X.X.X.X:554':
  Metadata:
    title           : Media Presentation
  Duration: N/A, bitrate: 64 kb/s
    Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
    Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
Press [q] to stop, [?] for help
[rtsp @ 0x80670e000] UDP timeout, retrying with TCP
[rtsp @ 0x80670e000] method PAUSE failed: 551 Option not supported
rtsp://stream:c0L3g!u2021@X.X.X.X:554: Operation not permitted
[aac @ 0x8066a5100] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
[segment @ 0x80670f200] dimensions not set
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument

In this case stream is on TCP but ffmpeg try first time with UDP. The problem is the ffmpeg not open the stream in this conditions.

To force ffmpeg to try in TCP only we use -rtsp_transport option tcp.

In this case we will have:

ffmpeg -rtsp_transport tcp -i rtsp://user:pass@X.X.X.X:554

 

This parameter work for following error:

Invalid data found when processing input

duminică, 23 august 2020

Restreaming with ffmpeg

 

Re-stream sample.mp4


This example re-streams the sample.mp4 video.

Notes:

  • The sample.mp4 file is about 10 minutes long. FFmpeg stops when streaming ends, so you may have to restart FFmpeg during configuration and testing. To loop your command to generate a constant test stream, preface the FFmpeg command with

FOR /L %% IN (0) DO

  • To host FFmpeg on a computer other than the computer, change udp://127.0.0.1:10000 in the example to the IP address and any destination UDP port. Be sure that the specified UDP port is open on any routers or firewalls between the server hosting FFmpeg.
     
  1. In a Terminal window, enter one of the following commands.
  • For a low-bitrate, low-complexity, low-quality stream that can be played on most devices and systems:
ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -pix_fmt yuv420p -vsync 1 -threads 0 -vcodec libx264 -r 30 -g 60 -sc_threshold 0 -b:v 512k -bufsize 640k -maxrate 640k -preset veryfast -profile:v baseline -tune film -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -bsf:v h264_mp4toannexb -f mpegts udp://127.0.0.1:10000?pkt_size=1316
  • For a higher-quality stream:
ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -pix_fmt yuv420p -vsync 1 -threads 0 -vcodec libx264 -r 30 -g 60 -sc_threshold 0 -b:v 640k -bufsize 768k -maxrate 800k -preset veryfast -profile:v baseline -tune film -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -bsf:v h264_mp4toannexb -f mpegts udp://127.0.0.1:10000?pkt_size=1316
  1. Follow the instructions to set up a live application to re-stream the FFmpeg stream. When configuring the application and adding a stream file on the Stream Files page, use udp://127.0.0.1:10000 as the Stream URI.

Re-stream using passthrough


Content can also be re-streamed by passing the existing encode though FFmpeg without re-encoding. For passthrough re-streaming, use the -codec option and set it to copy. This example re-streams sample.mp4 as a passthrough instead of the full encode shown in the previous example.

ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -codec copy -bsf:v h264_mp4toannexb -f mpegts udp://127.0.0.1:10000?pkt_size=1316

Re-stream RTSP with password authentication


This example re-streams sample.mp4 with user authentication, level 3.0 logging verbosity, a 24-fps frame rate, 2-second keyframe frequency, 310 kbps bitrate, and 44.1 kHz stereo audio.

ffmpeg -re -i "%WMSAPP_HOME%/content/sample.mp4" -pix_fmt yuv420p -vsync 1 -threads 0 -vcodec libx264 -r 30 -g 60 -sc_threshold 0 -b:v 640k -bufsize 768k -maxrate 800k -preset veryfast -profile:v baseline -tune film -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -f rtsp rtsp://username:password@[server-address]:1935/live/myStream

Re-stream RTP with SDP


This example captures local hardware devices, uses a 15-fps frame rate, 8-bit color, and generates an SDP file that contains metadata about the streaming session.

ffmpeg -f dshow -s 640x480 -r 15 -i video="Logitech HD Pro Webcam C920" -f dshow -i audio="Microphone (HD Pro Webcam C920)" -pix_fmt yuv420p -vsync 1 -threads 0 -vcodec libx264 -r 15 -g 30 -sc_threshold 0 -b:v 640k -bufsize 768k -maxrate 800k -preset veryfast -profile:v baseline -tune film -an -f rtp rtp://127.0.0.1:10000 -acodec aac -b:a 128k -ac 2 -ar 48000 -af "aresample=async=1:min_hard_comp=0.100000:first_pts=0" -vn -f rtp rtp://127.0.0.1:10002 > 10000.sdp

Re-stream UDP-based MPEG-TS


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -bsf:v h264_mp4toannexb -f mpegts udp://[<em>server-address</em>]:1234?pkt_size=1316
  1. Follow the instructions to create a live application to broadcast the FFmpeg stream.

Re-stream TCP-based MPEG-TS


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -bsf:v h264_mp4toannexb -f mpegts tcp://[<em>server-address</em>]:1234?listen
  1. Follow the instructions to create a live application to broadcast the FFmpeg stream.

Re-stream UDP-based RTSP


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -f rtsp rtsp://username:password@[server-address]:1935/live/myStream
  1. Follow the instructions to connect your RTSP encoder  and create a live application to broadcast the FFmpeg stream.

Re-stream TCP-based RTSP


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -rtsp_transport tcp -f rtsp rtsp://username:password@[server-address]:1935/live/myStream
  1. Follow the instructions  to connect your RTSP encoder and create a live application to broadcast the FFmpeg stream.

Re-stream RTMP


  1. In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -f flv rtmp://username:password@[server-address]:1935/live/myStream
  1. Follow the instructions to connect your RTMP encoder and create a live application to broadcast the FFmpeg stream.

Re-stream to MP4


  • In a Terminal window, enter:
ffmpeg -re -i inputfile.mp4 -codec copy -f mp4 output.mp4
 

source

duminică, 1 martie 2020

Install Docker under Debian 10

Step 1 — Installing Docker

The Docker installation package available in the official Debian repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository. To do that, we’ll add a new package source, add the GPG key from Docker to ensure the downloads are valid, and then install the package.
First, update your existing list of packages:
  • sudo apt update
Next, install a few prerequisite packages which let apt use packages over HTTPS:
  • sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
Then add the GPG key for the official Docker repository to your system:
  • curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
Add the Docker repository to APT sources:
  • sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
Next, update the package database with the Docker packages from the newly added repo:
  • sudo apt update
Make sure you are about to install from the Docker repo instead of the default Debian repo:
  • apt-cache policy docker-ce
You’ll see output like this, although the version number for Docker may be different:
Output of apt-cache policy docker-ce
ocker-ce:
  Installed: (none)
  Candidate: 5:18.09.7~3-0~debian-buster
  Version table:
     5:18.09.7~3-0~debian-buster 500
        500 https://download.docker.com/linux/debian buster/stable amd64 Packages
Notice that docker-ce is not installed, but the candidate for installation is from the Docker repository for Debian 10 (buster).
Finally, install Docker:
  • sudo apt install docker-ce
Docker is now installed, the daemon started, and the process enabled to start on boot. Check that it’s running:
  • sudo systemctl status docker
The output will be similar to the following, showing that the service is active and running:
Output
● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2019-07-08 15:11:19 UTC; 58s ago Docs: https://docs.docker.com Main PID: 5709 (dockerd) Tasks: 8 Memory: 31.6M CGroup: /system.slice/docker.service └─5709 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Installing Docker gives you not just the Docker service (daemon) but also the docker command line utility, or the Docker client. We’ll explore how to use the docker command later in this tutorial.

Step 2 — Executing the Docker Command Without Sudo (Optional)

By default, the docker command can only be run the root user or by a user in the docker group, which is automatically created during Docker’s installation process. If you attempt to run the docker command without prefixing it with sudo or without being in the docker group, you’ll get an output like this:
Output
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?. See 'docker run --help'.
If you want to avoid typing sudo whenever you run the docker command, add your username to the docker group:
  • sudo usermod -aG docker ${USER}
To apply the new group membership, log out of the server and back in, or type the following:
  • su - ${USER}
You will be prompted to enter your user’s password to continue.
Confirm that your user is now added to the docker group by typing:
  • id -nG
Output
sammy sudo docker
If you need to add a user to the docker group that you’re not logged in as, declare that username explicitly using:
  • sudo usermod -aG docker username
The rest of this article assumes you are running the docker command as a user in the docker group. If you choose not to, please prepend the commands with sudo.
Let’s explore the docker command next.

Step 3 — Using the Docker Command

Using docker consists of passing it a chain of options and commands followed by arguments. The syntax takes this form:
  • docker [option] [command] [arguments]
To view all available subcommands, type:
  • docker
As of Docker 18, the complete list of available subcommands includes:
Output
attach Attach local standard input, output, and error streams to a running container build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers pull Pull an image or a repository from a registry push Push an image or a repository to a registry rename Rename a container restart Restart one or more containers rm Remove one or more containers rmi Remove one or more images run Run a command in a new container save Save one or more images to a tar archive (streamed to STDOUT by default) search Search the Docker Hub for images start Start one or more stopped containers stats Display a live stream of container(s) resource usage statistics stop Stop one or more running containers tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE top Display the running processes of a container unpause Unpause all processes within one or more containers update Update configuration of one or more containers version Show the Docker version information wait Block until one or more containers stop, then print their exit codes
To view the options available to a specific command, type:
  • docker docker-subcommand --help
To view system-wide information about Docker, use:
  • docker info
Let’s explore some of these commands. We’ll start by working with images.

Step 4 — Working with Docker Images

Docker containers are built from Docker images. By default, Docker pulls these images from Docker Hub, a Docker registry managed by Docker, the company behind the Docker project. Anyone can host their Docker images on Docker Hub, so most applications and Linux distributions you’ll need will have images hosted there.
To check whether you can access and download images from Docker Hub, type:
  • docker run hello-world
The output will indicate that Docker in working correctly:
Output
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. ...
Docker was initially unable to find the hello-world image locally, so it downloaded the image from Docker Hub, which is the default repository. Once the image downloaded, Docker created a container from the image and the application within the container executed, displaying the message.
You can search for images available on Docker Hub by using the docker command with the search subcommand. For example, to search for the Ubuntu image, type:
  • docker search ubuntu
The script will crawl Docker Hub and return a listing of all images whose name match the search string. In this case, the output will be similar to this:
Output
NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating sys… 9704 [OK] dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interface … 319 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 224 [OK] consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC session… 183 [OK] ubuntu-upstart Upstart is an event-based replacement for th… 99 [OK] ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 97 [OK] neurodebian NeuroDebian provides neuroscience research s… 57 [OK] 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK] ubuntu ...
In the OFFICIAL column, OK indicates an image built and supported by the company behind the project. Once you’ve identified the image that you would like to use, you can download it to your computer using the pull subcommand.
Execute the following command to download the official ubuntu image to your computer:
  • docker pull ubuntu
You’ll see the following output:
Output
Using default tag: latest latest: Pulling from library/ubuntu 5b7339215d1d: Pull complete 14ca88e9f672: Pull complete a31c3b1caad4: Pull complete b054a26005b7: Pull complete Digest: sha256:9b1702dcfe32c873a770a32cfd306dd7fc1c4fd134adfb783db68defc8894b3c Status: Downloaded newer image for ubuntu:latest
After an image has been downloaded, you can then run a container using the downloaded image with the run subcommand. As you saw with the hello-world example, if an image has not been downloaded when docker is executed with the run subcommand, the Docker client will first download the image, then run a container using it.
To see the images that have been downloaded to your computer, type:
  • docker images
The output should look similar to the following:
Output
REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 4c108a37151f 2 weeks ago 64.2MB hello-world latest fce289e99eb9 6 months ago 1.84kB
As you’ll see later in this tutorial, images that you use to run containers can be modified and used to generate new images, which may then be uploaded (pushed is the technical term) to Docker Hub or other Docker registries.
Let’s look at how to run containers in more detail.

Step 5 — Running a Docker Container

The hello-world container you ran in the previous step is an example of a container that runs and exits after emitting a test message. Containers can be much more useful than that, and they can be interactive. After all, they are similar to virtual machines, only more resource-friendly.
As an example, let’s run a container using the latest image of Ubuntu. The combination of the -i and -t switches gives you interactive shell access into the container:
  • docker run -it ubuntu
Your command prompt should change to reflect the fact that you’re now working inside the container and should take this form:
Output
root@d9b100f2f636:/#
Note the container id in the command prompt. In this example, it is d9b100f2f636. You’ll need that container ID later to identify the container when you want to remove it.
Now you can run any command inside the container. For example, let’s update the package database inside the container. You don’t need to prefix any command with sudo, because you’re operating inside the container as the root user:
  • apt update
Then install any application in it. Let’s install Node.js:
  • apt install nodejs
This installs Node.js in the container from the official Ubuntu repository. When the installation finishes, verify that Node.js is installed:
  • node -v
You’ll see the version number displayed in your terminal:
Output
v8.10.0
Any changes you make inside the container only apply to that container.
To exit the container, type exit at the prompt.
Let’s look at managing the containers on our system next.

Step 6 — Managing Docker Containers

After using Docker for a while, you’ll have many active (running) and inactive containers on your computer. To view the active ones, use:
  • docker ps
You will see output similar to the following:
Output
CONTAINER ID IMAGE COMMAND CREATED
In this tutorial, you started two containers; one from the hello-world image and another from the ubuntu image. Both containers are no longer running, but they still exist on your system.
To view all containers — active and inactive, run docker ps with the -a switch:
  • docker ps -a
You’ll see output similar to this:
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                      PORTS               NAMES
d42d0bbfbd35        ubuntu              "/bin/bash"         About a minute ago   Exited (0) 20 seconds ago                       friendly_volhard
0740844d024c        hello-world         "/hello"            3 minutes ago        Exited (0) 3 minutes ago                        elegant_neumann
To view the latest container you created, pass it the -l switch:
  • docker ps -l
  • CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  • d42d0bbfbd35 ubuntu "/bin/bash" About a minute ago Exited (0) 34 seconds ago friendly_volhard
To start a stopped container, use docker start, followed by the container ID or the container’s name. Let’s start the Ubuntu-based container with the ID of d9b100f2f636:
  • docker start d42d0bbfbd35
The container will start, and you can use docker ps to see its status:
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
d42d0bbfbd35        ubuntu              "/bin/bash"         About a minute ago   Up 8 seconds                            friendly_volhard

To stop a running container, use docker stop, followed by the container ID or name. This time, we’ll use the name that Docker assigned the container, which is friendly_volhard:
  • docker stop friendly_volhard
Once you’ve decided you no longer need a container anymore, remove it with the docker rm command, again using either the container ID or the name. Use the docker ps -a command to find the container ID or name for the container associated with the hello-world image and remove it.
  • docker rm elegant_neumann
You can start a new container and give it a name using the --name switch. You can also use the --rm switch to create a container that removes itself when it’s stopped. See the docker run help command for more information on these options and others.
Containers can be turned into images which you can use to build new containers. Let’s look at how that works.

Step 7 — Committing Changes in a Container to a Docker Image

When you start up a Docker image, you can create, modify, and delete files just like you can with a virtual machine. The changes that you make will only apply to that container. You can start and stop it, but once you destroy it with the docker rm command, the changes will be lost for good.
This section shows you how to save the state of a container as a new Docker image.
After installing Node.js inside the Ubuntu container, you now have a container running off an image, but the container is different from the image you used to create it. But you might want to reuse this Node.js container as the basis for new images later.
Then commit the changes to a new Docker image instance using the following command.
  • docker commit -m "What you did to the image" -a "Author Name" container_id repository/new_image_name
The -m switch is for the commit message that helps you and others know what changes you made, while -a is used to specify the author. The container_id is the one you noted earlier in the tutorial when you started the interactive Docker session. Unless you created additional repositories on Docker Hub, the repository is usually your Docker Hub username.
For example, for the user sammy, with the container ID of d9b100f2f636, the command would be:
  • docker commit -m "added Node.js" -a "sammy" d42d0bbfbd35 sammy/ubuntu-nodejs
When you commit an image, the new image is saved locally on your computer. Later in this tutorial, you’ll learn how to push an image to a Docker registry like Docker Hub so others can access it.
Listing the Docker images again will show the new image, as well as the old one that it was derived from:
  • docker images
You’ll see output like this:
Output
REPOSITORY TAG IMAGE ID CREATED SIZE sammy/ubuntu-nodejs latest d441c62350b4 10 seconds ago 152MB ubuntu latest 4c108a37151f 2 weeks ago 64.2MB hello-world latest fce289e99eb9 6 months ago 1.84kB
In this example, ubuntu-nodejs is the new image, which was derived from the existing ubuntu image from Docker Hub. The size difference reflects the changes that were made. And in this example, the change was that NodeJS was installed. So next time you need to run a container using Ubuntu with NodeJS pre-installed, you can just use the new image.
You can also build Images from a Dockerfile, which lets you automate the installation of software in a new image. However, that’s outside the scope of this tutorial.
Now let’s share the new image with others so they can create containers from it.

Step 8 — Pushing Docker Images to a Docker Repository

The next logical step after creating a new image from an existing image is to share it with a select few of your friends, the whole world on Docker Hub, or other Docker registry that you have access to. To push an image to Docker Hub or any other Docker registry, you must have an account there.
This section shows you how to push a Docker image to Docker Hub. To learn how to create your own private Docker registry, check out How To Set Up a Private Docker Registry on Ubuntu 14.04.
To push your image, first log into Docker Hub.
  • docker login -u docker-registry-username
You’ll be prompted to authenticate using your Docker Hub password. If you specified the correct password, authentication should succeed.
Note: If your Docker registry username is different from the local username you used to create the image, you will have to tag your image with your registry username. For the example given in the last step, you would type:
  • docker tag sammy/ubuntu-nodejs docker-registry-username/ubuntu-nodejs
Then you may push your own image using:
  • docker push docker-registry-username/docker-image-name
To push the ubuntu-nodejs image to the sammy repository, the command would be:
  • docker push sammy/ubuntu-nodejs
The process may take some time to complete as it uploads the images, but when completed, the output will look like this:
Output
The push refers to a repository [docker.io/sammy/ubuntu-nodejs] e3fbbfb44187: Pushed 5f70bf18a086: Pushed a3b5c80a4eba: Pushed 7f18b442972b: Pushed 3ce512daaf78: Pushed 7aae4540b42d: Pushed ...
To enter in container you can run: docker exec -it  /bin/bash
source

Map


Visitor Map