I have a 1TB portable hard drive that I use for backups. The entire drive (/dev/sdb
) has been formatted as an ext4
filesystem.
I have been reading about the benefits of btrfs
for backups (checksums, self-healing, etc) and am considering converting this disk from ext4
to btrfs
.
I'm pretty sure I can still resize the disk (e2fsck -f /dev/sdb && resize2fs /dev/sdb 500G && fdisk /dev/sdb
, or thereabouts). However, I'm not sure how to "introduce" partitions to a device that didn't have partitions to start with.
Can this be done, and if so, how?
(Note that the filesystems themselves – ext4
, btrfs
, etc – are pretty much irrelevant – the question is purely about partitioning a device that was initially created without a partition – and doing so without losing the existing filesystem.)
Best Answer
Partition tables (at least in MBR or GPT style) live at the start and/or end of disks, so you can introduce them if you can free the required space.
Working with a terabyte disk, I would proceed as follows.
dd
or a similar tool.dd
or something similar. You’ll need to calculate the offsets and sizes based on what you did in step 2, but the target is easy (/dev/sdX1
).With a tool such as
ddrescue
which can copy in reverse, you could simplify this slightly:Given the amount of copying involved, it would be easier to back the data up somewhere else and restore it! You could limit the amount of copying by saving the start of the ext4 file system and restoring that followed by the rest of the data, but that requires more careful book-keeping.