You are not logged in.

#1 2025-06-30 20:25:09

entbratschrader
Member
Registered: 2025-06-30
Posts: 1

how do i format a drive with the exception of 1 partition?

I want to switch from Mint to Arch, but i dont want to lose my /home file. I have a seperate partition for my home file, so how can i format the whole drive without losing that partition?

Offline

#2 2025-06-30 21:00:00

seth
Member
Registered: 2012-09-03
Posts: 65,812

Re: how do i format a drive with the exception of 1 partition?

This does conceptually not exist - you partition drives and "format" partitions.
The latter more or less just means to create a new filesystem on the partition, it will start out empty.
(If there were any security concerns you could first dd /dev/null or /dev/urandom onto the partition to wipe old data fragments but I guess that's not a concern here since you keep the drive)

Pay very close attention to the device nodes, sda, sdb etc. are not stable identifiers. Make sure you're operating on the correct drive.


If you actually want to repartition the drive and keep the contents of a partition, but not the partition in its current location but move it on the drive, things get dicy and your chances to screw this on manual attempts are great, which is why you best use gparted, https://wiki.archlinux.org/title/Parted
There's also a live distro that ships gparted.
And even then, you're very well served by HAVING A BACKUP OF YOUR DATA

Online

#3 2025-07-01 05:40:19

SimonJ
Member
From: Alicante, Spain
Registered: 2021-05-11
Posts: 252
Website

Re: how do i format a drive with the exception of 1 partition?

I just want to add, you need a backup before you start, it is very easy to make a mistake, even with GUI tools, if you are not sure one small mistake can mean data loss.

Backup first!

I once lost several thousand music files because I was working on the wrong drive, luckily I am old enough that I still had the CD's and could rip them again but it was tedious and very annoying.

Last edited by SimonJ (2025-07-01 05:42:24)


Rlu: 222126

Offline

#4 2025-07-08 02:41:58

foobarDestroyer
Member
Registered: 2025-07-08
Posts: 9

Re: how do i format a drive with the exception of 1 partition?

entbratschrader wrote:

I want to switch from Mint to Arch, but i dont want to lose my /home file. I have a seperate partition for my home file, so how can i format the whole drive without losing that partition?

- https://man.archlinux.org/man/cfdisk.8

Refer to command: d

Delete the current partition. This will convert the current partition into free space and merge it with any free space immediately surrounding the current partition. A partition already marked as free space or marked as unusable cannot be deleted.

Assuming the partition layout resembles something akin to the following:

Partition A: EFI/MBR
Partition B: Platform (Arch Linux)
Partition C: Home/User data

You should be able to invoke d on partitions: A and B; this will of course cause partition C to stay where it is at, but have Nth space before it's assigned sector block.

You could optionally remove all partitions (minus the desired one to keep), create a partition at the end of the disk (EG: (End of disk - Home/User data partition) = New partition B), move everything from partition A (Home/User data) to partition B, delete partition A and then proceed to create partitions A, C and D (EFI/MBR, Arch Linux, new home/user data, respectively) and then finally clean up (delete/remove partition B at the very end of the disk).

In list form (from above):

  1. Delete EFI/MBR partition

  2. Delete platform/Arch partition

  3. Create a partition after home/data and fill the remainder of the disk (size of home/data partition = A; end of disk = B; create a new partition beginning at sector (B - A))

  4. Move/Copy partition A to newly created partition B (now at the end of the disk)

  5. Delete partition A

  6. Create your new disk layout (EFI/MBR, platform/arch, home equal to or greater than "partition B's" size)

  7. Move "partition B's" data to the new Linux home data partition (now partition "C")

Math simplified:
Current home partition is at sector #5000 of #25,000; home spans 2500 sectors; create a new partition beginning at #25,000 - #2500 (which starts at sector #22,500); your new home partition now fits perfectly at the end of the disk; this allows for a total disk volume of: 100% disk space - home partition size (say: 5%); because it is at the end: You can work with the disk until you bump into the old home partition (then sacrifices must be made).

Conceptually: This is how 'disk defragmenters' function.
You shift data from bucket/partition A to bucket/partition B and rearrange your structural layout.

Alternatively: Invest $5 USD into a 100GB USB device and copy /home data to it (cp -a) and reformat/repartition (wipefs) the disk. smile

Last edited by foobarDestroyer (2025-07-08 02:54:47)

Offline

#5 2025-07-08 09:14:39

lvsl
Member
Registered: 2024-08-22
Posts: 13

Re: how do i format a drive with the exception of 1 partition?

entbratschrader wrote:

I want to switch from Mint to Arch, but i dont want to lose my /home file. I have a seperate partition for my home file, so how can i format the whole drive without losing that partition?

Edit: I don't want to say that. but don't follow the guy above my post. While you can read it to your hearts content and use anyone's idea as a reference, the above post is just error prone, confusing, and make almost no sense.

I'll give you an outline on what you can do here:

The simplest solution here is to install your Arch linux seperately and leave your seperate partition where your data is located alone. Then later use fdisk -l to check where the data partition is, eg something like /dev/sdaX (X is a number), and then modify /etc/fstab to have that partition mounted to your home directory (/home/YourOwnUserName).

I highly recommended you, however, before tampering with your computer, backup your whole data partition somewhere else safe where you cannot easily erase it by mistake. For example, a thumb drive big enough to store them. Or even better, a hard disk or ssd that is seperated from your pc where you can plug it out and put it elsewhere physically. Example is an external hard drive

Here's a sample coming from my virtual pc. As you can see, the partition /dev/vda2 is mounted to the root directory. You can add an entry that looks similar to this one, using either its UUID, which is in here the case, or you can replace UUID with /dev/vda2 to get the same results. Although, generally, using UUID of the partition is preferred.

# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/vda2
UUID=7308471a-dd62-4298-92b2-8cd446bfd35a	/         	ext4      	rw,relatime	0 1

# /dev/vda1
UUID=5B69-A882      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

Last edited by lvsl (2025-07-08 09:29:08)

Offline

Board footer

Powered by FluxBB