Linux/Hard Drive Management: Difference between revisions

From Dev Wiki
Jump to navigation Jump to search
m (Fix formatting)
(Add label information)
Line 1: Line 1:
Various commands and tools to manage disks in Linux.
Various commands and tools to manage disks in Linux.


 
== General ==
View currently attached drives/devices:
* <code>lsblk</code>
 
GUI Hard Drive Management:
GUI Hard Drive Management:
* Use the <code>gparted</code> program.
* Use the <code>gparted</code> program.
Line 22: Line 19:


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.
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.
== View General Drive Info ==
For a simple overview, use:
* <code>lsblk</code>
For more detail, use:
* <code>sudo fdisk -l</code>
== Change Label of Drive ==
The drive label is generally what an OS will automatically name the drive, upon mounting.<br>
Thus, it can be useful to give your drive labels meaningful names.
For the following commands:
* <code><partition></code> corresponds to the partition name (ex, sda1, sdb2, etc).
* <code><label_name></code> 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>

Revision as of 19:32, 22 March 2020

Various commands and tools to manage disks in Linux.

General

GUI Hard Drive Management:

  • Use the gparted program.

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>

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.

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>