Join/Login and make your voice heard Connect With Other Naijatipsland Members

5 Linux Commands For Managing External Drives And How I Use Them

I currently have five external drives attached to my System76 Thelio, each of which serves a different purpose. I have one to house virtual machines, another for music files, another for backups, one for photos and videos, and one for miscellaneous things. Using these ensures the drive housing my operating system never fills up, which can cause slow-downs and lockups.

Even if you have only one external drive, you’ll want to know the Linux commands available to help you manage them — especially when it comes to adding or removing those drives.

1. lsblk

The lsblk command comes in very handy when you need to know the name of a drive. If you want to permanently mount a drive (via the /etc/fstab file) or want to format a drive, you have to know the name of that drive (such as /dev/sdb). To locate that name, there’s no better command to use than lsblk.

Issue that command and you’ll see a list of the drive names and the directories to which they are mounted. An lsblk listing will look something like this:

sda               8:0    0 931.5G  0 disk

└─sda1            8:1    0 931.5G  0 part  /media/jack/OLIVIA

As you can see, the device name is sda1 and it’s mounted to /media/jack/OLIVIA. If I were adding a new drive and needed to format it, I would know not to use the sda or sda1 names..

2. mkfs

Speaking of formatting, when you need to format a drive in Linux, you can either use a GUI tool like GNOME Disks or the mkfs command. Although formatting drives with mkfs isn’t exactly a task I’d hand over to someone with little Linux experience, it’s not as hard as you might think (beginners, check out these desktops).

 

For example, if you’ve used lsblk found found the drive to be formatted is sdb, the command to do so would be:

sudo mkfs -t ext4 /dev/sdb1

The -t option informs mkfs that we’re specifying a file system type and that type (in the above command) is ext4. One thing you might run into is if the disk hasn’t been partitioned. In that case, you’d use the fdisk command like so:

sudo fdisk /dev/sdb

3. blkid

When you want to permanently mount a drive with fstab, you might need to use a device ID and not a name. The blkid command lists block device attributes. One of the more important attributes is the UUID (Universally Unique Identifier) of a device. Using the blkid command also lists the label, block size, type, partition label, and the partition UUID.

 

When you want to permanently mount drives using fstab, it’s always best to use the UUID of a drive and this command will help you find it.

 

4. mount

This is one of the issues that never fails to confound new Linux users. When you attach an external drive, it has to be mounted to a directory so it can be viewed and/or used. Most Linux distributions are fully capable of doing this automatically. When that happens, the drives are typically mounted to the /media/USER (where USER is your username) directory.

 

Sometimes, however, you might want to mount it to a different location — the mount command is what you’ll use. Mounting a drive with this command will look something like this:

sudo mount /dev/sdb1 ~/mount

The above command would mount the sdb1 partition on the sdb drive to the /home/USER/mount directory (where USER is your username). Once mounted, you would use the external drive as if it were located in ~/mount.

5. umount

When you need to remove an external drive, you use the umount command. That’s not a typo. You’d think the command would be unmount (since that’s what it does) but no, it’s umount. The command is very simple and looks a little something like this:

sudo umount /dev/sdb1

You could also use the mount point like so:

sudo umount ~/mount

 

Both commands would unmount the external drive so you can remove it.

Source link

0 0 votes
Article Rating
Subscribe
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Nigeria's Fast-Growing Online Forum
Logo
Verified by MonsterInsights
situs togel sydneylotto situs toto toto slot https://sih3.kepriprov.go.id/berita/ https://fast.indihome.web.id/slot/ https://uninus.ac.id/ togel online terpercaya bento4d situs toto situs toto bento4d