Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm fairly new to Ubuntu (I'm using 12.04) and I am looking for a way to make it so that when I boot from my USB stick the internal HDDs of the computer I'm using dont mount. I would also like to know if there is a good way to force all mounts to default as read only.

share|improve this question

You need to edit /etc/fstab of the booting system. To have your HDD not automounted when you but from USB stick, add one line for each partition, such as:

/dev/hda1 / auto noauto 0 0

To have it mounted in readonly mode:

/dev/hda1 / auto ro 0 0

A complete manual for fstab is here, otherwise just google around!

share|improve this answer
Will this work if you don't know how many partitions there will be or what their filesystems are ahead of time? – Ryan Jun 27 '12 at 23:08
All partitions should be listed in fstab to be mounted. You can't add wildcards or refer to all present partitions with a single line but you could not list anything: in this case nothing will be mounted. – jasmines Jun 28 '12 at 4:33

You may find it best to use udev rules to ignore the HDD you want to ignore.

From this serverfault answer:

As root, open up /etc/udev/rules.d/60-persistent-storage.rules with your favorite text editor.

A few lines down, you'll probably see a line that looks like this:

# skip rules for inappropriate block devices KERNEL=="ram*|loop*|fd*|nbd*|gnbd*|dm-*|md*", GOTO="persistent_storage_end" Add "sdb*" to that second line, so it looks like this:

KERNEL=="ram*|loop*|fd*|nbd*|gnbd*|dm-*|md*|sdb*", GOTO="persistent_storage_end" Save the file and then reboot.

ErikA didn't have his system available to test this advice, and unfortunately I'm using a friends computer myself.

Many devices are now discovered by udev rather than relying on /etc/fstab, and that includes hard disks. Note that you may have to change sdb to the device you want to ignore (sda ?)

The udev man page has more information on udev rules, including how to change device permissions, which may be a good way to make such a device read-only.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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