349

I found a 6 GB IDE HDD in my basement. I want to plug it in and see what might be on it. The drive seems to be recognized in BIOS.

I can't find it in Ubuntu to view files, and Ubuntu is the only OS on that particular computer. I was wondering if Ubuntu has an equivalent to the Windows feature "My Computer", which lists all available drives/storage devices. Typically, My Computer shows C:, which can be opened to view all of your directories and files. At this point, it is very similar to Ubuntu's Home Folder.

How to view/select all available partitions of that drive or all available HDD's without formatting or tampering with the contents in any way?

Pro Backup
  • 3,248

12 Answers12

599

There are many ways but my favorite is lsblk. Here is a demonstration:

sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

That would show the following:

NAME   FSTYPE   SIZE MOUNTPOINT LABEL
sda           111.8G            
├─sda1 swap     121M [SWAP]     
└─sda2 ext4   111.7G /          
sdb             2.7T            
└─sdb1 ext4     2.7T            xtreme
sdc             3.7T            
└─sdc1 ext4     3.7T            titan

It is showing:

  • The name of the drive and the partitions it has.
  • The type of file system.
  • The size the whole drive has and the size each partition has.
  • The mount point and if available, the label for them.

You can play around with the options by first looking at the ones available with lsblk --help. I like lsblk because of the friendly way of showing the information if compared for example with fdisk or parted.

Eliah Kagan
  • 119,640
Luis Alvarado
  • 216,643
107

The command-line solution:

  • to check which drives your system can see:

    sudo fdisk -l
    

If your drive is in the list, you'll be able to see what partitions are on the drive, like this:

Disk /dev/sda: 160.0 GB, 160041885696 bytes
...

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      208844      104391   83  Linux
/dev/sda2          208845     2313359     1052257+  82  Linux swap / Solaris
/dev/sda3         2313360   312576704   155131672+  83  Linux

Then create a directory somewhere and mount one of the partitions. For example, to mount a FAT32 partition located at dev/sda3 read-only into directory /media/my_test_mount you can do

sudo mount -t cifs -o ro /dev/sda3 /media/my_test_mount

This approach gives you more control, as you can use different mount options, for example mount the partition read-only.

See man mount for details.

Sergey
  • 44,353
32

I second Luis in that lsblk(8) is probably the most straightforward and concise solution. It's very easy to visualize what is there and gives you all of the information needed quickly:

sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL

For your convenience, here is a list of all available columns that can be used.

Available columns:
       NAME  device name
      KNAME  internal kernel device name
    MAJ:MIN  major:minor device number
     FSTYPE  filesystem type
 MOUNTPOINT  where the device is mounted
      LABEL  filesystem LABEL
       UUID  filesystem UUID
         RO  read-only device
         RM  removable device
      MODEL  device identifier
       SIZE  size of the device
      STATE  state of the device
      OWNER  user name
      GROUP  group name
       MODE  device node permissions
  ALIGNMENT  alignment offset
     MIN-IO  minimum I/O size
     OPT-IO  optimal I/O size
    PHY-SEC  physical sector size
    LOG-SEC  logical sector size
       ROTA  rotational device
      SCHED  I/O scheduler name
    RQ-SIZE  request queue size
       TYPE  device type
   DISC-ALN  discard alignment offset
  DISC-GRAN  discard granularity
   DISC-MAX  discard max bytes
  DISC-ZERO  discard zeroes data
Dan
  • 14,180
Philip
  • 433
  • 4
  • 6
11

Use the following command lines, that together will give you a good overview of the partitions (location, sizes, free space and mount points),

df -h
sudo parted -ls
sudo lsblk -f
sudo lsblk -m

If your terminal window is wide enough (for example 130 characters), you can combine the lsblk commands to

sudo lsblk -fm
sudodus
  • 47,684
8

To list the hard drives/disks, I use

sudo parted -l

Output:

Model: ATA Samsung SSD 850 (scsi) 
Disk /dev/sda: 250GB 
Sector size (logical/physical): 512B/512B 
Partition Table: msdos

Number  Start   End    Size   Type      File system  Flags  
 1      1049kB  256MB  255MB  primary   ext2         boot
 2      257MB   120GB  120GB  extended  
 5      257MB   120GB  120GB  logical   lvm


Model: Linux device-mapper (linear) (dm) 
Disk /dev/mapper/ubuntu--vg-swap_1: 8573MB 
Sector size (logical/physical): 512B/512B 
Partition Table: loop

Number  Start  End     Size    File system     Flags  
 1      0.00B  8573MB  8573MB  linux-swap(v1)


Model: Linux device-mapper (linear) (dm) 
Disk /dev/mapper/ubuntu--vg-root: 111GB 
Sector size (logical/physical): 512B/512B 
Partition Table: loop

Number  Start  End    Size   File system  Flags
 1      0.00B  111GB  111GB  ext4

And then to list the partitions as other people have already suggested you can use:

sudo lsblk -f

Which will tell you the file system partition types

wjandrea
  • 14,504
Layke
  • 1,379
6

Nautilus (where you view your home folder) will show all mounted drives on the system. If the drive is recognized by the computer you can mount it and begin to use it.

Directions and information about mounting drives can be found here: https://help.ubuntu.com/community/Mount

Histo
  • 401
4

The solution below is very easy, clear, a GUI approach and it shows you exactly what you have laid out on your HDD:

  1. Go to: "System tools" in your main launch list
  2. Launch "GParted"
  3. Enter your password (should be your log on password if you are the admin.) You will be shown your HDD layouts, partitions sizes and amounts used.
  4. Quit the GParted application

CAUTION: Do not change ANYTHING unless you know what you are doing!

Fabby
  • 35,017
Auderus
  • 41
3

I have created some regex to help those who want to read this data into some application.

