There is no file system on the removable disk. The ntfs disk does not open. How to restore the file system of a hard drive. Why won't the flash drive mount?

Today, removable memory cards and flash drives have quite a large capacity and are used almost everywhere. However, they are more susceptible to serious physical damage compared to hard drives and internal storage. However, they may experience software failures to the same extent. Thus, it turns out that when the system tries to connect the device to the computer, the system will display a message stating that the volume’s file system was damaged or not recognized. The following will describe how to fix such failures.

Flash drive is not recognized: possible reasons

The most likely reasons why the operating system refuses to recognize the drive and file system include the following two broad categories of reasons: physical damage and software failures. Physical damage is usually associated with malfunctions of microcontrollers, internal and external damage, hypothermia or overheating, as well as many other negative factors, which we will not dwell on in detail. If there is physical damage, the USB drive will most likely just have to be thrown away. Replacing the microcontroller will cost much more than a new memory card and flash drive. In some cases, problems with the operation of USB ports may occur. However, in this case, the way out is quite obvious: you just need to connect the flash drive to another port.

Let's take a closer look at software failures. The most likely reasons why the volume’s file system may not be recognized (the flash drive is not displayed when connected, and if it is displayed, it is impossible to work with it) include the following:

— exposure to viruses;

— software failures that occur in the operation of the microcontroller;

— unfinished or incorrect formatting;

— incorrect removal of the device from the USB port;

— voltage surges;

— outdated drivers for the device;

- unsupported file system;

— mismatch between the port and USB flash drive standards.

If we talk in more detail about the last point, then most often the problem is that a USB 3.0 flash drive is connected to a USB 2.0 port. This problem can be solved by simply reconnecting to the desired port.

Damage to a removable USB device

Determining that a USB device is faulty is quite simple. When connected, the system begins to display warning messages stating that the file system is not recognized, the location is inaccessible, or a proposal appears to format the device. It is also worth noting in passing that the drive itself may or may not be visible. Fixing the problem in the first case is somewhat easier. In the second case, you will have to use special utilities for this purpose. If a warning appears about an inaccessible location, then most likely the reason lies in the fact that the removable card or flash drive is assigned an incorrect volume label, for example, X instead of F. In this situation, you can simply try changing it. For this purpose, you must first use the disk management section, where you must select the appropriate command by right-clicking on the device.

RAW format: what is it?

This structure in the usual sense is a modified format that is simply incompatible with most known operating systems. For this reason, quite often a notification appears on the screen stating that the volume's file system cannot be recognized. A RAW flash drive may be visible, but the files on it cannot be seen, even if you enable the display of hidden objects. Most often, format changes are associated with software failures resulting from incorrect formatting, exposure to viruses, or improper shutdown of the device. Converting this format into a readable format is quite simple. We will talk about this a little later.

Basic ways to solve problems

If you cannot recognize the volume's file system, you can use several methods to solve this problem, depending on the reasons for the failure. Possible ways to solve this problem include:

— conversion from one format to another, compatible with the system;

— removal of threats and viruses;

— full or quick formatting of the drive;

— use of special utilities if it is necessary to recover data.

First of all, just in case, you need to make sure that the appropriate driver is installed for the device. For this purpose, you can use the standard “Device Manager”. It can be accessed either from the Control Panel or by calling the special command devmgmt.msc from the Run console. If the device does not work or does not work correctly, it will be marked in yellow. In this case, you must either update the driver from the operating system's own database using a special context menu command, or install the driver manually from removable media, or use automatic updating using a program like Driver Booster. When the flash drive is turned on. In some cases, it may be necessary to update the driver of the USB controller itself.

Testing and recovery

Let's consider a situation in which the file system is not recognized from the point of view of a regular disk. For removable media, you can use special commands to check their status, which were originally intended for hard drives. In this case we are talking about checking the disk. To perform this operation manually, you need to call the command console from the “Run” menu, and then enter the line chkdskX/f in it, where the letter X denotes the letter assigned to the flash drive (usually the letter F). Even if the drive is in RAW format, this procedure will work in terms of restoring the file system or converting it to the NTFS format.

Virus check

Some malicious objects and viruses can purposefully change the structure of the file system of removable drives. In this case, a message will also appear notifying you that the volume's file system was not recognized. However, the drive will be visible in the system. This greatly simplifies the task. The easiest way to solve this problem is to completely check the drive. You can use portable utilities or a standard antivirus program for this purpose. However, unfortunately, there is no guarantee of a complete “cure” of the device. This is due to the presence on the media of a standard autorun file, autorun.inf, which may be hidden in some cases. To see it, in some cases it is necessary to set the display of hidden objects in the view menu of the standard Explorer program. If possible, you need to remove it manually, but most often it is protected from such procedures. Here again you need to use the command line.

How to remove components from the command line

Let's assume that the volume's file system was not recognized, but the flash drive is recognized in the system. For example, we can assume that the flash drive volume label has the letter Z. To delete the file you are looking for, you must enter the following commands: cdF:/; attrib –a –s –h –rautorun.inf; delautorun.inf. After each of these commands, you must press the “Enter” button. Only in this case will the complete removal of this object be guaranteed. Due to the close integration of Explorer with the operating system, viruses can set certain restrictions on actions in this program. The command line works on the principle of DOS systems.

How to fix the file system by formatting

Another example of problems with the drive is the situation when an SD card is inserted into the card reader, and the file system of the volume is not recognized, but the system “sees” the device and does not display a message about formatting the system. You can basically look at the card format in the disk management section. However, why do this if the problem is that the card cannot be written to? The easiest way to solve this problem is by formatting. Many users mistakenly believe that the easiest solution to the problem in this case is to quickly clear the table of contents. But this is completely wrong. Even if you install something from the drop-down list for your preferred system, there is no guarantee that you can continue working with it. Therefore, it is better to perform a full format. This will take more time, but after that the user will have a completely clean drive at his disposal, which is called from scratch. There definitely shouldn't be any problems with it. However, this method is applicable only if there is no important information on the device that cannot be destroyed under any circumstances. Is it possible to try to recover information on a damaged device? For many, the issue of information recovery is a clear criterion in favor of choosing special programs that are capable of not only restoring boot sectors and records on devices of any type, but also retrieving information that was previously present on them, which has become inaccessible for some reason. However, it is still possible to restore data. But popular programs like Recuva will be completely useless if the removable media is not recognized by the system. Then professional utilities can come to the rescue. We will look at two such utilities: the unique R.Saver program and Test Disk. Both of these utilities are portable.

Recovering data using the Test Disk utility

Consider a situation in which the volume's file system is not recognized. It’s worth noting right away that the solution below can be used for memory cards of any standard. This program is free and does not require installation. Many may be upset by working in DOS mode and the lack of a Russian-language interface. This utility is quite powerful because it is able to first restore the file system itself, and then the necessary information. You need to run this utility and select Create in the window that appears. Next, a list of all available disks will appear, including a flash drive invisible to the system. In the list, it is usually designated as Disk/dev/sdc with an indication of the volume. Additionally, a description of the Generic-Multi-Card type may be present. If there is no description, then you can determine that this is the flash drive you are looking for by the letter or size of the disk. After this, you need to activate the Proceed analysis process and select Intel Partition in the partition table. Next, you need to go to the Advanced item and press the enter key. After this, you need to use the Undelete recovery command at the bottom of the window. Now all you have to do is wait for the scanning process to complete. As a result, red lines corresponding to the deleted files will appear in the window. You shouldn’t be surprised that even files you don’t remember about can be found here. Now you need to use the arrows to move through the list, select the desired object and press the C button to restore. Next, you need to select the directory in which the files will be saved and press the “Enter” button. After selecting the folder, you must press the C button again. When the recovery process is completed, a message will appear indicating that the copy is ready.

Universal program R.Saver

Let's look at another utility that can be used if the file system is not recognized. It is best suited for recovering data and sectors on SD cards. After starting the application, you need to select the flash drive and start the scanning process. After this, the procedure for restoring sectors and the information contained in them will begin.

Creating a root file system involves selecting the files needed to start the system. In this section we describe how to create a compressed root file system. A less common option is to create an uncompressed filesystem on a floppy disk that is directly mounted as the root; this option is described in the section ``Non-ramdisk Root File System''.

4.1. Review.

