steps for how to convert a windows ntfs drive to linux btrfs
- navigate to the ntfs2btrfs repo
- download and install it for your OS. This guide will use Fedora. Open a new terminal
-
dnf install ntfs2btrfs- in root/sudo
-
- get the name of the ntfs partition to convert write it down if needed
-
lsblk -
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 3.7T 0 disk ├─sda1 8:1 0 1K 0 part └─sda5 8:5 0 931.5G 0 part ... - In this case I know that it is on the sda drive because it is the only drive with >3tb. if you need more information with the drive name, you can use the
-fcommand to get thelabelandUUID. Alternatively if you use the gnome-disk-utility to check with a graphical interface
-
- back up your drive data. I recommend rescuezilla the interface is a lot more approachable than clonezilla
- start ntfs2btrfs (in root/sudo), recall the name of the partition and replace
$partition_namewith the name from the previous step-
ntfs2btrfs /dev/$partition_name- in root/sudo
-
- wait for it to finish. the output should look like this
-
Using Zstd compression. Using CRC32C for checksums. Processing inode 153629 / 153629 (100.0%) Mapped 91054 inodes directly. Rewrote 0 inodes. Inlined 30767 inodes. Updating directory sizes Calculating checksums 219684372 / 219684372 (100.0%)
-
- install the winbtrfs driver following the instructions in the readme
additional steps/troubleshooting
The following steps are what I used to finish setting up/troubleshoot my 4tb drive
how do I expand my partition
- start by getting the partitions and available drives using
lsblkin a terminal session-
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 3.7T 0 disk └─sda1 8:1 0 1T 0 part /mnt/sda1
-
- based on the output we want to expand sda1 to the entire sda drive
- If your drive is > 2tb and is MBR, you’ll need to change the partition type to GPT
- ensure that gdisk is installed the command will change for your package manager
-
dnf install gdisk- in root/sudo
-
- run gdisk in root/sudo
-
gdisk /dev/sda GPT fdisk (gdisk) version 1.0.10 Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present *************************************************************** Found invalid GPT and valid MBR; converting MBR to GPT format in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by typing 'q' if you don't want to convert your MBR partitions to GPT format! ***************************************************************
-
- within the gdisk prompt, type
wand hit enter. This is what you should see-
Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N):
-
- respond to the command with
yand hit enter. When it finishes, it will return the following-
OK; writing new GUID partition table (GPT) to /dev/sda. The operation has completed successfully.
-
- ensure that gdisk is installed the command will change for your package manager
- with the table set to GPT, lets continue with
parted- ensure that parted is installed the command will change for your package manager
-
dnf install parted- in root/sudo
-
- run parted in root/sudo
-
parted /dev/sda -
GNU Parted 3.6 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands.
-
- confirm that you have the correct drive with
printwithin the parted shell-
(parted) print -
Model: ATA T-FORCE T253TY00 (scsi) Disk /dev/sda: 4097GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 1000GB 1000GB btrfs Linux filesystem
-
- if this looks like the correct drive, run the following command within the parted shell
-
(parted) resizepart 1 100%
-
- ensure that parted is installed the command will change for your package manager
whoops I deleted my partition
-
install testdisk for your OS. In my case it is Fedora
-
dnf install testdisk- in root/sudo
- the command will return
TestDisk 7.2, Data Recovery Utility, February 2024 Christophe GRENIER <[email protected]> https://www.cgsecurity.org TestDisk is free data recovery software designed to help recover lost partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software, certain types of viruses or human error. It can also be used to repair some filesystem errors. Information gathered during TestDisk use can be recorded for later review. If you choose to create the text file, testdisk.log , it will contain TestDisk options, technical information and various outputs; including any folder/file names TestDisk was used to find and list onscreen. Use arrow keys to select, then press Enter key: >[ Create ] Create a new log file [ Append ] Append information to log file [ No Log ] Don't record anything
-
-
using the arrow keys hover over the
[ Create ] Create a new log fileoption and hit enter to select it -
using the arrow keys hover over the disk that you accidentally deleted the partition on and hit enter to select it
-
you’ll be greeted with this menu
-
TestDisk 7.2, Data Recovery Utility, February 2024 Christophe GRENIER <[email protected]> https://www.cgsecurity.org Disk /dev/sda - 4096 GB / 3815 GiB - T-FORCE T253TY00 Please select the partition table type, press Enter when done. >[Intel ] Intel/PC partition [EFI GPT] EFI GPT partition map (Mac i386, some x86_64...) [Humax ] Humax partition table [Mac ] Apple partition map (legacy) [None ] Non partitioned media [Sun ] Sun Solaris partition [XBox ] XBox partition [Return ] Return to disk selection Hint: None partition table type has been detected.- using the arrow keys hover over to
[Intel ] Intel/PC partitionand hit enter to select it. If you are using a different partition type, make sure to check if the other partition types are relevant
- using the arrow keys hover over to
-
-
after selecting the partition type, you’ll be prompted with this menu
-
TestDisk 7.2, Data Recovery Utility, February 2024 Christophe GRENIER <[email protected]> https://www.cgsecurity.org Disk /dev/sda - 4096 GB / 3815 GiB - T-FORCE T253TY00 CHS 498074 255 63 - sector size=512 >[ Analyse ] Analyse current partition structure and search for lost partitions [ Advanced ] Filesystem Utils [ Geometry ] Change disk geometry [ Options ] Modify options [ MBR Code ] Write TestDisk MBR code to first sector [ Delete ] Delete all data in the partition table [ Quit ] Return to disk selection Note: Correct disk geometry is required for a successful recovery. 'Analyse' process may give some warnings if it thinks the logical geometry is mismatched.- using the arrow keys hover over to
[ Analyse ] Analyse current partition structure and search for lost partitionsand hit enter to select it.
- using the arrow keys hover over to
-
-
after selecting the partition type, you’ll be prompted with this menu
-
TestDisk 7.2, Data Recovery Utility, February 2024 Christophe GRENIER <[email protected]> https://www.cgsecurity.org Disk /dev/sda - 4096 GB / 3815 GiB - CHS 498074 255 63 Current partition structure: Partition Start End Size in sectors *=Primary bootable P=Primary L=Logical E=Extended D=Deleted >[Quick Search] [ Backup ]- using the arrow keys hover over to
[Quick Search]and hit enter to select it.
- using the arrow keys hover over to
-
-
let testdisk scan for the partitions
-
if the data is recoverable, you’ll see this menu
-
TestDisk 7.2, Data Recovery Utility, February 2024 Christophe GRENIER <[email protected]> https://www.cgsecurity.org Disk /dev/sda - 4096 GB / 3815 GiB - CHS 498074 255 63 Partition Start End Size in sectors >* Linux 0 32 33 121601 25 24 1953519616 [MassStorage] P HPFS - NTFS 121601 25 25 124032 144 16 39061504 P HPFS - NTFS 124032 144 17 131344 239 31 117473280- the first entry is the partition I am trying to recover, so using the arrow keys hover over to
>* Linux 0 32 33 121601 25 24 1953519616 [MassStorage]and hit enter to select it.
- the first entry is the partition I am trying to recover, so using the arrow keys hover over to
-
context
while working on the previous to expand my drive, I wanted to remove the ntfs partition. I didn’t realize that as part of the migration, the ntfs partition wasn’t cleared from the disks, so when I tried to remove it I accidentally deleted the btrfs partition.
background
I previously asked the community for a suggested file system that can be shared between windows and Linux. After reading through some of the suggestions and some additional research, I came to the conclusion that btrfs was the move.
why btrfs?
why btrfs specifically
I currently use Fedora 39 as my work/general browsing system and have a separate drive for windows to play games with friends. When Windows 10 reaches EOL, I plan to switch to linux for gaming as most of my library is on steam. Therefore, I need a file system that is currently compatible with both operating systems and will make the migration to Linux easier
why not NTFS
Although NTFS3g helps bridge the compatibility gap. I would prefer to a file system that is open and well supported on linux
why not exFAT
Initially, I was going to go with exFAT as, it has better compatibility between the two systems. However when I read the post about how exFAT is more prone to data corruption/loss, I changed my mind,
I didn’t read too much more but it seems that it is due to exFAT not having journals
https://old.reddit.com/r/editors/comments/6k3u4k/whats_the_problem_with_exfat/djj82k9/