Introduction
This article will guide you through the process of transferring a Debian installation from a smaller SATA drive to a larger drive, while maintaining BIOS booting on your computer. We will cover the key concepts of MBR partitioning, the differences between BIOS and UEFI booting, and provide detailed instructions for transferring your Debian installation. By the end of this article, you will have successfully moved your Debian system to a larger drive, preserving its BIOS booting capabilities.
Understanding MBR Partitioning and Debian Installation
When you installed Debian on your smaller SATA drive, the Debian installer determined the partitioning scheme for you, using the Master Boot Record (MBR) method by default. MBR partitioning is a legacy partitioning method that has been widely used for many years. It allows up to four primary partitions or three primary partitions and one extended partition. Each primary partition can be formatted and used as a separate drive, while the extended partition is used to hold logical partitions. The MBR itself contains the boot loader for the operating system.
# fdisk -l
Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x12345678
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 195359999 194858242 92.7G 83 Linux
/dev/sda3 195360000 390702899 195342900 93.1G 83 Linux
BIOS vs. UEFI Booting
UEFI, or Unified Extensible Firmware Interface, is a newer firmware interface that is gradually replacing BIOS in modern computers. UEFI provides several advantages over BIOS, such as faster boot times, better security, and support for larger drive sizes (beyond 2TB). However, UEFI also has a different way of handling boot loaders and partitioning schemes. It uses the GUID Partition Table (GPT) instead of MBR. To maintain BIOS booting, we will continue to use MBR partitioning.
Transferring Debian from a Smaller SATA Drive to a Larger Drive
Now that we understand MBR partitioning and the difference between BIOS and UEFI booting, let's move on to transfer the Debian installation to a larger SATA drive. We will assume that you have already connected the new drive to your computer.
- Backup your data: Before proceeding, make sure to backup any important data from both the smaller and the larger drive. This will ensure that you don't lose any valuable information.
- Identify the drives: Use the following command to identify the drives:
# fdisk -l
Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x12345678
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 195359999 194858242 92.7G 83 Linux
/dev/sda3 195360000 390702899 195342900 93.1G 83 Linux
Disk /dev/sdb: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x9abcdef0
- Copy the data: Use the
ddcommand to create a block-by-block copy of the smaller drive to the larger drive.
# dd if=/dev/sdb bs=4M status=progress- Resize the partition: The larger drive now has the exact copy of your Debian installation from the smaller drive. To utilize the entire space of the larger drive, you need to resize the partition. We will use the
fdiskcommand to delete the partition on the larger drive and recreate a new bigger one.
# fdisk /dev/sdb
Command (m for help): d
Partition number (1,2, default 1):
Partition 1 is deleted
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-7814037167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-7814037167, default 7814037167):
+93G
Created a new partition 1 of type 'Linux' and of size 93.7 GiB
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
- Check the filesystem: After resizing the partition, use the
e2fsckcommand to check the filesystem.
# e2fsck -f /dev/sdb1
e2fsck 1.44.1 (24-Mar-2018)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 19513623/61034496 files (0.8% non-contiguous), 156362136/244199321 blocks
- Resize the filesystem: Use the
resize2fscommand to resize the filesystem to use the entire partition.
# resize2fs /dev/sdb1
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/sdb1 is mounted on /mnt/5e4debd8-1832-4b2c-bc21-cc2dee5e5a94; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/sdb1 is now 245730304 (4k) blocks long.
You've successfully transferred your Debian installation from a smaller SATA drive to a larger drive, preserving its BIOS booting capabilities. By following the detailed instructions provided and understanding key concepts like MBR partitioning and BIOS vs. UEFI booting, you've ensured a smooth transition and have a better understanding of your Debian system. Some references for further reading include: