LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-07-2024, 04:07 PM   #1
Jackson111
LQ Newbie
 
Registered: Jul 2019
Posts: 28

Rep: Reputation: Disabled
Encrypted Disk


Hello,

I have a Linux desktop, with an added encrypted backup disk. There was no OS installed there whatsoever, just ext2, and the files on top of it. I was unmounting it after use.

Yesterday, I found out the disk was nowhere to be seen in the Nautilus. I checked via lsblk, and it was in the /sdb. Upon closer inspection, i found out that there was nothing to mount, as there was no file system there any more, and all the space was considered UNALLOCATED!

Basically, the disk was wiped clean somehow. The subsequent test concluded that disk was otherwise OK.

What could have happened? I don't consider myself so clumsy to wipe it out just like that without noticing.

Is there a possibility that the Windows partition on the same Desktop could have done it? I couldn't prevent it from updating recently. Strangely, on the disk that got wiped there was also a 16 MB Windows partition.

As I don't have much experience with encrypted disks, some input would be appreciated!

Last edited by Jackson111; 05-07-2024 at 04:12 PM.
 
Old 05-07-2024, 10:40 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
The encryption is not the problem here. Post this output (using [code] tags)
Code:
sudo parted /dev/sdb "print free"
If it was simply the partition table being erased, testdisk will likely be the best way to recover your partition.

Last edited by syg00; 05-07-2024 at 10:42 PM. Reason: typo
 
Old 05-07-2024, 11:02 PM   #3
Jackson111
LQ Newbie
 
Registered: Jul 2019
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
The encryption is not the problem here. Post this output (using [code] tags)
Code:
sudo parted /dev/sdb "print free"
If it was simply the partition table being erased, testdisk will likely be the best way to recover your partition.
sudo parted /dev/sdb "print free"
Model: ATA ST4000DM004-2CV1 (scsi)
Disk /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 17.4kB 16.8MB 16.8MB Microsoft reserved partition msftres
16.8MB 4001GB 4001GB Free Space
 
Old 05-07-2024, 11:24 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
Code:
sudo parted /dev/sdb "print free"
Model: ATA ST4000DM004-2CV1 (scsi)
Disk /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name                          Flags
 1      17.4kB  16.8MB  16.8MB               Microsoft reserved partition  msftres
        16.8MB  4001GB  4001GB  Free Space
Code tags make it much more readable.
The reserved partition shouldn't have been formatted with a filesystem, so you might be in luck - what does this show ?.
Code:
 lsblk -f
 
1 members found this post helpful.
Old 05-07-2024, 11:45 PM   #5
Jackson111
LQ Newbie
 
Registered: Jul 2019
Posts: 28

Original Poster
Rep: Reputation: Disabled
It just shows that there is sdb1 on sdb

Zero other info (like filesystem etc)

Last edited by Jackson111; 05-07-2024 at 11:47 PM.
 
Old 05-08-2024, 01:21 AM   #6
lvm_
Member
 
Registered: Jul 2020
Posts: 961

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
What's you primary concern - recover the data or find out what has happened? If the former, use testdisk. The are other ways, but this one is probably the safest. But if the latter, can't help you especially if windows is involved.
 
Old 05-08-2024, 02:08 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
if you are lucky only the gpt/mbr was overwritten and probably you can restore it. Otherwise windows do not make things like this "just for fun". Did you boot windows at all?
In linux the name of the disk sometimes changes, it can be /dev/sdb, /dev/sda or probably something else.
 
Old 05-08-2024, 04:26 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
What now worries me is that lsblk should be aware of LUKS, even on a truncated partition like the current /dev/sdb1. If the magic bytes are missing, then the header might have been trashed. Without a (separate) backup of the header the data would be lost in that case.

If the encryption was something other than LUKS, I've no experience.
 
Old 05-08-2024, 11:37 AM   #9
Jackson111
LQ Newbie
 
Registered: Jul 2019
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thanks everybody for the great input!

I would like to gain understanding in what had happened, but also to recover the data.

It IS concerning that the LUKS encrypted partition got wiped out. I will try the Testdisk to see if something can be done, but I just wonder what may have happened. The encrypted disks are not erasable just like that.

Admittedly, I don't have too much experience with LUKS. The partition has been created over a year ago, and I actually may have initially formatted disk as FAT. Can that play a role?
 
