2

I tried google and searching this site, didn't get very good answers.

I'm running 14.04.1 LTS. I have multiple 3.5" internal drives in my system with very important data on them. I'm only using one of them for ubuntu. I installed ubuntu hoping I could use it to play and mess around, without worrying about hurting the rest of my system.

In windows you can go to device manager, right click an internal drive, and click disable. Is there an equivalent in Ubuntu? I want it so that nothing can access the drives in any way until I manually re-enable them.

Thanks!

1

2 Answers 2

6

If the disks are SATA (the most normal thing; they are sda, sdb, etc.) you can do that two ways:

  1. After the boot, you can disable them. The "magic" is (as root)

     echo 1 > /sys/block/sdx/device/delete
    

    where sdx is your disk. This will make the device disappear. Notice however that if something triggers an update of udev the disks may reappear.

    Note also that the sdx denomination is not completely fixed; it can change especially if you add/delete disks to the system.

  2. At boot level, if you have a kernel with version 3.13 or newer. You need to identify the ATA address, which is a number like 4.00 (you can use dmesg | grep " ata") :

     ata4.00: ATA-8: ST2000DM001-1CH164, CC24, max UDMA/133
    

    and you can completely hide the disk with the boot parameter:

     libata.force=4.00:disable
    

    the disk will act as if it were not connected at all to the system.

  3. Another option is using udev rules as explained (I did not test) here. The difference in this case is that the disk devices are still there, but the disks are not mounted. In 99% of the case the result is the same, unless you are playing tricks with directly writing to the raw disk devices...

0

There's no integrated way that I know of (which needn't say anything, you can probably achieve this using udev rules). As a workaround, you could use something like this:

ls /dev | grep -P "^sd[^a].?$" | xargs -d"\n" rm

This command first lists all device files, then picks the drives from there (every drive except sda, sda1, ..., e.g. sdb). Those device files are then removed and thus can't be mounted any longer. This needs to be run as root. However, all USB sticks mounted at that time will be thrown away, too. If this happens, just replug them.

You could set this to be run at system startup.

Not the answer you're looking for? Browse other questions tagged .