The root file system must contain everything needed to support a full Linux system. To do this, the disk must include the minimum requirements for a Linux system:
  • basic file system,
  • Minimum set of directories: /dev, /proc, /bin, /etc, /lib, /usr, /tmp,
  • Basic set of utilities: sh, ls, cp, mv, etc.,
  • Minimum set of configuration files: rc, inittab, fstab, etc.,
  • Devices: /dev/hd *, /dev/tty *, /dev/fd0, etc.
  • Support libraries to provide basic functions used by utilities.

    Of course, any system only becomes useful when you can do something on it, and a root floppy becomes useful when you can do something like:

  • Check the file system of another device, for example check the root file system on the hard drive, you should be able to boot Linux from another device - the root floppy. You can then fsck your primary root drive while it is not mounted.
  • Restore all or part of your primary root device from an archive using backup utilities such as cpio, tar, gzip and ftape.

    We will describe how to create a compressed file system, so called because it is compressed on disk and, when loaded, decompressed onto the ramdisk. With a compressed file system, you can fit many files (approximately two megabytes) on a standard 1440KB floppy disk. Since the file system is much larger than a floppy disk, it cannot fit on a floppy disk. We must create it somewhere else, compress it, and then copy it to a floppy disk.

    4.2. Creating a file system.

    To create such a root file system, you need a spare device large enough to hold all the files before compression. You need a device that can store approximately four megabytes. There are several options:
  • Use ramdisk (DEVICE = /dev/ram0). In this case, memory is used to simulate a disk drive. The Ramdisk must be large enough to contain a file system of the appropriate size. If you are using LILO, check in your configuration file (/etc/lilo.conf) the line: RAMDISK_SIZE = nnn Which determines how much RAM will be allocated. The default value is 4096KB, which should be sufficient. You should not try to use such a ramdisk on a machine with less than 8MB of memory.

    Make sure that the device /dev/ram0, /dev/ram or /dev/ramdisk exists. If necessary, create /dev/ram0 with mknod (major number 1, minor 0).

  • If you have a large enough (several megabytes) unused hard drive partition, this is a good solution. If you have enough physical RAM, you can turn off swap and create a file system in your swap partition.
  • Use a loopback device, which allows you to work with a file on disk as a device. When using a loopback device, you can create a three megabyte file on your hard drive and create a file system on it.

    To use loopback devices, you need specially modified mount and unmount programs. You can find them in the catalog:

    If your system does not have loop devices (/dev/loop0, /dev/loop1, etc.), you must create them - ``mknod /dev/loop0 b 7 0"". Once you have installed the special mount and umount, create a temporary file on your hard drive with sufficient capacity (eg, /tmp/fsfile). You can use the command

    Dd if=/dev/zero of=/tmp/fsfile bs=1k count=nnn to create an nnn block file.

    Use filename instead of DEVICE below. When you issue the mount command, you must include the ``-o loop' option to have the mount use a loop device.

    Mount -o loop -t ext2 /tmp/fsfile /mnt mounts /tmp/fsfile (via a loop device) at the /mnt mount point. The df command should confirm this.

    Once you have selected one of these options, prepare the DEVICE:

    Dd if=/dev/zero of=DEVICE bs=1k count=3000 This command zeroes the device. This step is important because... The file system on the device will be compressed; to achieve maximum compression, all unused parts must be filled with zeros.

    Next, create the file system. The Linux kernel recognizes two file system types for root disks, which are automatically copied to the ramdisk. These are minix and ext2, of which ext2 is the preferred filesystem. When using ext2, you can use the -i option to specify a larger number of inodes than the default; -i 2000 is suggested so that you don't run out of inodes. Alternatively, you can save inodes by deleting most of the unnecessary /dev files. mke2fs will by default create 360 ​​inodes on a 1.44MB floppy. I find 120 inodes to be sufficient for my current rescue root floppy, but if you include all devices in the /dev directory, you will easily exceed 360. Using a compressed root filesystem allows you to have a larger filesystem, and therefore a larger number of inodes by default, but you must either reduce the number of files or increase the number of inodes.

    So your command looks like this:

    Mke2fs -m 0 -i 2000 DEVICE (If you are using a loopback device, DEVICE must be substituted with the name of the disk file being used. mke2fs will ask if you really want to do this; say yes.)

    The mke2fs command will automatically detect the available space and configure itself accordingly. The -m 0 option prevents space from being reserved for the root, and therefore provides more usable disk space.

    Then, mount the device:

    Mount -t ext2 DEVICE /mnt (You must create the mount directory /mnt if it does not exist.) In the following sections, all destination directory names are set to /mnt.

    4.3. Filling the file system.

    There is a reasonable minimum set of directories for your root filesystem:
  • /dev --- Devices required for I/O
  • /proc --- stub directory required for proc file system
  • /etc --- system configuration files
  • /sbin --- critical system binaries
  • /bin --- base binaries part of the intended system
  • /lib --- shared libraries to provide run-time support tools
  • /mnt --- mount point to support other drives
  • /usr --- additional utilities and applications

    (The directory structure presented here is for root floppy use only. Real Linux systems have a more comprehensive and precise set of rules, called the File System Standard, for determining file placement.)

    Three of these directories must be empty on the root file system, i.e. that they should only be created by mkdir. The /proc directory is basically a stub where the proc file system is placed. The /mnt and /usr directories are only mount points to use once the boot/root system is up and running. Therefore, these directories only need to be created.

    The remaining four directories are described in the following sections.

    4.3.1. /dev

    The /dev directory contains special files for all devices that are necessarily used in any Linux system. The directory itself is a normal directory, and can be created by mkdir in the normal way. However, special device files must be created in a special way using the mknod command.

    There is a shorter way - to copy the contents of your existing /dev directory, and remove those devices that you do not need. The only requirement is that you use the -R option when copying special device files. This will copy the directory without attempting to copy the contents of the files. Make sure you use uppercase R. If you specify the lowercase -r option, you will likely copy the entire contents of all your hard drives - or at least as much as will fit on the floppy disk! Therefore, be careful and use the command:

    Cp -dpR /dev /mnt assumes the floppy is mounted at /mnt. The dp options ensure that symbolic links are copied as links rather than as file content, and that the original file attributes are preserved, thus retaining information about the file's owner.

    Alternatively, you can use the cpio program with the -p option because cpio handles special device files correctly and will not attempt to copy the contents. For example, commands:

    Cd /dev find . -print | cpio -pmd /mnt/dev will copy all device special files from /dev to /mnt/dev. Essentially, all files in the /dev directory tree are copied, and the required subdirectories are created in the resulting directory tree.

    If you want to do it the hard way, use ls -l to display the major and minor device numbers for the devices you need, and create them on a floppy disk using mknod.

    Once the devices have been copied, it is worth checking that all the required special devices are placed on the rescue floppy. For example, ftape is used for tape devices, so you will need to copy all of them if you plan to access your tape devices from the boot floppy.

    Note that each device file requires one inode, and inodes can be a scarce resource, especially on a floppy file system. Therefore, it makes sense to delete any device files in the /dev directory of the floppy disk that you don't need. Many devices are obviously not needed on specific systems. For example, if you do not have SCSI drives, you can freely delete all device files starting with sd. Likewise, if you do not intend to use the serial port, all device files starting with cua can be deleted.

    Make sure to include the following files in this directory: console, kmem, mem, null,ram, tty1.

    4.3.2. /etc

    This directory should contain a number of configuration files. On most systems, they can be divided into three groups:

    1.Always required, for example rc, fstab, passwd.

    2. Which may be required, but not required.

    3. All kinds of rubbish.

    Files that are not needed can be identified with the command:

    Ls -ltru It displays files in reverse order by last accessed date, so if any files have not been accessed, they do not need to be included in the root floppy.

    On my root floppies the number of configuration files is up to 15. This reduces my work by dividing it into three sets of files:

    1. Those that I should configure for the boot system

    a. rc.d/* - system startup scripts and runlevel changes

    b. fstab --- list of filesystems to be mounted

    c. inittab --- parameters for the init process - the first process launched during boot.

    2. Those that I need to tidy up for the boot system

    a. Passwd --- list of users, home directories, etc.

    b. group - user groups.

    c. shadow --- user passwords. You may not have it.

    If security is important, passwd and shadow should be shortened to avoid copying user passwords outside the system, and so that when you boot from a floppy disk, unwanted logins are rejected. However, there is a reason not to shorten passwd and group. tar (and probably other archivers) stores the user name and group with the files. If you restore files to your hard drive from tape, the files will be restored with their original owner names. If these names do not exist in passwd/group, when restored, the UIDs/GIDs will not be correct.

    Make sure passwd contains at least root. If you allow other users to log in, make sure their home directories and shells exist.

    3. The rest. They are working at the moment, so I leave them.

    Other than that, I only really have to configure two files, and what they have to contain is surprisingly small.

  • rc should contain: #!/bin/sh /bin/mount -av /bin/hostname Kangaroo Make sure the directories are correct. In reality, you don't have to do hostname - it just looks better if you do.
  • fstab must contain at least: /dev/ram0 / ext2 defaults /dev/fd0 / ext2 defaults /proc /proc proc defaults You can copy entries from your existing fstab, but you should not automatically mount all your hard drive partitions; use the noauto keyword with them. Your hard drive may be damaged or dead when using a boot floppy.

    Your inittab should be modified so that the sysinit line will execute rc, or whatever basic bootstrap script will be used. Also, if you want to ensure that users on serial ports cannot log in, comment out all getty entries that include ttys or ttyS devices at the end of the line. Leave the tty ports so that you can log in from the console.

    The minimum inittab file looks like this:

    Id:2:initdefault: si::sysinit:/etc/rc 1:2345:respawn:/sbin/getty 9600 tty1 2:23:respawn:/sbin/getty 9600 tty2 Inittab file determines that the system will start in different modes including startup, switching to multi-user mode, etc. The main thing is to be careful here, and carefully check that the commands specified in inittab refer to programs that exist and are in the correct directory. If you put your batch files on your rescue disk using the "Root Disk Directory Example" section as instructions, and then copy your inittab to your boot disk without checking, the probability of failure will be very high because half of the inittab entries will refer to missing programs or to the wrong directories.

    Note that some programs cannot be placed elsewhere because other programs are hardcoded to their location. For example on my system, /etc/shutdown is hard-linked to /etc/reboot. If I move reboot to /bin/reboot and then issue the shutdown command, it will fail because it can't find the reboot file.

    For everyone else, just copy all the text files in your /etc directory, plus any executable programs in your /etc directory that you aren't sure you won't need. As a guide, follow the example in the "Example Root Disk Directory" section. It's probably enough to copy just those files, but systems vary widely, so you can't be sure that the same set of files on your system is equivalent to the files in the list. The only correct method is to start with inittab and select what is required.

    Most systems now use an /etc/rc.d/ directory containing shell scripts for various runlevels. The minimum is a single rc script, but it may be easier to copy the inittab and /etc/rc.d directory from your existing system, and shorten the shell scripts in the rc.d directory to remove processing irrelevant to the system floppy environment.

    4.3.3. /bin and /sbin

    The /bin directory is a convenient place for additional utilities that need to perform basic operations, utilities like ls, mv, cat and dd. See the "Root Disk Directory Example" appendix for a sample list of files that are included in the /bin and /sbin directories. It does not include any backup recovery utilities such as cpio, tar and gzip. This is because I put them on a separate service floppy, saving space for the boot floppy. Once the boot floppy is loaded, it is copied to the ramdisk, leaving the drive free to mount another floppy, the service floppy. I usually mount it as /usr.

    Creating a service diskette is described below in the “Creating a service disk” section. It is probably advisable to keep a copy of the same version of the backup utilities used to record the backup, so that you don't waste time trying to install versions that won't be able to read your backup tapes.

    Make sure you include the following programs: init, getty or equivalent, login, mount, some shells capable of running your rc scripts, a link from sh to the shell.

    4.3.4. /lib

    In /lib you place the necessary public libraries and loaders. If the required libraries are not found in your /lib directory, the system will not be able to boot. If you are lucky, you may see an error message telling you the reason.

    Almost every program requires at least the libc library, libc.so.N, where N is the current version number. Check your /lib directory. libc.so.5 - usually a symlink to the filename with the full version number:

    % ls -l /lib/libc.so* lrwxrwxrwx 1 root root 14 Nov 1 20:34 /lib/libc.so.5 -> libc.so.5.4.33* -rwxr-xr-x 1 root root 573176 Jun 12 02:05 /lib/libc.so.5.4.33* In this case, you need libc.so.5.4.33. To find other libraries, you must go through all the binaries you plan to include and check their dependencies with the ldd command. For example: % ldd /sbin/mke2fs libext2fs.so.2 => /lib/libext2fs.so.2 libcom_err.so.2 => /lib/libcom_err.so.2 libuuid.so.1 => /lib/libuuid. so.1 libc.so.5 => /lib/libc.so.5 Each file on the right is needed. Please be aware that the libraries listed may be symbolic links.

    In /lib you must also include the ld.so loader for a.out libraries or ld-linux.so (for ELF libraries). If you are not sure which one you need, run the file command on the library. For example:

    % file /lib/libc.so.5.4.33 /lib/libc.so.4.7.2 /lib/libc.so.4.7.2: Linux/i386 demand-paged executable (QMAGIC), stripped /lib/libc. so.5.4.33: ELF 32-bit LSB shared object, Intel 386, version 1, stripped QMAGIC specifies that 4.7.2 is for a.out libraries, and ELF specifies that 5.4.33 is for ELF.

    Copy specific boot loaders that are needed for the root file system being created. Libraries and loaders should be checked carefully along with included binaries. If the kernel cannot load a required library, the kernel will typically hang without error messages.

    4.4 Provision for PAM and NSS.

    Your system may require some dynamically loaded libraries that are not visible to ldd.

    4.4.1 PAM (Pluggable Authentication Modules).

    If your system uses PAM (Pluggable Authentication Modules) you must take some precautions, otherwise you will not be able to log in to the system. PAM is a sophisticated, modular method for identifying users and their access to services. A simple way to check your system's use of PAM is to check the /etc directory on your disk for a pam.conf file or a pam.d directory; if they exist, you must provide minimal PAM support. (Alternatively, run ldd on your login executable; if the output includes libpam.so, you need PAM).

    At best, security doesn't matter for boot disks, because... if someone has physical access to the machine they can do whatever they want. Therefore, you can essentially disable PAM by creating a simple /etc/pam.conf on your root filesystem:

    OTHER auth optional /lib/security/pam_permit.so OTHER account optional /lib/security/pam_permit.so OTHER password optional /lib/security/pam_permit.so OTHER session optional /lib/security/pam_permit.so Also copy the file /lib/ security/pam_permit.so to your root file system. This library is approximately 8Kb, so it imposes minimum costs.

    Note that this configuration allows anyone full access to files and services on your machine. If for some reason you are concerned about the security of your boot disk, you should copy some or all of the PAM settings to your root file system. Read the PAM documentation carefully and copy the required libraries to /lib/security on your root file system.

    You should also include /lib/libpam.so on your boot disk, but you already know this because ran ldd for /bin/login, which showed this dependency.

    4.4.2 NSS (Name Service Switch).

    If you are using glibc (or libc6) you must provide name services or you will not be able to log in. The file /etc/nsswitch.conf controls the search of databases for various services. Unless you plan to access network services (such as DNS, NIS lookup). You should prepare a simple nsswitch.conf file that looks like this:

    Passwd: files shadow: files group: files hosts: files services: files networks: files protocols: files rpc: files ethers: files netmasks: files bootparams: files automount: files aliases: files netgroup: files publickey: files This indicates that each the service will only have access to local files. You should also include /lib/libnss_files.so.1, which is loaded dynamically to work with file browsing.

    If you plan to access the network from your boot disk, you must create a more sophisticated nsswitch.conf file. For details see the nsswitch man page. Remember that you must include the /lib/libnss_files.so.1 file for each service specified.

    4.5. Modules

    If you have a modular kernel, you should consider which modules you want to load from your boot disk after booting. You may want to include the ftape and zftape modules if you have floppy tape backup devices, modules for SCSI devices if you have them, and perhaps PPP or SLIP modules if you want network access in a disaster.

    These modules can be placed in /lib/modules. You must also enable insmod, rmmod and lsmod. Depending on whether you want to load modules automatically, you can also enable modprobe, depmod and swapout. If you use kerneld, include it along with /etc/conf.modules.

    However, the main advantage of using modules is that you can move non-critical modules to the service disk and load them when needed, i.e. Uses less space on your startup disk. If you may have to deal with many different devices, this approach is preferable to creating one huge kernel with many built-in drivers.

    Please note, to boot a compressed ext2 filesystem, you must have native ramdisk and ext2 support. They cannot be modular.

    4.6. Some final details.

    Some system programs, such as login, complain if the file /var/run/utmp and the directory /var/log do not exist. mkdir -p /mnt/var/(log,run) touch /mnt/var/run/utmp Finally, after you have installed all the libraries, you need to run ldconfig to recreate /etc/ld.so.cache on the root file system. The cache tells the loader where to find the libraries. To recreate ld.so.cache, issue the following commands: chdir /mnt; chroot /mnt /sbin/ldconfig chroot is necessary because ldconfig always recreates the cache for the root filesystem.

    4.7. Transfer.

    Once you've finished creating the root filesystem, unmount it, copy it to a file, and compress it: umount /mnt dd if=DEVICE bs=1k | gzip -v9 > rootfs.gz This may take a few minutes. When finished, you will have a file called rootfs.gz, which is your compressed root file system. You should check the size to make sure it will fit on the floppy disk; if it doesn't fit you should go back and delete some files. Some tips are contained in the section "Reducing the size of the root file system".
  • Instructions

    It is very difficult to solve this problem without partially losing files. But with the right approach, file loss can be reduced to almost zero. Click on the hard drive partition, file system which you want to restore, right-click. From the context menu that appears, select Format. In the window that appears, select the file system, in which the section should be formatted. Set the formatting method to "Quick". By formatting the disk in this way, you can later restore the information. After that, click “Start”. After a few seconds, the hard drive partition will be formatted and the file system will be restored.

    Now that the hard drive partition is formatted and the file system has been restored, you can recover the lost information. After returning the file system, do not save any information to this partition, as this will significantly increase the chances of data recovery. To restore them, you will need the TuneUp Utilities program. Download the program from the Internet and install it on your computer.

    Launch the program. After scanning your computer, you will be taken to the main menu of the program. In this menu, left-click on the “Troubleshooting” tab. In the window that appears, select “ Recover deleted data". In the next window, select the desired disk partition and click “Next”. Another window will appear. There is no need to write anything in the “Search Criteria” line, since you are not looking for a specific file. In the same window, check the box next to “Show files only in good condition” and click “Next”. The process of searching for deleted files will begin. After it is completed, the found files will be displayed in the program window. Just select them with the left mouse button and click “Recovery” at the bottom of the program window. Lost files will be recovered.

    Sometimes, installing new programs or updating drivers can disrupt the operation of the operating system. You can restore it using a special program included in the standard set of operating system utilities. This program periodically creates system restore points, recording system information and registry settings in them. Enabling workable settings from such a point allows you to return the computer to a normal state. In the Windows operating system, there are several ways to restore the system.

    Instructions

    If the problem appeared immediately after installing the new driver, then after restarting Windows you will see a black screen with boot options. You must select "Load last known known configuration (with working settings)." This mode will return the last working driver settings and registry settings.

    If problems arise while working with your PC, and you do not know when the failure occurred, then you need to enter the System Restore program. After that, select one of the restore points, for example, for yesterday. If restoring the settings from yesterday did not help, you need to

    Most often, the disk file system is changed to RAW after the computer was turned off incorrectly, when the lights were turned off, or the user saved time and pulled the power cord from the outlet. Another reason is viruses that change NTFS to RAW format of HDD drives. How to fix this problem, read this article.

    What is the RAW file system?

    If the disk is in RAW format, Windows will display it among other hard drive partitions. But when you try to open it, the computer will give you an error and ask you to format it. In addition, any actions with this volume will be unavailable: error checking, defragmentation, etc. (it is useful to read “”).

    There is no RAW file system as such. If the disk receives this formatting, it means that the computer drivers are not able to determine the type of its file system - NTFS, FAT or FAT32. In practice, this happens in several cases:

    • the file system structure is damaged;
    • The partition has not been formatted;
    • There is no correct access to the contents of the volume.

    If the OS volume is damaged, the “Reboot and select proper boot device” or “Operating System not found” warnings will appear when the computer boots.

    Recovery

    If the problem occurs on a non-system drive, but it contains important information that will be lost when formatted, use standard Windows tools or third-party programs to fix the error.

    Windows tools

    Basically, the standard chkdsk utility helps fix problems with formatting in RAW.

    After checking, the computer will repair damaged sectors and the NTFS file system on the problematic volume.

    Important! This method is effective if the flash drive or hard drive has been formatted in NTFS.

    The chkdsk utility will also help when the system disk is damaged. But for this you will need a boot disk or flash drive.

    1. Start the computer from a bootable USB flash drive or disk → Select “System Restore”.
    2. Advanced options -> command line -> enter chkdsk drive_letter: /f.

    In the recovery environment, the partition letters are different from the names of the logical drives. To avoid mistakes, open the list of computer partitions in the command line.

    Enter diskpart → list volume → the list will indicate which disk is the system one.

    Third party programs

    There are third-party programs that help restore the NTFS file system if for some reason it was reformatted to RAW. They do not damage the user’s information stored on the volume, unlike the chkdsk utility, which can “affect” them during the recovery process.

    MiniTool Power Data Recovery

    Important! This method is most effective if the RAW file system appears on a flash drive.

    TestDisk

    This is a multifunctional free utility that works with hard drive partitions using a large number of options. The program is presented in a portable version, so it does not require installation. Main disadvantage

    If at one point you connect your removable drive with a bunch of important information to your computer, you see the message “To use the disk in drive n:, first format it. Do you want to format it?”, then this article is just for you.

    Restoring a flash drive after converting it to RAW format.

    First, let's figure out what RAW is. After all, everyone is accustomed to seeing familiar file systems on their drives, such as NTFS, FAT32. They are used for both SSD solid state drives and hard drives and flash drives.

    The file system is needed so that the disks can function and communicate with the computer. Thanks to it, the computer translates information into binary code, which it understands and with which it can work, and the user already sees the result of this work: photographs, text, videos, audio recordings, games and applications. What exactly is RAW? Without going into too much detail, RAW is a glitch, a system error. Let's figure out why this problem occurs.

    Why did the flash drive become RAW?

    If the file system on your flash drive suddenly becomes RAW, it means that there have been various types of failures while working with it or your computer. Starting from banal system failures, ending with the operation of a malicious program, the so-called virus. If you are sure that the failure occurred due to a virus - when you connected the flash drive, the antivirus informed you that there was a threat on it, but you ignored these warnings - then first you should scan the system and eliminate the original source of the problem, namely the virus that caused you have a lot of problems.


    The virus could also get onto your computer via the Internet; to prevent infection in the future, you should be more selective in choosing sites when searching for this or that information, focusing on trusted sites. It is also quite possible for physical damage to the drive, for example, due to a fall, voltage drop in the computer, or incorrect removal of the flash drive.

    So now you know why this problem occurs. The main thing is, do not rush to format the flash drive, you will lose all the files on it. You can try to “revive” it with the built-in Windows utility or other third-party programs that are publicly available on the Internet.

    How to fix RAW format on a flash drive

    If you don’t need the data on the flash drive, then you can safely format it using the built-in tools. But if it contains valuable data, you need to fix this problem. This raises the question: how to fix a flash drive in RAW format?

    There is no need to despair, everything can be restored without loss, however, everything is not always so easy and cloudless. If you have little idea what to do if the flash drive is in RAW format, then you should still contact a specialized one, where they will restore all the data for a fee. If you are confident in yourself, then you can restore the flash drive yourself. There are special programs to solve this problem.

    How to fix the RAW format on a flash drive? You should start with the built-in program, which is launched via the command line. You just need to enter the command in the command line field: chkdsk n: /n, where n is the letter indicating the drive that you want to “cure”, and the second /n is the function of fixing the file system during scanning. If the built-in program does not cope with this problem, it will display the message “Chkdsk is not valid for RAW disks.” But don’t be upset, there are many more that will help in the fight against this ill-fated RAW.


    If the built-in program is powerless, the relatively free DMDE program will come to the rescue, which can be downloaded from the official website. Launching and installing this utility is not difficult, so we won’t dwell on it in detail. After installing and launching the application, you will see two windows. On the left, select “Phys. Device”, on the right - a problematic flash drive. Double click on it. At this moment, an express scan of the contents of the flash drive will take place.

    Go to the “Found” folder, then to the “All found + reconstructions” folder, then click “Rescan entire volume” and confirm your actions. Now be patient, because the larger the capacity of your flash drive, the longer the scanning will take. After completing this procedure, in the window you will see all the files contained on the flash drive before it failed, but keep in mind that they will have completely different names. Then you can start restoring them.


    If, after all that has been done, nothing worked for you or the functionality of this program does not meet your requirements, you should consider another option, namely MiniTool Power Data Recovery. There is a free version of the program, the functionality of which is limited only by the maximum weight of the restored file (up to 1 GB).


    1. After installing and running this utility, you must specify the drive from which you want to recover data.
    2. Select a flash drive. MiniTool Power Data Recovery will show you the files it contains. You can select all or only the necessary ones.
    3. In order to save files, you need to click the Save Files button (located on the left, blue).
    4. Next, the program will ask you to specify the directory (disk) where you want to save the files from the ill-fated flash drive. And she will also warn you so that you do not try to save data to the flash drive from which you are restoring it.

    From this moment the copying process will begin; the duration can be a decent amount of time, which depends on the size of the files and the computing power of the computer. After all your manipulations, wait for the copying to complete. That's all, all that remains is to check the necessary files in the folder where you saved them to see if they are readable. And actually start “resurrecting” the flash drive. That is, simply format it.

    What to do if the flash drive cannot be formatted in RAW format

    It would be useful to touch upon one more aspect of this problem, namely: what to do if the flash drive cannot be formatted in RAW format? If you managed to extract the files using the above program, you now need to think about how to restore a flash drive that has become a RAW format and return it to its previous functionality. Go to “My Computer”, right-click on the drive and select “Format”. If after this the same ill-fated RAW format remains, then not everything is so rosy and you will have to “sweat a little”.

    In this case, to restore the flash drive, it is necessary to perform the so-called low-level “deep” formatting of the drive. Unfortunately, Windows itself does not know how to do this, but the wonderful NDD low level format utility, which is distributed shareware, will come to the rescue.

    Working with this utility is simple:

    1. Launch it in “Continue for free” mode to continue using it for free. In this case, the functionality of the free version will be enough for us.
    2. In the window that opens, select the drive.
    3. Next, in the window that opens, go to the “LOW-LEVEL FORMAT” tab, click “Format This Device” and confirm this action.


    After completing the low-level formatting process, the duration of which depends on the computing power of the computer and the size of the flash drive, a message will appear that you need to format the flash drive using built-in Windows utilities in order to restore the “normal” file system. When formatting, specify your preferred NTFS or FAT32 format, but remember that the FAT32 file system does not allow storing large single files, so if you download movies, games and similar “heavy” files, the NTSF file system is perfect for you.

    To sum up all of the above, I would like to say that there is nothing terrible in this problem and everything can be solved. Even if your flash drive contains very important files, documents, etc., there is no need to hang your nose. If you do everything correctly, you will recover all your files without loss.

    Photos from open sources

    A situation in which a hard drive requires recovery can happen to every PC user. It may be needed for various reasons. One of them is file system corruption.

    How to determine if a file system has crashed

    If the disk is used for its intended purpose, it has a FAT or NTFS file system. These formats indicate that it works well and does not require restoration. But sometimes it turns into RAW. How can you understand that a failure has occurred?
    If you access the disk, but it does not open and a message appears about the need to format it, then a failure has occurred.
    This message may mean the following:
    1. The structure of the file system used was destroyed;
    2. There is no clear access to the content;
    3. Invalid data was written to the boot sector.
    If you open the properties section, you can see that it seems to contain no information. But you will still need to restore the file system to get back your lost data.

    How to perform a restore

    Don't rush into formatting. You can restore the file system of your hard drive without resorting to extreme measures.

    Recovery using Testdisk

    It is offered free of charge. It makes it possible to return lost data to a state that is close to ideal.
    Let's say our hard drive has several partitions. For example, partition D turned out to be damaged. We select the damaged partition in the program, then indicate the type of structure that we have. In our example, this is the Intel/PC partition. Select the Analyze item. An analysis will be carried out and a list of partitions for recovery will be provided. Select the Quick search option. She, in turn, will select all files from the partitions. Once you find what you need, click the Write button. After all the actions performed, the lost information will be restored.

    Recovery using RS Partition Recovery program

    Its interface is quite simple. The main menu has 3 parts. On the left is a list of hard drives and logical partitions. The center shows their data load. The files selected by the user are displayed on the right.
    1. To start the recovery, you must click “Wizard”. After this, the operation menu will appear. The hard drive will be analyzed.
    2. In the program, all partitions are divided into 3 categories: hard, removable and logical drives. In order to start data recovery, you will need to select the desired partition. After that, click "Next". You will be asked to select the type of analysis: operational scanning or full analysis.
    3. It is better to immediately conduct a full analysis. It processes 3 filters at once. The first filter will calculate NTFS systems. The second one will process files that belong to this system. Deep analysis will work regardless of the file system.
    4. If you choose the first option, then some of the files simply will not be found. In this case, files may be found that do not show signs of damage.
    5. After this you can start scanning. The larger the volume of the disk being checked, the longer the process will be.
    6. After the analysis is completed, you will find out how many folders are in this section.
    7. In order to familiarize yourself with all the files found during the analysis, you need to go to the main menu and click “Finish”.
    8. The “Deep Analysis” folder will appear in the center of the window. Next, you will need to select them in this folder, and then click “Restore”. All that remains is to choose a place to save them.
    9. In this window, you will need to select the location to save the data, the option to restore the folder structure that was deleted, and restore file streams to NTFS. After this, you will need to click the “Restore” button.

    Generally speaking, there is no RAW file system. In the Windows operating system, RAW means that the file system type was simply not determined correctly. This can happen for various reasons:

    • because the disk is not formatted;
    • the disk is faulty or its file system is damaged;
    • Correct disk access is not defined.

    In this case, the operating system reports a corresponding error and offers to reformat the disk again. Of course, all data on it will be lost.

    Naturally, this raises the question: if the flash drive has a raw file system, how can I correct the situation? And this can be done both with the standard tools of the Windows OS itself, and with the help of third-party utilities.

    Restoring the file system using Windows

    • call the command line using the keyboard shortcut - ;
    • In the window that opens, type the command: cmd;
    • The management console will open, where you will need to type the command: CHKDSK /F. The name of the disc may be different. For example: /C, /A, /I, etc.

    A special utility program will launch, which will not only check the disk partitions for errors, but also try to eliminate them.

    You may also need to restart your computer before scanning.

    After the program has completed its work, you will need to call another one to scan errors in real time:

    • the management console is called as described above;
    • enter the command: sfc /scannow.

    So the problem can be solved: if the hard drive is raw how to fix it?

    Restoring a file system using utilities

    Restoring the file system of a flash drive without losing data is also possible using third-party utilities. They have various additional functionality and differ in the organization of the interface, but their common purpose is the same: to restore a damaged disk file system, but without losing a single bit of data.

    Here are just a few of these programs:

    • RS Partition Recovery;
    • Mini Tool Power Data Recovery;
    • Test Disk (this utility does not work with file names written in Cyrillic);
    • Win Hex;
    • Get Data Back for FAT/NTFS (only for FAT and NTFS systems).

    Modern flash memory drives have large capacities and high read-write speeds, thanks to the new USB 3.0 data transfer protocol. They have practically replaced other external storage media, as they are convenient and easy to use. Flash drives do not require additional devices or adapters to connect to a personal computer, and drivers for working with them are included in all operating systems. One of the disadvantages of drives of this type is instability in operation, which occurs quite rarely, but causes a lot of unpleasant moments for the user. If the volume file system of a flash drive is not recognized, then further work with it is impossible, and you have to look for a solution to this problem.

    The Windows operating system works with two types of file systems - FAT (and its variants, for example, exFAT) and NTFS. Drives out of the box already have a specific partition table prepared by the manufacturer. If the flash memory disk operates correctly, the software environment automatically recognizes the USB device connected to the port and mounts it. After completing these operations, the flash drive becomes part of the PC disk subsystem with an assigned partition letter and it becomes possible to perform read-write operations with it.

    Checking disk mount

    If the flash drive does not appear in the system as a disk with a certain letter designation, you need to check the functionality of the drive. First of all, you need to make sure that the device is recognized by the operating system. In Windows, for this you can use the “Disk Management” snap-in, which is launched through the context menu when you right-click on the “Computer” icon, select “Manage”. It happens that the system detects an external flash drive and assigns a letter designation to its partition, but it may be occupied by some network resource. In this case, you just need to change it by right-clicking on the disk device and selecting the “Change drive letter or drive path” pop-up menu item and assigning a free system letter to it.

    On Linux operating distributions, the physical connection of a flash device can be checked using the fdisk –l command, run as root. All detected disk devices will be displayed on the screen and their characteristics will be listed. If the flash drive is present in this list and has the correct file system, then you need to mount it manually.

    Unlike Linux distributions, which support a large number of file systems, Windows support for them is limited. Therefore, even if the external drive is identified as a device, the unknown file system of the flash drive may become an obstacle to working with it due to the lack of necessary drivers. In this case, the media volume will be marked as a partition with an undefined partition table, although the disk itself will be in a healthy state.

    On Linux, Windows file system drivers may not be installed out of the box. In this case, it is necessary to install them. There is a special package for ntfs, ntfs-3g, and programs have also been developed to work with exFAT. The latter is widely used in various digital devices for large-capacity storage devices.

    Reasons for the appearance of the RAW file system

    There are special cases where operating system drivers are notified of the presence of a RAW type system on the disk. This happens when the file system of the flash drive cannot be recognized. There may be several reasons why this happens. The main ones are the following:


    Why won't the flash drive mount?

    The cases of drive failure discussed above are not fatal, and they can be corrected in one way or another. If, when installing the device, you not only fail to correctly recognize the file system of the flash drive, but also mount it, then this may indicate a failure of the drive. The reasons can be very different: from factory defects to broken contacts. Unfortunately, the design features of flash drives are such that this equipment requires quite careful handling, especially during installation and removal. Failure to follow the rules of accuracy can lead to a banal breakdown.

    In addition, the number of write cycles of non-volatile memory drives is limited due to the characteristics of the data storage technology itself. Therefore, the service life of such disks is limited in principle, and sooner or later there comes a time when the memory simply stops working. And this happens the sooner the more intensively the drive is used.

    File system recovery

    With the final failure of the flash drive, everything is clear, and there is practically nothing that can be done here. Even broken contacts are not so easy to re-solder, and without special equipment nothing can be repaired. Let's look at what to do if the file system of the flash drive is not recognized.

    Fixes when working in Windows

    Let's start with Windows. It may turn out that the drive's partition table is of a type that is unknown to the Microsoft operating system kernel. For example, a flash drive with an ext4 partition (widely used in Linux) will be detected as working, but the volume type will not be displayed in the Disk Manager, and when mounting such a drive, the system driver will prompt the user to format it. But in this case, all data located on a working file system will be lost. Therefore, the best solution is to take into account the limitations of Windows working with “non-native” partition tables and use drives with NTFS or FAT for data exchange.

    If the file system type is determined to be RAW, then first you can try to restore it. To do this, you should use the standard operating system utility chkdsk. It is launched from the command line. The whole procedure takes several steps:

    1. Click the Start button and select “Run” from its menu;
    2. Enter the cmd command in the window and then click OK;
    3. The Windows command shell will launch. Type the command chkdsk H:/F/R in the window

    /F - fix file system errors. Flag /R - repair of damaged sectors.

    IMPORTANT. Running a file system check on a flash drive does not mean that it will be restored after it is completed. In case of critical errors, the partition table cannot be restored.

    If the file system could not be restored, you will have to recreate it. There are several paths you can use on Windows. The first is to use the Disk Management snap-in. Select the disk corresponding to the flash drive, right-click the context menu for it and select the “Delete volume” item. After this, the disk will go into the “Unallocated” state, and it will be possible to create a partition table on it again. Call up the pop-up menu again, and in it there is the item “Create a simple volume”. A wizard will launch, with the help of which a new file system is created in a few simple steps. The user selects its type, label, assigned letter, and formatting method.

    In addition to system capabilities, there is a huge selection of utilities from third-party developers that allow you to work with partition tables of flash drives. The actions performed with their help are similar to those performed by the snap-ins built into Windows.

    After rebuilding the file system, you can try to recover the lost data. For this purpose, there are also special software packages developed for Microsoft systems, for example, RS Partition Recovery. The disadvantage of such programs is their cost, although when it is not possible to recognize the file system of a flash drive important for business, the cost of recovery may not be decisive.

    How to fix the system in Linux

    Linux distributions have several tools for dealing with damaged file systems. All of them require root rights and certain skills and knowledge to run, since the vast majority are launched in the command shell. The most effective tool is fsck, which is used with many options.

    For regular distribution users, it is recommended to use the GParted program, which runs in the graphics subsystem and has a graphical interface (GUI). It also requires privileged rights, but is intuitive and does not require much knowledge about creating partition tables.

    Conclusion

    The described methods for restoring file systems of external drives can be used for any type of rewritable digital media. The same methods are used to recover data on hard drives, including solid-state drives (SSDs). And yet, the main rule for saving important files is their regular backup. Not everyone has been able to completely restore data from damaged file systems.

    Hello, dear visitors, readers, friends and foes, regular customers and other personalities of the site.

    We continue the series of articles devoted to Linux systems. Today we will talk about such important (maybe not very simple) concepts as:

    • Linux file system;
    • Main directories of the root file system;
    • Console commands for working with files and directories.

    So, let's begin.

    Linux root file system

    It's hard to imagine an operating system (even one like Linux) without a file system. The system-wide order rests on it. The file system strictly monitors the organization, storage, and naming of data. For example, when a program accesses a file, it knows nothing about where the information about this file is located or on what physical medium it is recorded. The only thing the program knows is the name of the file it is accessing, its size and other parameters that distinguish the sought file from many other files (the date and time the file was created, the name of the file owner, the rights and method of accessing the file, etc. .). It receives all this data from the file system. It is the file system that determines where and how a file will be written on physical media (for example, a hard drive or removable device). All directories (also known as folders), subdirectories, and files collected in one place are file system data. Moreover, one of these directories in Linux systems is the most important, namely the “top” (in other words, “root”) of the file system - it contains all other directories and files.

    In order for you to understand what we are talking about, I opened the Linux file system directories through the Midnight Commander (MC) file manager. The top of the file system (root directory) was indicated with a red arrow - and this is where all other file systems are mounted. Next, we will try to more clearly describe everything that you currently see in the picture (in the text we will dwell on certain concepts so that it is clear what we are talking about, and you can get your bearings by looking at the picture).

    If a hard drive is divided into partitions, then each of them has separate file systems with its own root and its own directory structure. Any operating system supports several file systems, for example, Windows supports such well-known file systems as FAT, FAT32, NTFS, etc. Linux is no exception. However, it is important to distinguish between file systems that can be used as a root file system and file systems that simply support the operating system, but are not used to install Linux or Windows (such as ISO9660 (this model ensures compatibility of media under different operating systems). systems), UDF (this is a special file system format designed for storing files on optical media), etc.). We will not consider Windows file systems, we will not dwell on file systems that are not used to install operating systems, but will simply give a brief overview and get acquainted with some of the most famous root file systems Linux.

    • ext - Extended File System (extended file system) the first file system designed specifically for operating systems based on the Linux kernel.
    • ext2 - Second Extended File System (literally: “second extended file system”)- standard, but already outdated Linux file system. In terms of speed and performance, it can serve as a benchmark in file system performance tests. Its only drawback is that it is not a journaling file system. (a journaled file system is a system that records a journal and stores a list of changes, which in turn helps maintain the integrity of the file system during failures). This flaw was corrected in the next ext3 file system.
    • ext3 - Third Extended File System (third version of the extended file system) An improved version of the ext2 file system with journaling support, which undoubtedly improves its reliability.
    • ext4 - Fourth Extended File System (fourth version of the extended file system)- the latest Linux file system. Since Linux kernel 2.6.28 (released December 25, 2008) the filesystem is already considered stable and is used by default in many Linux distributions.
    • The ext4 file system is seen as a transitional step towards the next generation file system Btrfs, which is already aspiring to be the main Linux file system in the future.

    Attention! There are several other file systems, for example, ReiserFS, JFS, XFS, etc., but it is not advisable to use them at home, because ReiserFS is sensitive to failures and needs to be defragmented regularly, JFS does not work well with large files (for example, with video), it is better to use this file system for a database server, and XFS is good to use on graphics stations for video processing.

    Let's repeat it again (repetition is the mother of learning) :). When installing Linux, a root file system is created on the hard disk partition of your choice, and for Linux it is the most important one. It is to this that all other file systems on other devices will be mounted. The root file system is also mounted, but not to another file system, but to “Linux itself,” with the root directory serving as the mount point. Therefore, when the system boots, the root file system is mounted first, and when it shuts down, it is unmounted last. (we will talk about the very concept of mounting and unmounting in the following articles - this is a separate and also important topic). The root file system contains a set of standard directories and utilities, without which Linux cannot work. In Linux, the root directory is designated as “/” (slash). Full names (in other words - paths) all other directories are obtained from “/”, to which the names of successively nested directories are appended to the right. Directory names in the path are also separated by a “/” character. For example, /home represents the “home” directory in the root directory (“/”), and /home/Sonikelf represents the “Sonikelf” directory in the “home” directory, which in turn is located in the root directory. The directories listed in this way, ending with the file name, make up full path to the file.

    In Linux, in addition to the full path, there is also relative path, which is constructed in exactly the same way as a complete one - by listing, separated by a slash (“/”), all the directory names encountered when moving to the desired directory or file. There is only one important difference between a full path and a relative path: a relative path starts from the current directory, and a full path always starts from the root directory. Linux distinguishes between full and relative paths simply: if the object name begins with “/” it is a full path, in any other case it is a relative path.

    Main directories of the root file system
    Different Linux distributions may also have different directories: some will have additional configuration files/directories, and some configuration files may well be named something else. I will give the names of the directories that are included in the Fedora distribution. So, here we go:

    / - root directory

    • /bin - contains standard Linux utilities. Or let's put it this way - this directory contains the main executable files (in Windows, such files have the extension .exe), accessible to all users, and also contains symbolic links to executable files. A symbolic link is a special file in the file system, inside of which there are only one or two lines indicating the full path that must be opened when trying to access this link (file).
    • /boot - contains configuration files of the GRUB boot loader, kernel images (the last three are stored by default), Initrd files. To make it clear what kind of mythical files these are, a disk that contains a temporary root file system, with the help of which, in turn, the Linux kernel is launched. The Initrd file is an image of this temporary root system that is stored on the boot device.
    • /dev - contains device files. In Linux, a device is hardware that is connected to the system during the kernel boot process or while the system is running. These devices represent methods for inputting or outputting information. For example, a hard drive is a device for input (writing) and output (reading), a mouse is an input device. Each movement or click of the mouse buttons sends a character to the /dev/mouse device, the keyboard is also an input device. Most devices in Linux are files in a special file system (exception is network cards). And these files are stored in the /dev directory, where the system accesses them to perform I/O-related tasks.
    • /etc - contains configuration files of the operating system and all network services. This directory can be compared to the Windows registry, but in Windows system-wide settings are stored in one large binary file, and in Linux they are stored in different configuration files that can be edited with a regular text editor.
    • /home - the directory name speaks for itself. This contains the home directories of all users who are registered in the system. Users' home directories store user files, as well as user settings for various programs. As we already mentioned in the previous article, and therefore each user has his own unique and inimitable directory for his personal, personal files. This directory is called the user's Home directory and is designated, as we said a little earlier, /home/UserName. This separation of user directories and operating system files simplifies data storage and increases the reliability of the operating system itself.
    • /lib - This is where various libraries and kernel modules are located. During the installation of various programs in Linux (including drivers), (we have already talked about them) for the program to work correctly. In most cases, these dependencies are libraries - a set of files assembled in a special way that are connected to the program being installed during installation.
    • /lost+found - this directory is needed to store damaged files in case of problems with the file system, which were restored after, for example, incorrect unmounting of the file system. This is a very valuable directory; you cannot delete it (it will still appear again).
    • /misc - can contain anything.
    • /mnt and /media - These directories typically contain mount points. In modern Linux distributions this process usually happens automatically. In this case, a subdirectory is created in the /mnt or /media directories, the name of which matches the name of the mounted volume.
    • /opt - installed programs with a large disk space or auxiliary packages are usually located here, for example, I have only two programs in this directory - Adobe Reader and Google Chrome
    • /proc is not an ordinary directory, it is a directory of the procfs pseudo-file system, which is used to provide information about processes (in other words, this is a virtual file system that provides communication with the kernel and is mounted in the /proc directory). Yes, yes, Linux has a virtual file object called the /proc directory. It exists only while the system is running in the computer's RAM. The directory is also of interest from a security point of view. Many of the utilities that display information about the system (for example, ps command), take their source data from this directory.
    • /root - user directory (we mentioned who this is in one of the previous articles).
    • /run is a completely new directory that just appeared recently. And it was created (as conceived by the developers) to store data that was launched by applications required during operation (these can be services launched by the system itself, and programs that you launch yourself).
      This includes:
      • Process identifiers PID (each process running in the Linux environment has its own unique identifier - in other words, this is the address (in numerical form) of the process with which other running processes will interact during operation);
      • Interprocessor communication information (in simple terms, this is the exchange of data between running processes);
      • Locked files (if during operation the application either does not start or is unstable? this may mean that some files of this application are locked by other processes and this happens when several applications try to use one shared resource at once); - well, and other data necessary during work.
    • /sbin - a set of utilities for system administration, contains executable files necessary to boot the system and restore it in various delicate situations. Only root has the right to run these utilities.
    • /tmp is the directory where temporary files are stored. Linux, unlike Windows, keeps this directory clean and regularly cleans it.
    • /usr - contains user programs, documentation, source codes for programs and kernels. In terms of size, it is one of the largest directories in the file system. Almost all programs are installed in this directory. And it (this directory), with a big stretch, can be compared with the Program Files directory in Windows.
    • /var - contains files that are subject to the most frequent changes. For example, caches of various programs; lock files to prevent the simultaneous use of one program by several users; system log files; temporary files (when the computer is turned off, the contents are cleared); information about various programs; general information about the state of the system since the last boot, login, etc.; print queue, fax queue, as well as user inboxes, etc.

    Conclusion. The file system in Linux is an indivisible whole, starting from the root directory (the so-called “top”), and inside the directory there can be entire disks or their partitions (with other file systems), which can be easily mounted (attached) and just as easily unmounted (detached). ) from unique, united, indivisible, whole tree. I specially highlighted these words to make the difference from the Windows file system clear. If anyone doesn't know, in Windows each logical drive is a root directory. For example, if there are three logical drives - C, D, F, then there will be three root directories.

    Necessary commands you need to know to work with files and directories

    Now that Linux has a good graphical interface, the console is used less and less (which personally disheartens me). In any case, knowledge of a simple basis, namely, simple and useful commands, is necessary for any user (for example, your X server crashed (roughly speaking, this is the so-called graphical interface in Linux - this is not an entirely accurate definition, but at the moment , we will not delve into the jungle of terminology) or you needed to install the program from the source code, or something else). You cannot do without a console (or terminal). And to work effectively in the console, you need to know Linux commands. In general, there are a lot of commands, so it would be simply unrealistic to cover them all (at least within the framework of this article), so for now we will limit ourselves to commands for working with files and directories.

    Note:
    Please note that all file names and command names must be entered in the correct case, i.e. names in Linux are "case sensitive". For example, the cd command is not at all the same as the Cd or CD command. The same applies to file and directory names.

    The cd command is used to move through a directory tree. If you enter this command without arguments (i.e. just write cd - see the first line in the figure), you will be taken to your home directory, and to get to any other directory, you must specify the path to it. By default, you are always initially in your home directory (/home). The first line contains the relative path, the second - the full path. If you need to move to some other directory, then enter cd , be sure to have a space and the directory where you need to go, for example cd /usr . The fourth line of the figure indicates in square brackets that we have moved to the usr directory. You can specify the entire path at once, for example, cd /usr/games . You will be taken to the games directory, which is located in the usr directory, which in turn is located in the system root directory. To go back to your home directory, just specify the relative path cd ~.

    Now that, with a little practice, you already know how to move from directory to directory, it’s time to learn how to view the contents of a directory. And the ls command will help us with this. With its help you can display a list of files and directories in the current directory. The ls command has many options. The ls command itself (without the switch) will not show all the files in a directory. Some files are hidden and can only be seen by specifying an additional switch (option) to the ls command. If we type ls -a , we will see a list of all the files in the directory (even hidden ones will open).

    It is not necessary to be in the directory whose contents you want to find out using the ls command. For example, to see what's in the /etc directory while in your home directory, type:

    ls -al /etc

    Here we have specified two keys - show hidden files (a) and display information (l). Please note that we can specify several keys at once to get all the information about a directory or file.

    Here are the most commonly used ls command options:

    A (all) - will display a list of all files in the directory, including hidden files;

    L (long) - will display information about the contents of the directory, including access rights (first column), owner (second column), group (third column), size (fourth column), creation time (fifth column), whether the file is a symbolic link to another file and which one (sixth column);

    R (reverse) - lists the contents of the directory in reverse order;

    S (size) - sorts files by size.

    The next useful and necessary command is pwd. Moving through different directories, you can find yourself in a rather sticky situation when you don't know or don't remember the name of the current directory - in other words, you get lost in the file system :). After all, by default in Linux, the command line prompt displays only the name of the current directory, and not the full path to it. This is where the pwd team will provide you with an invaluable service

    Look at the first line. The square brackets indicate that I am in the services directory. But where it is located, in which or which directory is completely unclear. By entering the above command, I was given the full path to this directory (second line). With this command you will definitely not get lost in the Linux file system.

    The mkdir command creates a new directory. In the user's home directory - /home, as in any other, you can create an unlimited number of subdirectories, in them - your own subdirectories, etc. In other words, you own a "subtree" of the file system whose root is the user's home directory.
    To organize such a subtree, you will need to create directories inside the home one. This is what the mkdir utility is used for. It is used with one required parameter: the name of the directory to be created. By default, the directory will be created in the current directory.

    Let's create a globus directory (first line in the picture). Let's enter the command mkdir globus. To make sure that the directory has been created, enter the ls command with the -F switch (add the suffix “/” for each directory name). The directory has been created.

    Next. You can use this command to move files and directories. mv has two required parameters: first, the file or directory to be moved must be specified, second, the destination file or directory must be specified. File and directory names can be specified in any valid form: using a full or relative path. In addition, mv allows you to move not only one file or directory, but several at once (files/directories are listed separated by a space).

    Let's practice a little: create two directories in your home directory - Globus and Dos and create a file - dokument. Now let's start practicing:

    1) Rename one file to another. To rename, for example, the dokument file to dokument.old , enter:

    mv document dokument.old

    2) Now let's move one directory to another. To move the Globus directory from the current working directory to the Dos directory, enter:

    mv Globus Dos

    If the Dos directory already exists (as in our case), mv will place Globus inside Dos. And if you haven’t created a Dos directory, then mv will RENAME (overwrite) Globus to Dos

    3) To move a file or directory that is not in the current directory, specify its full name and path as an option.

    For example, to move the file /usr/tmp/dokument to the current working directory, enter:

    mv /usr/tmp/dokument txt.txt

    The dokument file was originally in /usr/tmp/, we moved it to the home directory and renamed it txt.txt

    4) Now to move the txt.txt file from the current working directory to the /usr/tmp directory, type:

    mv txt.txt /usr/tmp

    There can be a lot of files in the tmp directory, so for convenience I divided the image and made it smaller. The second line means that to make sure our file is moved, we must change to this directory, which we did with the cd command. And using the ls command, we opened the tmp directory for viewing and made sure that the move was successful.

    The next useful and necessary command is cp.
    It creates a copy of the file. The cp utility also requires the presence of two mandatory parameters: the first is what we want to copy (file or directory), the second is where we want to copy it (destination). For example, you need to copy the dokument file to the Globus directory - enter the command

    cp document Globe

    and the dokument file will appear in the Globus directory (this will be a copy of the dokument file, which is located in our home directory)

    Using the cp command, you can copy not only one file or directory at a time - you can list everything you want to copy and specify it to the cp command. For example, we need to copy two files dokument and dokument.old to the Dos directory, nothing could be simpler - list all files or directories separated by a space:

    cp dokument dokument.old Dos

    You can not only copy, but also delete files and directories, and the rm (deletes files) commands will help us with this.

    And rmdir (removes directories). rmdir will only agree to remove a directory if it is empty, i.e. there are no files or subdirectories in it.

    You can delete a directory along with all its contents using the rm command with the “-r” switch. The command rm -r name of directory(s) is a very convenient way to lose all files overnight: it recursively (this term means approximately the same as running uninstaller in Windows) traverses the entire directory, deleting everything it comes across - files, subdirectories, etc. .d., and the “-f” (force) switch makes its work even more inevitable, since it suppresses requests like “delete a write-protected file”, so rm works silently and non-stop. Be careful when using this command.

    The cat command allows you to display the contents of any file, but in this form this command is practically not used. If the file is too large, its contents will scroll on the screen and you will only see the last lines of the file. Using this command, you can combine and merge copies of files, as well as create new files. If you simply type cat on the command line and press Enter, you can enter (and therefore see) text on the screen. Pressing Enter again will double the line and allow the next one to begin. When the text is typed, press the Ctrl and d keys simultaneously.

    This happens because you enter the first line yourself, and the second line is copied by the cat command onto the screen. If you redirect (i.e. write) the output to a txt file, then no doubling will occur, but a new file with the typed text will appear in the working directory, which can be easily viewed using this command:

    cat > txt

    This command will be able to read and open any file, not just text, but there will be no benefit from opening, for example, a graphic file. A confusing set of characters will be displayed on the screen.

    Some options that can be used with this command:

    • -A shows all invisible characters;
    • -E shows end-of-line characters;
    • -e shows non-printing characters plus end-of-line character;
    • -b numbers non-empty lines;
    • -n numbers all lines.

    Let's try to combine two files into one using the cat command:
    We have two files - dokument and txt, we will merge them into one galina by entering the command

    cat document txt >galina

    That's all - our two files are combined into one, saving both the first and second files in one common file :)

    If the file is too large, then to view it on the screen you need to use with the more and less commands.

    • more displays the contents of the file on the screen page by page, just the size of the entire screen. In order to see the next page, you need to press the spacebar. You can exit viewing mode using the Q key.
    • less contains all the functions and output control commands found in more and additional ones, for example, to move through the text you can use the Up Arrow, Down Arrow, PgUp, PgDown keys.
    • The locate command searches for a file. With this command you can see all files or directories whose names contain the pattern you are looking for. For example, to search for a file containing the word dokument.old in the name, enter

    locate document.old

    The locate command found all dokument.old files. There were three of them in the system. You can also set a more advanced search, for example, if instead of dokument.old you specify a “piece” of the name, for example “doku”. ALL files containing this letter combination will be found.

    There is another similar command for searching files - find . This command has many options, but the most commonly used option is -name - it searches for all files and directories containing the combination of letters you specify in the name.

    Another useful command is which. It shows the location of executable files. The command is useful when creating a button to launch an application.

    To create a launch button, you must know the launch command for the application for which you want to create a launch button on the desktop. This figure shows that ls run command- this is /usr/bin/ls

    The clear command (as well as the Ctrl+L key combination) clears the terminal window. This can be useful when you are moving through directories or files, since the terminal window is filled with a bunch of commands or just some information. In this case, the command line prompt will be shifted down – which is not always convenient. To avoid leaving the command line and re-entering it, you need to use the clear command.

    And finally, I would like to mention two more useful and very necessary commands.

    The first is history. The name of the team speaks for itself. This is the history of the commands you entered in the terminal window. For beginners or even advanced users, it is quite tedious to remember how to write this or that command (I'm not talking about one-word commands, but about commands containing 2-3-4 words, for example, system-config-authentication). This command will display a list of previously entered commands (the list of these commands can also be viewed in the .bash_history file. It is located in your user's home folder). Just type: !command number in history ", for example !847.

    And we will finish our acquaintance with perhaps the most important command in Linux. This is the man command - short for "manual". It can bring up documentation pages about the purpose and use of commands in the system. By entering man , a space and the name of any command, you will see the documentation page for the selected command, for example, enter man clear

    Exit help - q

    Like any other help system, the man system has its own man page. Type man man to get detailed documentation on the man command itself.

    Afterword.

    Something like this. As always, we look forward to your comments, additions and all that other stuff.

    This concludes our next lecture :). There will be future ones, I hope they will be interesting and exciting. If you have anything to add (add), please add it in your comments.

    P.S. Thanks to a member of the Pantera team for the existence of this article.

    Any operating system supports several file systems, for example, Windows supports such well-known file systems as FAT, FAT32, NTFS, etc. Linux is no exception.