3

History:

My laptop came with a Windows 7 OS installed, with a single partition (C:). I made a secondary partition out of that C: drive and installed Linux Mint in the second drive. I installed Linux Mint using bootable USB and selected "Something else". I made a separate /, swap, and /home out of the second partition. Therefore, making a dual-boot.

Now, I wanted to go Linux full time. I deleted/removed the Windows partition using Gparted. Then after that, I clicked the unallocated drive and made a new partition in which I renamed Data mounted at /mnt/Data (highlighted in the screenshot). Please see attached screenshot from Gparted.

enter image description here

Now, my question is: is it possible to merge /dev/sda2 to my /home partition (which is /dev/sda7 under /dev/sda3)? I wanted to make that "Data" partition included in the /home so that I will just have a single partition. "Data" partition does not contain any data at since I just created that last night.

jdee025
  • 31
  • 1
  • 3

4 Answers4

2

The best solution might be to go with LVM, but sadly it look that you didn't go for it at install time. If you feel confident enough you can, in the same time, convert /dev/sda2 to LVM by creating a base LVM volume (if there is no data on it), then move you data from one old volume /home to the LVM volume, then extend your LVM with the freed space from /home. This move could have been avoided with the help of LVM, So next time you'll remember to use it :-).

so all in one without reboot.

  1. backup /home (just for security)
  2. it appear to me that you don't have data on /dev/sda2, so with fdisk mark /dev/sda2 as LVM (8e but double check)
  3. pvcreate /dev/sda2
  4. vgcreate newvg /dev/sda2
  5. lvcreate -n newhome newvg
  6. mkfs -t ext4 /dev/newvg/newhome
  7. mount /dev/newvg/newhome /mnt
  8. mv /home/. /mnt/.
  9. umount /home (better be logged as root)
  10. mount /dev/newvg/newhome /home
  11. modify /etc/fstab so it mount /dev/newvg/newhome as /home
  12. with fdisk /dev/sda set sda7 as 8e
  13. pvcreate /dev/sda7
  14. vgextend newhome /dev/sda7
  15. lvextend -l +100%VG /dev/newvg/newhome
  16. resize2fs /dev/newvg/newhome et voila.
dominix
  • 610
  • I will try your suggestion after I backed-up my /home folder. Just a question, does your solution the same as of the answer provided by @SACHIN GARG? I have no knowledge about LVM. – jdee025 Aug 22 '16 at 07:26
  • I have done such modification many time. I am very confident on this sequence but I highly recommend that you read some howto about LVM and get used of the documentation. It is important as a user that you understand what append. – dominix Aug 22 '16 at 18:26
0

I am not sure that you will be able to use gparted for this because you are planning to merge 2 non-contiguous partitions.

As I see, you are not really using a lot of your hard disk space. Now that you are comfortable with using Linux, may I suggest that you switch your system to using the Logical Volume Manager (LVM) which can help you solve all these problems. The best would be to re-install your system by using LVM - am not sure if Mint provides that.

See: https://askubuntu.com/questions/3596/what-is-lvm-and-what-is-it-used-for for a discussion of LVM.

If you do not want to go the whole hog, you can just put your /home on LVM.

The following is a very brief set of steps that you would need to follow. You can search for detailed instructions on the Internet.

  1. Backup your home directory - you can do that on a flash drive or an external HDD.
  2. As you would be touching your home directory and rebooting the computer multiple times, you may face problems logging in as yourself. To avoid these problems you can unlock the root account by setting a specific password. The way to do that is simply sudo passwd root and set an easily memorizable, but tough password. Also, it may be good to use a rescuecd like that from http://www.system-rescue-cd.org and burn it on USB drive.
  3. Reboot the computer. Using fdisk change the type of partition of /dev/sda2 and /dev/sda7 to 8e (Linux LVM) from 83 (linux).

    fdisk  /dev/sda
    Welcome to fdisk (util-linux 2.28.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command
    
    Command (m for help): t
    Partition number (1-3, default 3): 2
    Partition type (type L to list all types): 8e
    
    Changed type of partition 'Linux LVM' to 'Linux LVM'.
    
    Command (m for help): w
    

    Do the same for partition 7

  4. Now reboot again to get the kernel to read your partition table and login as root. If using sysrescucd, it automatically logs in as root.

  5. Create a physical volume (PV) on /dev/sda2 and /dev/sda7 using pvcreate. Again please see the resources linked in this post etc.
  6. Create a Volume Group (VG) and then a Logical Volume (LV) called "home" which you can then install with any filesystem of your choice.

I prefer ext4 and now xfs because they allow for online re-sizing of the file system. The advantage of online re-sizing is that I do not have to umount the filesystem to extend it, and also while extending the logical volume, one can pass in a flag to resize the fielsystem.

  • @jdee025: just saw your comment to @b-janis. Considering the constraints, I do not think it is possible as pointed out in the linked answer: cannot merge primary & extended partitions. Would strongly suggest you to follow the LVM route. – SACHIN GARG Aug 22 '16 at 04:06
  • I will try your and the suggestion of @dominix after I backed-up my /home folder. But since I never encountered LVM (this is my first time to encounter such word), does the "detailed" instruction was the one provided by dominix or your suggestions different? – jdee025 Aug 22 '16 at 07:24
  • @dominix provides a very nice way of doing things in one go, taking advantage of the fact that your /dev/sda2 is larger than your used /home. However, you need to be logged in as root - not sudo. Before trying what we suggest, read up on LVM, especially on its concept of "physical volume", "volume group" & "logical volume". – SACHIN GARG Aug 22 '16 at 11:40
  • @dominix: from a quick Internet search it seems Linux Mint does not allow installation using LVM, which is a pity. – SACHIN GARG Aug 22 '16 at 17:21
0

Back up the Linux then reformat the entire drive to make one large drive then write your backup into the larger partition. Test the backup on another drive if you are unsure of your software skills.

Bixbyte
  • 17
0
  1. Right click the free space partiton and "delete" it.
  2. Then right-click the target space you are going to resize: "resize"
  3. drag the boundary of your target space!

For reference: resize tutorial

skytree
  • 101