Is there a way to mount multiple partitions, or even all partitions, of a disk with a single command in Linux? Is there, perhaps, an option that the mount command accepts that would facilitate this? I'm running Fedora 18; if I try mount /dev/sda* /media/sda* the operation fails.

Alternatively, can you suggest a script that I could put together for all my future uses?

I've come across some potentially useful posts that mention writing udev-rules; I'm not sure if that would be useful, though, since (as far as I know) the partitions on my main HDD already have those set up - which is evident by looking at the sidebar-list of accessible drives/partitions within my file manager.

To clarify, I'm simply trying to do something like '/dev/{sda1,sda2,...}', where each one of those would be mounted to their own directory with the same name.


First of all, a partition can be mounted to multiple locations.

And for your own purpose, I doubt mount itself supports so. But you could definitely use your own script,


for x in $*; do
    echo mount "$x" "/media/${x##*/}"

And launch it with (Remove the echo before running it)

./XX.sh /dev/sda* /dev/sdb*

P.S: you should consider udisks, which would mount the partition to /media/label_of_drive

  • thank you warlock, and thanks to cinelli as well, I will look into udisks...it sounds like that's what I'm looking for! :D – ILMostro_7 Mar 18 '13 at 2:38

The mount command will only map one device at a time, so whatever method you choose will have to call mount for each partition.

/proc/partitions will give you a list of what's detected:

# cat /proc/partitions
major minor  #blocks  name

   8        0 1465138584 sda
   8        1 1465134488 sda1
   8       32 1465138584 sdc
   8       33 1465134488 sdc1
   8       16 1465138584 sdb
   8       17 1465134488 sdb1
   8       48 1465138584 sdd
   8       49 1465134488 sdd1
   8       64  156290904 sde
   8       65      96358 sde1
   8       66    4000185 sde2
   8       67          1 sde3
   8       69    2000061 sde5
   8       70   14996646 sde6
   8       71  135197527 sde7

This is where fdisk -l gets its information. You could use this to do something like:

awk '$4 ~ /^sda[0-9]+/{print $4}' /proc/partitions | while read dev; do
    if findmnt /dev/$dev >/dev/null; then
        echo "/dev/$dev is already mounted.  Skipping."
    elif findmnt /media/$dev >/dev/null; then
        echo "/media/$dev is already a mount point.  Skipping /dev/$dev."
    mount /dev/$dev /media/$dev
  • Wealth of information in this answer. For simplicity, however, I selected the simple for loop answer. The background information in here, along with the awk scripting details, makes this an answer worth exploring for anyone interested in how mount works. Additionally, as always, the man-pages are a must-read. – ILMostro_7 Oct 1 '18 at 16:40

If you're going to be booting the partitions at boot then you could add them to /etc/fstab. man fstab to see what all the different options are for the rows inside the configuration file. The columns should be organized as follows.

<file system>   <dir>   <fs-type>   <mount-options>   <dump> <pass>

If you are not going to be mounting them then look into using udisks or udiskie. You cannot mount two partitions to the same directory. You can mount one inside a sub-directory of an already mounted device though.

  • I'm not trying to mount them into a single directory, more like their own sub-directories within the /media/ folder: /dev/sda* /media/sda* ; also, I'm trying to chroot into them while mounted...but it's more of a general question, I suppose, about mounting multiple partitions without having to do a separate command for each partition; kinda like mount /dev/{sda1,sda2,...} or something like that. – ILMostro_7 Mar 18 '13 at 2:28
  • You either have them auto mount at boot in fstab or systemd.units (man systemd.mount, or you have the auto mounted upon being plugged in wish udisks. Or you have them auto mount upon access with x-systemd.automount. Other than that you're stuck to typing commands. Also, you should be mounting any additional partitions from inside the chroot. Only the partitions that you need in order to chroot` should be mounted outside the chroot. – cinelli Mar 18 '13 at 5:36

Backup of current fstab:

#cp -a /etc/fstab /etc/fstab.bk

process the output of lsblk -f using sed and awk and redirect output to fstab:

#lsblk -f|sed 's/\[SWAP]/swap /g'|awk '/(-)/{printf"UUID=%-36s %-23s %-7s defaults 
           0 0\n", $3, ($4==""?mnt"NR:$4), $2}'>/etc/fstab

Your Answer

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

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