Tuesday, October 3, 2023
rated 0 times [  36] [ 0]  / answers: 1 / hits: 365891  / 2 Years ago, sun, march 6, 2022, 9:20:29

In DOS, I switch between different drives by typing c:, d:, e: and so forth. But it doesn't work that way in Linux.

Could anyone please tell me how to switch between different drives?

More From » command-line


Linux doesn't really have a way to work with "drives", per se, except with system utilities that access partitions; they often need to specify the drive that contains the partition. But if your drives each only have one partition, it doesn't really matter.

Anyway, to access a drive, you actually need to specify the partition in some way, usually by a definition like /dev/sda1 (1st partition on 1st drive) or /dev/sda2 (2nd partition on first drive). Using the Disk Utility or gparted, you can see all the partitions graphically. If you're only using the terminal, I've found that the command "blkid" is handy to list the drives with their UUIDs. I use the form:

sudo blkid -c /dev/null

Using the terminal, you need to mount a partition to actually use it. This is actually pretty easy to do. In most cases, you would want to use an empty directory as the "mount point"; if the directory is not empty, its contents will be masked and unavailable during the mount. This may be useful in certain circumstances, such as testing or temporarily changing a configuration for some other reason, as it will alleviate the need to rename or delete the current contents.

If you have a directory named /mnt/drive2 (/mnt is commonly used, but it can be in your home directory if you want), and your drive is /dev/sdb, with a single partition, then the simplest command is:

sudo mount -t type /dev/sdb1 /mnt/drive2

where "type" is the type shown in the blkid command, such as ntfs, ext4, etc.

EDIT: to experiment, don't be afraid to try the mount command. It is only temporary until you reboot (or unmount using the "umount" command). To make it permanent, you need to enter it into /etc/fstab. If you want to do that, you can experiment by creating an entry, then using the command "mount -a" to mount everything in /etc/fstab. If there are errors, it will tell you, and you can correct and repeat until it works.

[#40622] Sunday, March 6, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 241
Total Questions: 113
Total Answers: 118

Location: Liechtenstein
Member since Wed, Dec 8, 2021
2 Years ago