L in u X ba sics for h acke rs g e t t I n g s t a r t e d w I t h




Download 7,3 Mb.
Pdf ko'rish
bet116/125
Sana14.05.2024
Hajmi7,3 Mb.
#232858
1   ...   112   113   114   115   116   117   118   119   ...   125
Bog'liq
linuxbasicsforhackers

sd
SATA hard drive
a
First hard drive
1
First partition on that drive
My 64GB flash drive is designated as sdb1, and my external drive as sdc1.
Checking for Errors
The 
fsck
command (short for filesystem check) checks the filesystem for errors 
and repairs the damage, if possible, or else puts the bad area into a bad blocks 
table to mark it as bad. To run the 
fsck
command, you need to specify the 
device file to check. It’s important to note that you must unmount the drive 
before running a filesystem check. If you fail to unmount the mounted 
device, you will receive the error message shown in Listing 10-5.
kali >
fsck
fsck from util-linux 2.20.1
e2fsck 1.42.5 (29-Jul-2012)
/dev/sda1 is mounted
e2fsck: Cannot continue, aborting.
Listing 10-5: Trying (and failing) to run an error check on a mounted drive
So, the first step when performing a filesystem check is to unmount the 
device. In this case, I will unmount my flash drive to do a filesystem check:
kali >
umount /dev/sdb1
I can add the 
-p
option to have 
fsck
automatically repair any problems 
with the device, like so:
kali >
fsck -p /dev/sdb1
With the device unmounted, I can now check for any bad sectors or 
other problems with the device, as follows:
kali >
fsck -p /dev/sdb1
fsck from util-linux 2.30.2
exfatfsck 1.2.7
Checking file system on /dev/sdb1.
File system version 1.0
Sector size 512 bytes


Filesystem and Storage Device Management
109
Cluster size 32 KB
Volume size 7648 MB
Used space 1265 MB
Available space 6383 MB
Totally 20 directories and 111 files.
File system checking finished. No errors found.
Summary
Understanding how Linux designates and manages its devices is crucial 
for any Linux user and hacker. Hackers will need to know what devices 
are attached to a system and how much space is available. Because storage 
devices often develop errors, we can check and repair those errors with 
fsck
. The 
dd
command is capable of making a physical copy of a device, 
including any deleted files.
E XERCISES
Before you move on to Chapter 11, try out the skills you learned from this chapter 
by completing the following exercises:
1. Use the 
mount
and 
umount
commands to mount and unmount your flash 
drive.
2. Check the amount of disk space free on your primary hard drive.
3. Check for errors on your flash drive with 
fsck
.
4. Use the 
dd
command to copy the entire contents of one flash drive to 
another, including deleted files.
5. Use the 
lsblk
command to determine basic characteristics of your block 
devices.




Download 7,3 Mb.
1   ...   112   113   114   115   116   117   118   119   ...   125




Download 7,3 Mb.
Pdf ko'rish

Bosh sahifa
Aloqalar

    Bosh sahifa



L in u X ba sics for h acke rs g e t t I n g s t a r t e d w I t h

Download 7,3 Mb.
Pdf ko'rish