You can do just about all of this in a GUI program like gparted. If you like GUI's, by all means use these programs.
But sometimes, GUI's are not an option. If you have to something on a remote Linux system, ssh is often the only
access you have. While using gparted can make things easier, it's sometimes nice to know what it's doing under the
covers.
The other thing I will say here, is there are always more than one way to do something. So usually whatever example
I'm giving here... yes, there is another way to do it.
So.. how can I see what disks are in my computer?
I typically use a program called fdisk. It comes installed by default on many distro's.
That's a lot of information. I deliberately picked a difficult example to start with, because often times, you will see something like this.
fdisk -l ( lowercase L ) lists the disks I have in my system. In this case there are just two.
/dev/nvme0n1 and /dev/sda
What makes fdisk a little bit difficult to use, is that it also shows disk partitions. Usually, the most common disk types you will see
are /dev/sdX or /dev/nvmeXnX. Depending on what virtual machine software you are running, disks will sometimes show up as
/dev/vdX. If you have older hardware with spindle type disks, they might show up up as /dev/hdX. I do have a small portable computer
that has a MMC type drive that shows up as /dev/mmcX.
In the example above, I have a USB thumb drive plugged into one of the USB ports. These almost always show up as /dev/sdX.
Note: For sake of convention here, I'm using the character "X" as a placeholder. None of my drives are actually /dev/sdX but rather /dev/sda or /dev/sdb, and some cases /dev/sdc. Usually, the first drive the computer finds on its system hardware bus gets the letter "a" in the case of SSD and USB drives, or the number "0" in the case of nvme or mmc type drives.
The problem with USB thumb drives, is they play games with your mind and move around. For example.
My internal SSD drive shows up as /dev/sda. OK, so far so good. I plugged in a thumb drive to one of my USB ports and it shows up as /dev/sdb, I'm still good so far. and I plug in a third drive it shows up as /dev/sdc. all is as expected right?
But now turn my computer off, and tomorrow morning I turn the computer back on. All my drives got moved around.
My 16GB drive is now /dev/sdb and my 32GB drive is now /dev/sdc. What happened? Yes, the order you plug them in matters. But also
which port you plug them into can make a difference. This usually only matters if the computer is turned off. If the computer is already turned on, then the order I plug them assigns the drive letter. If the computer is turned off, the port I plug them into assigns the letter.
For example, USB port 1 will almost always get a lower letter than something plugged into USB port 2 or 3.
The point here is, always check. Don't assume the drive letters for a specific drive will always be the same. For internal fixed disk drives
on the system bus, you can assume they will always be the same.
.. to be continued.
But sometimes, GUI's are not an option. If you have to something on a remote Linux system, ssh is often the only
access you have. While using gparted can make things easier, it's sometimes nice to know what it's doing under the
covers.
The other thing I will say here, is there are always more than one way to do something. So usually whatever example
I'm giving here... yes, there is another way to do it.
So.. how can I see what disks are in my computer?
I typically use a program called fdisk. It comes installed by default on many distro's.
Code:
fdisk -l
Disk /dev/nvme0n1: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: INTEL SSDPEKKR256G8
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 8330A4F0-E6BB-4704-9C29-04885739E053
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 759807 757760 370M EFI System
/dev/nvme0n1p2 759808 7051263 6291456 3G Linux filesystem
/dev/nvme0n1p3 7051264 495695871 488644608 233G Linux LVM
Disk /dev/mapper/fedora_devnuc1-root: 40 GiB, 42949672960 bytes, 83886080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora_devnuc1-swap: 8 GiB, 8589934592 bytes, 16777216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/zram0: 7.63 GiB, 8188329984 bytes, 1999104 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/fedora_devnuc1-opt_esco: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora_devnuc1-var: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora_devnuc1-home: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/fedora_devnuc1-data: 85 GiB, 91268055040 bytes, 178257920 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 7.5 GiB, 8053063680 bytes, 15728640 sectors
Disk model: UDisk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x39f5d30c
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 15726591 15724544 7.5G c W95 FAT32 (LBA)
That's a lot of information. I deliberately picked a difficult example to start with, because often times, you will see something like this.
fdisk -l ( lowercase L ) lists the disks I have in my system. In this case there are just two.
/dev/nvme0n1 and /dev/sda
What makes fdisk a little bit difficult to use, is that it also shows disk partitions. Usually, the most common disk types you will see
are /dev/sdX or /dev/nvmeXnX. Depending on what virtual machine software you are running, disks will sometimes show up as
/dev/vdX. If you have older hardware with spindle type disks, they might show up up as /dev/hdX. I do have a small portable computer
that has a MMC type drive that shows up as /dev/mmcX.
In the example above, I have a USB thumb drive plugged into one of the USB ports. These almost always show up as /dev/sdX.
Note: For sake of convention here, I'm using the character "X" as a placeholder. None of my drives are actually /dev/sdX but rather /dev/sda or /dev/sdb, and some cases /dev/sdc. Usually, the first drive the computer finds on its system hardware bus gets the letter "a" in the case of SSD and USB drives, or the number "0" in the case of nvme or mmc type drives.
The problem with USB thumb drives, is they play games with your mind and move around. For example.
My internal SSD drive shows up as /dev/sda. OK, so far so good. I plugged in a thumb drive to one of my USB ports and it shows up as /dev/sdb, I'm still good so far. and I plug in a third drive it shows up as /dev/sdc. all is as expected right?
But now turn my computer off, and tomorrow morning I turn the computer back on. All my drives got moved around.
My 16GB drive is now /dev/sdb and my 32GB drive is now /dev/sdc. What happened? Yes, the order you plug them in matters. But also
which port you plug them into can make a difference. This usually only matters if the computer is turned off. If the computer is already turned on, then the order I plug them assigns the drive letter. If the computer is turned off, the port I plug them into assigns the letter.
For example, USB port 1 will almost always get a lower letter than something plugged into USB port 2 or 3.
The point here is, always check. Don't assume the drive letters for a specific drive will always be the same. For internal fixed disk drives
on the system bus, you can assume they will always be the same.
.. to be continued.