r/linuxquestions • • 8d ago

How to isolate my usb linux system

I have a debian based system and i want to isolate the system in a way it doesnt have a chance to interact with my main ssd
Now i have 2 scary solutions either to air gap my ssd which is pain in the ass and doing so daily could break something and second solution is to block tge pci from bios now i dont have the settings to do so i found an open source solution but it may brick my device 2 risky approaches

8 Upvotes

40 comments sorted by

5

u/Drate_Otin 8d ago

More information required:

  1. Links to these approaches you're considering.
  2. Details on your stated goals. The whole point of an operating system is to act as an interface between you and your hardware. I'm guessing you're wanting to dual boot and keep one SSD as visible only to one of your operating systems? If so... what is it you're worried about Debian doing to that other SSD that air gapping and such is required to prevent it?

1

u/BMW-E60-535i 8d ago

Well i have a usb that im going to load debian based os on all i need is that os should not interact with my main os on my ssd so i thought a out making a wall between both its for security reasons

1

u/fuldigor42 8d ago

Against normal users: just don’t mount it
Against Rroot: encrypt your ssd , that’s it. Very simple.

1

u/BMW-E60-535i 8d ago

It is encrypted im afraid it deletes it

1

u/fuldigor42 8d ago

If availability is your only concern, than just do backups as you should do anyway (like 3-2-1 strategy). That’s a normal risk. There is no 100% security. You are overthinking it.

1

u/BMW-E60-535i 8d ago

Mabye i should use arch to overthink freely😂😂

1

u/Drate_Otin 8d ago

Are you doing things that make that a likely outcome?

In any case, links to these methods you're considering would still go a long way here.

1

u/BMW-E60-535i 8d ago

Im not sure if i will do but if i do i want to make sure im safe

1

u/Drate_Otin 8d ago

Links to these methods you're considering would go a long way here.

3

u/serverhorror 8d ago

The only way to achieve that with guarantees is to nit have the SSD attached to the device.

Just buy a second cheap device or find a way to make the removal easier.

0

u/BMW-E60-535i 8d ago

Im afraid with all of this pulling and putting back possibly breaking screws breaking those tiny slot holders they feel very brittle plus it very hard to remove my ssd would take at least 20-30 mins

4

u/serverhorror 8d ago

Then buy a different device with a separate disk.

You're not adding security, you're only adding complexity

3

u/realddgamer 8d ago

Yeah like others said, either unplug it or if you just want to prevent reads then have it encrypted.

Though this seems silly anyways. If your goal is security then don't do anything that would compromise your security on debian

1

u/BMW-E60-535i 8d ago

What other distors you recommend?

1

u/realddgamer 8d ago

For what purpose? Generally all distributions are equally secure. I was telling you to always use good security practices

1

u/BMW-E60-535i 8d ago

Malware analysis

1

u/DudeEngineer 8d ago

Why????

1

u/BMW-E60-535i 8d ago

Idk probably bored

1

u/DudeEngineer 8d ago

You are so bored that you are willing to risk bricking your device?

3

u/realddgamer 8d ago

You probably want to do that in a virtual machine. If you're worried about the (very rare) case of malware that can escape virtual machines then you want to do it on a burner laptop/the likes

2

u/kbeezie Fedora/uBuntu/Debian 8d ago

You want an isolated virtual machine. Don't do those kind of things on a system you care about. If you can't afford to lose something, don't do it.

2

u/CardOk755 8d ago

Is your "main SSD" encrypted? If not, why not?

If it was your "USB Linux" system couldn't read your "main SSD".

If you're worried about your "USB Linux" writing to your "main SSD" then run it in a VM.

1

u/BMW-E60-535i 8d ago

It is encrypted and im pretty skeptical about vms just not convinced that sandboxing is this safe

3

u/Drate_Otin 8d ago

Skeptical about VM's?! I don't even know where to start. Sandboxing is hardly even the right term here. They exist in completely emulated hardware. They have their own BIOS. What is it you believe is going to happen?

It sounds like you need to spend some time learning what you're using in a controlled environment. Stress test what you're worried about but without anything attached that you're worried about losing. Attach only what you can afford to destroy... Then go nuts. See if you can break out of your VM or see if Debian randomly destroys anything without your permission. Press all the buttons. Then when you've gotten a handle on how things work you'll know what's safe and what's not.

1

u/CardOk755 8d ago

You're skeptical about a technology that has been used for over 50 years to protect host machines from guests. Ok.

Just get another machine. Nothing else will make you feel safe.

1

u/victormas208 8d ago

It's a very new concept for me; besides security, what's the advantage? Stability or a requirement for a project?

2

u/BMW-E60-535i 8d ago

My main goal is security nothing else

1

u/meijad 8d ago

