Server Fault is a question and answer site for system and network administrators. 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 have a partition /dev/sdb1 and a partition /dev/sdb2

They are both in /etc/fstab with proper UUIDs and mounted as /opt and /home

I'd like to merge them without losing any files

Can this be done from the command line without having to move all the files?

share|improve this question
up vote 1 down vote accepted

Not that I'm aware of although you could delete one partition and resize the other:

Obviously for that to work you'd have to have enough space to store the data in one partition elsewhere however.

share|improve this answer

No, you'll have to move the files.

Even then you still have an issue: you'd have to mount the partition as "/home" and symlink "/home/opt" to /opt.

share|improve this answer

When you say merge, I take it you want to have one file system that can use all the space currently allocated to /opt and /home? The only "right" way I know how to do this is recreate the partitions, make them part of a LVM physical volume, and create a logical volume on top of it.

Do you just need to borrow space that's allocated to one and use it in the other? You can use mount --bind if you don't want to use symlinks.

share|improve this answer

Are you sure it is /dev/sdb and /dev/sdc? By convention /dev/sdb and /dev/sdc are individual disks and not partitions on a disk. Disk partitions typically have a number associated with them (i.e. /dev/sdb1, /dev/sdb2, /dev/sdc1, etc). You cannot merge partitions on separate physical hard drives, you have to move the data from one to the other.

As has already been said by others, it's not really possible to merge them. You'd have to move the data and resize the partitions appropriately.

share|improve this answer
Actually, you're right /dev/sdc is the usb device. – sal Apr 30 '09 at 18:57

You can't merge /opt and /home without also having one inside of the other.

For example /home -> /opt/home.

Then you could do ln -s /home /opt/home.

or better yet: mount --bind /opt/home /home

or fstab entry is: /opt/home /home none bind

I have actually added the following to my /etc/fstab file. (actually my real one uses the UUID of the partion instead of [/dev/sdb1])


/dev/sdb1    /share ext3  noatime,errors=remount-ro 0       1
/share/home  /home  none  bind
share|improve this answer
You can merge them, say moving /home to /opt/home and then ln -s /opt/home /home – Hamish Downer Apr 30 '09 at 20:56

This could work:

# copy files preserving attributes
cp -Rp /home /opt # --recursive --preserve

# comment out old /home entry
perl -pie'$_ = "#$_" if m[/home]' /etc/fstab 

# add a bind entry to the end of fstab
echo /opt/home  /home  none  bind >> /etc/fstab

# unmount both partitions
umount /home
umount /opt

# remove original /home partition
# resize /opt partition to use the freed space

# could also just restart here
mount /opt
mount /home

You will either need to append sudo to each line, or run as root   [sudo bash].

share|improve this answer

Merging is not feasible because some numbers, like inodes, are expected to be unique within a filesystem, but some will be repeated when you have two. Internal filesystem structures would conflict in the same way.

Absorbing a filesystem into another is theoretically feasible, but I don't think it has been attempted, because tools that cater to rare use cases have a higher risk of bugs, which can have fatal consequences. You would be required to make backups, and now that you have backups you don't need in-place conversion. If you wanted to implement this, the closest tool is btrfs-convert, which phagocites an ext4 filesystem by keeping both filesystems on the same partition, with the btrfs structures referring to the ext4 structures and copy-on-write ensuring that new files are btrfs-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.