Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Dual boot Debian and Windows + copy Debian O/S to new laptop

Ask for help with issues regarding the Installations of the Debian O/S.
Message
Author
ticketman
Posts: 136
Joined: 2012-06-30 11:06
Has thanked: 3 times

[Solved] Dual boot Debian and Windows + copy Debian O/S to new laptop

#1 Post by ticketman »

NOTE : A summary of this thread is at my post dated 2021-11-22

I have a laptop with a RTX3060 graphics card, currently booting Windows Home.
I want to move my debian 11 installation that is on another PC to the laptop (and make it dual boot Windows and Debian).

I have discovered that I need Debian 12 (bookworm) in order for Debian to run on this laptop.

So my plan is to upgrade my current PC installation to bookworm (Debian testing) and save the partition containing the debian 12 O/S onto removal media using fsarchiver.

I then plan to use the debian 12 installer to install debian as dual boot on the laptop, then overwrite the debian O/S partition on the laptop with the one from the PC using fsarchiver (I expect I will have to reset the nvidia debian graphics driver on the laptop).
Both the laptop and the PC use GPT for their system discs.

My problem is this:
In order to copy the saved O/S partition from my PC onto the laptop, I need to boot the laptop with a live Linux distribution that supports fsarchiver. Unfortunately the latest version of system rescue disk (8.05) will not boot on the laptop becuase the rescue disk does not have an officially signed O/S certificate (and I don't want to turn off secure boot). I have tried the latest ubuntu live disc,(21.10) which boots ok, but this does not have fsarchiver on it.

I have considered using dd instead of fsarchiver to save the partition, but the partition is over 160GB and dd will try to save all of that instead of just the files occupying it.

Do you guys have a solution?

Is there a way to get the system rescue disk (https://www.system-rescue.org/) to boot on a system that has secure boot enabled? (otherwise the rescue disk isn't going to be of much use in rescuing anything!).

Thanks!
Last edited by ticketman on 2021-12-07 12:39, edited 3 times in total.

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Copy O/S partition to new laptop

#2 Post by LE_746F6D617A7A69 »

First of all, You don't need fsarchiver or system rescue disk to copy/backup the OS - those are just convenient wrappers for tools that are included in every linux distro.

To copy/move the entire os file by file, there are 2 options:

Code: Select all

> rsync -axHAWXS --numeric-ids --info=progress2 / <destination path>
#or
> cp -ax / <destination path>
See also man dd if You want to move whole partitions.

By using pipes, it's also possible to create a compressed file system image.

Regards
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: Copy O/S partition to new laptop

#3 Post by CwF »

I use qemu-img, a super dd.
If you relocate just a partition, you'll need to adjust the boot loader.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Copy O/S partition to new laptop

#4 Post by p.H »

ticketman wrote: 2021-11-14 19:26 I then plan to use the debian 12 installer to install debian as dual boot on the laptop, then overwrite the debian O/S partition on the laptop with the one from the PC
IMO, this is silly. Either install a new system or transfer the old one, but there is no point in installing a system then overwriting it with the old one.
ticketman wrote: 2021-11-14 19:26 I have tried the latest ubuntu live disc,(21.10) which boots ok, but this does not have fsarchiver on it.
You can install it in the live system If it is in the repository. This applies to any distribution live system.
LE_746F6D617A7A69 wrote: 2021-11-14 21:40 You don't need fsarchiver or system rescue disk to copy/backup the OS - those are just convenient wrappers for tools that are included in every linux distro.
What tools is fsarchiver a wrapper for (beside mkfs to create the destination filesystem on restore) ?

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Copy O/S partition to new laptop

#5 Post by LE_746F6D617A7A69 »

p.H wrote: 2021-11-14 22:30
LE_746F6D617A7A69 wrote: 2021-11-14 21:40 You don't need fsarchiver or system rescue disk to copy/backup the OS - those are just convenient wrappers for tools that are included in every linux distro.
What tools is fsarchiver a wrapper for (beside mkfs to create the destination filesystem on restore) ?
Really?
All the functionality that fsarchiver can offer can be achieved by using a sequence of calls to standard tools. In that sense fsarchiver is a wrapper.
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

ticketman
Posts: 136
Joined: 2012-06-30 11:06
Has thanked: 3 times

Re: Copy O/S partition to new laptop

#6 Post by ticketman »

p.H wrote:
IMO, this is silly. Either install a new system or transfer the old one, but there is no point in installing a system then overwriting it with the old one.
Well, I will be installing a new system onto the laptop using the debian 12 installer (so I can resize the existing windows O/S partition and to update the EFI partition). But I then want to install all of the packages and customisations I have from the old system (after updating it to debian 12). Maybe this is silly, but is this a safe and reliable way of going about it?

I did try to install fsarchiver while using the ubuntu live disc, but it could not find the package (must be a bug - it is there in the repositories).

I will look into LE_746F6D617A7A69 suggestions, i.e.
> rsync -axHAWXS --numeric-ids --info=progress2 / <destination path>
#or
> cp -ax / <destination path>
I use rsync for data backups, but have never used it for an O/S backup - I seem to recall there were certain system files that would not copy over. But I have used fsarchiver before, and I know it works.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Copy O/S partition to new laptop

#7 Post by p.H »

ticketman wrote: 2021-11-15 12:08 Well, I will be installing a new system onto the laptop using the debian 12 installer (so I can resize the existing windows O/S partition and to update the EFI partition). But I then want to install all of the packages and customisations I have from the old system (after updating it to debian 12). Maybe this is silly, but is this a safe and reliable way of going about it?
IMO it is neither safe and reliable nor needed for this.
The EFI partition would be updated for the new installation only, not the old restored system.
You can resize the existing Windows partition without installing, and update the EFI setup after restoring the old system.
Or you can import the package list, custom config files and data from the old to the new system.
ticketman wrote: 2021-11-15 12:08 I did try to install fsarchiver while using the ubuntu live disc, but it could not find the package (must be a bug - it is there in the repositories).
Did the live system have a working internet connection ?

ticketman
Posts: 136
Joined: 2012-06-30 11:06
Has thanked: 3 times

Re: Copy O/S partition to new laptop

#8 Post by ticketman »

The EFI partition would be updated for the new installation only, not the old restored system.
The idea is that the laptop EFI partition on the system disc on the laptop (GPT format) will be updated by the debian 12 installer. Debian 12 will then be installed in a separate partition of the system disc. I then would use fsarchiver to copy the OS partition (sda2 in my case) from my desktop PC to the laptop partition holding the debian O/S. I hope this makes sense?
Did the live system have a working internet connection ?
Yes, it did.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Copy O/S partition to new laptop

#9 Post by p.H »

ticketman wrote: 2021-11-15 16:02 The idea is that the laptop EFI partition on the system disc on the laptop (GPT format) will be updated by the debian 12 installer.
No need to rephrase, I already understood the idea. But it will not work without extra tuning, because the boot loader config in the EFI partition (EFI/debian/grub.cfg) will search the UUID of the newly installed root filesystem which does not exist anymore (replaced by fsarchiver). Of course you can update it with the new/old UUID before leaving the installer, but instead you could directly restore the old system, chroot into it from the installer in rescue mode (or any live system) then install the boot loader in the EFI partition.

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: Copy O/S partition to new laptop

#10 Post by CwF »

p.H wrote: 2021-11-15 18:50 Of course you can update it with the new/old UUID before leaving the installer, but instead you could directly restore the old system, chroot into it from the installer in rescue mode (or any live system) then install the boot loader in the EFI partition.
I'm wondering, a few times I have simply typed E, or -e to enter edit mode within a grub that does come up - so a workable grub with a wrong uuid. There we can edit the uuid (3 times PIA). It will then boot into the OS, and then update grub. Is this not possible with an EFI setup?

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Copy O/S partition to new laptop

#11 Post by p.H »

Problem is you won't even get a menu to edit because it is stored in /boot/grub.grub.cfg in the root filesystem, not in the EFI partition. Only GRUB command line. Fine if you can boot with it.

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: Copy O/S partition to new laptop

#12 Post by CwF »

p.H wrote: 2021-11-15 20:33 Problem is you won't even get a menu to edit because it is stored in /boot/grub.grub.cfg in the root filesystem,
Well, no. On multiple occasions I have split a multi boot and or replaced a partition. Grub is installed to the disk boot sector, not any partition - ie sda. I place sda* from an image, important note a partition image and not a disk image that includes the boot sector. Then the sda boot sector installed grub does work and is editable. Edit it to see the new (single) bootable partition, get in, update. On multi OS could just whatever functioning OS to update it, then no need to edit, os-prober takes care of it.

So I think the question is where is grub on an EFI setup? Is it not a 'boot sector' equivalent?

Also, if you image a 'disk' as partition into an existing partition on a disk with a boot sector loader, it will chain load. I did that accidentally once. I then explored nesting multiple 'disk' images on one disk, not really useful.

ticketman
Posts: 136
Joined: 2012-06-30 11:06
Has thanked: 3 times

Re: Copy O/S partition to new laptop

#13 Post by ticketman »

Many thanks everyone for the discussions!
I have some more information that may help.

Firstly I note that the methods to save/restore a partition are mainly the same, whther using dd, cp, fsarchiver, etc.
The good news is that I have succeeded in disabling secure boot on the laptop (I also had to remove bitlocker encryption), so I can now boot my system rescue disk. This gave me the following info on the laptop disk:

Code: Select all

NAME        FSTYPE          LABEL           SIZE    PURPOSE
nvme0n1p1   vfat, FAT32                     100M    EFI
nvme0n1p2   [unable to detect file system]  16M     MS Reserved   
nvme0n1p3   ntfs            Boot            444.8G  Windows O/S 
nvme0n1p4   ntfs                            999M    hidden, diagnostics
nvme0n1p5   ntfs            Recover         30G     Recovery disc
nvme0n1p6   vfat, FAT32     PRC_RP          1G      (?) hidden
I don't use disk uuids on my old system, I use file system labels instead, and I plan to do the same with this laptop.
Clearly I will need to resize the nvme0n1p3 partition in order to add debian 12 to the released unallocated space.
Unfortuately when running gparted it detected an error on the laptop disk. I decided to save the partition tables using sgdisk:

Code: Select all

sgdisk --backup=/mnt/MedionGPT /dev/nvme0n1
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.

Warning! One or more CRCs don't match. You should repair the disk!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
The operation has completed successfully.
So I am going to have to fix this issue first before going any further. Any advice on that?

ticketman
Posts: 136
Joined: 2012-06-30 11:06
Has thanked: 3 times

Re: Copy O/S partition to new laptop

#14 Post by ticketman »

Well I fixed the GPT errors - there were two main issues reported by gdisk:
- invalid backup GPT header
- Partition(s) in the protective MBR are too big for the disk!
Here's how they were fixed:

Code: Select all

gdisk /dev/nvme0n1
GPT fdisk (gdisk) version 1.0.8

Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.

Warning! One or more CRCs don't match. You should repair the disk!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Command (? for help): p
Disk /dev/nvme0n1: 1000215216 sectors, 476.9 GiB
Model: SAMSUNG MZVLB512HBJQ-00000              
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 4C05C00F-518F-44E2-ADCB-458903630153
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1000215182
Partitions will be aligned on 2048-sector boundaries
Total free space is 2669 sectors (1.3 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          206847   100.0 MiB   EF00  EFI system partition
   2          206848          239615   16.0 MiB    0C01  Microsoft reserved ...
   3          239616       933156863   444.8 GiB   0700  Basic data partition
   4       933156864       935202815   999.0 MiB   2700  Basic data partition
   5       935202816       998117375   30.0 GiB    0700  Basic data partition
   6       998117376      1000214527   1024.0 MiB  FFFF  Basic data partition

Command (? for help): v

Caution: The CRC for the backup partition table is invalid. This table may
be corrupt. This program will automatically create a new backup partition
table when you save your partitions.

Partition(s) in the protective MBR are too big for the disk! Creating a
fresh protective or hybrid MBR is recommended.

Identified 2 problems!

Command (? for help): w

Partition(s) in the protective MBR are too big for the disk! Creating a
fresh protective or hybrid MBR is recommended.

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.
Warning! An error was reported when writing the partition table! This error
MIGHT be harmless, or the disk might be damaged! Checking it is advisable.

Command (? for help): v

Caution: The CRC for the backup partition table is invalid. This table may
be corrupt. This program will automatically create a new backup partition
table when you save your partitions.

Partition(s) in the protective MBR are too big for the disk! Creating a
fresh protective or hybrid MBR is recommended.

Identified 2 problems!
Although problems were still identified, it needed a reboot to clear them. Rebooting and running gdisk from the rescue disk:

Code: Select all

gdisk /dev/nvme0n1
GPT fdisk (gdisk) version 1.0.8

The protective MBR's 0xEE partition is oversized! Auto-repairing.

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/nvme0n1: 1000215216 sectors, 476.9 GiB
Model: SAMSUNG MZVLB512HBJQ-00000              
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 4C05C00F-518F-44E2-ADCB-458903630153
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 1000215182
Partitions will be aligned on 2048-sector boundaries
Total free space is 2669 sectors (1.3 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          206847   100.0 MiB   EF00  EFI system partition
   2          206848          239615   16.0 MiB    0C01  Microsoft reserved ...
   3          239616       933156863   444.8 GiB   0700  Basic data partition
   4       933156864       935202815   999.0 MiB   2700  Basic data partition
   5       935202816       998117375   30.0 GiB    0700  Basic data partition
   6       998117376      1000214527   1024.0 MiB  FFFF  Basic data partition

Command (? for help): v

No problems found. 2669 free sectors (1.3 MiB) available in 2
segments, the largest of which is 2014 (1007.0 KiB) in size.

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.
The operation has completed successfully.
After all this, the laptop was still able to boot Windows, so whatever caused the GPT errors (manufacturer install? Removal of secure boot? Removal of bitlocker encryption?) has been fixed and I am in a safer position to resize partitions etc for the debian installation.
NOTE: a very common cause of "invalid backup GPT header" is where the PC is using RAID of any sort. The laptop has only one disk and it is configured as AHCI, so I am ok on that.

Next decision is whteher to use gparted to resize the windows partition and add debian and swap partitions, or do this through the debian installer.

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: Copy O/S partition to new laptop

#15 Post by Dai_trying »

ticketman wrote: 2021-11-16 19:44Next decision is whteher to use gparted to resize the windows partition and add debian and swap partitions, or do this through the debian installer.
Whenever I dual boot with windows I use the windows partitions app to resize the windows installation as I would think it is going to be safer than a different OS, I have never (yet) had any issues with it. After resizing windows that way reboot straight into installation media and use the free space for Debian (or whichever OS you want).

ticketman
Posts: 136
Joined: 2012-06-30 11:06
Has thanked: 3 times

Re: Copy O/S partition to new laptop

#16 Post by ticketman »

Hi Dai_trying,

Do you run the windows partition app from the running windows O/S?
i.e. can you resize the windows O/S partition while windows is still running from it?

CwF
Global Moderator
Global Moderator
Posts: 2625
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 190 times

Re: Copy O/S partition to new laptop

#17 Post by CwF »

ticketman wrote: 2021-11-17 11:36 resize the windows O/S partition while windows is still running from it?
Linux can, about time windows could!
Partition Magic under NT4 was my last try! Good going ticketman pushing through to conclusion! I'm happy I don't need to mess with things with things that have "Microsoft reserved ." on my hard drive(s)

ticketman
Posts: 136
Joined: 2012-06-30 11:06
Has thanked: 3 times

Re: Copy O/S partition to new laptop

#18 Post by ticketman »

My research shows that Win10 can resize its installation partition (Boot) on the fly.
But there is a catch. The partition will have some 'un-movable' system files, and if they are located near the end of the partition, it will not be possible to shrink the partition by very much. I don't know if such immovable system files only appear when the system is running. See the first post in this forum:
https://superuser.com/questions/1370229 ... ng-gparted
Also from same forum:
I had similar problem with resizing. It took me a lot of time and a lot of tries. At the end (before reinstalling Windows) I uninstalled Reboot Restore. And that was it, resizing worked like a charm. So my advice, ALWAYS uninstall Reboot Restore (not only disable) before mixing with partitions.
And:
If in the future you would like to shrink the Windows partition, you should first disable the page-file and swap space, then defragment the disk to move all sectors to its begining, and resize only using Disk Management.
All of which is one hell of a mess to trundle through. On the other hand a post from:
https://superuser.com/questions/821131/ ... th-gparted
says that you can use gparted. The advice is to not move the partition, only resize it by dragging the right hand side of the partition boundary. Apparently shifting the location of the start of the partition will cause windows not to boot.
So opinion is divided on the issue and I don't want to turn this thread into a windows support thread!
I'll do some more research and then take the plunge, most likely I will try gparted.

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: Copy O/S partition to new laptop

#19 Post by Dai_trying »

My experience with Windows partitioning has been very good, it can adjust it's size "on the fly" as you stated, I have freed up a lot of space and often have to claw some back as it shrinks it too much for me. One thing to note though would be that I would also do a "disc cleanup" and "defregmentation" before shrinking any windows partition as this can significantly increase the amount of space to be freed.

Also, as for any operation of this kind it is always prudent to make a backup beforehand (just in case).

ticketman
Posts: 136
Joined: 2012-06-30 11:06
Has thanked: 3 times

Re: Copy O/S partition to new laptop

#20 Post by ticketman »

Dai_trying:
My experience with Windows partitioning has been very good, it can adjust it's size "on the fly" as you stated,
Did you ever encounter the problem with immovable files restricting the amount you can shrink by?

Yes, backing up the laptop first is certainly a good idea. I was planning to dd the whole disk of the laptop to an external SDD drive, but found that the laptop disk was just a larger than my SDD, so the dd copy didn't produce a usable image. I did discover that pagefile.sys etc was on the windows disk even when not booted, so the immovable files are not temporary.

I am now going to have to make images of each partition on the laptop disk separately and compress them, so I can then save them all onto my external SDD.

I'll keep posting on my progress.

Post Reply