Linux/Hard Drive Management

From Dev Wiki
< Linux
Revision as of 23:31, 22 March 2020 by Brodriguez (talk | contribs) (Create symlink info)
Jump to navigation Jump to search

Various commands and tools to manage disks in Linux.

General

GUI Hard Drive Management:

  • Use the gparted program.

Verifying a download against a hash: Some large files (particularly iso/img files, such as for an OS install) will have an associated SHA256 string on the website download page.
To verify your download had no errors, you can run the command:

  • sha256sum <file_location>

This should output a string, which you can directly compare to the string on the website. If they match, then the file is valid with no errors.

File Management

Copying Files

Copy Files Locally:

dd if=<input_location> of=<output_location> status=progress conv=fsync

Copy Files Over a Network:

rsync -avh <input_location> <output_location>

Note that input/output locations can be a local file path or a network path. If it's a network path, then it takes the format of:

  • <username>@<network_location>:<input_or_output_location>

Sym Links

ln -s <location_of_original_file_or_folder> <location_of_sym_link>

In this case, the <location_of_sym_link> will point to <location_of_original_file_or_folder>.

View General Drive Info

For a simple overview, use:

  • lsblk

For more detail, use:

  • sudo fdisk -l

Change Label of Drive

The drive label is generally what an OS will automatically name the drive, upon mounting.
Thus, it can be useful to give your drive labels meaningful names.

For the following commands:

  • <partition> corresponds to the partition name (ex, sda1, sdb2, etc).
  • <label_name> corresponds to the new label you wish to give the drive.

Ext Partitions

e2label /dev/<partition> <label_name>

NTFS Partitions

ntsflabel /dev/<partition> <label_name>