5

I have 2 HDD installed in my PC. One of them is empty (I just added it) and the other one contains everything else.

Output from fdisk:

root@*****:~# sudo fdisk -l  
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors   
Units: sectors of 1 * 512 = 512 bytes   
Sector size (logical/physical): 512 bytes / 512 bytes    
I/O size (minimum/optimal): 512 bytes / 512 bytes    
Disklabel type: dos   
Disk identifier: *****   

Device     Boot Start     End   Sectors  Size Id Type  
/dev/sda1  *     2048 209715166 209713119  100G 83 Linux


Disk /dev/sdb: 100 GiB, 107374182400 bytes, 209715200 sectors  
Units: sectors of 1 * 512 = 512 bytes  
Sector size (logical/physical): 512 bytes / 512 bytes   
I/O size (minimum/optimal): 512 bytes / 512 bytes  
Disklabel type: dos  
Disk identifier: ******

So the system is on /dev/sda. How can i merge the old HDD with the new one so i get a 200GB /dev/sda partition?

4
  • Just out of curiosity... is this a physical system or VM? I ask because 100GB drives are relatively ancient.
    – RonJohn
    Dec 26, 2017 at 19:50
  • @RonJohn The size reported by fdisk is 100 x 2^30 bytes to the byte. That feels much more like a VM disk image than a physical drive, though of course it could still be a physical drive.
    – user
    Dec 26, 2017 at 20:49
  • @MichaelKjörling but then, OP specifically writes "My PC", which sounds pretty "physical"...
    – RonJohn
    Dec 26, 2017 at 21:01
  • @RonJohn Yeah, I know... it's odd, and hopefully we'll get clarification soon.
    – user
    Dec 26, 2017 at 21:04

1 Answer 1

11

Sorry, but there's no such thing as merging two HDDs.

What you can do is use LVM to create a volume group which contains both disks, and then create a logical volume that's ~200GB. Roughly-speaking, the steps boil down to the following:

  1. Back up your /dev/sda1
  2. Familiarize yourself with how your boot loader is currently configured (ex. GRUB2) and ensure there's a way for it to boot from LVM. For example, GRUB2 can boot from LVM, but you'll likely need a GRUB partition to do so.
  3. Re-partition /dev/sda according to what you learned in step 2. For example, you may need a small partition for GRUB2 and the rest can be dedicated to LVM. You don't need to partition /dev/sdb.
  4. Create two LVM physical volumes, one on each disk. For example, pvcreate /dev/sda2 && pvcreate /dev/sdb
  5. Create a volume group which contains the two physical volumes. Ex: vgcreate vg0 /dev/sda2 /dev/sdb
  6. Create a logical volume for your filesystem. Ex: lvcreate -ay -l 100%FREE --name rootfs vg0
  7. Format your new filesystem. Ex: mkfs.ext4 /dev/vg0/rootfs
  8. Restore your backup to /dev/vg0/rootfs
  9. Mount /dev/vg0/rootfs and modify the /etc/fstab so that the "/" filesystem is mounted from /dev/vg0/rootfs.
  10. You may have to reconfigure your boot loader so it knows where to find the Linux kernel in your LVM logical volume.

As you may have guessed, /dev/vg0/rootfs is essentially your two HDDs merged.

5
  • 4
    This needs a BIG caveat in that any kind of combining or striping across multiple storage devices typically means that if either storage device breaks, you lose all your data. I don't know about LVM specifically, but very few RAID 0 type systems handle that case gracefully, and many don't handle it at all.
    – user
    Dec 26, 2017 at 19:28
  • 1
    @MichaelKjörling by it's very nature, RAID 0 (aka striping) can't handle it gracefully.
    – RonJohn
    Dec 26, 2017 at 19:48
  • 1
    @RonJohn Depending on the implementation, partial data recovery may be possible after losing a portion of a RAID 0 array. If it's truly striped then data recovery is unlikely; but if it's a concatenation of devices, partial data recovery may very well be possible. Either way, it's something one should be aware of.
    – user
    Dec 26, 2017 at 20:47
  • @MichaelKjörling, LVM uses concatenation. If you want some other method of grouping drives (eg. RAID 0), it has to take place at a lower level.
    – Mark
    Dec 27, 2017 at 1:03
  • btrfs can also be used to append two or more drives....and ext4 can be easily converted to btrfs (warning: backup first is very strongly recommended).
    – cas
    Dec 27, 2017 at 2:09

You must log in to answer this question.

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