17

I have a 2nd hard drive SDB but not sure how to mount it under linux.

mount -a did not seem to mount all.

Also would like to mount this RO for recovery.

migrated from serverfault.com Apr 11 '13 at 21:10

This question came from our site for system and network administrators.

  • How are you trying to mount it, what does your fstab look like, and what's the partitioning scheme? – tink Apr 11 '13 at 20:49
  • Permanently or just for temporary use? Also, has the drive been partitioned with fdisk and then formatted with newfs or mkfs? What type is the filesystem on the formatting? – mdpc Apr 11 '13 at 21:52
17

mount -a mounts all filesystems in /etc/fstab.

If the drive is not yet in fstab, then it will do nothing with regard to that drive.

First, check how the disk is partitioned (e.g. with fdisk -l (that is an lowercase L, not a number 1) or with another tool such as gpart.)

If your hard drive is an LVM, these instructions won't work, stop and follow these directions: https://superuser.com/a/666034/121698

Test things with a manual mount command. Example:
mount -t ext2 /dev/sdb1 /mnt.

The contents of the first partition should now be visible under /mnt.

Note that this assumed ext2 as file system. Adjust as needed.

Note that this assumed a /dev/sdb1, it could have been /dev/sdb2, sdb3, ...
There can even be multiple partitions on that disk. Adjust as needed.

If this works: umount /mnt and add a line to /etc/fstab. Easiest is to copy one of the existing lines and adjust it. Understanding just what those values mean is recommended, so look at the top for a line like this:
Device Mountpoint FStype Options Dump Pass#

Device is the device you are trying to mount/ E.g. /dev/sdb1
mountpoint is the directory where you want the folders to show up.
FStype is the filesystem type. E.g. ext2, ext3, ext4, fat, iso9660, ...
Options are FS options, such as rw for read write, or ro for read only.
Dump and pass are for recovery. Which disk needs to be fsck'ed? In which sequence etc.

Thus... choose where you want to mount the disk. For example in /home/old_backup. It that directory does not exist then make it. (e.g. mkdir /home/old_backup). If there are already content in that directory then realise that you will not see them anymore once you mount a disk in that location. (They will show up again after you umount it, and they will still use diskspace).

Now edit /etc/fstab and add the relevant lines.

#Device       Mountpoint          FStype  Options       Dump    Pass#
/dev/sdb1     /home/old_backup    ext2    ro              2       2      

Test with mount /home/old_backup.

The next time you boot or issue a mount -a it will be automatically mounted.

  • 3
    mount -a only mounts filesystems listed in fstab with the auto option set (which I believe is the default). Any filesystems listed as noauto won't be mounted automatically. – a CVn Apr 12 '13 at 8:52
  • 1
    Correct. Though I never saw that auto option used anywhere, ever. (The option ro,noauto though is familiar to me, back from the time that optical drives where used) – Hennes Apr 12 '13 at 8:53
  • 2
    That's probably because as I mentioned auto is almost certainly the default. – a CVn Apr 12 '13 at 8:55
  • to see the file system type and get a nice overview you can use lsblk -f – the.polo Nov 6 '17 at 8:35
1

First you need to make sure that you have a mount directory. /mnt is what I use. (if not mkdir /mnt) Then from there you need to make sure you are mounting to correct partition by issuing the command ls /dev, and verifying the device name. After you have done this you should be able to issue the command mount /dev/sdb2 /mnt

0

How to format and mount a disk permanently using its's UUID.

Find the disk name

sudo lsblk

This will show you a list of disks. Usually the first disk is vda and bootable. The second disk will be vdb, third vdc etc.

vda will typically be split in to multiple partitions, e.g. vda1 (/boot) and vda2 (/).

The new disk will have no partitions and no mountpoint.

Format the new disk

sudo mkfs.ext4 /dev/vdX

Where X is the correct letter for the disk.

The output will include the UUID of the disk, you will need this later.

Mount the disk

sudo mkdir /archive
sudo mount /dev/vdX /archive

This is only temporary and the mount will be lost on reboot.

Add mount to fstab

Add to /etc/fstab:

UUID=XXXX-XXXX-XXXX-XXXX-XXXX     /archive ext4 errors=remount-ro 0 1

You can find the UUID, if you didn't note it down earlier, with sudo blkid.

For more information on UUID's

Your Answer

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