Old 05-08-2024, 05:21 PM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,783

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Quote:
Originally Posted by Jackson111 View Post
The encrypted disks are not erasable just like that.
Actually, they are. If you overwrite any part of the master key salt or the material in the keyslot, the data is unrecoverable unless you saved a backup of the LUKS header.
Quote:
The partition has been created over a year ago, and I actually may have initially formatted disk as FAT. Can that play a role?
Does "initially" mean before or after you set up the LUKS encryption? If before, then it would not be relevant.

About your only chance now is if testdisk can identify a LUKS header**, perhaps somewhere other than the current start of partition 1. If so, note that testdisk has no way to determine the size of the LUKS partition, as there is nothing in the LUKS header to indicate that, and testdisk will assume a size just large enough to hold the LUKS header. You should create a new partition at the determined starting point and of maximum possible size.

**You can also use a hex editor to search the disk for a sector beginning with the ASCII characters "LUKS" followed by the hex bytes "BA" and "BE" (total of 6 bytes). Doing that will avoid testdisk's assumptions about the reasonable starting locations for a partition.

Last edited by rknichols; 05-08-2024 at 05:28 PM.
 
Old 05-08-2024, 05:50 PM   #11
Jackson111
LQ Newbie
 
Registered: Jul 2019
Posts: 28

Original Poster
Rep: Reputation: Disabled
Although I know how to create an encrypted partition from the Terminal, I did it from the GUI, just for the sakes of having the mainstream settings, which would play well with removing the disk and opening elsewhere. As I said, I am not very experienced in that field.

I will have time to run all the great suggestions in peace over weekend, and I hope that I get to recover the data. It is not critical, as nothing will get lost forever, but I'd have to go through a variety of backups and restore some stuff manually. What I might lose forever though would be some GoPro metadata, that apparently gets lost when saving in their cloud (as many users say).

One last thing that bothers me is this:

Microsoft reserved partition msftres

Created by the Nautilus, or some violent overwriting via the Windows update on other partition? I wonder, as I haven't seen it before.

Thanks again everybody!
 
Old 05-08-2024, 08:22 PM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
No, that would be Microsoft in action, I meant to mention that earlier. Never seen it clobber an already existing disk without asking tho'.
 
Old 05-09-2024, 12:54 AM   #13
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
I wonder if they zeroed it out .... ugh. Try this; if it returns a single line of zeroes, I'm afraid your data is probably lost.
Code:
sudo dd if=/dev/sdb1 count=2 | hexdump
 
Old 05-09-2024, 03:26 PM   #14
Jackson111
LQ Newbie
 
Registered: Jul 2019
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
I wonder if they zeroed it out .... ugh. Try this; if it returns a single line of zeroes, I'm afraid your data is probably lost.
Code:
sudo dd if=/dev/sdb1 count=2 | hexdump

IT DIDN'T!

Thx!!!!!!
 
Old 05-10-2024, 03:27 PM   #15
Jackson111
LQ Newbie
 
Registered: Jul 2019
Posts: 28

Original Poster
Rep: Reputation: Disabled
TestDisk 7.1, Data Recovery Utility, July 2019
Christophe GRENIER <grenier@cgsecurity.org>
https://www.cgsecurity.org

Disk /dev/sdb - 4000 GB / 3726 GiB - CHS 486401 255 63
Partition Start End Size in sectors
>P Linux filesys. data 1046287267 1053821026 7533760 [^K~M27n1ҥ %~JMM-7D]



Structure: Ok. Use Up/Down Arrow keys to select partition.
Use Left/Right Arrow keys to CHANGE partition characteristics:
P=Primary D=Deleted
Keys A: add partition, L: load backup, T: change type,
Enter: to continue
cramfs, 3857 MB / 3678 MiB


Any suggestions while I am going through the manual?

Last edited by Jackson111; 05-10-2024 at 04:27 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I have an encrypted HD and a non-encrypted HD in the same computer? grumpyskeptic Linux Mint 1 02-15-2017 05:21 PM
LXer: Two Tips to Keep Your Phone's Encrypted Messages Encrypted LXer Syndicated Linux News 0 05-02-2016 11:21 PM
Shrink partition (LVM encrypted PVs + encrypted LVs) gedaj Linux - Newbie 2 05-22-2013 03:44 AM
Resizable encrypted LVM requiring just one password on boot (encrypted volume group)? Nyyr Linux - Software 9 01-24-2013 05:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 02:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration