CLI Change drive

Please -- I cannot find how to change in terminal from e.g. sda1 to sda2 or to sdb*

Any ideas please?

In windows you change drives e.g., c: to e:

You do not do that in UNIX. What are you trying to do?

df -h 

shows the mounted disks or volumes. The last column is a mountpoint (directory).
Use the cd command to change directories so that your current directory is the mountpoint.

1 Like

UNIX partitions don't work that way. You don't use drive letters or device names to access files. In UNIX, files are all organized as one great big tree. Instead of drive letters, UNIX uses directories as mount points. This lets you put partitions on whatever folder you want. This is even customizable.

This is what the file tree on my system looks like:

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdc3            1008M  318M  639M  34% /
udev                   10M  284K  9.8M   3% /dev
/dev/sdc5              20G   11G  8.4G  56% /home
/dev/sdc6             9.9G  4.6G  4.9G  49% /usr
/dev/sdc7             5.6G  1.6G  3.9G  29% /var
/dev/sdc8             116G  5.1G  111G   5% /var/lib/mysql
shm                   948M     0  948M   0% /dev/shm
/dev/md125            394G  351G   24G  94% /opt
/dev/md126            1.5T  1.4T  106G  93% /opt/disk-images
$

'udev' and 'shm' are special kernel filesystems which you can ignore for now.

If I created a file inside /, or /tmp/, or /sbin/, or /etc/ -- nowhere inside any of the other folders listed -- the file would end up inside /dev/sdc3.

If I created a file in /home/username/, it would end up in /dev/sdc5.

My /var/ partition ended up not being large enough to hold our database, so I grafted another partition onto /var/lib/mysql for it to work inside.

Which partitions go where is traditionally controlled by lines in the /etc/fstab file, but various systems may handle it different ways.

1 Like

I am beginning to get my head around it now. Very grateful. Roy