To do that, The lsblk command it is more usefully when you use the "-P" command. Here a example:

$ lsblk -P -o KNAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL
KNAME="sda" FSTYPE="" SIZE="80G" MOUNTPOINT="" LABEL="" MODEL="VBOX HARDDISK   "
KNAME="sda1" FSTYPE="" SIZE="243M" MOUNTPOINT="/boot" LABEL="" MODEL=""
KNAME="sda2" FSTYPE="" SIZE="1K" MOUNTPOINT="" LABEL="" MODEL=""
KNAME="sda5" FSTYPE="" SIZE="79.8G" MOUNTPOINT="" LABEL="" MODEL=""
KNAME="dm-0" FSTYPE="" SIZE="79G" MOUNTPOINT="/" LABEL="" MODEL=""
KNAME="dm-1" FSTYPE="" SIZE="768M" MOUNTPOINT="[SWAP]" LABEL="" MODEL=""
KNAME="sr0" FSTYPE="" SIZE="1024M" MOUNTPOINT="" LABEL="" MODEL="CD-ROM          "
KNAME="sr1" FSTYPE="" SIZE="1024M" MOUNTPOINT="" LABEL="" MODEL="CD-ROM          "

You can read this output usign some regex like

/KNAME=\"(.*)\" FSTYPE=\"(.*)\" SIZE=\"(.*)\" MOUNTPOINT=\"(.)*\" LABEL=\"(.*)\" MODEL=\"(.*)\"/g

http://regex101.com/r/uX5eG3/1

If you don't need the size of the partition, you can use the mount -l to

$ mount -l
/dev/mapper/precise32-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sda1 on /boot type ext2 (rw)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
/vagrant on /vagrant type vboxsf (uid=1000,gid=1000,rw)

And read it using some Regex like that

/(.*) on (.*) type (.*) \((.*)\)/g

http://regex101.com/r/nE4pQ9/1

If you are doing that in node, you can convert the string into a array of occurrences using some code like

stdout.split("\n").map(function(x){return x.split(/(.*) on (.*) type (.*) \((.*\))/g)}); 
3

(building on previous advise in regards to lsblk).

For the lazy typist (and if you don't need the sizes) you can use:

sudo lsblk -f

which is same as using -o NAME,FSTYPE,LABEL,MOUNTPOINT

for example

NAME                 FSTYPE             LABEL MOUNTPOINT
sda
└─sda1               ntfs             TOSHIBA
sdb
└─sdb1               LVM2_member
  └─root-root (dm-0) ext4                     /
Jack
  • 31
  • 1
1

Late answer but try this:

  1. Open files (Application from dash or open a folder)
  2. Go to "File System"
  3. Go to "media"
  4. Go into your user E.g. Lola Chang (From Ubuntu.com)
  5. It should list all attached drives, not including the SDA 1 (In your case probably C:)
Braiam
  • 69,112
0

Simply install gparted:

sudo apt update
sudo apt install gparted

This can perform all actions graphically.

Nmath
  • 12,664
0

I've made my own script to have only the wanted data shown for any type of partitions for:

  • raid "type"
  • ext volumes and partitions
  • lvm volumes and partitions

It shows shows UUID, PARTUUID and mount points for each. Here is the link to it: https://github.com/wingarmac/diskinfo

Output format (based on my own devices):

# (The following headings are color-coded when running in your terminal:)
# Main title is in lighter blue, subtitles in light blue,
# RAID info in light green, and LVM info in red.

DISK INFO ______________

Standard disks and partitions: ______________________________

volume: nvme1n1 Size: 119,2G └─ /dev/nvme1n1p1: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

volume: nvme1n1 Size: 119,2G ├─ /dev/nvme1n1p2: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/mnt/OS-BOOT Size: 59G Left: 43G

volume: nvme1n1 Size: 119,2G ├─ /dev/nvme1n1p5: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/mnt/LANSHARE Size: 40G Left: 38G

volume: nvme1n1 Size: 119,2G ├─ /dev/nvme1n1p7: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/mnt/SECOND-MOUNT Size: 18G Left: 17G

volume: nvme0n1 Size: 465,8G ├─ /dev/nvme0n1p1: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/mnt/VIRT Size: 458G Left: 395G

volume: nvme2n1 Size: 465,8G ├─ /dev/nvme2n1p1: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/boot/efi

volume: nvme2n1 Size: 465,8G ├─ /dev/nvme2n1p2: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/boot Size: 2G Left: 2G

RAID DISK INFO ______________

RAID: raid0 RAID Device: /dev/md126 Members: /dev/sda,/dev/sdb Partition: /dev/md126p1 Size: 931,5G ├─ UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/home/USERNAME Partition Size: 916G Free: 663G

LVM DISK INFO ______________

Volume: nvme2n1 Size: 465,8G ├─ /dev/nvme2n1p1: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/boot/efi ├─ /dev/nvme2n1p2: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/boot └─ lvm2: VG_NAME Size: 462,7G ├─ /dev/VG_NAME/swap: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=[SWAP] ├─ /dev/VG_NAME/OS_ROOT: UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX └─ MOUNTPOINT=/ Size: 448G Left: 360G

The script has being updated on 05-03-2025 and now gives raid details separated with type, members, mountpoints. By the way all mount points show total size and size left for any type of configurations.

Tools used for it:

lsblk Lists block devices, showing relationships between disks, partitions, and mount points.

blkid Identifies block devices and displays attributes such as UUID, PARTUUID, and filesystem type.

pvs Shows physical volumes used by LVM (Logical Volume Manager).

lvs Lists logical volumes within an LVM volume group.

mdadm Manages software RAID arrays, providing detailed status and configuration options.

df Displays filesystem usage information, including total size and free space on mounted partitions.

wingarmac
  • 111