1

My ubuntu laptop has died, and so I am attempting to recover some files off the hard drive using a raspberry pi. I have removed my laptop's hard drive and attached it to my raspberry pi via usb. I am now trying to figure out how I can cd into it to view my files.

online, various forums say to use sudo fdisk -l but this apparently cannot read GPT. When I run the command, a message says "The util fdisk doesn't support GPT. Use GNU Parted."

Gparted is a graphical application. I would like a way to do this using the terminal alone.

I do not wish to modify the hard drive, only read from it.

How can I do this and access my files?

Update: So I figured out sudo parted -l outputs

Model: ST500LT0 32-1E9142 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size    File system     Name  Flags
 1      1049kB  538MB  537MB   fat32                 boot
 2      538MB   492GB  491GB   ext4
 3      492GB   500GB  8483MB  linux-swap(v1)

I want to cd into the 492GB partition. I tried sudo mount /dev/sda2 /mnt but that gives me

mount: wrong fs type, bad option, bad superblock on /dev/sda2,
missing codepage or helper program, or other error

Any ideas as to what I'm doing wrong?

  • 1
    parted is different from gparted. Have you tried to have a look? – Rui F Ribeiro Jun 17 '17 at 19:55
  • "parted -l" isn't printing anything out for some reason – quantumbutterfly Jun 17 '17 at 21:20
  • 1
    What does sudo file -s /dev/sda? print? – Gilles Jun 17 '17 at 22:25
  • See the edit to my question. parted - l wasn't printing anything because I wasn't using sudo – quantumbutterfly Jun 17 '17 at 22:28
  • What happens when you do fsck -N /dev/sda2 (the -N prevents it from changing anything, which is a bad idea if the file system is corrupted)? Does it complain about errors? – dirkt Jun 18 '17 at 13:07
1

Using parted is fairly straightforward. The man page doesn't give examples but it's quite readable. Really. Here's a safe example for you:

parted /dev/sdb unit MiB print

Once you have this information you still need to mount the various filesystems.

mkdir /mnt/part              # Adjust to suit
mount /dev/sdb1 /mnt/part    # You might need /dev/sdb2, /dev/sdb3, etc.
cd /mnt/part
...
cd
umount /mnt/part

These will be read/write mounts. If you want to mount read-only then include the -r flag - mount -r /dev/sdb1 /mnt/part, etc.

  • okay, so "sudo parted -l" outputs Model: ST500LT0 32-1E9142 (scsi) Disk /dev/sda: 500GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 538MB 537MB fat32 boot 2 538MB 492GB 491GB ext4 3 492GB 500GB 8483MB linux-swap(v1) I want to access the 492GB volume. I try "sudo mount /dev/sda2 /mnt" but that says "mount: wrong fs type, bad option, bad superblock on /dev/sda2, missing codepage or helper program, or other error" What am I doing wrong – quantumbutterfly Jun 17 '17 at 21:31
  • @quantumbutterfly yes, on all block devices. You asked for one so I gave you options for one. – roaima Jun 17 '17 at 21:34
  • okay, I tried to comment the error this is giving me, but comments don't support formatting or line breaks, so I edited it into my main question. – quantumbutterfly Jun 17 '17 at 21:41
0

You can use sgdisk utility, sgdisk supports GPT.

To list the partition table

  sgdisk -p /dev/<dev-node>
  • how do I install sgdisk? – quantumbutterfly Jun 17 '17 at 21:06
  • You can try Ubuntu MATE, you can use the apt package manager to install sgdisk. – sob Jun 17 '17 at 21:17
  • Alternatively, if you can, build your own sgdisk from sources. – sob Jun 17 '17 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.