Combining partitions - (including root and swap)

  • Thread starter Thread starter Deleted member 9563
  • Start date Start date
D

Deleted member 9563

Guest
I plan to add a new drive for my root system. After I install that I was hoping to take the unused partitions on the old drive with my /home directory and combine them into a useful partition. Here is the current setup:

Code:
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/ada1p2     19G     15G    3.0G    83%    /
devfs          1.0K    1.0K      0B   100%    /dev
/dev/ada1p4     19G    381M     17G     2%    /tmp
/dev/ada1p5     31G    7.8G     21G    27%    /usr
/dev/ada1p6    9.7G    1.7G    7.2G    19%    /x
/dev/ada1p7    362G    243G     90G    73%    /home
/dev/ada0p1    891G    553G    267G    67%    /home/archive
procfs         4.0K    4.0K      0B   100%    /proc
fdescfs        1.0K    1.0K      0B   100%    /dev/fd

The /dev/ada0 is a terabyte drive for archival and backup. It will be left as it.

On /dev/ada1 I would like to take p1, p2, p3 (swap), p4, and p5, and combine them into /home/user/stuff or similar.

Can this be done? I assume that gpart can do this, thus leaving me with only two partitions - /home and /home/user/stuff.

This would leave me with the original /home intact. And yes, I do have a backup should I need to go that route.[/file]
 
Minimum requirement is a root partition to boot from.
And it is a wise idea to separate data from the OS.

Not sure if that is within your thoughts.
 
Thanks for answering getopt. Yes, I understand the requirements. That is not the question. :) The OS will go on another drive (which I'm adding first). I want to remove the OS from this drive and use those partitions with a simple gpart delete followed by a gpart create with whatever the switches might be.
 
Chances are that you may combine p1 to p5 into a new partition. The point is that you can combine only adjacent partitions and depending on the history of the disk some partitions may not be adjacent, even if the p-serials suggest that they are. Another consideration is that the data on the partitions that you are going to join will be lost.

Verify with gpart show the partition scheme of ada1.

Using gpart(8), you would first delete each single partition which you want to join, and after all deletions follows one single add command.

I assume this is a GPT partition scheme, and in this case the delete command is gpart delete -i X adaY and you need to replace the X with the actual index, and you would repeat this command for each index from 1 to 5. Y is the number of the respective device identifier. Be very careful with the indece and the device number. Do verify this with gpart show and repeat gpart show after each delete command. If you accidentally submit a wrong command, then you may loose data. You said, you got a good backup and that is a good start already.

The final gpart show command then should exhibit a large free block, and you would add a new partition into this free block using the add command. The first column of that free block listing entry gives the base address <BASEADDR>, and the second column informs its size <PARTSIZE>. If you are concerned in 4k alignment, then you would calculate an aligned base address like so:

<BASEADDR_4k> = floor(<BASEADDR>*512/4096 + 0.99)*4096/512
<PARTSIZE_4k> = <PARTSIZE> - (<BASEADDR_4k> - <BASEADDR>)

With that the actual add command would be: gpart add -b <BASEADDR_4k> -s <PARTSIZE_4k> -t freebsd-ufs adaY

Again, please verify each step using gpart show. You may want to post that output before you begin, and we can perhaps give more educated suggestions.
 
Hi obsigna I just got to the point where I'm actually doing this - having had a fight with KDE and fretted over partitioning and adding an SSD with the OS. I now deleted the useless partitions and realized that It might be wise for me to ask for help with the actual command needed. I can see where this could go very wrong if I mess it up. ;) Here is the output of gpart show.

Code:
=>       34  976773101  ada2  GPT  (466G)
         34  171967488        - free -  (82G)
  171967522   20971520     6  freebsd-ufs  (10G)
  192939042  783834092     7  freebsd-ufs  (374G)
  976773134          1        - free -  (512B)

As you see, that gained me 82G. I'm assuming it's best to make the new partition a little less, say 80G. I'm not concerned with 4K alignment for this partition. In such case, is this the right command?
Code:
gpart add -b 171967488 -s 80G -t freebsd-ufs ada2
 
... I now deleted the useless partitions and realized that It might be wise for me to ask for help with the actual command needed. I can see where this could go very wrong if I mess it up. ;) Here is the output of gpart show.

Code:
=>       34  976773101  ada2  GPT  (466G)
         34  171967488        - free -  (82G)
  171967522   20971520     6  freebsd-ufs  (10G)
  192939042  783834092     7  freebsd-ufs  (374G)
  976773134          1        - free -  (512B)

As you see, that gained me 82G. I'm assuming it's best to make the new partition a little less, say 80G. I'm not concerned with 4K alignment for this partition. In such case, is this the right command?
Code:
gpart add -b 171967488 -s 80G -t freebsd-ufs ada2
The -b flag in the suggested command is not correct, 171967488 is the size of the free space in terms of count of 512B blocks: echo "171967488*512/1024/1024/1024" | bc = 82 GB.

I suggest to start the new partition on a block count of -b 40 (even if you don't care about 4k alignment, let it go for the sake of good order), and with that the size would be -s 171967482. I cannot imagine any benefit in leaving a magin of 2 GB between the new partition and p6, I never did it.

While there, I suggest to already assign a gpt label for the new partition using the -l flag, for example morehome. You can later use that label /dev/gpt/morehome instead of the device identifier in fstab or in respective manual mount(8) commands.

gpart add -b 40 -s 171967482 -t freebsd-ufs -l morehome ada2

For adding labels to p6 and p7, you could use gpart(8) with the modify directive. For example:
gpart modify -i 6 -l x ada2
gpart modify -i 7 -l home ada2
 
obsigna Thanks for the detailed information and setting me straight. That worked very well and I now have exactly what I had hoped for.

Also, I had expected the partition to eat up some space for formatting, but of course that's not happening at this point. So yes, the 2GB idea is wrong here.
 
Back
Top