Which hard drive have the OS
I have initially installed Ubuntu server 16.04 on the machine with 1 hard disk.
Some time later, I decided to add two more hard disks on the machine to provide more storage capability. All the three hard drives are identical, same size, brand...
So how can I find out which hard drive actually has the boot loader and OS? So that I can format the other two.
22 Answers
When the hard drives are physically identical it can be a little tricky. You can run commands such as lsblk, parted, and fdisk from the terminal to analyze the content and format of the drives.
Those commands takes parameters. This is a command I often use:
$ lsblk -o name,mountpoint,label,size,fstype,uuid | egrep -v "^loop"
NAME MOUNTPOINT LABEL SIZE FSTYPE UUID
sda 111.8G
├─sda1 Recovery 450M ntfs 4E98CBF598CBD99B
├─sda2 /boot/efi 100M vfat 90CE-9CE3
├─sda3 16M
├─sda4 24.5G ntfs 3874F30874F2C820
├─sda5 [SWAP] 7.8G swap c9334080-5716-4af6-8223-c2f7ab8b42be
└─sda6 / 79G ext4 183a59f8-4023-4204-bf16-ef9ab0c61c7e
sdb 115.7G
├─sdb1 1000M ext4 e6bf0b64-ef88-424e-9e2b-d8f397c009c8
└─sdb2 114.7G ext4 bd72b737-16e9-4c39-8b1e-610b8897a892
sdc 115.7G
├─sdc1 1010M
├─sdc2 /media/ljames/DFF1-8069 8.8G vfat DFF1-8069
├─sdc3 OS1 52.2G ext4 a13034ce-00a0-4bd2-8188-f780137413d7
├─sdc4 /media/ljames/verba1 verba1 44G ext4 248301e7-25c1-4fc6-8d98-6c96b5eaa284
└─sdc5 swap 9.8G swap a0fdc51f-79fd-4e77-a9f7-967384b56bc2The columns for identifying how the disks are used are as follows:
- NAME - This is the name of the drive. The
sdXwithout a number is the whole physical drive. The number after thesdXis the partition of the drive. - MOUNTPOINT - This is where the drive is mounted. This is the information you can use in your case. As long as you see which drives have their mounting points, mounted, you can use that to identify which drives you currently have in use. The one with the mounted point
/is mounted as root. - LABEL - The label is a description that you provide. This is also convenient for you to identify how you are using the partitions of the drive.
- SIZE - Obviously the size of the partition.
- FSTYPE - The partition type can help you to identify which OS or other components of the way it's formatted.
- UUID - This is convenient information for having a unique identification for being sure which drive you have mounted.
The Boot Loader:
In the case of my example, the bootloader is in the /dev/sda2 partition. A legacy bootloader is normally is located on reserved sectors of the drive. The bootloader can actually be on a USB drive or any other drive. The actual OS can be on a separate drive from the bootloader. It's most often on the same drive as the OS.
The OS:
The is always the root, and identified by /. FYI, it's possible to have symbolic links or actually separate links to partitions with the name of some of the OS folders, and having them mounted in the /etc/fstab.
So with this information, you can have a good idea of which drives or partitions to should be eliminated when formatting your drives, or any partitions of your drives.
By the way, I filtered out the loop devices to have a cleaner output. Recently there are many loop devices for Snap programs, which I already know have their data and installation files off the root (/) partition. The filter removes reduncancy which I wouldn't consder the most important in this case.
By default the installation will go to /dev/sda1, a partition on sda. Unless you have other disks, your two new disks will be /dev/sdb and /dev/sdc.
One way to verify this is to run the df command from a terminal.
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 2,0G 0 2,0G 0% /dev
tmpfs 396M 5,9M 390M 2% /run
/dev/sda1 30G 12G 17G 41% /In this example, notice that /dev/sda1 is mounted on / . The '/' is the root directory of the system.
Unless you have through either intent or mishap altered the default, your Ubuntu 16.04 system will be configured this way.