If the debian system is on an SSD and not a NVMe and in a desktop computer, you could do something like a sata power selector (Hard disk control system) to keep the drive unpowered when in the other OS/drive. Or wire together your own togglable disconnect. Or just reach in and disconnect the drive when not used.

1

u/BMW-E60-535i 8d ago

Well my ssd is connected to the board i dont think any hardware related thing would solve cuz even my bios is very limited

1

u/BCMM 8d ago

You could remove the nvme and/or ahci kernel modules from your live environment, so the kernel won't know how to talk to SSDs. Make sure they're gone from the main filesystem and from the initramfs.

You'll need to manually do this again every time you upgrade the kernel, or find a way to automate it.

Important note: if you're just trying to protect against your own honest mistakes, this might be useful. If this is supposed to be protection against potentially malicious software that you intend to test, this is a bad idea (and your whole approach is also a bad idea).

1

u/BMW-E60-535i 8d ago

It is for a malicious software what better idea can you come up with and why is this one bad

1

u/BCMM 8d ago

It is for a malicious software what better idea can you come up

First of all, not intentionally running malicious software unless you're absolutely sure you know what you're doing!

Secondly, a VM.

and why is this one bad

Not difficult to reinstall the kernel module and then load it. A similar problem is going to apply to any other idea that just involves configuring your live environment.

Additionally, the SSD is not the only non-volatile storage on your real hardware.

1

u/chuggerguy Linux Mint 22.3 Zena | MATÉ 8d ago

I have a total of five internal devices that I was able to hide when booting to my USB mirror. Normally booting a USB mirror automounts all five devices just like I was booting to my internal device.

The image was taken while booted to the USB for a one time test. Notice that no other devices appear either in the disks app or lsblk.

cat etc/udev/rules.d/99-hide-all-devices-except-usb.rules 

SUBSYSTEM=="block", ENV{ID_BUS}=="ata", ENV{ID_PATH}!="*usb*", RUN+="/bin/sh -c 'echo 1 > /sys/%p/device/delete'"
SUBSYSTEM=="block", KERNEL=="nvme*[0-9]n*[0-9]", ENV{ID_PATH}!="*usb*", RUN+="/bin/sh -c 'echo 1 > /sys/block/%k/device/../../remove'"

I have no reason to do that but maybe that's what you're after?

Myself, I'd probably just not allow them to automount if I were worried but that's just me.

Disclaimer, although I have hidden devices by a single UUID before, I used Gemini to expand it to hide ALL internal devices.

Have fun.

2

u/BMW-E60-535i 8d ago

Hmmm this is actually very nice btw gemini proposed an idea where i can block modules during booting you actually lightened us to a new level
Thx :)

1

u/ThellraAK 8d ago

What's the goal?

If it's write protecting the drive, add the windows drive to your fstab, and mount it read only somewhere only root can you touch it.

1

u/BMW-E60-535i 8d ago

But can root write it?

1

u/ThellraAK 7d ago

Not if it's mounted read only.

You would need to unmount it and mount it again with a separate command to be able to write to it.

Not something that could happen by accident.

2

u/inbetween-genders 8d ago

Do the pain the the ass one 👍 

1

u/levelZeroWizard 8d ago

By turning it into a vm disk and running it with whatever vm manager. You can pass through whatever hardware you need

My question is what on earth problem do you have that requires any of this? Are you fighting ultron or something?

1

u/mredding 7d ago

The best way to do this is to disable the whole SATA controller via boot parameters. Get the device ID for your SATA controller with lspci -nn | grep -i sata. Then, append to the end of GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub:

modprobe.blacklist=ahci pci-stub.ids=<Controller device ID here>

Update GRUB: sudo update-grub.

If you want to use the SATA controller and you just want to unbind this one device, then first find the device ID with lsblk -o NAME,SERIAL. Create a file /etc/systemd/system/unbind-sata.service, and put this in it:

[Unit]
Description=Unbind specific SATA SSD by serial number
DefaultDependencies=no
Before=local-fs-pre.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c 'for dev in /sys/block/sd*; do serial=$(udevadm info --query=property --path="$dev" | grep "^ID_SERIAL_SHORT=" | cut -d= -f2); if [ "$serial" = "<SATA device ID here>" ]; then scsi_id=$(basename $(readlink "$dev/device")); echo "$scsi_id" > /sys/bus/scsi/drivers/sd/unbind; fi; done'

[Install]
WantedBy=sysinit.target

Then run the commands:

sudo systemctl daemon-reload
sudo systemctl enable unbind-sata.service
sudo systemctl start unbind-sata.service

Either way, reboot and verify.

The result should be the same, your USB Linux environment will come up and ignore either the SATA controller or the specific drive. You cannot do better without either disabling the device in the BIOS, or physically removing it from the machine.

And the other thing to know is this is us using the OS, opting-in to ignoring the device. You can always load the device after booting, we didn't lock ourselves out entirely; so this is only good for preventing accidental access, it's not security from a determined user.